diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/animal/IronGolem.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/animal/IronGolem.java.patch | 365 |
1 files changed, 365 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/IronGolem.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/IronGolem.java.patch new file mode 100644 index 0000000000..fb29fc60f9 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/animal/IronGolem.java.patch @@ -0,0 +1,365 @@ +--- a/net/minecraft/world/entity/animal/IronGolem.java ++++ b/net/minecraft/world/entity/animal/IronGolem.java +@@ -2,6 +2,7 @@ + + import com.google.common.collect.ImmutableList; + import java.util.Comparator; ++import java.util.Iterator; + import java.util.List; + import java.util.UUID; + import java.util.stream.Stream; +@@ -16,7 +17,7 @@ + import net.minecraft.sounds.SoundEvents; + 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.Entity; +@@ -38,18 +39,19 @@ + import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal; + import net.minecraft.world.entity.ai.goal.target.ResetUniversalAngerTargetGoal; + import net.minecraft.world.entity.monster.Creeper; +-import net.minecraft.world.entity.monster.Enemy; ++import net.minecraft.world.entity.monster.IMonster; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.Items; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.LevelReader; + import net.minecraft.world.level.NaturalSpawner; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.material.Fluids; + import net.minecraft.world.phys.Vec3; + + public class IronGolem extends AbstractGolem implements NeutralMob { ++ + protected static final EntityDataAccessor<Byte> DATA_FLAGS_ID = SynchedEntityData.defineId(IronGolem.class, EntityDataSerializers.BYTE); + private static final int IRON_INGOT_HEAL_AMOUNT = 25; + private int attackAnimationTick; +@@ -66,33 +68,30 @@ + + @Override + protected void registerGoals() { +- this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0, true)); +- this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9, 32.0F)); +- this.goalSelector.addGoal(2, new MoveBackToVillageGoal(this, 0.6, false)); +- this.goalSelector.addGoal(4, new GolemRandomStrollInVillageGoal(this, 0.6)); ++ this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0D, true)); ++ this.goalSelector.addGoal(2, new MoveTowardsTargetGoal(this, 0.9D, 32.0F)); ++ this.goalSelector.addGoal(2, new MoveBackToVillageGoal(this, 0.6D, false)); ++ this.goalSelector.addGoal(4, new GolemRandomStrollInVillageGoal(this, 0.6D)); + this.goalSelector.addGoal(5, new OfferFlowerGoal(this)); + this.goalSelector.addGoal(7, new LookAtPlayerGoal(this, Player.class, 6.0F)); + this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); + this.targetSelector.addGoal(1, new DefendVillageTargetGoal(this)); +- this.targetSelector.addGoal(2, new HurtByTargetGoal(this)); ++ this.targetSelector.addGoal(2, new HurtByTargetGoal(this, new Class[0])); + this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt)); +- this.targetSelector +- .addGoal(3, new NearestAttackableTargetGoal<>(this, Mob.class, 5, false, false, entity -> entity instanceof Enemy && !(entity instanceof Creeper))); ++ this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, Mob.class, 5, false, false, (entityliving) -> { ++ return entityliving instanceof IMonster && !(entityliving instanceof Creeper); ++ })); + this.targetSelector.addGoal(4, new ResetUniversalAngerTargetGoal<>(this, false)); + } + + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(DATA_FLAGS_ID, (byte)0); ++ this.entityData.define(IronGolem.DATA_FLAGS_ID, (byte) 0); + } + + public static AttributeSupplier.Builder createAttributes() { +- return Mob.createMobAttributes() +- .add(Attributes.MAX_HEALTH, 100.0) +- .add(Attributes.MOVEMENT_SPEED, 0.25) +- .add(Attributes.KNOCKBACK_RESISTANCE, 1.0) +- .add(Attributes.ATTACK_DAMAGE, 15.0); ++ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 100.0D).add(Attributes.MOVEMENT_SPEED, 0.25D).add(Attributes.KNOCKBACK_RESISTANCE, 1.0D).add(Attributes.ATTACK_DAMAGE, 15.0D); + } + + @Override +@@ -102,8 +101,8 @@ + + @Override + protected void doPush(Entity entity) { +- if (entity instanceof Enemy && !(entity instanceof Creeper) && this.getRandom().nextInt(20) == 0) { +- this.setTarget((LivingEntity)entity); ++ if (entity instanceof IMonster && !(entity instanceof Creeper) && this.getRandom().nextInt(20) == 0) { ++ this.setTarget((LivingEntity) entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason + } + + super.doPush(entity); +@@ -113,26 +112,27 @@ + public void aiStep() { + super.aiStep(); + if (this.attackAnimationTick > 0) { +- this.attackAnimationTick--; ++ --this.attackAnimationTick; + } + + if (this.offerFlowerTick > 0) { +- this.offerFlowerTick--; ++ --this.offerFlowerTick; + } + + if (!this.level().isClientSide) { +- this.updatePersistentAnger((ServerLevel)this.level(), true); ++ this.updatePersistentAnger((ServerLevel) this.level(), true); + } ++ + } + + @Override + public boolean canSpawnSprintParticle() { +- return this.getDeltaMovement().horizontalDistanceSqr() > 2.5000003E-7F && this.random.nextInt(5) == 0; ++ return this.getDeltaMovement().horizontalDistanceSqr() > 2.500000277905201E-7D && this.random.nextInt(5) == 0; + } + + @Override + public boolean canAttackType(EntityType<?> type) { +- return (!this.isPlayerCreated() || type != EntityType.PLAYER) && type != EntityType.CREEPER && super.canAttackType(type); ++ return this.isPlayerCreated() && type == EntityType.PLAYER ? false : (type == EntityType.CREEPER ? false : super.canAttackType(type)); + } + + @Override +@@ -151,7 +151,7 @@ + + @Override + public void startPersistentAngerTimer() { +- this.setRemainingPersistentAngerTime(PERSISTENT_ANGER_TIME.sample(this.random)); ++ this.setRemainingPersistentAngerTime(IronGolem.PERSISTENT_ANGER_TIME.sample(this.random)); + } + + @Override +@@ -176,20 +176,32 @@ + } + + private float getAttackDamage() { +- return (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); ++ return (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE); + } + + @Override + public boolean doHurtTarget(Entity entity) { + this.attackAnimationTick = 10; +- this.level().broadcastEntityEvent(this, (byte)4); +- float attackDamage = this.getAttackDamage(); +- float f = (int)attackDamage > 0 ? attackDamage / 2.0F + (float)this.random.nextInt((int)attackDamage) : attackDamage; +- boolean flag = entity.hurt(this.damageSources().mobAttack(this), f); ++ this.level().broadcastEntityEvent(this, (byte) 4); ++ float f = this.getAttackDamage(); ++ float f1 = (int) f > 0 ? f / 2.0F + (float) this.random.nextInt((int) f) : f; ++ boolean flag = entity.hurt(this.damageSources().mobAttack(this), f1); ++ + if (flag) { +- double d = entity instanceof LivingEntity livingEntity ? livingEntity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE) : 0.0; +- double max = Math.max(0.0, 1.0 - d); +- entity.setDeltaMovement(entity.getDeltaMovement().add(0.0, 0.4F * max, 0.0)); ++ double d0; ++ ++ if (entity instanceof LivingEntity) { ++ LivingEntity entityliving = (LivingEntity) entity; ++ ++ d0 = entityliving.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); ++ } else { ++ d0 = 0.0D; ++ } ++ ++ double d1 = d0; ++ double d2 = Math.max(0.0D, 1.0D - d1); ++ ++ entity.setDeltaMovement(entity.getDeltaMovement().add(0.0D, 0.4000000059604645D * d2, 0.0D)); + this.doEnchantDamageEffects(this, entity); + } + +@@ -199,9 +211,10 @@ + + @Override + public boolean hurt(DamageSource source, float amount) { +- IronGolem.Crackiness crackiness = this.getCrackiness(); ++ IronGolem.Crackiness entityirongolem_cracklevel = this.getCrackiness(); + boolean flag = super.hurt(source, amount); +- if (flag && this.getCrackiness() != crackiness) { ++ ++ if (flag && this.getCrackiness() != entityirongolem_cracklevel) { + this.playSound(SoundEvents.IRON_GOLEM_DAMAGE, 1.0F, 1.0F); + } + +@@ -224,6 +237,7 @@ + } else { + super.handleEntityEvent(id); + } ++ + } + + public int getAttackAnimationTick() { +@@ -233,11 +247,12 @@ + public void offerFlower(boolean offeringFlower) { + if (offeringFlower) { + this.offerFlowerTick = 400; +- this.level().broadcastEntityEvent(this, (byte)11); ++ this.level().broadcastEntityEvent(this, (byte) 11); + } else { + this.offerFlowerTick = 0; +- this.level().broadcastEntityEvent(this, (byte)34); ++ this.level().broadcastEntityEvent(this, (byte) 34); + } ++ + } + + @Override +@@ -251,20 +266,23 @@ + } + + @Override +- protected InteractionResult mobInteract(Player player, InteractionHand hand) { +- ItemStack itemInHand = player.getItemInHand(hand); +- if (!itemInHand.is(Items.IRON_INGOT)) { ++ protected InteractionResult mobInteract(Player player, EnumHand hand) { ++ ItemStack itemstack = player.getItemInHand(hand); ++ ++ if (!itemstack.is(Items.IRON_INGOT)) { + return InteractionResult.PASS; + } else { +- float health = this.getHealth(); ++ float f = this.getHealth(); ++ + this.heal(25.0F); +- if (this.getHealth() == health) { ++ if (this.getHealth() == f) { + return InteractionResult.PASS; + } else { +- float f = 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F; +- this.playSound(SoundEvents.IRON_GOLEM_REPAIR, 1.0F, f); ++ float f1 = 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.2F; ++ ++ this.playSound(SoundEvents.IRON_GOLEM_REPAIR, 1.0F, f1); + if (!player.getAbilities().instabuild) { +- itemInHand.shrink(1); ++ itemstack.shrink(1); + } + + return InteractionResult.sidedSuccess(this.level().isClientSide); +@@ -273,7 +291,7 @@ + } + + @Override +- protected void playStepSound(BlockPos pos, BlockState block) { ++ protected void playStepSound(BlockPos pos, IBlockData block) { + this.playSound(SoundEvents.IRON_GOLEM_STEP, 1.0F, 1.0F); + } + +@@ -282,16 +300,18 @@ + } + + public boolean isPlayerCreated() { +- return (this.entityData.get(DATA_FLAGS_ID) & 1) != 0; ++ return ((Byte) this.entityData.get(IronGolem.DATA_FLAGS_ID) & 1) != 0; + } + + public void setPlayerCreated(boolean playerCreated) { +- byte b = this.entityData.get(DATA_FLAGS_ID); ++ byte b0 = (Byte) this.entityData.get(IronGolem.DATA_FLAGS_ID); ++ + if (playerCreated) { +- this.entityData.set(DATA_FLAGS_ID, (byte)(b | 1)); ++ this.entityData.set(IronGolem.DATA_FLAGS_ID, (byte) (b0 | 1)); + } else { +- this.entityData.set(DATA_FLAGS_ID, (byte)(b & -2)); ++ this.entityData.set(IronGolem.DATA_FLAGS_ID, (byte) (b0 & -2)); + } ++ + } + + @Override +@@ -301,55 +321,58 @@ + + @Override + public boolean checkSpawnObstruction(LevelReader level) { +- BlockPos blockPos = this.blockPosition(); +- BlockPos blockPos1 = blockPos.below(); +- BlockState blockState = level.getBlockState(blockPos1); +- if (!blockState.entityCanStandOn(level, blockPos1, this)) { ++ BlockPos blockposition = this.blockPosition(); ++ BlockPos blockposition1 = blockposition.below(); ++ IBlockData iblockdata = level.getBlockState(blockposition1); ++ ++ if (!iblockdata.entityCanStandOn(level, blockposition1, this)) { + return false; + } else { +- for (int i = 1; i < 3; i++) { +- BlockPos blockPos2 = blockPos.above(i); +- BlockState blockState1 = level.getBlockState(blockPos2); +- if (!NaturalSpawner.isValidEmptySpawnBlock(level, blockPos2, blockState1, blockState1.getFluidState(), EntityType.IRON_GOLEM)) { ++ for (int i = 1; i < 3; ++i) { ++ BlockPos blockposition2 = blockposition.above(i); ++ IBlockData iblockdata1 = level.getBlockState(blockposition2); ++ ++ if (!NaturalSpawner.isValidEmptySpawnBlock(level, blockposition2, iblockdata1, iblockdata1.getFluidState(), EntityType.IRON_GOLEM)) { + return false; + } + } + +- return NaturalSpawner.isValidEmptySpawnBlock( +- level, blockPos, level.getBlockState(blockPos), Fluids.EMPTY.defaultFluidState(), EntityType.IRON_GOLEM +- ) +- && level.isUnobstructed(this); ++ return NaturalSpawner.isValidEmptySpawnBlock(level, blockposition, level.getBlockState(blockposition), Fluids.EMPTY.defaultFluidState(), EntityType.IRON_GOLEM) && level.isUnobstructed(this); + } + } + + @Override + public Vec3 getLeashOffset() { +- return new Vec3(0.0, (double)(0.875F * this.getEyeHeight()), (double)(this.getBbWidth() * 0.4F)); ++ return new Vec3(0.0D, (double) (0.875F * this.getEyeHeight()), (double) (this.getBbWidth() * 0.4F)); + } + + public static enum Crackiness { +- NONE(1.0F), +- LOW(0.75F), +- MEDIUM(0.5F), +- HIGH(0.25F); + +- private static final List<IronGolem.Crackiness> BY_DAMAGE = Stream.of(values()) +- .sorted(Comparator.comparingDouble(crack -> (double)crack.fraction)) +- .collect(ImmutableList.toImmutableList()); ++ NONE(1.0F), LOW(0.75F), MEDIUM(0.5F), HIGH(0.25F); ++ ++ private static final List<IronGolem.Crackiness> BY_DAMAGE = (List) Stream.of(values()).sorted(Comparator.comparingDouble((entityirongolem_cracklevel) -> { ++ return (double) entityirongolem_cracklevel.fraction; ++ })).collect(ImmutableList.toImmutableList()); + private final float fraction; + +- private Crackiness(float fraction) { +- this.fraction = fraction; ++ private Crackiness(float f) { ++ this.fraction = f; + } + + public static IronGolem.Crackiness byFraction(float fraction) { +- for (IronGolem.Crackiness crackiness : BY_DAMAGE) { +- if (fraction < crackiness.fraction) { +- return crackiness; ++ Iterator iterator = IronGolem.Crackiness.BY_DAMAGE.iterator(); ++ ++ IronGolem.Crackiness entityirongolem_cracklevel; ++ ++ do { ++ if (!iterator.hasNext()) { ++ return IronGolem.Crackiness.NONE; + } +- } + +- return NONE; ++ entityirongolem_cracklevel = (IronGolem.Crackiness) iterator.next(); ++ } while (fraction >= entityirongolem_cracklevel.fraction); ++ ++ return entityirongolem_cracklevel; + } + } + } |