aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Rabbit.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Rabbit.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Rabbit.java.patch637
1 files changed, 637 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Rabbit.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Rabbit.java.patch
new file mode 100644
index 0000000000..0e30aea3e3
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Rabbit.java.patch
@@ -0,0 +1,637 @@
+--- a/net/minecraft/world/entity/animal/Rabbit.java
++++ b/net/minecraft/world/entity/animal/Rabbit.java
+@@ -27,10 +27,10 @@
+ import net.minecraft.world.entity.AgeableMob;
+ import net.minecraft.world.entity.Entity;
+ import net.minecraft.world.entity.EntityType;
++import net.minecraft.world.entity.EnumMobSpawn;
++import net.minecraft.world.entity.GroupDataEntity;
+ import net.minecraft.world.entity.LivingEntity;
+ import net.minecraft.world.entity.Mob;
+-import net.minecraft.world.entity.MobSpawnType;
+-import net.minecraft.world.entity.SpawnGroupData;
+ import net.minecraft.world.entity.VariantHolder;
+ import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
+ import net.minecraft.world.entity.ai.attributes.Attributes;
+@@ -62,17 +62,21 @@
+ import net.minecraft.world.level.block.Block;
+ import net.minecraft.world.level.block.Blocks;
+ import net.minecraft.world.level.block.CarrotBlock;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.level.gameevent.GameEvent;
+ import net.minecraft.world.level.pathfinder.Path;
+ import net.minecraft.world.phys.Vec3;
++// CraftBukkit start
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++// CraftBukkit end
+
+ public class Rabbit extends Animal implements VariantHolder<Rabbit.Variant> {
+- public static final double STROLL_SPEED_MOD = 0.6;
+- public static final double BREED_SPEED_MOD = 0.8;
+- public static final double FOLLOW_SPEED_MOD = 1.0;
+- public static final double FLEE_SPEED_MOD = 2.2;
+- public static final double ATTACK_SPEED_MOD = 1.4;
++
++ public static final double STROLL_SPEED_MOD = 0.6D;
++ public static final double BREED_SPEED_MOD = 0.8D;
++ public static final double FOLLOW_SPEED_MOD = 1.0D;
++ public static final double FLEE_SPEED_MOD = 2.2D;
++ public static final double ATTACK_SPEED_MOD = 1.4D;
+ private static final EntityDataAccessor<Integer> DATA_TYPE_ID = SynchedEntityData.defineId(Rabbit.class, EntityDataSerializers.INT);
+ private static final ResourceLocation KILLER_BUNNY = new ResourceLocation("killer_bunny");
+ public static final int EVIL_ATTACK_POWER = 8;
+@@ -88,40 +92,42 @@
+ super(entityType, level);
+ this.jumpControl = new Rabbit.RabbitJumpControl(this);
+ this.moveControl = new Rabbit.RabbitMoveControl(this);
+- this.setSpeedModifier(0.0);
+ }
+
+ @Override
+- protected void registerGoals() {
++ public void registerGoals() {
+ this.goalSelector.addGoal(1, new FloatGoal(this));
+ this.goalSelector.addGoal(1, new ClimbOnTopOfPowderSnowGoal(this, this.level()));
+- this.goalSelector.addGoal(1, new Rabbit.RabbitPanicGoal(this, 2.2));
+- this.goalSelector.addGoal(2, new BreedGoal(this, 0.8));
+- this.goalSelector.addGoal(3, new TemptGoal(this, 1.0, Ingredient.of(Items.CARROT, Items.GOLDEN_CARROT, Blocks.DANDELION), false));
+- this.goalSelector.addGoal(4, new Rabbit.RabbitAvoidEntityGoal<>(this, Player.class, 8.0F, 2.2, 2.2));
+- this.goalSelector.addGoal(4, new Rabbit.RabbitAvoidEntityGoal<>(this, Wolf.class, 10.0F, 2.2, 2.2));
+- this.goalSelector.addGoal(4, new Rabbit.RabbitAvoidEntityGoal<>(this, Monster.class, 4.0F, 2.2, 2.2));
++ this.goalSelector.addGoal(1, new Rabbit.RabbitPanicGoal(this, 2.2D));
++ this.goalSelector.addGoal(2, new BreedGoal(this, 0.8D));
++ this.goalSelector.addGoal(3, new TemptGoal(this, 1.0D, Ingredient.of(Items.CARROT, Items.GOLDEN_CARROT, Blocks.DANDELION), false));
++ this.goalSelector.addGoal(4, new Rabbit.RabbitAvoidEntityGoal<>(this, Player.class, 8.0F, 2.2D, 2.2D));
++ this.goalSelector.addGoal(4, new Rabbit.RabbitAvoidEntityGoal<>(this, Wolf.class, 10.0F, 2.2D, 2.2D));
++ this.goalSelector.addGoal(4, new Rabbit.RabbitAvoidEntityGoal<>(this, Monster.class, 4.0F, 2.2D, 2.2D));
+ this.goalSelector.addGoal(5, new Rabbit.RaidGardenGoal(this));
+- this.goalSelector.addGoal(6, new WaterAvoidingRandomStrollGoal(this, 0.6));
++ this.goalSelector.addGoal(6, new WaterAvoidingRandomStrollGoal(this, 0.6D));
+ this.goalSelector.addGoal(11, new LookAtPlayerGoal(this, Player.class, 10.0F));
+ }
+
+ @Override
+ protected float getJumpPower() {
+ float f = 0.3F;
+- if (this.horizontalCollision || this.moveControl.hasWanted() && this.moveControl.getWantedY() > this.getY() + 0.5) {
++
++ if (this.horizontalCollision || this.moveControl.hasWanted() && this.moveControl.getWantedY() > this.getY() + 0.5D) {
+ f = 0.5F;
+ }
+
+- Path path = this.navigation.getPath();
+- if (path != null && !path.isDone()) {
+- Vec3 nextEntityPos = path.getNextEntityPos(this);
+- if (nextEntityPos.y > this.getY() + 0.5) {
++ Path pathentity = this.navigation.getPath();
++
++ if (pathentity != null && !pathentity.isDone()) {
++ Vec3 vec3d = pathentity.getNextEntityPos(this);
++
++ if (vec3d.y > this.getY() + 0.5D) {
+ f = 0.5F;
+ }
+ }
+
+- if (this.moveControl.getSpeedModifier() <= 0.6) {
++ if (this.moveControl.getSpeedModifier() <= 0.6D) {
+ f = 0.2F;
+ }
+
+@@ -131,21 +137,24 @@
+ @Override
+ protected void jumpFromGround() {
+ super.jumpFromGround();
+- double speedModifier = this.moveControl.getSpeedModifier();
+- if (speedModifier > 0.0) {
+- double d = this.getDeltaMovement().horizontalDistanceSqr();
+- if (d < 0.01) {
+- this.moveRelative(0.1F, new Vec3(0.0, 0.0, 1.0));
++ double d0 = this.moveControl.getSpeedModifier();
++
++ if (d0 > 0.0D) {
++ double d1 = this.getDeltaMovement().horizontalDistanceSqr();
++
++ if (d1 < 0.01D) {
++ this.moveRelative(0.1F, new Vec3(0.0D, 0.0D, 1.0D));
+ }
+ }
+
+ if (!this.level().isClientSide) {
+- this.level().broadcastEntityEvent(this, (byte)1);
++ this.level().broadcastEntityEvent(this, (byte) 1);
+ }
++
+ }
+
+ public float getJumpCompletion(float partialTick) {
+- return this.jumpDuration == 0 ? 0.0F : ((float)this.jumpTicks + partialTick) / (float)this.jumpDuration;
++ return this.jumpDuration == 0 ? 0.0F : ((float) this.jumpTicks + partialTick) / (float) this.jumpDuration;
+ }
+
+ public void setSpeedModifier(double speedModifier) {
+@@ -159,6 +168,7 @@
+ if (jumping) {
+ this.playSound(this.getJumpSound(), this.getSoundVolume(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
+ }
++
+ }
+
+ public void startJumping() {
+@@ -170,17 +180,17 @@
+ @Override
+ protected void defineSynchedData() {
+ super.defineSynchedData();
+- this.entityData.define(DATA_TYPE_ID, Rabbit.Variant.BROWN.id);
++ this.entityData.define(Rabbit.DATA_TYPE_ID, Rabbit.Variant.BROWN.id);
+ }
+
+ @Override
+ public void customServerAiStep() {
+ if (this.jumpDelayTicks > 0) {
+- this.jumpDelayTicks--;
++ --this.jumpDelayTicks;
+ }
+
+ if (this.moreCarrotTicks > 0) {
+- this.moreCarrotTicks = this.moreCarrotTicks - this.random.nextInt(3);
++ this.moreCarrotTicks -= this.random.nextInt(3);
+ if (this.moreCarrotTicks < 0) {
+ this.moreCarrotTicks = 0;
+ }
+@@ -193,28 +203,31 @@
+ }
+
+ if (this.getVariant() == Rabbit.Variant.EVIL && this.jumpDelayTicks == 0) {
+- LivingEntity target = this.getTarget();
+- if (target != null && this.distanceToSqr(target) < 16.0) {
+- this.facePoint(target.getX(), target.getZ());
+- this.moveControl.setWantedPosition(target.getX(), target.getY(), target.getZ(), this.moveControl.getSpeedModifier());
++ LivingEntity entityliving = this.getTarget();
++
++ if (entityliving != null && this.distanceToSqr((Entity) entityliving) < 16.0D) {
++ this.facePoint(entityliving.getX(), entityliving.getZ());
++ this.moveControl.setWantedPosition(entityliving.getX(), entityliving.getY(), entityliving.getZ(), this.moveControl.getSpeedModifier());
+ this.startJumping();
+ this.wasOnGround = true;
+ }
+ }
+
+- Rabbit.RabbitJumpControl rabbitJumpControl = (Rabbit.RabbitJumpControl)this.jumpControl;
+- if (!rabbitJumpControl.wantJump()) {
++ Rabbit.RabbitJumpControl entityrabbit_controllerjumprabbit = (Rabbit.RabbitJumpControl) this.jumpControl;
++
++ if (!entityrabbit_controllerjumprabbit.wantJump()) {
+ if (this.moveControl.hasWanted() && this.jumpDelayTicks == 0) {
+- Path path = this.navigation.getPath();
+- Vec3 vec3 = new Vec3(this.moveControl.getWantedX(), this.moveControl.getWantedY(), this.moveControl.getWantedZ());
+- if (path != null && !path.isDone()) {
+- vec3 = path.getNextEntityPos(this);
++ Path pathentity = this.navigation.getPath();
++ Vec3 vec3d = new Vec3(this.moveControl.getWantedX(), this.moveControl.getWantedY(), this.moveControl.getWantedZ());
++
++ if (pathentity != null && !pathentity.isDone()) {
++ vec3d = pathentity.getNextEntityPos(this);
+ }
+
+- this.facePoint(vec3.x, vec3.z);
++ this.facePoint(vec3d.x, vec3d.z);
+ this.startJumping();
+ }
+- } else if (!rabbitJumpControl.canJump()) {
++ } else if (!entityrabbit_controllerjumprabbit.canJump()) {
+ this.enableJumpControl();
+ }
+ }
+@@ -227,24 +240,25 @@
+ return false;
+ }
+
+- private void facePoint(double x, double z) {
+- this.setYRot((float)(Mth.atan2(z - this.getZ(), x - this.getX()) * 180.0F / (float)Math.PI) - 90.0F);
++ private void facePoint(double x, double d1) {
++ this.setYRot((float) (Mth.atan2(d1 - this.getZ(), x - this.getX()) * 57.2957763671875D) - 90.0F);
+ }
+
+ private void enableJumpControl() {
+- ((Rabbit.RabbitJumpControl)this.jumpControl).setCanJump(true);
++ ((Rabbit.RabbitJumpControl) this.jumpControl).setCanJump(true);
+ }
+
+ private void disableJumpControl() {
+- ((Rabbit.RabbitJumpControl)this.jumpControl).setCanJump(false);
++ ((Rabbit.RabbitJumpControl) this.jumpControl).setCanJump(false);
+ }
+
+ private void setLandingDelay() {
+- if (this.moveControl.getSpeedModifier() < 2.2) {
++ if (this.moveControl.getSpeedModifier() < 2.2D) {
+ this.jumpDelayTicks = 10;
+ } else {
+ this.jumpDelayTicks = 1;
+ }
++
+ }
+
+ private void checkLandingDelay() {
+@@ -256,16 +270,17 @@
+ public void aiStep() {
+ super.aiStep();
+ if (this.jumpTicks != this.jumpDuration) {
+- this.jumpTicks++;
++ ++this.jumpTicks;
+ } else if (this.jumpDuration != 0) {
+ this.jumpTicks = 0;
+ this.jumpDuration = 0;
+ this.setJumping(false);
+ }
++
+ }
+
+ public static AttributeSupplier.Builder createAttributes() {
+- return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 3.0).add(Attributes.MOVEMENT_SPEED, 0.3F);
++ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 3.0D).add(Attributes.MOVEMENT_SPEED, 0.30000001192092896D);
+ }
+
+ @Override
+@@ -323,24 +338,31 @@
+ @Nullable
+ @Override
+ public Rabbit getBreedOffspring(ServerLevel level, AgeableMob otherParent) {
+- Rabbit rabbit = EntityType.RABBIT.create(level);
+- if (rabbit != null) {
+- Rabbit.Variant randomRabbitVariant;
+- randomRabbitVariant = getRandomRabbitVariant(level, this.blockPosition());
+- label16:
++ Rabbit entityrabbit = (Rabbit) EntityType.RABBIT.create(level);
++
++ if (entityrabbit != null) {
++ Rabbit.Variant entityrabbit_variant = getRandomRabbitVariant(level, this.blockPosition());
++
+ if (this.random.nextInt(20) != 0) {
+- if (otherParent instanceof Rabbit rabbit1 && this.random.nextBoolean()) {
+- randomRabbitVariant = rabbit1.getVariant();
+- break label16;
+- }
++ label15:
++ {
++ if (otherParent instanceof Rabbit) {
++ Rabbit entityrabbit1 = (Rabbit) otherParent;
+
+- randomRabbitVariant = this.getVariant();
++ if (this.random.nextBoolean()) {
++ entityrabbit_variant = entityrabbit1.getVariant();
++ break label15;
++ }
++ }
++
++ entityrabbit_variant = this.getVariant();
++ }
+ }
+
+- rabbit.setVariant(randomRabbitVariant);
++ entityrabbit.setVariant(entityrabbit_variant);
+ }
+
+- return rabbit;
++ return entityrabbit;
+ }
+
+ @Override
+@@ -350,54 +372,47 @@
+
+ @Override
+ public Rabbit.Variant getVariant() {
+- return Rabbit.Variant.byId(this.entityData.get(DATA_TYPE_ID));
++ return Rabbit.Variant.byId((Integer) this.entityData.get(Rabbit.DATA_TYPE_ID));
+ }
+
+- @Override
+ public void setVariant(Rabbit.Variant variant) {
+ if (variant == Rabbit.Variant.EVIL) {
+- this.getAttribute(Attributes.ARMOR).setBaseValue(8.0);
+- this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.4, true));
+- this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers());
++ this.getAttribute(Attributes.ARMOR).setBaseValue(8.0D);
++ this.goalSelector.addGoal(4, new MeleeAttackGoal(this, 1.4D, true));
++ this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[0])).setAlertOthers());
+ this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
+ this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Wolf.class, true));
+ if (!this.hasCustomName()) {
+- this.setCustomName(Component.translatable(Util.makeDescriptionId("entity", KILLER_BUNNY)));
++ this.setCustomName(Component.translatable(Util.makeDescriptionId("entity", Rabbit.KILLER_BUNNY)));
+ }
+ }
+
+- this.entityData.set(DATA_TYPE_ID, variant.id);
++ this.entityData.set(Rabbit.DATA_TYPE_ID, variant.id);
+ }
+
+ @Nullable
+ @Override
+- public SpawnGroupData finalizeSpawn(
+- ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag dataTag
+- ) {
+- Rabbit.Variant randomRabbitVariant = getRandomRabbitVariant(level, this.blockPosition());
++ public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) {
++ Rabbit.Variant entityrabbit_variant = getRandomRabbitVariant(level, this.blockPosition());
++
+ if (spawnData instanceof Rabbit.RabbitGroupData) {
+- randomRabbitVariant = ((Rabbit.RabbitGroupData)spawnData).variant;
++ entityrabbit_variant = ((Rabbit.RabbitGroupData) spawnData).variant;
+ } else {
+- spawnData = new Rabbit.RabbitGroupData(randomRabbitVariant);
++ spawnData = new Rabbit.RabbitGroupData(entityrabbit_variant);
+ }
+
+- this.setVariant(randomRabbitVariant);
+- return super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag);
++ this.setVariant(entityrabbit_variant);
++ return super.finalizeSpawn(level, difficulty, reason, (GroupDataEntity) spawnData, dataTag);
+ }
+
+ private static Rabbit.Variant getRandomRabbitVariant(LevelAccessor level, BlockPos pos) {
+- Holder<Biome> biome = level.getBiome(pos);
+- int randomInt = level.getRandom().nextInt(100);
+- if (biome.is(BiomeTags.SPAWNS_WHITE_RABBITS)) {
+- return randomInt < 80 ? Rabbit.Variant.WHITE : Rabbit.Variant.WHITE_SPLOTCHED;
+- } else if (biome.is(BiomeTags.SPAWNS_GOLD_RABBITS)) {
+- return Rabbit.Variant.GOLD;
+- } else {
+- return randomInt < 50 ? Rabbit.Variant.BROWN : (randomInt < 90 ? Rabbit.Variant.SALT : Rabbit.Variant.BLACK);
+- }
++ Holder<Biome> holder = level.getBiome(pos);
++ int i = level.getRandom().nextInt(100);
++
++ return holder.is(BiomeTags.SPAWNS_WHITE_RABBITS) ? (i < 80 ? Rabbit.Variant.WHITE : Rabbit.Variant.WHITE_SPLOTCHED) : (holder.is(BiomeTags.SPAWNS_GOLD_RABBITS) ? Rabbit.Variant.GOLD : (i < 50 ? Rabbit.Variant.BROWN : (i < 90 ? Rabbit.Variant.SALT : Rabbit.Variant.BLACK)));
+ }
+
+- public static boolean checkRabbitSpawnRules(EntityType<Rabbit> rabbit, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random) {
++ public static boolean checkRabbitSpawnRules(EntityType<Rabbit> rabbit, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) {
+ return level.getBlockState(pos.below()).is(BlockTags.RABBITS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos);
+ }
+
+@@ -414,43 +429,22 @@
+ } else {
+ super.handleEntityEvent(id);
+ }
++
+ }
+
+ @Override
+ public Vec3 getLeashOffset() {
+- return new Vec3(0.0, (double)(0.6F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.4F));
++ return new Vec3(0.0D, (double) (0.6F * this.getEyeHeight()), (double) (this.getBbWidth() * 0.4F));
+ }
+
+- static class RabbitAvoidEntityGoal<T extends LivingEntity> extends AvoidEntityGoal<T> {
+- private final Rabbit rabbit;
+-
+- public RabbitAvoidEntityGoal(Rabbit rabbit, Class<T> entityClassToAvoid, float maxDist, double walkSpeedModifier, double sprintSpeedModifier) {
+- super(rabbit, entityClassToAvoid, maxDist, walkSpeedModifier, sprintSpeedModifier);
+- this.rabbit = rabbit;
+- }
+-
+- @Override
+- public boolean canUse() {
+- return this.rabbit.getVariant() != Rabbit.Variant.EVIL && super.canUse();
+- }
+- }
+-
+- public static class RabbitGroupData extends AgeableMob.AgeableMobGroupData {
+- public final Rabbit.Variant variant;
+-
+- public RabbitGroupData(Rabbit.Variant variant) {
+- super(1.0F);
+- this.variant = variant;
+- }
+- }
+-
+ public static class RabbitJumpControl extends JumpControl {
++
+ private final Rabbit rabbit;
+ private boolean canJump;
+
+- public RabbitJumpControl(Rabbit mob) {
+- super(mob);
+- this.rabbit = mob;
++ public RabbitJumpControl(Rabbit rabbit) {
++ super(rabbit);
++ this.rabbit = rabbit;
+ }
+
+ public boolean wantJump() {
+@@ -471,22 +465,24 @@
+ this.rabbit.startJumping();
+ this.jump = false;
+ }
++
+ }
+ }
+
+- static class RabbitMoveControl extends MoveControl {
++ private static class RabbitMoveControl extends MoveControl {
++
+ private final Rabbit rabbit;
+ private double nextJumpSpeed;
+
+- public RabbitMoveControl(Rabbit mob) {
+- super(mob);
+- this.rabbit = mob;
++ public RabbitMoveControl(Rabbit rabbit) {
++ super(rabbit);
++ this.rabbit = rabbit;
+ }
+
+ @Override
+ public void tick() {
+- if (this.rabbit.onGround() && !this.rabbit.jumping && !((Rabbit.RabbitJumpControl)this.rabbit.jumpControl).wantJump()) {
+- this.rabbit.setSpeedModifier(0.0);
++ if (this.rabbit.onGround() && !this.rabbit.jumping && !((Rabbit.RabbitJumpControl) this.rabbit.jumpControl).wantJump()) {
++ this.rabbit.setSpeedModifier(0.0D);
+ } else if (this.hasWanted()) {
+ this.rabbit.setSpeedModifier(this.nextJumpSpeed);
+ }
+@@ -495,19 +491,21 @@
+ }
+
+ @Override
+- public void setWantedPosition(double x, double y, double z, double speed) {
++ public void setWantedPosition(double x, double d1, double y, double d3) {
+ if (this.rabbit.isInWater()) {
+- speed = 1.5;
++ d3 = 1.5D;
+ }
+
+- super.setWantedPosition(x, y, z, speed);
+- if (speed > 0.0) {
+- this.nextJumpSpeed = speed;
++ super.setWantedPosition(x, d1, y, d3);
++ if (d3 > 0.0D) {
++ this.nextJumpSpeed = d3;
+ }
++
+ }
+ }
+
+- static class RabbitPanicGoal extends PanicGoal {
++ private static class RabbitPanicGoal extends PanicGoal {
++
+ private final Rabbit rabbit;
+
+ public RabbitPanicGoal(Rabbit rabbit, double speedModifier) {
+@@ -522,13 +520,29 @@
+ }
+ }
+
+- static class RaidGardenGoal extends MoveToBlockGoal {
++ private static class RabbitAvoidEntityGoal<T extends LivingEntity> extends AvoidEntityGoal<T> {
++
+ private final Rabbit rabbit;
++
++ public RabbitAvoidEntityGoal(Rabbit rabbit, Class<T> entityClassToAvoid, float maxDist, double walkSpeedModifier, double d1) {
++ super(rabbit, entityClassToAvoid, maxDist, walkSpeedModifier, d1);
++ this.rabbit = rabbit;
++ }
++
++ @Override
++ public boolean canUse() {
++ return this.rabbit.getVariant() != Rabbit.Variant.EVIL && super.canUse();
++ }
++ }
++
++ private static class RaidGardenGoal extends MoveToBlockGoal {
++
++ private final Rabbit rabbit;
+ private boolean wantsToRaid;
+ private boolean canRaid;
+
+ public RaidGardenGoal(Rabbit rabbit) {
+- super(rabbit, 0.7F, 16);
++ super(rabbit, 0.699999988079071D, 16);
+ this.rabbit = rabbit;
+ }
+
+@@ -554,29 +568,33 @@
+ @Override
+ public void tick() {
+ super.tick();
+- this.rabbit
+- .getLookControl()
+- .setLookAt(
+- (double)this.blockPos.getX() + 0.5,
+- (double)(this.blockPos.getY() + 1),
+- (double)this.blockPos.getZ() + 0.5,
+- 10.0F,
+- (float)this.rabbit.getMaxHeadXRot()
+- );
++ this.rabbit.getLookControl().setLookAt((double) this.blockPos.getX() + 0.5D, (double) (this.blockPos.getY() + 1), (double) this.blockPos.getZ() + 0.5D, 10.0F, (float) this.rabbit.getMaxHeadXRot());
+ if (this.isReachedTarget()) {
+- Level level = this.rabbit.level();
+- BlockPos blockPos = this.blockPos.above();
+- BlockState blockState = level.getBlockState(blockPos);
+- Block block = blockState.getBlock();
++ Level world = this.rabbit.level();
++ BlockPos blockposition = this.blockPos.above();
++ IBlockData iblockdata = world.getBlockState(blockposition);
++ Block block = iblockdata.getBlock();
++
+ if (this.canRaid && block instanceof CarrotBlock) {
+- int i = blockState.getValue(CarrotBlock.AGE);
++ int i = (Integer) iblockdata.getValue(CarrotBlock.AGE);
++
+ if (i == 0) {
+- level.setBlock(blockPos, Blocks.AIR.defaultBlockState(), 2);
+- level.destroyBlock(blockPos, true, this.rabbit);
++ // CraftBukkit start
++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, Blocks.AIR.defaultBlockState())) {
++ return;
++ }
++ // CraftBukkit end
++ world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 2);
++ world.destroyBlock(blockposition, true, this.rabbit);
+ } else {
+- level.setBlock(blockPos, blockState.setValue(CarrotBlock.AGE, Integer.valueOf(i - 1)), 2);
+- level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(this.rabbit));
+- level.levelEvent(2001, blockPos, Block.getId(blockState));
++ // CraftBukkit start
++ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, iblockdata.setValue(CarrotBlock.AGE, i - 1))) {
++ return;
++ }
++ // CraftBukkit end
++ world.setBlock(blockposition, (IBlockData) iblockdata.setValue(CarrotBlock.AGE, i - 1), 2);
++ world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of((Entity) this.rabbit));
++ world.levelEvent(2001, blockposition, Block.getId(iblockdata));
+ }
+
+ this.rabbit.moreCarrotTicks = 40;
+@@ -585,14 +603,16 @@
+ this.canRaid = false;
+ this.nextStartTick = 10;
+ }
++
+ }
+
+ @Override
+ protected boolean isValidTarget(LevelReader level, BlockPos pos) {
+- BlockState blockState = level.getBlockState(pos);
+- if (blockState.is(Blocks.FARMLAND) && this.wantsToRaid && !this.canRaid) {
+- blockState = level.getBlockState(pos.above());
+- if (blockState.getBlock() instanceof CarrotBlock && ((CarrotBlock)blockState.getBlock()).isMaxAge(blockState)) {
++ IBlockData iblockdata = level.getBlockState(pos);
++
++ if (iblockdata.is(Blocks.FARMLAND) && this.wantsToRaid && !this.canRaid) {
++ iblockdata = level.getBlockState(pos.above());
++ if (iblockdata.getBlock() instanceof CarrotBlock && ((CarrotBlock) iblockdata.getBlock()).isMaxAge(iblockdata)) {
+ this.canRaid = true;
+ return true;
+ }
+@@ -603,22 +623,17 @@
+ }
+
+ public static enum Variant implements StringRepresentable {
+- BROWN(0, "brown"),
+- WHITE(1, "white"),
+- BLACK(2, "black"),
+- WHITE_SPLOTCHED(3, "white_splotched"),
+- GOLD(4, "gold"),
+- SALT(5, "salt"),
+- EVIL(99, "evil");
+
+- private static final IntFunction<Rabbit.Variant> BY_ID = ByIdMap.sparse(Rabbit.Variant::id, values(), BROWN);
++ BROWN(0, "brown"), WHITE(1, "white"), BLACK(2, "black"), WHITE_SPLOTCHED(3, "white_splotched"), GOLD(4, "gold"), SALT(5, "salt"), EVIL(99, "evil");
++
++ private static final IntFunction<Rabbit.Variant> BY_ID = ByIdMap.sparse(Rabbit.Variant::id, values(), Rabbit.Variant.BROWN);
+ public static final Codec<Rabbit.Variant> CODEC = StringRepresentable.fromEnum(Rabbit.Variant::values);
+ final int id;
+ private final String name;
+
+- private Variant(int id, String name) {
+- this.id = id;
+- this.name = name;
++ private Variant(int i, String s) {
++ this.id = i;
++ this.name = s;
+ }
+
+ @Override
+@@ -631,7 +646,17 @@
+ }
+
+ public static Rabbit.Variant byId(int id) {
+- return BY_ID.apply(id);
++ return (Rabbit.Variant) Rabbit.Variant.BY_ID.apply(id);
+ }
+ }
++
++ public static class RabbitGroupData extends AgeableMob.AgeableMobGroupData {
++
++ public final Rabbit.Variant variant;
++
++ public RabbitGroupData(Rabbit.Variant variant) {
++ super(1.0F);
++ this.variant = variant;
++ }
++ }
+ }