aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Pig.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Pig.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Pig.java.patch386
1 files changed, 386 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Pig.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Pig.java.patch
new file mode 100644
index 0000000000..760608d1fa
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/animal/Pig.java.patch
@@ -0,0 +1,386 @@
+--- a/net/minecraft/world/entity/animal/Pig.java
++++ b/net/minecraft/world/entity/animal/Pig.java
+@@ -13,20 +13,20 @@
+ import net.minecraft.sounds.SoundEvents;
+ import net.minecraft.sounds.SoundSource;
+ import net.minecraft.world.Difficulty;
+-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.EquipmentSlot;
++import net.minecraft.world.entity.ISteerable;
+ import net.minecraft.world.entity.ItemBasedSteering;
+-import net.minecraft.world.entity.ItemSteerable;
+ import net.minecraft.world.entity.LightningBolt;
+ import net.minecraft.world.entity.LivingEntity;
+ import net.minecraft.world.entity.Mob;
+-import net.minecraft.world.entity.Pose;
+ import net.minecraft.world.entity.Saddleable;
+ import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
+ import net.minecraft.world.entity.ai.attributes.Attributes;
+@@ -44,27 +44,30 @@
+ import net.minecraft.world.item.ItemStack;
+ import net.minecraft.world.item.Items;
+ import net.minecraft.world.item.crafting.Ingredient;
+-import net.minecraft.world.level.ItemLike;
++import net.minecraft.world.level.IMaterial;
+ import net.minecraft.world.level.Level;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.phys.AABB;
+ import net.minecraft.world.phys.Vec3;
+ import org.joml.Vector3f;
+
+-public class Pig extends Animal implements ItemSteerable, Saddleable {
++// CraftBukkit start
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++// CraftBukkit end
+
++public class Pig extends Animal implements ISteerable, Saddleable {
++
+ private static final EntityDataAccessor<Boolean> DATA_SADDLE_ID = SynchedEntityData.defineId(Pig.class, EntityDataSerializers.BOOLEAN);
+ private static final EntityDataAccessor<Integer> DATA_BOOST_TIME = SynchedEntityData.defineId(Pig.class, EntityDataSerializers.INT);
+ private static final Ingredient FOOD_ITEMS = Ingredient.of(Items.CARROT, Items.POTATO, Items.BEETROOT);
+- private final ItemBasedSteering steering;
++ public final ItemBasedSteering steering;
+
+- public Pig(EntityType<? extends Pig> entitytype, Level level) {
+- super(entitytype, level);
++ public Pig(EntityType<? extends Pig> entityType, Level level) {
++ super(entityType, level);
+ this.steering = new ItemBasedSteering(this.entityData, Pig.DATA_BOOST_TIME, Pig.DATA_SADDLE_ID);
+ }
+
+ @Override
+- @Override
+ protected void registerGoals() {
+ this.goalSelector.addGoal(0, new FloatGoal(this));
+ this.goalSelector.addGoal(1, new PanicGoal(this, 1.25D));
+@@ -83,16 +86,15 @@
+
+ @Nullable
+ @Override
+- @Override
+ public LivingEntity getControllingPassenger() {
+ if (this.isSaddled()) {
+ Entity entity = this.getFirstPassenger();
+
+ if (entity instanceof Player) {
+- Player player = (Player) entity;
++ Player entityhuman = (Player) entity;
+
+- if (player.isHolding(Items.CARROT_ON_A_STICK)) {
+- return player;
++ if (entityhuman.isHolding(Items.CARROT_ON_A_STICK)) {
++ return entityhuman;
+ }
+ }
+ }
+@@ -101,17 +103,15 @@
+ }
+
+ @Override
+- @Override
+- public void onSyncedDataUpdated(EntityDataAccessor<?> entitydataaccessor) {
+- if (Pig.DATA_BOOST_TIME.equals(entitydataaccessor) && this.level().isClientSide) {
++ public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
++ if (Pig.DATA_BOOST_TIME.equals(key) && this.level().isClientSide) {
+ this.steering.onSynced();
+ }
+
+- super.onSyncedDataUpdated(entitydataaccessor);
++ super.onSyncedDataUpdated(key);
+ }
+
+ @Override
+- @Override
+ protected void defineSynchedData() {
+ super.defineSynchedData();
+ this.entityData.define(Pig.DATA_SADDLE_ID, false);
+@@ -119,47 +119,40 @@
+ }
+
+ @Override
+- @Override
+- public void addAdditionalSaveData(CompoundTag compoundtag) {
+- super.addAdditionalSaveData(compoundtag);
+- this.steering.addAdditionalSaveData(compoundtag);
++ public void addAdditionalSaveData(CompoundTag compound) {
++ super.addAdditionalSaveData(compound);
++ this.steering.addAdditionalSaveData(compound);
+ }
+
+ @Override
+- @Override
+- public void readAdditionalSaveData(CompoundTag compoundtag) {
+- super.readAdditionalSaveData(compoundtag);
+- this.steering.readAdditionalSaveData(compoundtag);
++ public void readAdditionalSaveData(CompoundTag compound) {
++ super.readAdditionalSaveData(compound);
++ this.steering.readAdditionalSaveData(compound);
+ }
+
+ @Override
+- @Override
+ protected SoundEvent getAmbientSound() {
+ return SoundEvents.PIG_AMBIENT;
+ }
+
+ @Override
+- @Override
+- protected SoundEvent getHurtSound(DamageSource damagesource) {
++ protected SoundEvent getHurtSound(DamageSource damageSource) {
+ return SoundEvents.PIG_HURT;
+ }
+
+ @Override
+- @Override
+ protected SoundEvent getDeathSound() {
+ return SoundEvents.PIG_DEATH;
+ }
+
+ @Override
+- @Override
+- protected void playStepSound(BlockPos blockpos, BlockState blockstate) {
++ protected void playStepSound(BlockPos pos, IBlockData block) {
+ this.playSound(SoundEvents.PIG_STEP, 0.15F, 1.0F);
+ }
+
+ @Override
+- @Override
+- public InteractionResult mobInteract(Player player, InteractionHand interactionhand) {
+- boolean flag = this.isFood(player.getItemInHand(interactionhand));
++ public InteractionResult mobInteract(Player player, EnumHand hand) {
++ boolean flag = this.isFood(player.getItemInHand(hand));
+
+ if (!flag && this.isSaddled() && !this.isVehicle() && !player.isSecondaryUseActive()) {
+ if (!this.level().isClientSide) {
+@@ -168,167 +161,159 @@
+
+ return InteractionResult.sidedSuccess(this.level().isClientSide);
+ } else {
+- InteractionResult interactionresult = super.mobInteract(player, interactionhand);
++ InteractionResult enuminteractionresult = super.mobInteract(player, hand);
+
+- if (!interactionresult.consumesAction()) {
+- ItemStack itemstack = player.getItemInHand(interactionhand);
++ if (!enuminteractionresult.consumesAction()) {
++ ItemStack itemstack = player.getItemInHand(hand);
+
+- return itemstack.is(Items.SADDLE) ? itemstack.interactLivingEntity(player, this, interactionhand) : InteractionResult.PASS;
++ return itemstack.is(Items.SADDLE) ? itemstack.interactLivingEntity(player, this, hand) : InteractionResult.PASS;
+ } else {
+- return interactionresult;
++ return enuminteractionresult;
+ }
+ }
+ }
+
+ @Override
+- @Override
+ public boolean isSaddleable() {
+ return this.isAlive() && !this.isBaby();
+ }
+
+ @Override
+- @Override
+ protected void dropEquipment() {
+ super.dropEquipment();
+ if (this.isSaddled()) {
+- this.spawnAtLocation((ItemLike) Items.SADDLE);
++ this.spawnAtLocation((IMaterial) Items.SADDLE);
+ }
+
+ }
+
+ @Override
+- @Override
+ public boolean isSaddled() {
+ return this.steering.hasSaddle();
+ }
+
+ @Override
+- @Override
+- public void equipSaddle(@Nullable SoundSource soundsource) {
++ public void equipSaddle(@Nullable SoundSource source) {
+ this.steering.setSaddle(true);
+- if (soundsource != null) {
+- this.level().playSound((Player) null, (Entity) this, SoundEvents.PIG_SADDLE, soundsource, 0.5F, 1.0F);
++ if (source != null) {
++ this.level().playSound((Player) null, (Entity) this, SoundEvents.PIG_SADDLE, source, 0.5F, 1.0F);
+ }
+
+ }
+
+ @Override
+- @Override
+- public Vec3 getDismountLocationForPassenger(LivingEntity livingentity) {
+- Direction direction = this.getMotionDirection();
++ public Vec3 getDismountLocationForPassenger(LivingEntity livingEntity) {
++ Direction enumdirection = this.getMotionDirection();
+
+- if (direction.getAxis() == Direction.Axis.Y) {
+- return super.getDismountLocationForPassenger(livingentity);
++ if (enumdirection.getAxis() == Direction.Axis.Y) {
++ return super.getDismountLocationForPassenger(livingEntity);
+ } else {
+- int[][] aint = DismountHelper.offsetsForDirection(direction);
+- BlockPos blockpos = this.blockPosition();
+- BlockPos.MutableBlockPos blockpos_mutableblockpos = new BlockPos.MutableBlockPos();
+- UnmodifiableIterator unmodifiableiterator = livingentity.getDismountPoses().iterator();
++ int[][] aint = DismountHelper.offsetsForDirection(enumdirection);
++ BlockPos blockposition = this.blockPosition();
++ BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
++ UnmodifiableIterator unmodifiableiterator = livingEntity.getDismountPoses().iterator();
+
+ while (unmodifiableiterator.hasNext()) {
+- Pose pose = (Pose) unmodifiableiterator.next();
+- AABB aabb = livingentity.getLocalBoundsForPose(pose);
++ EntityPose entitypose = (EntityPose) unmodifiableiterator.next();
++ AABB axisalignedbb = livingEntity.getLocalBoundsForPose(entitypose);
+ int[][] aint1 = aint;
+ int i = aint.length;
+
+ for (int j = 0; j < i; ++j) {
+ int[] aint2 = aint1[j];
+
+- blockpos_mutableblockpos.set(blockpos.getX() + aint2[0], blockpos.getY(), blockpos.getZ() + aint2[1]);
+- double d0 = this.level().getBlockFloorHeight(blockpos_mutableblockpos);
++ blockposition_mutableblockposition.set(blockposition.getX() + aint2[0], blockposition.getY(), blockposition.getZ() + aint2[1]);
++ double d0 = this.level().getBlockFloorHeight(blockposition_mutableblockposition);
+
+ if (DismountHelper.isBlockFloorValid(d0)) {
+- Vec3 vec3 = Vec3.upFromBottomCenterOf(blockpos_mutableblockpos, d0);
++ Vec3 vec3d = Vec3.upFromBottomCenterOf(blockposition_mutableblockposition, d0);
+
+- if (DismountHelper.canDismountTo(this.level(), livingentity, aabb.move(vec3))) {
+- livingentity.setPose(pose);
+- return vec3;
++ if (DismountHelper.canDismountTo(this.level(), livingEntity, axisalignedbb.move(vec3d))) {
++ livingEntity.setPose(entitypose);
++ return vec3d;
+ }
+ }
+ }
+ }
+
+- return super.getDismountLocationForPassenger(livingentity);
++ return super.getDismountLocationForPassenger(livingEntity);
+ }
+ }
+
+ @Override
+- @Override
+- public void thunderHit(ServerLevel serverlevel, LightningBolt lightningbolt) {
+- if (serverlevel.getDifficulty() != Difficulty.PEACEFUL) {
+- ZombifiedPiglin zombifiedpiglin = (ZombifiedPiglin) EntityType.ZOMBIFIED_PIGLIN.create(serverlevel);
++ public void thunderHit(ServerLevel level, LightningBolt lightning) {
++ if (level.getDifficulty() != Difficulty.PEACEFUL) {
++ ZombifiedPiglin entitypigzombie = (ZombifiedPiglin) EntityType.ZOMBIFIED_PIGLIN.create(level);
+
+- if (zombifiedpiglin != null) {
+- zombifiedpiglin.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD));
+- zombifiedpiglin.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
+- zombifiedpiglin.setNoAi(this.isNoAi());
+- zombifiedpiglin.setBaby(this.isBaby());
++ if (entitypigzombie != null) {
++ entitypigzombie.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD));
++ entitypigzombie.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
++ entitypigzombie.setNoAi(this.isNoAi());
++ entitypigzombie.setBaby(this.isBaby());
+ if (this.hasCustomName()) {
+- zombifiedpiglin.setCustomName(this.getCustomName());
+- zombifiedpiglin.setCustomNameVisible(this.isCustomNameVisible());
++ entitypigzombie.setCustomName(this.getCustomName());
++ entitypigzombie.setCustomNameVisible(this.isCustomNameVisible());
+ }
+
+- zombifiedpiglin.setPersistenceRequired();
+- serverlevel.addFreshEntity(zombifiedpiglin);
++ entitypigzombie.setPersistenceRequired();
++ // CraftBukkit start
++ if (CraftEventFactory.callPigZapEvent(this, lightning, entitypigzombie).isCancelled()) {
++ return;
++ }
++ // CraftBukkit - added a reason for spawning this creature
++ level.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
++ // CraftBukkit end
+ this.discard();
+ } else {
+- super.thunderHit(serverlevel, lightningbolt);
++ super.thunderHit(level, lightning);
+ }
+ } else {
+- super.thunderHit(serverlevel, lightningbolt);
++ super.thunderHit(level, lightning);
+ }
+
+ }
+
+ @Override
+- @Override
+- protected void tickRidden(Player player, Vec3 vec3) {
+- super.tickRidden(player, vec3);
++ protected void tickRidden(Player player, Vec3 travelVector) {
++ super.tickRidden(player, travelVector);
+ this.setRot(player.getYRot(), player.getXRot() * 0.5F);
+ this.yRotO = this.yBodyRot = this.yHeadRot = this.getYRot();
+ this.steering.tickBoost();
+ }
+
+ @Override
+- @Override
+- protected Vec3 getRiddenInput(Player player, Vec3 vec3) {
++ protected Vec3 getRiddenInput(Player player, Vec3 travelVector) {
+ return new Vec3(0.0D, 0.0D, 1.0D);
+ }
+
+ @Override
+- @Override
+ protected float getRiddenSpeed(Player player) {
+ return (float) (this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 0.225D * (double) this.steering.boostFactor());
+ }
+
+ @Override
+- @Override
+ public boolean boost() {
+ return this.steering.boost(this.getRandom());
+ }
+
+ @Nullable
+ @Override
+- @Override
+- public Pig getBreedOffspring(ServerLevel serverlevel, AgeableMob ageablemob) {
+- return (Pig) EntityType.PIG.create(serverlevel);
++ public Pig getBreedOffspring(ServerLevel level, AgeableMob otherParent) {
++ return (Pig) EntityType.PIG.create(level);
+ }
+
+ @Override
+- @Override
+- public boolean isFood(ItemStack itemstack) {
+- return Pig.FOOD_ITEMS.test(itemstack);
++ public boolean isFood(ItemStack stack) {
++ return Pig.FOOD_ITEMS.test(stack);
+ }
+
+ @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.0F);
++ protected Vector3f getPassengerAttachmentPoint(Entity entity, EntityDimensions entitysize, float f) {
++ return new Vector3f(0.0F, entitysize.height - 0.03125F * f, 0.0F);
+ }
+ }