Paper/nms-patches/EntityRabbit.patch

55 lines
2.9 KiB
Diff

--- a/net/minecraft/server/EntityRabbit.java
+++ b/net/minecraft/server/EntityRabbit.java
@@ -17,11 +17,17 @@
super(entitytypes, world);
this.bp = new EntityRabbit.ControllerJumpRabbit(this);
this.moveController = new EntityRabbit.ControllerMoveRabbit(this);
+ this.initializePathFinderGoals(); // CraftBukkit - moved code
+ }
+
+ // CraftBukkit start - code from constructor
+ public void initializePathFinderGoals(){
this.i(0.0D);
}
+ // CraftBukkit end
@Override
- protected void initPathfinder() {
+ public void initPathfinder() {
this.goalSelector.a(1, new PathfinderGoalFloat(this));
this.goalSelector.a(1, new EntityRabbit.PathfinderGoalRabbitPanic(this, 2.2D));
this.goalSelector.a(2, new PathfinderGoalBreed(this, 0.8D));
@@ -285,7 +291,7 @@
if (i == 99) {
this.getAttributeInstance(GenericAttributes.ARMOR).setValue(8.0D);
this.goalSelector.a(4, new EntityRabbit.PathfinderGoalKillerRabbitMeleeAttack(this));
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityWolf.class, true));
if (!this.hasCustomName()) {
@@ -401,9 +407,23 @@
Integer integer = (Integer) iblockdata.get(BlockCarrots.AGE);
if (integer == 0) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2);
world.a(blockposition, true, this.entity);
} else {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(
+ this.entity,
+ blockposition,
+ iblockdata.set(BlockCarrots.AGE, integer - 1)
+ ).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCarrots.AGE, integer - 1), 2);
world.triggerEffect(2001, blockposition, Block.getCombinedId(iblockdata));
}