diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Wolf.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Wolf.java.patch | 589 |
1 files changed, 589 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Wolf.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Wolf.java.patch new file mode 100644 index 0000000000..75050baf96 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Wolf.java.patch @@ -0,0 +1,589 @@ +--- a/net/minecraft/world/entity/animal/Wolf.java ++++ b/net/minecraft/world/entity/animal/Wolf.java +@@ -17,18 +17,18 @@ + import net.minecraft.util.RandomSource; + import net.minecraft.util.TimeUtil; + import net.minecraft.util.valueproviders.UniformInt; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.AgeableMob; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntityDimensions; ++import net.minecraft.world.entity.EntityPose; + import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.entity.EnumMobSpawn; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.Mob; +-import net.minecraft.world.entity.MobSpawnType; + import net.minecraft.world.entity.NeutralMob; +-import net.minecraft.world.entity.Pose; + import net.minecraft.world.entity.TamableAnimal; + import net.minecraft.world.entity.ai.attributes.AttributeSupplier; + import net.minecraft.world.entity.ai.attributes.Attributes; +@@ -64,21 +64,27 @@ + import net.minecraft.world.item.Items; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.LevelAccessor; +-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.BlockPathTypes; + import net.minecraft.world.phys.Vec3; + import org.joml.Vector3f; + ++// CraftBukkit start ++import org.bukkit.event.entity.EntityRegainHealthEvent; ++import org.bukkit.event.entity.EntityTargetEvent; ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++// CraftBukkit end ++ + public class Wolf extends TamableAnimal implements NeutralMob { + + private static final EntityDataAccessor<Boolean> DATA_INTERESTED_ID = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.BOOLEAN); + private static final EntityDataAccessor<Integer> DATA_COLLAR_COLOR = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.INT); + private static final EntityDataAccessor<Integer> DATA_REMAINING_ANGER_TIME = SynchedEntityData.defineId(Wolf.class, EntityDataSerializers.INT); +- public static final Predicate<LivingEntity> PREY_SELECTOR = (livingentity) -> { +- EntityType<?> entitytype = livingentity.getType(); ++ public static final Predicate<LivingEntity> PREY_SELECTOR = (entityliving) -> { ++ EntityType<?> entitytypes = entityliving.getType(); + +- return entitytype == EntityType.SHEEP || entitytype == EntityType.RABBIT || entitytype == EntityType.FOX; ++ return entitytypes == EntityType.SHEEP || entitytypes == EntityType.RABBIT || entitytypes == EntityType.FOX; + }; + private static final float START_HEALTH = 8.0F; + private static final float TAME_HEALTH = 20.0F; +@@ -92,15 +98,14 @@ + @Nullable + private UUID persistentAngerTarget; + +- public Wolf(EntityType<? extends Wolf> entitytype, Level level) { +- super(entitytype, level); ++ public Wolf(EntityType<? extends Wolf> entityType, Level level) { ++ super(entityType, level); + this.setTame(false); + this.setPathfindingMalus(BlockPathTypes.POWDER_SNOW, -1.0F); + this.setPathfindingMalus(BlockPathTypes.DANGER_POWDER_SNOW, -1.0F); + } + + @Override +- @Override + protected void registerGoals() { + this.goalSelector.addGoal(1, new FloatGoal(this)); + this.goalSelector.addGoal(1, new Wolf.WolfPanicGoal(1.5D)); +@@ -129,7 +134,6 @@ + } + + @Override +- @Override + protected void defineSynchedData() { + super.defineSynchedData(); + this.entityData.define(Wolf.DATA_INTERESTED_ID, false); +@@ -138,56 +142,48 @@ + } + + @Override +- @Override +- protected void playStepSound(BlockPos blockpos, BlockState blockstate) { ++ protected void playStepSound(BlockPos pos, IBlockData block) { + this.playSound(SoundEvents.WOLF_STEP, 0.15F, 1.0F); + } + + @Override +- @Override +- public void addAdditionalSaveData(CompoundTag compoundtag) { +- super.addAdditionalSaveData(compoundtag); +- compoundtag.putByte("CollarColor", (byte) this.getCollarColor().getId()); +- this.addPersistentAngerSaveData(compoundtag); ++ public void addAdditionalSaveData(CompoundTag compound) { ++ super.addAdditionalSaveData(compound); ++ compound.putByte("CollarColor", (byte) this.getCollarColor().getId()); ++ this.addPersistentAngerSaveData(compound); + } + + @Override +- @Override +- public void readAdditionalSaveData(CompoundTag compoundtag) { +- super.readAdditionalSaveData(compoundtag); +- if (compoundtag.contains("CollarColor", 99)) { +- this.setCollarColor(DyeColor.byId(compoundtag.getInt("CollarColor"))); ++ public void readAdditionalSaveData(CompoundTag compound) { ++ super.readAdditionalSaveData(compound); ++ if (compound.contains("CollarColor", 99)) { ++ this.setCollarColor(DyeColor.byId(compound.getInt("CollarColor"))); + } + +- this.readPersistentAngerSaveData(this.level(), compoundtag); ++ this.readPersistentAngerSaveData(this.level(), compound); + } + + @Override +- @Override + protected SoundEvent getAmbientSound() { + return this.isAngry() ? SoundEvents.WOLF_GROWL : (this.random.nextInt(3) == 0 ? (this.isTame() && this.getHealth() < 10.0F ? SoundEvents.WOLF_WHINE : SoundEvents.WOLF_PANT) : SoundEvents.WOLF_AMBIENT); + } + + @Override +- @Override +- protected SoundEvent getHurtSound(DamageSource damagesource) { ++ protected SoundEvent getHurtSound(DamageSource damageSource) { + return SoundEvents.WOLF_HURT; + } + + @Override +- @Override + protected SoundEvent getDeathSound() { + return SoundEvents.WOLF_DEATH; + } + + @Override +- @Override + protected float getSoundVolume() { + return 0.4F; + } + + @Override +- @Override + public void aiStep() { + super.aiStep(); + if (!this.level().isClientSide && this.isWet && !this.isShaking && !this.isPathFinding() && this.onGround()) { +@@ -204,7 +200,6 @@ + } + + @Override +- @Override + public void tick() { + super.tick(); + if (this.isAlive()) { +@@ -239,13 +234,13 @@ + if (this.shakeAnim > 0.4F) { + float f = (float) this.getY(); + int i = (int) (Mth.sin((this.shakeAnim - 0.4F) * 3.1415927F) * 7.0F); +- Vec3 vec3 = this.getDeltaMovement(); ++ Vec3 vec3d = this.getDeltaMovement(); + + for (int j = 0; j < i; ++j) { + float f1 = (this.random.nextFloat() * 2.0F - 1.0F) * this.getBbWidth() * 0.5F; + float f2 = (this.random.nextFloat() * 2.0F - 1.0F) * this.getBbWidth() * 0.5F; + +- this.level().addParticle(ParticleTypes.SPLASH, this.getX() + (double) f1, (double) (f + 0.8F), this.getZ() + (double) f2, vec3.x, vec3.y, vec3.z); ++ this.level().addParticle(ParticleTypes.SPLASH, this.getX() + (double) f1, (double) (f + 0.8F), this.getZ() + (double) f2, vec3d.x, vec3d.y, vec3d.z); + } + } + } +@@ -260,25 +255,24 @@ + } + + @Override +- @Override +- public void die(DamageSource damagesource) { ++ public void die(DamageSource cause) { + this.isWet = false; + this.isShaking = false; + this.shakeAnimO = 0.0F; + this.shakeAnim = 0.0F; +- super.die(damagesource); ++ super.die(cause); + } + + public boolean isWet() { + return this.isWet; + } + +- public float getWetShade(float f) { +- return Math.min(0.5F + Mth.lerp(f, this.shakeAnimO, this.shakeAnim) / 2.0F * 0.5F, 1.0F); ++ public float getWetShade(float partialTicks) { ++ return Math.min(0.5F + Mth.lerp(partialTicks, this.shakeAnimO, this.shakeAnim) / 2.0F * 0.5F, 1.0F); + } + +- public float getBodyRollAngle(float f, float f1) { +- float f2 = (Mth.lerp(f, this.shakeAnimO, this.shakeAnim) + f1) / 1.8F; ++ public float getBodyRollAngle(float partialTicks, float offset) { ++ float f2 = (Mth.lerp(partialTicks, this.shakeAnimO, this.shakeAnim) + offset) / 1.8F; + + if (f2 < 0.0F) { + f2 = 0.0F; +@@ -289,44 +283,44 @@ + return Mth.sin(f2 * 3.1415927F) * Mth.sin(f2 * 3.1415927F * 11.0F) * 0.15F * 3.1415927F; + } + +- public float getHeadRollAngle(float f) { +- return Mth.lerp(f, this.interestedAngleO, this.interestedAngle) * 0.15F * 3.1415927F; ++ public float getHeadRollAngle(float partialTicks) { ++ return Mth.lerp(partialTicks, this.interestedAngleO, this.interestedAngle) * 0.15F * 3.1415927F; + } + + @Override +- @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions entitydimensions) { +- return entitydimensions.height * 0.8F; ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { ++ return size.height * 0.8F; + } + + @Override +- @Override + public int getMaxHeadXRot() { + return this.isInSittingPose() ? 20 : super.getMaxHeadXRot(); + } + + @Override +- @Override +- public boolean hurt(DamageSource damagesource, float f) { +- if (this.isInvulnerableTo(damagesource)) { ++ public boolean hurt(DamageSource source, float amount) { ++ if (this.isInvulnerableTo(source)) { + return false; + } else { +- Entity entity = damagesource.getEntity(); ++ Entity entity = source.getEntity(); + +- if (!this.level().isClientSide) { +- this.setOrderedToSit(false); +- } ++ // CraftBukkit - move diff down + + if (entity != null && !(entity instanceof Player) && !(entity instanceof AbstractArrow)) { +- f = (f + 1.0F) / 2.0F; ++ amount = (amount + 1.0F) / 2.0F; + } + +- return super.hurt(damagesource, f); ++ // CraftBukkit start ++ boolean result = super.hurt(source, amount); ++ if (!this.level().isClientSide && result) { ++ this.setOrderedToSit(false); ++ } ++ return result; ++ // CraftBukkit end + } + } + + @Override +- @Override + public boolean doHurtTarget(Entity entity) { + boolean flag = entity.hurt(this.damageSources().mobAttack(this), (float) ((int) this.getAttributeValue(Attributes.ATTACK_DAMAGE))); + +@@ -338,12 +332,11 @@ + } + + @Override +- @Override +- public void setTame(boolean flag) { +- super.setTame(flag); +- if (flag) { ++ public void setTame(boolean tamed) { ++ super.setTame(tamed); ++ if (tamed) { + this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(20.0D); +- this.setHealth(20.0F); ++ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth() + } else { + this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0D); + } +@@ -352,9 +345,8 @@ + } + + @Override +- @Override +- public InteractionResult mobInteract(Player player, InteractionHand interactionhand) { +- ItemStack itemstack = player.getItemInHand(interactionhand); ++ public InteractionResult mobInteract(Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); + Item item = itemstack.getItem(); + + if (this.level().isClientSide) { +@@ -367,17 +359,17 @@ + itemstack.shrink(1); + } + +- this.heal((float) item.getFoodProperties().getNutrition()); ++ this.heal((float) item.getFoodProperties().getNutrition(), EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit + return InteractionResult.SUCCESS; + } else { + if (item instanceof DyeItem) { +- DyeItem dyeitem = (DyeItem) item; ++ DyeItem itemdye = (DyeItem) item; + + if (this.isOwnedBy(player)) { +- DyeColor dyecolor = dyeitem.getDyeColor(); ++ DyeColor enumcolor = itemdye.getDyeColor(); + +- if (dyecolor != this.getCollarColor()) { +- this.setCollarColor(dyecolor); ++ if (enumcolor != this.getCollarColor()) { ++ this.setCollarColor(enumcolor); + if (!player.getAbilities().instabuild) { + itemstack.shrink(1); + } +@@ -385,20 +377,20 @@ + return InteractionResult.SUCCESS; + } + +- return super.mobInteract(player, interactionhand); ++ return super.mobInteract(player, hand); + } + } + +- InteractionResult interactionresult = super.mobInteract(player, interactionhand); ++ InteractionResult enuminteractionresult = super.mobInteract(player, hand); + +- if ((!interactionresult.consumesAction() || this.isBaby()) && this.isOwnedBy(player)) { ++ if ((!enuminteractionresult.consumesAction() || this.isBaby()) && this.isOwnedBy(player)) { + this.setOrderedToSit(!this.isOrderedToSit()); + this.jumping = false; + this.navigation.stop(); +- this.setTarget((LivingEntity) null); ++ this.setTarget((LivingEntity) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason + return InteractionResult.SUCCESS; + } else { +- return interactionresult; ++ return enuminteractionresult; + } + } + } else if (itemstack.is(Items.BONE) && !this.isAngry()) { +@@ -406,7 +398,8 @@ + itemstack.shrink(1); + } + +- if (this.random.nextInt(3) == 0) { ++ // CraftBukkit - added event call and isCancelled check. ++ if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { + this.tame(player); + this.navigation.stop(); + this.setTarget((LivingEntity) null); +@@ -418,21 +411,20 @@ + + return InteractionResult.SUCCESS; + } else { +- return super.mobInteract(player, interactionhand); ++ return super.mobInteract(player, hand); + } + } + + @Override +- @Override +- public void handleEntityEvent(byte b0) { +- if (b0 == 8) { ++ public void handleEntityEvent(byte id) { ++ if (id == 8) { + this.isShaking = true; + this.shakeAnim = 0.0F; + this.shakeAnimO = 0.0F; +- } else if (b0 == 56) { ++ } else if (id == 56) { + this.cancelShake(); + } else { +- super.handleEntityEvent(b0); ++ super.handleEntityEvent(id); + } + + } +@@ -442,93 +434,84 @@ + } + + @Override +- @Override +- public boolean isFood(ItemStack itemstack) { +- Item item = itemstack.getItem(); ++ public boolean isFood(ItemStack stack) { ++ Item item = stack.getItem(); + + return item.isEdible() && item.getFoodProperties().isMeat(); + } + + @Override +- @Override + public int getMaxSpawnClusterSize() { + return 8; + } + + @Override +- @Override + public int getRemainingPersistentAngerTime() { + return (Integer) this.entityData.get(Wolf.DATA_REMAINING_ANGER_TIME); + } + + @Override +- @Override +- public void setRemainingPersistentAngerTime(int i) { +- this.entityData.set(Wolf.DATA_REMAINING_ANGER_TIME, i); ++ public void setRemainingPersistentAngerTime(int time) { ++ this.entityData.set(Wolf.DATA_REMAINING_ANGER_TIME, time); + } + + @Override +- @Override + public void startPersistentAngerTimer() { + this.setRemainingPersistentAngerTime(Wolf.PERSISTENT_ANGER_TIME.sample(this.random)); + } + + @Nullable + @Override +- @Override + public UUID getPersistentAngerTarget() { + return this.persistentAngerTarget; + } + + @Override +- @Override +- public void setPersistentAngerTarget(@Nullable UUID uuid) { +- this.persistentAngerTarget = uuid; ++ public void setPersistentAngerTarget(@Nullable UUID target) { ++ this.persistentAngerTarget = target; + } + + public DyeColor getCollarColor() { + return DyeColor.byId((Integer) this.entityData.get(Wolf.DATA_COLLAR_COLOR)); + } + +- public void setCollarColor(DyeColor dyecolor) { +- this.entityData.set(Wolf.DATA_COLLAR_COLOR, dyecolor.getId()); ++ public void setCollarColor(DyeColor collarColor) { ++ this.entityData.set(Wolf.DATA_COLLAR_COLOR, collarColor.getId()); + } + + @Nullable + @Override +- @Override +- public Wolf getBreedOffspring(ServerLevel serverlevel, AgeableMob ageablemob) { +- Wolf wolf = (Wolf) EntityType.WOLF.create(serverlevel); ++ public Wolf getBreedOffspring(ServerLevel level, AgeableMob otherParent) { ++ Wolf entitywolf = (Wolf) EntityType.WOLF.create(level); + +- if (wolf != null) { ++ if (entitywolf != null) { + UUID uuid = this.getOwnerUUID(); + + if (uuid != null) { +- wolf.setOwnerUUID(uuid); +- wolf.setTame(true); ++ entitywolf.setOwnerUUID(uuid); ++ entitywolf.setTame(true); + } + } + +- return wolf; ++ return entitywolf; + } + +- public void setIsInterested(boolean flag) { +- this.entityData.set(Wolf.DATA_INTERESTED_ID, flag); ++ public void setIsInterested(boolean isInterested) { ++ this.entityData.set(Wolf.DATA_INTERESTED_ID, isInterested); + } + + @Override +- @Override +- public boolean canMate(Animal animal) { +- if (animal == this) { ++ public boolean canMate(Animal otherAnimal) { ++ if (otherAnimal == this) { + return false; + } else if (!this.isTame()) { + return false; +- } else if (!(animal instanceof Wolf)) { ++ } else if (!(otherAnimal instanceof Wolf)) { + return false; + } else { +- Wolf wolf = (Wolf) animal; ++ Wolf entitywolf = (Wolf) otherAnimal; + +- return !wolf.isTame() ? false : (wolf.isInSittingPose() ? false : this.isInLove() && wolf.isInLove()); ++ return !entitywolf.isTame() ? false : (entitywolf.isInSittingPose() ? false : this.isInLove() && entitywolf.isInLove()); + } + } + +@@ -537,15 +520,14 @@ + } + + @Override +- @Override +- public boolean wantsToAttack(LivingEntity livingentity, LivingEntity livingentity1) { +- if (!(livingentity instanceof Creeper) && !(livingentity instanceof Ghast)) { +- if (livingentity instanceof Wolf) { +- Wolf wolf = (Wolf) livingentity; ++ public boolean wantsToAttack(LivingEntity target, LivingEntity owner) { ++ if (!(target instanceof Creeper) && !(target instanceof Ghast)) { ++ if (target instanceof Wolf) { ++ Wolf entitywolf = (Wolf) target; + +- return !wolf.isTame() || wolf.getOwner() != livingentity1; ++ return !entitywolf.isTame() || entitywolf.getOwner() != owner; + } else { +- return livingentity instanceof Player && livingentity1 instanceof Player && !((Player) livingentity1).canHarmPlayer((Player) livingentity) ? false : (livingentity instanceof AbstractHorse && ((AbstractHorse) livingentity).isTamed() ? false : !(livingentity instanceof TamableAnimal) || !((TamableAnimal) livingentity).isTame()); ++ return target instanceof Player && owner instanceof Player && !((Player) owner).canHarmPlayer((Player) target) ? false : (target instanceof AbstractHorse && ((AbstractHorse) target).isTamed() ? false : !(target instanceof TamableAnimal) || !((TamableAnimal) target).isTame()); + } + } else { + return false; +@@ -553,25 +535,22 @@ + } + + @Override +- @Override + public boolean canBeLeashed(Player player) { + return !this.isAngry() && super.canBeLeashed(player); + } + + @Override +- @Override + public Vec3 getLeashOffset() { + return new Vec3(0.0D, (double) (0.6F * this.getEyeHeight()), (double) (this.getBbWidth() * 0.4F)); + } + + @Override +- @Override +- protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitydimensions, float f) { +- return new Vector3f(0.0F, entitydimensions.height - 0.03125F * f, -0.0625F * f); ++ protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitysize, float f) { ++ return new Vector3f(0.0F, entitysize.height - 0.03125F * f, -0.0625F * f); + } + +- public static boolean checkWolfSpawnRules(EntityType<Wolf> entitytype, LevelAccessor levelaccessor, MobSpawnType mobspawntype, BlockPos blockpos, RandomSource randomsource) { +- return levelaccessor.getBlockState(blockpos.below()).is(BlockTags.WOLVES_SPAWNABLE_ON) && isBrightEnoughToSpawn(levelaccessor, blockpos); ++ public static boolean checkWolfSpawnRules(EntityType<Wolf> wolf, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) { ++ return level.getBlockState(pos.below()).is(BlockTags.WOLVES_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos); + } + + private class WolfPanicGoal extends PanicGoal { +@@ -581,7 +560,6 @@ + } + + @Override +- @Override + protected boolean shouldPanic() { + return this.mob.isFreezing() || this.mob.isOnFire(); + } +@@ -591,13 +569,12 @@ + + private final Wolf wolf; + +- public WolfAvoidEntityGoal(Wolf wolf, Class<T> oclass, float f, double d0, double d1) { +- super(wolf, oclass, f, d0, d1); +- this.wolf = wolf; ++ public WolfAvoidEntityGoal(Wolf entitywolf, Class oclass, float f, double d0, double d1) { ++ super(entitywolf, oclass, f, d0, d1); ++ this.wolf = entitywolf; + } + + @Override +- @Override + public boolean canUse() { + return super.canUse() && this.toAvoid instanceof Llama ? !this.wolf.isTame() && this.avoidLlama((Llama) this.toAvoid) : false; + } +@@ -607,14 +584,12 @@ + } + + @Override +- @Override + public void start() { + Wolf.this.setTarget((LivingEntity) null); + super.start(); + } + + @Override +- @Override + public void tick() { + Wolf.this.setTarget((LivingEntity) null); + super.tick(); |