mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 00:38:35 +01:00
care about horses
This commit is contained in:
parent
cd4c1b9d1c
commit
f019fbfcda
1 changed files with 5 additions and 14 deletions
|
@ -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;
|
Item item = stack.getItem();
|
||||||
if(horse.isTame()){
|
return (animal.getGrowingAge() == 0 && !animal.isInLove()) && (item == Items.GOLDEN_APPLE || item == Items.GOLDEN_CARROT);
|
||||||
Item item = stack.getItem();
|
|
||||||
return 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue