Skip to content

Commit

Permalink
Make rats not bring back items if player inv is full
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor4t committed Jul 27, 2021
1 parent e6f1fd6 commit 927aa43
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ protected void initEquipment(LocalDifficulty difficulty) {
}



@Override
public EntityData initialize(ServerWorldAccess world, LocalDifficulty difficulty, SpawnReason spawnReason, @Nullable EntityData entityData, @Nullable NbtCompound entityTag) {
this.initEquipment(difficulty);
Expand Down Expand Up @@ -851,24 +850,22 @@ public BringItemToOwnerGoal(TameableEntity tameable, double speed, float minDist
public void tick() {
super.tick();

if (RatEntity.this.getOwner() != null && RatEntity.this.getOwner().isAlive()) {
if (RatEntity.this.getOwner() != null && RatEntity.this.getOwner().isAlive() && ((PlayerEntity) RatEntity.this.getOwner()).getInventory().getEmptySlot() >= 0) {
if (RatEntity.this.squaredDistanceTo(RatEntity.this.getOwner()) <= 3.0f && RatEntity.this.getOwner() instanceof PlayerEntity) {
if (((PlayerEntity) RatEntity.this.getOwner()).getInventory().getEmptySlot() >= 0) {
RatEntity.this.dropStack(RatEntity.this.getEquippedStack(EquipmentSlot.MAINHAND));
RatEntity.this.equipStack(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
}
RatEntity.this.dropStack(RatEntity.this.getEquippedStack(EquipmentSlot.MAINHAND));
RatEntity.this.equipStack(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
}
}
}

@Override
public boolean canStart() {
return super.canStart() && !RatEntity.this.getEquippedStack(EquipmentSlot.MAINHAND).isEmpty() && RatEntity.this.isTamed() && !RatEntity.this.isSitting() && !RatEntity.this.isEating() && RatEntity.this.getOwner() != null && RatEntity.this.getOwner().isAlive();
return super.canStart() && !RatEntity.this.getEquippedStack(EquipmentSlot.MAINHAND).isEmpty() && RatEntity.this.isTamed() && !RatEntity.this.isSitting() && !RatEntity.this.isEating() && RatEntity.this.getOwner() != null && RatEntity.this.getOwner().isAlive() && ((PlayerEntity) RatEntity.this.getOwner()).getInventory().getEmptySlot() >= 0;
}

@Override
public boolean shouldContinue() {
return super.shouldContinue() && !RatEntity.this.getEquippedStack(EquipmentSlot.MAINHAND).isEmpty() && RatEntity.this.isTamed() && !RatEntity.this.isSitting() && !RatEntity.this.isEating() && RatEntity.this.getOwner() != null && RatEntity.this.getOwner().isAlive();
return super.shouldContinue() && !RatEntity.this.getEquippedStack(EquipmentSlot.MAINHAND).isEmpty() && RatEntity.this.isTamed() && !RatEntity.this.isSitting() && !RatEntity.this.isEating() && RatEntity.this.getOwner() != null && RatEntity.this.getOwner().isAlive() && ((PlayerEntity) RatEntity.this.getOwner()).getInventory().getEmptySlot() >= 0;
}
}

Expand Down

0 comments on commit 927aa43

Please sign in to comment.