diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/animal/SnowGolem.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/animal/SnowGolem.java.patch | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/SnowGolem.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/SnowGolem.java.patch new file mode 100644 index 0000000000..5c5fc33cb6 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -0,0 +1,221 @@ +--- a/net/minecraft/world/entity/animal/SnowGolem.java ++++ b/net/minecraft/world/entity/animal/SnowGolem.java +@@ -11,14 +11,15 @@ + import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.BiomeTags; + import net.minecraft.util.Mth; +-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.Entity; + import net.minecraft.world.entity.EntityDimensions; ++import net.minecraft.world.entity.EntityPose; + import net.minecraft.world.entity.EntityType; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.Mob; +-import net.minecraft.world.entity.Pose; + import net.minecraft.world.entity.Shearable; + import net.minecraft.world.entity.ai.attributes.AttributeSupplier; + import net.minecraft.world.entity.ai.attributes.Attributes; +@@ -27,7 +28,7 @@ + import net.minecraft.world.entity.ai.goal.RangedAttackGoal; + import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal; + import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; +-import net.minecraft.world.entity.monster.Enemy; ++import net.minecraft.world.entity.monster.IMonster; + import net.minecraft.world.entity.monster.RangedAttackMob; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.entity.projectile.Snowball; +@@ -36,11 +37,15 @@ + import net.minecraft.world.level.GameRules; + import net.minecraft.world.level.Level; + 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.level.gameevent.GameEvent; + import net.minecraft.world.phys.Vec3; ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++// CraftBukkit end + + public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob { ++ + private static final EntityDataAccessor<Byte> DATA_PUMPKIN_ID = SynchedEntityData.defineId(SnowGolem.class, EntityDataSerializers.BYTE); + private static final byte PUMPKIN_FLAG = 16; + private static final float EYE_HEIGHT = 1.7F; +@@ -51,21 +56,23 @@ + + @Override + protected void registerGoals() { +- this.goalSelector.addGoal(1, new RangedAttackGoal(this, 1.25, 20, 10.0F)); +- this.goalSelector.addGoal(2, new WaterAvoidingRandomStrollGoal(this, 1.0, 1.0000001E-5F)); ++ this.goalSelector.addGoal(1, new RangedAttackGoal(this, 1.25D, 20, 10.0F)); ++ this.goalSelector.addGoal(2, new WaterAvoidingRandomStrollGoal(this, 1.0D, 1.0000001E-5F)); + this.goalSelector.addGoal(3, new LookAtPlayerGoal(this, Player.class, 6.0F)); + this.goalSelector.addGoal(4, new RandomLookAroundGoal(this)); +- this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Mob.class, 10, true, false, entity -> entity instanceof Enemy)); ++ this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Mob.class, 10, true, false, (entityliving) -> { ++ return entityliving instanceof IMonster; ++ })); + } + + public static AttributeSupplier.Builder createAttributes() { +- return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 4.0).add(Attributes.MOVEMENT_SPEED, 0.2F); ++ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 4.0D).add(Attributes.MOVEMENT_SPEED, 0.20000000298023224D); + } + + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(DATA_PUMPKIN_ID, (byte)16); ++ this.entityData.define(SnowGolem.DATA_PUMPKIN_ID, (byte) 16); + } + + @Override +@@ -80,6 +87,7 @@ + if (compound.contains("Pumpkin")) { + this.setPumpkin(compound.getBoolean("Pumpkin")); + } ++ + } + + @Override +@@ -92,54 +100,69 @@ + super.aiStep(); + if (!this.level().isClientSide) { + if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) { +- this.hurt(this.damageSources().onFire(), 1.0F); ++ this.hurt(this.damageSources().melting, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING + } + + if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + return; + } + +- BlockState blockState = Blocks.SNOW.defaultBlockState(); ++ IBlockData iblockdata = Blocks.SNOW.defaultBlockState(); + +- for (int i = 0; i < 4; i++) { +- int floor = Mth.floor(this.getX() + (double)((float)(i % 2 * 2 - 1) * 0.25F)); +- int floor1 = Mth.floor(this.getY()); +- int floor2 = Mth.floor(this.getZ() + (double)((float)(i / 2 % 2 * 2 - 1) * 0.25F)); +- BlockPos blockPos = new BlockPos(floor, floor1, floor2); +- if (this.level().getBlockState(blockPos).isAir() && blockState.canSurvive(this.level(), blockPos)) { +- this.level().setBlockAndUpdate(blockPos, blockState); +- this.level().gameEvent(GameEvent.BLOCK_PLACE, blockPos, GameEvent.Context.of(this, blockState)); ++ for (int i = 0; i < 4; ++i) { ++ int j = Mth.floor(this.getX() + (double) ((float) (i % 2 * 2 - 1) * 0.25F)); ++ int k = Mth.floor(this.getY()); ++ int l = Mth.floor(this.getZ() + (double) ((float) (i / 2 % 2 * 2 - 1) * 0.25F)); ++ BlockPos blockposition = new BlockPos(j, k, l); ++ ++ if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { ++ // CraftBukkit start ++ if (!CraftEventFactory.handleBlockFormEvent(this.level(), blockposition, iblockdata, this)) { ++ continue; ++ } ++ // CraftBukkit end ++ this.level().gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.Context.of(this, iblockdata)); + } + } + } ++ + } + + @Override + public void performRangedAttack(LivingEntity target, float distanceFactor) { +- Snowball snowball = new Snowball(this.level(), this); +- double d = target.getEyeY() - 1.1F; ++ Snowball entitysnowball = new Snowball(this.level(), this); ++ double d0 = target.getEyeY() - 1.100000023841858D; + double d1 = target.getX() - this.getX(); +- double d2 = d - snowball.getY(); ++ double d2 = d0 - entitysnowball.getY(); + double d3 = target.getZ() - this.getZ(); +- double d4 = Math.sqrt(d1 * d1 + d3 * d3) * 0.2F; +- snowball.shoot(d1, d2 + d4, d3, 1.6F, 12.0F); ++ double d4 = Math.sqrt(d1 * d1 + d3 * d3) * 0.20000000298023224D; ++ ++ entitysnowball.shoot(d1, d2 + d4, d3, 1.6F, 12.0F); + this.playSound(SoundEvents.SNOW_GOLEM_SHOOT, 1.0F, 0.4F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); +- this.level().addFreshEntity(snowball); ++ this.level().addFreshEntity(entitysnowball); + } + + @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions size) { ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { + return 1.7F; + } + + @Override +- protected InteractionResult mobInteract(Player player, InteractionHand hand) { +- ItemStack itemInHand = player.getItemInHand(hand); +- if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { ++ protected InteractionResult mobInteract(Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ ++ if (itemstack.is(Items.SHEARS) && this.readyForShearing()) { ++ // CraftBukkit start ++ if (!CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand)) { ++ return InteractionResult.PASS; ++ } ++ // CraftBukkit end + this.shear(SoundSource.PLAYERS); + this.gameEvent(GameEvent.SHEAR, player); + if (!this.level().isClientSide) { +- itemInHand.hurtAndBreak(1, player, entity -> entity.broadcastBreakEvent(hand)); ++ itemstack.hurtAndBreak(1, player, (entityhuman1) -> { ++ entityhuman1.broadcastBreakEvent(hand); ++ }); + } + + return InteractionResult.sidedSuccess(this.level().isClientSide); +@@ -150,11 +173,14 @@ + + @Override + public void shear(SoundSource category) { +- this.level().playSound(null, this, SoundEvents.SNOW_GOLEM_SHEAR, category, 1.0F, 1.0F); ++ this.level().playSound((Player) null, (Entity) this, SoundEvents.SNOW_GOLEM_SHEAR, category, 1.0F, 1.0F); + if (!this.level().isClientSide()) { + this.setPumpkin(false); ++ this.forceDrops = true; // CraftBukkit + this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), 1.7F); ++ this.forceDrops = false; // CraftBukkit + } ++ + } + + @Override +@@ -163,16 +189,18 @@ + } + + public boolean hasPumpkin() { +- return (this.entityData.get(DATA_PUMPKIN_ID) & 16) != 0; ++ return ((Byte) this.entityData.get(SnowGolem.DATA_PUMPKIN_ID) & 16) != 0; + } + + public void setPumpkin(boolean pumpkinEquipped) { +- byte b = this.entityData.get(DATA_PUMPKIN_ID); ++ byte b0 = (Byte) this.entityData.get(SnowGolem.DATA_PUMPKIN_ID); ++ + if (pumpkinEquipped) { +- this.entityData.set(DATA_PUMPKIN_ID, (byte)(b | 16)); ++ this.entityData.set(SnowGolem.DATA_PUMPKIN_ID, (byte) (b0 | 16)); + } else { +- this.entityData.set(DATA_PUMPKIN_ID, (byte)(b & -17)); ++ this.entityData.set(SnowGolem.DATA_PUMPKIN_ID, (byte) (b0 & -17)); + } ++ + } + + @Nullable +@@ -195,6 +223,6 @@ + + @Override + public Vec3 getLeashOffset() { +- return new Vec3(0.0, (double)(0.75F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.4F)); ++ return new Vec3(0.0D, (double) (0.75F * this.getEyeHeight()), (double) (this.getBbWidth() * 0.4F)); + } + } |