aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Ocelot.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Ocelot.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Ocelot.java.patch342
1 files changed, 342 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Ocelot.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Ocelot.java.patch
new file mode 100644
index 0000000000..cc9e027272
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/Ocelot.java.patch
@@ -0,0 +1,342 @@
+--- a/net/minecraft/world/entity/animal/Ocelot.java
++++ b/net/minecraft/world/entity/animal/Ocelot.java
+@@ -1,9 +1,11 @@
+ package net.minecraft.world.entity.animal;
+
++import java.util.Objects;
++import java.util.function.Predicate;
+ import javax.annotation.Nullable;
+ import net.minecraft.core.BlockPos;
+-import net.minecraft.core.particles.ParticleOptions;
+ import net.minecraft.core.particles.ParticleTypes;
++import net.minecraft.core.particles.SimpleParticleType;
+ import net.minecraft.nbt.CompoundTag;
+ import net.minecraft.network.syncher.EntityDataAccessor;
+ import net.minecraft.network.syncher.EntityDataSerializers;
+@@ -14,19 +16,19 @@
+ import net.minecraft.tags.BlockTags;
+ import net.minecraft.util.RandomSource;
+ import net.minecraft.world.DifficultyInstance;
+-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.EntitySelector;
+ 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.Pose;
+-import net.minecraft.world.entity.SpawnGroupData;
+ import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
+ import net.minecraft.world.entity.ai.attributes.Attributes;
+ import net.minecraft.world.entity.ai.goal.AvoidEntityGoal;
+@@ -47,14 +49,15 @@
+ import net.minecraft.world.level.LevelReader;
+ import net.minecraft.world.level.ServerLevelAccessor;
+ import net.minecraft.world.level.block.Blocks;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.phys.Vec3;
+ import org.joml.Vector3f;
+
+ public class Ocelot extends Animal {
+- public static final double CROUCH_SPEED_MOD = 0.6;
+- public static final double WALK_SPEED_MOD = 0.8;
+- public static final double SPRINT_SPEED_MOD = 1.33;
++
++ public static final double CROUCH_SPEED_MOD = 0.6D;
++ public static final double WALK_SPEED_MOD = 0.8D;
++ public static final double SPRINT_SPEED_MOD = 1.33D;
+ private static final Ingredient TEMPT_INGREDIENT = Ingredient.of(Items.COD, Items.SALMON);
+ private static final EntityDataAccessor<Boolean> DATA_TRUSTING = SynchedEntityData.defineId(Ocelot.class, EntityDataSerializers.BOOLEAN);
+ @Nullable
+@@ -67,12 +70,12 @@
+ this.reassessTrustingGoals();
+ }
+
+- boolean isTrusting() {
+- return this.entityData.get(DATA_TRUSTING);
++ public boolean isTrusting() {
++ return (Boolean) this.entityData.get(Ocelot.DATA_TRUSTING);
+ }
+
+- private void setTrusting(boolean trusting) {
+- this.entityData.set(DATA_TRUSTING, trusting);
++ public void setTrusting(boolean trusting) {
++ this.entityData.set(Ocelot.DATA_TRUSTING, trusting);
+ this.reassessTrustingGoals();
+ }
+
+@@ -91,18 +94,18 @@
+ @Override
+ protected void defineSynchedData() {
+ super.defineSynchedData();
+- this.entityData.define(DATA_TRUSTING, false);
++ this.entityData.define(Ocelot.DATA_TRUSTING, false);
+ }
+
+ @Override
+ protected void registerGoals() {
+- this.temptGoal = new Ocelot.OcelotTemptGoal(this, 0.6, TEMPT_INGREDIENT, true);
++ this.temptGoal = new Ocelot.OcelotTemptGoal(this, 0.6D, Ocelot.TEMPT_INGREDIENT, true);
+ this.goalSelector.addGoal(1, new FloatGoal(this));
+ this.goalSelector.addGoal(3, this.temptGoal);
+ this.goalSelector.addGoal(7, new LeapAtTargetGoal(this, 0.3F));
+ this.goalSelector.addGoal(8, new OcelotAttackGoal(this));
+- this.goalSelector.addGoal(9, new BreedGoal(this, 0.8));
+- this.goalSelector.addGoal(10, new WaterAvoidingRandomStrollGoal(this, 0.8, 1.0000001E-5F));
++ this.goalSelector.addGoal(9, new BreedGoal(this, 0.8D));
++ this.goalSelector.addGoal(10, new WaterAvoidingRandomStrollGoal(this, 0.8D, 1.0000001E-5F));
+ this.goalSelector.addGoal(11, new LookAtPlayerGoal(this, Player.class, 10.0F));
+ this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Chicken.class, false));
+ this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, false, false, Turtle.BABY_ON_LAND_SELECTOR));
+@@ -111,21 +114,23 @@
+ @Override
+ public void customServerAiStep() {
+ if (this.getMoveControl().hasWanted()) {
+- double speedModifier = this.getMoveControl().getSpeedModifier();
+- if (speedModifier == 0.6) {
+- this.setPose(Pose.CROUCHING);
++ double d0 = this.getMoveControl().getSpeedModifier();
++
++ if (d0 == 0.6D) {
++ this.setPose(EntityPose.CROUCHING);
+ this.setSprinting(false);
+- } else if (speedModifier == 1.33) {
+- this.setPose(Pose.STANDING);
++ } else if (d0 == 1.33D) {
++ this.setPose(EntityPose.STANDING);
+ this.setSprinting(true);
+ } else {
+- this.setPose(Pose.STANDING);
++ this.setPose(EntityPose.STANDING);
+ this.setSprinting(false);
+ }
+ } else {
+- this.setPose(Pose.STANDING);
++ this.setPose(EntityPose.STANDING);
+ this.setSprinting(false);
+ }
++
+ }
+
+ @Override
+@@ -134,7 +139,7 @@
+ }
+
+ public static AttributeSupplier.Builder createAttributes() {
+- return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 10.0).add(Attributes.MOVEMENT_SPEED, 0.3F).add(Attributes.ATTACK_DAMAGE, 3.0);
++ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 10.0D).add(Attributes.MOVEMENT_SPEED, 0.30000001192092896D).add(Attributes.ATTACK_DAMAGE, 3.0D);
+ }
+
+ @Nullable
+@@ -159,7 +164,7 @@
+ }
+
+ private float getAttackDamage() {
+- return (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE);
++ return (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE);
+ }
+
+ @Override
+@@ -168,18 +173,19 @@
+ }
+
+ @Override
+- public InteractionResult mobInteract(Player player, InteractionHand hand) {
+- ItemStack itemInHand = player.getItemInHand(hand);
+- if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemInHand) && player.distanceToSqr(this) < 9.0) {
+- this.usePlayerItem(player, hand, itemInHand);
++ public InteractionResult mobInteract(Player player, EnumHand hand) {
++ ItemStack itemstack = player.getItemInHand(hand);
++
++ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && player.distanceToSqr((Entity) this) < 9.0D) {
++ this.usePlayerItem(player, hand, itemstack);
+ if (!this.level().isClientSide) {
+- if (this.random.nextInt(3) == 0) {
++ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call and isCancelled check
+ this.setTrusting(true);
+ this.spawnTrustingParticles(true);
+- this.level().broadcastEntityEvent(this, (byte)41);
++ this.level().broadcastEntityEvent(this, (byte) 41);
+ } else {
+ this.spawnTrustingParticles(false);
+- this.level().broadcastEntityEvent(this, (byte)40);
++ this.level().broadcastEntityEvent(this, (byte) 40);
+ }
+ }
+
+@@ -198,58 +204,65 @@
+ } else {
+ super.handleEntityEvent(id);
+ }
++
+ }
+
+ private void spawnTrustingParticles(boolean isTrusted) {
+- ParticleOptions particleOptions = ParticleTypes.HEART;
++ SimpleParticleType particletype = ParticleTypes.HEART;
++
+ if (!isTrusted) {
+- particleOptions = ParticleTypes.SMOKE;
++ particletype = ParticleTypes.SMOKE;
+ }
+
+- for (int i = 0; i < 7; i++) {
+- double d = this.random.nextGaussian() * 0.02;
+- double d1 = this.random.nextGaussian() * 0.02;
+- double d2 = this.random.nextGaussian() * 0.02;
+- this.level().addParticle(particleOptions, this.getRandomX(1.0), this.getRandomY() + 0.5, this.getRandomZ(1.0), d, d1, d2);
++ for (int i = 0; i < 7; ++i) {
++ double d0 = this.random.nextGaussian() * 0.02D;
++ double d1 = this.random.nextGaussian() * 0.02D;
++ double d2 = this.random.nextGaussian() * 0.02D;
++
++ this.level().addParticle(particletype, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), d0, d1, d2);
+ }
++
+ }
+
+ protected void reassessTrustingGoals() {
+ if (this.ocelotAvoidPlayersGoal == null) {
+- this.ocelotAvoidPlayersGoal = new Ocelot.OcelotAvoidEntityGoal<>(this, Player.class, 16.0F, 0.8, 1.33);
++ this.ocelotAvoidPlayersGoal = new Ocelot.OcelotAvoidEntityGoal<>(this, Player.class, 16.0F, 0.8D, 1.33D);
+ }
+
+ this.goalSelector.removeGoal(this.ocelotAvoidPlayersGoal);
+ if (!this.isTrusting()) {
+ this.goalSelector.addGoal(4, this.ocelotAvoidPlayersGoal);
+ }
++
+ }
+
+ @Nullable
+ @Override
+ public Ocelot getBreedOffspring(ServerLevel level, AgeableMob otherParent) {
+- return EntityType.OCELOT.create(level);
++ return (Ocelot) EntityType.OCELOT.create(level);
+ }
+
+ @Override
+ public boolean isFood(ItemStack stack) {
+- return TEMPT_INGREDIENT.test(stack);
++ return Ocelot.TEMPT_INGREDIENT.test(stack);
+ }
+
+- public static boolean checkOcelotSpawnRules(EntityType<Ocelot> ocelot, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random) {
++ public static boolean checkOcelotSpawnRules(EntityType<Ocelot> ocelot, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) {
+ return random.nextInt(3) != 0;
+ }
+
+ @Override
+ public boolean checkSpawnObstruction(LevelReader level) {
+ if (level.isUnobstructed(this) && !level.containsAnyLiquid(this.getBoundingBox())) {
+- BlockPos blockPos = this.blockPosition();
+- if (blockPos.getY() < level.getSeaLevel()) {
++ BlockPos blockposition = this.blockPosition();
++
++ if (blockposition.getY() < level.getSeaLevel()) {
+ return false;
+ }
+
+- BlockState blockState = level.getBlockState(blockPos.below());
+- if (blockState.is(Blocks.GRASS_BLOCK) || blockState.is(BlockTags.LEAVES)) {
++ IBlockData iblockdata = level.getBlockState(blockposition.below());
++
++ if (iblockdata.is(Blocks.GRASS_BLOCK) || iblockdata.is(BlockTags.LEAVES)) {
+ return true;
+ }
+ }
+@@ -259,19 +272,17 @@
+
+ @Nullable
+ @Override
+- public SpawnGroupData finalizeSpawn(
+- ServerLevelAccessor level, DifficultyInstance difficulty, MobSpawnType reason, @Nullable SpawnGroupData spawnData, @Nullable CompoundTag dataTag
+- ) {
++ public GroupDataEntity finalizeSpawn(ServerLevelAccessor level, DifficultyInstance difficulty, EnumMobSpawn reason, @Nullable GroupDataEntity spawnData, @Nullable CompoundTag dataTag) {
+ if (spawnData == null) {
+ spawnData = new AgeableMob.AgeableMobGroupData(1.0F);
+ }
+
+- return super.finalizeSpawn(level, difficulty, reason, spawnData, dataTag);
++ return super.finalizeSpawn(level, difficulty, reason, (GroupDataEntity) spawnData, dataTag);
+ }
+
+ @Override
+ public Vec3 getLeashOffset() {
+- return new Vec3(0.0, (double)(0.5F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.4F));
++ return new Vec3(0.0D, (double) (0.5F * this.getEyeHeight()), (double) (this.getBbWidth() * 0.4F));
+ }
+
+ @Override
+@@ -280,40 +291,45 @@
+ }
+
+ @Override
+- protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entityDimensions, float f) {
+- return new Vector3f(0.0F, entityDimensions.height - 0.0625F * f, 0.0F);
++ protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitysize, float f) {
++ return new Vector3f(0.0F, entitysize.height - 0.0625F * f, 0.0F);
+ }
+
+- static class OcelotAvoidEntityGoal<T extends LivingEntity> extends AvoidEntityGoal<T> {
++ private static class OcelotTemptGoal extends TemptGoal {
++
+ private final Ocelot ocelot;
+
+- public OcelotAvoidEntityGoal(Ocelot ocelot, Class<T> entityClassToAvoid, float maxDist, double walkSpeedModifier, double sprintSpeedModifier) {
+- super(ocelot, entityClassToAvoid, maxDist, walkSpeedModifier, sprintSpeedModifier, EntitySelector.NO_CREATIVE_OR_SPECTATOR::test);
++ public OcelotTemptGoal(Ocelot ocelot, double speedModifier, Ingredient recipeitemstack, boolean items) {
++ super(ocelot, speedModifier, recipeitemstack, items);
+ this.ocelot = ocelot;
+ }
+
+ @Override
+- public boolean canUse() {
+- return !this.ocelot.isTrusting() && super.canUse();
++ protected boolean canScare() {
++ return super.canScare() && !this.ocelot.isTrusting();
+ }
+-
+- @Override
+- public boolean canContinueToUse() {
+- return !this.ocelot.isTrusting() && super.canContinueToUse();
+- }
+ }
+
+- static class OcelotTemptGoal extends TemptGoal {
++ private static class OcelotAvoidEntityGoal<T extends LivingEntity> extends AvoidEntityGoal<T> {
++
+ private final Ocelot ocelot;
+
+- public OcelotTemptGoal(Ocelot ocelot, double speedModifier, Ingredient items, boolean canScare) {
+- super(ocelot, speedModifier, items, canScare);
++ public OcelotAvoidEntityGoal(Ocelot ocelot, Class<T> entityClassToAvoid, float maxDist, double walkSpeedModifier, double d1) {
++ // Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; // CraftBukkit - decompile error
++
++ // Objects.requireNonNull(predicate); // CraftBukkit - decompile error
++ super(ocelot, entityClassToAvoid, maxDist, walkSpeedModifier, d1, EntitySelector.NO_CREATIVE_OR_SPECTATOR::test); // CraftBukkit - decompile error
+ this.ocelot = ocelot;
+ }
+
+ @Override
+- protected boolean canScare() {
+- return super.canScare() && !this.ocelot.isTrusting();
++ public boolean canUse() {
++ return !this.ocelot.isTrusting() && super.canUse();
+ }
++
++ @Override
++ public boolean canContinueToUse() {
++ return !this.ocelot.isTrusting() && super.canContinueToUse();
++ }
+ }
+ }