care about horses

This commit is contained in:
Shadows_of_Fire 2018-01-29 16:43:14 -05:00
parent cd4c1b9d1c
commit f019fbfcda

View file

@ -63,7 +63,6 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
super.updateEntity(); super.updateEntity();
currentTimer = MathHelper.clamp(++currentTimer, 0, 100); currentTimer = MathHelper.clamp(++currentTimer, 0, 100);
if(world.isRemote) return; if(world.isRemote) return;
boolean theFlag = this.currentTimer > 0;
int range = 5; int range = 5;
ItemStack stack = this.slots.getStackInSlot(0); ItemStack stack = this.slots.getStackInSlot(0);
if(!stack.isEmpty() && this.currentTimer >= TIME) { if(!stack.isEmpty() && this.currentTimer >= TIME) {
@ -72,18 +71,13 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
if(currentAnimalAmount >= 2 && currentAnimalAmount < THRESHOLD){ if(currentAnimalAmount >= 2 && currentAnimalAmount < THRESHOLD){
Optional<EntityAnimal> opt = animals.stream().filter((e) -> canBeFed(stack, e)).findAny(); Optional<EntityAnimal> opt = animals.stream().filter((e) -> canBeFed(stack, e)).findAny();
if(opt.isPresent()) { if(opt.isPresent()) {
EntityAnimal animal = opt.get(); feedAnimal(opt.get());
feedAnimal(animal);
stack.shrink(1); stack.shrink(1);
this.currentTimer = 0; this.currentTimer = 0;
markDirty();
} }
} }
} }
if(theFlag != this.currentTimer > 0){
this.markDirty();
}
if((this.lastAnimalAmount != this.currentAnimalAmount || this.lastTimer != this.currentTimer) && this.sendUpdateWithInterval()){ if((this.lastAnimalAmount != this.currentAnimalAmount || this.lastTimer != this.currentTimer) && this.sendUpdateWithInterval()){
this.lastAnimalAmount = this.currentAnimalAmount; this.lastAnimalAmount = this.currentAnimalAmount;
this.lastTimer = this.currentTimer; this.lastTimer = this.currentTimer;
@ -111,12 +105,9 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
} }
private static boolean canBeFed(ItemStack stack, EntityAnimal animal){ private static boolean canBeFed(ItemStack stack, EntityAnimal animal){
if(animal instanceof EntityHorse){ if(animal instanceof EntityHorse && ((EntityHorse) animal).isTame()){
EntityHorse horse = (EntityHorse)animal;
if(horse.isTame()){
Item item = stack.getItem(); Item item = stack.getItem();
return item == Items.GOLDEN_APPLE || item == Items.GOLDEN_CARROT; return (animal.getGrowingAge() == 0 && !animal.isInLove()) && (item == Items.GOLDEN_APPLE || item == Items.GOLDEN_CARROT);
}
} }
return animal.getGrowingAge() == 0 && !animal.isInLove() && animal.isBreedingItem(stack); return animal.getGrowingAge() == 0 && !animal.isInLove() && animal.isBreedingItem(stack);
} }