diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Ghast.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Ghast.java.patch | 392 |
1 files changed, 392 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Ghast.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Ghast.java.patch new file mode 100644 index 0000000000..883eb23c05 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/Ghast.java.patch @@ -0,0 +1,392 @@ +--- a/net/minecraft/world/entity/monster/Ghast.java ++++ b/net/minecraft/world/entity/monster/Ghast.java +@@ -15,12 +15,12 @@ + 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.EnumMobSpawn; + import net.minecraft.world.entity.FlyingMob; + 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.ai.attributes.AttributeSupplier; + import net.minecraft.world.entity.ai.attributes.Attributes; + import net.minecraft.world.entity.ai.control.MoveControl; +@@ -34,7 +34,8 @@ + import net.minecraft.world.phys.Vec3; + import org.joml.Vector3f; + +-public class Ghast extends FlyingMob implements Enemy { ++public class Ghast extends FlyingMob implements IMonster { ++ + private static final EntityDataAccessor<Boolean> DATA_IS_CHARGING = SynchedEntityData.defineId(Ghast.class, EntityDataSerializers.BOOLEAN); + private int explosionPower = 1; + +@@ -49,18 +50,17 @@ + this.goalSelector.addGoal(5, new Ghast.RandomFloatAroundGoal(this)); + this.goalSelector.addGoal(7, new Ghast.GhastLookGoal(this)); + this.goalSelector.addGoal(7, new Ghast.GhastShootFireballGoal(this)); +- this.targetSelector +- .addGoal( +- 1, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, livingEntity -> Math.abs(livingEntity.getY() - this.getY()) <= 4.0) +- ); ++ this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, (entityliving) -> { ++ return Math.abs(entityliving.getY() - this.getY()) <= 4.0D; ++ })); + } + + public boolean isCharging() { +- return this.entityData.get(DATA_IS_CHARGING); ++ return (Boolean) this.entityData.get(Ghast.DATA_IS_CHARGING); + } + + public void setCharging(boolean charging) { +- this.entityData.set(DATA_IS_CHARGING, charging); ++ this.entityData.set(Ghast.DATA_IS_CHARGING, charging); + } + + public int getExplosionPower() { +@@ -87,18 +87,18 @@ + super.hurt(source, 1000.0F); + return true; + } else { +- return !this.isInvulnerableTo(source) && super.hurt(source, amount); ++ return this.isInvulnerableTo(source) ? false : super.hurt(source, amount); + } + } + + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(DATA_IS_CHARGING, false); ++ this.entityData.define(Ghast.DATA_IS_CHARGING, false); + } + + public static AttributeSupplier.Builder createAttributes() { +- return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 10.0).add(Attributes.FOLLOW_RANGE, 100.0); ++ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 10.0D).add(Attributes.FOLLOW_RANGE, 100.0D); + } + + @Override +@@ -126,7 +126,7 @@ + return 5.0F; + } + +- public static boolean checkGhastSpawnRules(EntityType<Ghast> ghast, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random) { ++ public static boolean checkGhastSpawnRules(EntityType<Ghast> ghast, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) { + return level.getDifficulty() != Difficulty.PEACEFUL && random.nextInt(20) == 0 && checkMobSpawnRules(ghast, level, spawnType, pos, random); + } + +@@ -136,8 +136,8 @@ + } + + @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); + } + + @Override +@@ -148,7 +148,7 @@ + @Override + public void addAdditionalSaveData(CompoundTag compound) { + super.addAdditionalSaveData(compound); +- compound.putByte("ExplosionPower", (byte)this.explosionPower); ++ compound.putByte("ExplosionPower", (byte) this.explosionPower); + } + + @Override +@@ -157,91 +157,142 @@ + if (compound.contains("ExplosionPower", 99)) { + this.explosionPower = compound.getByte("ExplosionPower"); + } ++ + } + + @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions size) { ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { + return 2.6F; + } + +- static class GhastLookGoal extends Goal { ++ private static class GhastMoveControl extends MoveControl { ++ + private final Ghast ghast; ++ private int floatDuration; + +- public GhastLookGoal(Ghast ghast) { ++ public GhastMoveControl(Ghast ghast) { ++ super(ghast); + this.ghast = ghast; +- this.setFlags(EnumSet.of(Goal.Flag.LOOK)); + } + + @Override +- public boolean canUse() { +- return true; ++ public void tick() { ++ if (this.operation == MoveControl.Operation.MOVE_TO) { ++ if (this.floatDuration-- <= 0) { ++ this.floatDuration += this.ghast.getRandom().nextInt(5) + 2; ++ Vec3 vec3d = new Vec3(this.wantedX - this.ghast.getX(), this.wantedY - this.ghast.getY(), this.wantedZ - this.ghast.getZ()); ++ double d0 = vec3d.length(); ++ ++ vec3d = vec3d.normalize(); ++ if (this.canReach(vec3d, Mth.ceil(d0))) { ++ this.ghast.setDeltaMovement(this.ghast.getDeltaMovement().add(vec3d.scale(0.1D))); ++ } else { ++ this.operation = MoveControl.Operation.WAIT; ++ } ++ } ++ ++ } + } + +- @Override +- public boolean requiresUpdateEveryTick() { ++ private boolean canReach(Vec3 pos, int length) { ++ AABB axisalignedbb = this.ghast.getBoundingBox(); ++ ++ for (int j = 1; j < length; ++j) { ++ axisalignedbb = axisalignedbb.move(pos); ++ if (!this.ghast.level().noCollision(this.ghast, axisalignedbb)) { ++ return false; ++ } ++ } ++ + return true; + } ++ } + ++ private static class RandomFloatAroundGoal extends Goal { ++ ++ private final Ghast ghast; ++ ++ public RandomFloatAroundGoal(Ghast ghast) { ++ this.ghast = ghast; ++ this.setFlags(EnumSet.of(Goal.Type.MOVE)); ++ } ++ + @Override +- public void tick() { +- if (this.ghast.getTarget() == null) { +- Vec3 deltaMovement = this.ghast.getDeltaMovement(); +- this.ghast.setYRot(-((float)Mth.atan2(deltaMovement.x, deltaMovement.z)) * (180.0F / (float)Math.PI)); +- this.ghast.yBodyRot = this.ghast.getYRot(); ++ public boolean canUse() { ++ MoveControl controllermove = this.ghast.getMoveControl(); ++ ++ if (!controllermove.hasWanted()) { ++ return true; + } else { +- LivingEntity target = this.ghast.getTarget(); +- double d = 64.0; +- if (target.distanceToSqr(this.ghast) < 4096.0) { +- double d1 = target.getX() - this.ghast.getX(); +- double d2 = target.getZ() - this.ghast.getZ(); +- this.ghast.setYRot(-((float)Mth.atan2(d1, d2)) * (180.0F / (float)Math.PI)); +- this.ghast.yBodyRot = this.ghast.getYRot(); +- } ++ double d0 = controllermove.getWantedX() - this.ghast.getX(); ++ double d1 = controllermove.getWantedY() - this.ghast.getY(); ++ double d2 = controllermove.getWantedZ() - this.ghast.getZ(); ++ double d3 = d0 * d0 + d1 * d1 + d2 * d2; ++ ++ return d3 < 1.0D || d3 > 3600.0D; + } + } ++ ++ @Override ++ public boolean canContinueToUse() { ++ return false; ++ } ++ ++ @Override ++ public void start() { ++ RandomSource randomsource = this.ghast.getRandom(); ++ double d0 = this.ghast.getX() + (double) ((randomsource.nextFloat() * 2.0F - 1.0F) * 16.0F); ++ double d1 = this.ghast.getY() + (double) ((randomsource.nextFloat() * 2.0F - 1.0F) * 16.0F); ++ double d2 = this.ghast.getZ() + (double) ((randomsource.nextFloat() * 2.0F - 1.0F) * 16.0F); ++ ++ this.ghast.getMoveControl().setWantedPosition(d0, d1, d2, 1.0D); ++ } + } + +- static class GhastMoveControl extends MoveControl { ++ private static class GhastLookGoal extends Goal { ++ + private final Ghast ghast; +- private int floatDuration; + +- public GhastMoveControl(Ghast mob) { +- super(mob); +- this.ghast = mob; ++ public GhastLookGoal(Ghast ghast) { ++ this.ghast = ghast; ++ this.setFlags(EnumSet.of(Goal.Type.LOOK)); + } + + @Override +- public void tick() { +- if (this.operation == MoveControl.Operation.MOVE_TO) { +- if (this.floatDuration-- <= 0) { +- this.floatDuration = this.floatDuration + this.ghast.getRandom().nextInt(5) + 2; +- Vec3 vec3 = new Vec3(this.wantedX - this.ghast.getX(), this.wantedY - this.ghast.getY(), this.wantedZ - this.ghast.getZ()); +- double len = vec3.length(); +- Vec3 var4 = vec3.normalize(); +- if (this.canReach(var4, Mth.ceil(len))) { +- this.ghast.setDeltaMovement(this.ghast.getDeltaMovement().add(var4.scale(0.1))); +- } else { +- this.operation = MoveControl.Operation.WAIT; +- } +- } +- } ++ public boolean canUse() { ++ return true; + } + +- private boolean canReach(Vec3 pos, int length) { +- AABB boundingBox = this.ghast.getBoundingBox(); ++ @Override ++ public boolean requiresUpdateEveryTick() { ++ return true; ++ } + +- for (int i = 1; i < length; i++) { +- boundingBox = boundingBox.move(pos); +- if (!this.ghast.level().noCollision(this.ghast, boundingBox)) { +- return false; ++ @Override ++ public void tick() { ++ if (this.ghast.getTarget() == null) { ++ Vec3 vec3d = this.ghast.getDeltaMovement(); ++ ++ this.ghast.setYRot(-((float) Mth.atan2(vec3d.x, vec3d.z)) * 57.295776F); ++ this.ghast.yBodyRot = this.ghast.getYRot(); ++ } else { ++ LivingEntity entityliving = this.ghast.getTarget(); ++ double d0 = 64.0D; ++ ++ if (entityliving.distanceToSqr((Entity) this.ghast) < 4096.0D) { ++ double d1 = entityliving.getX() - this.ghast.getX(); ++ double d2 = entityliving.getZ() - this.ghast.getZ(); ++ ++ this.ghast.setYRot(-((float) Mth.atan2(d1, d2)) * 57.295776F); ++ this.ghast.yBodyRot = this.ghast.getYRot(); + } + } + +- return true; + } + } + +- static class GhastShootFireballGoal extends Goal { ++ private static class GhastShootFireballGoal extends Goal { ++ + private final Ghast ghast; + public int chargeTime; + +@@ -271,74 +322,44 @@ + + @Override + public void tick() { +- LivingEntity target = this.ghast.getTarget(); +- if (target != null) { +- double d = 64.0; +- if (target.distanceToSqr(this.ghast) < 4096.0 && this.ghast.hasLineOfSight(target)) { +- Level level = this.ghast.level(); +- this.chargeTime++; ++ LivingEntity entityliving = this.ghast.getTarget(); ++ ++ if (entityliving != null) { ++ double d0 = 64.0D; ++ ++ if (entityliving.distanceToSqr((Entity) this.ghast) < 4096.0D && this.ghast.hasLineOfSight(entityliving)) { ++ Level world = this.ghast.level(); ++ ++ ++this.chargeTime; + if (this.chargeTime == 10 && !this.ghast.isSilent()) { +- level.levelEvent(null, 1015, this.ghast.blockPosition(), 0); ++ world.levelEvent((Player) null, 1015, this.ghast.blockPosition(), 0); + } + + if (this.chargeTime == 20) { +- double d1 = 4.0; +- Vec3 viewVector = this.ghast.getViewVector(1.0F); +- double d2 = target.getX() - (this.ghast.getX() + viewVector.x * 4.0); +- double d3 = target.getY(0.5) - (0.5 + this.ghast.getY(0.5)); +- double d4 = target.getZ() - (this.ghast.getZ() + viewVector.z * 4.0); ++ double d1 = 4.0D; ++ Vec3 vec3d = this.ghast.getViewVector(1.0F); ++ double d2 = entityliving.getX() - (this.ghast.getX() + vec3d.x * 4.0D); ++ double d3 = entityliving.getY(0.5D) - (0.5D + this.ghast.getY(0.5D)); ++ double d4 = entityliving.getZ() - (this.ghast.getZ() + vec3d.z * 4.0D); ++ + if (!this.ghast.isSilent()) { +- level.levelEvent(null, 1016, this.ghast.blockPosition(), 0); ++ world.levelEvent((Player) null, 1016, this.ghast.blockPosition(), 0); + } + +- LargeFireball largeFireball = new LargeFireball(level, this.ghast, d2, d3, d4, this.ghast.getExplosionPower()); +- largeFireball.setPos(this.ghast.getX() + viewVector.x * 4.0, this.ghast.getY(0.5) + 0.5, largeFireball.getZ() + viewVector.z * 4.0); +- level.addFreshEntity(largeFireball); ++ LargeFireball entitylargefireball = new LargeFireball(world, this.ghast, d2, d3, d4, this.ghast.getExplosionPower()); ++ ++ // CraftBukkit - set bukkitYield when setting explosionpower ++ entitylargefireball.bukkitYield = entitylargefireball.explosionPower = this.ghast.getExplosionPower(); ++ entitylargefireball.setPos(this.ghast.getX() + vec3d.x * 4.0D, this.ghast.getY(0.5D) + 0.5D, entitylargefireball.getZ() + vec3d.z * 4.0D); ++ world.addFreshEntity(entitylargefireball); + this.chargeTime = -40; + } + } else if (this.chargeTime > 0) { +- this.chargeTime--; ++ --this.chargeTime; + } + + this.ghast.setCharging(this.chargeTime > 10); + } + } + } +- +- static class RandomFloatAroundGoal extends Goal { +- private final Ghast ghast; +- +- public RandomFloatAroundGoal(Ghast ghast) { +- this.ghast = ghast; +- this.setFlags(EnumSet.of(Goal.Flag.MOVE)); +- } +- +- @Override +- public boolean canUse() { +- MoveControl moveControl = this.ghast.getMoveControl(); +- if (!moveControl.hasWanted()) { +- return true; +- } else { +- double d = moveControl.getWantedX() - this.ghast.getX(); +- double d1 = moveControl.getWantedY() - this.ghast.getY(); +- double d2 = moveControl.getWantedZ() - this.ghast.getZ(); +- double d3 = d * d + d1 * d1 + d2 * d2; +- return d3 < 1.0 || d3 > 3600.0; +- } +- } +- +- @Override +- public boolean canContinueToUse() { +- return false; +- } +- +- @Override +- public void start() { +- RandomSource random = this.ghast.getRandom(); +- double d = this.ghast.getX() + (double)((random.nextFloat() * 2.0F - 1.0F) * 16.0F); +- double d1 = this.ghast.getY() + (double)((random.nextFloat() * 2.0F - 1.0F) * 16.0F); +- double d2 = this.ghast.getZ() + (double)((random.nextFloat() * 2.0F - 1.0F) * 16.0F); +- this.ghast.getMoveControl().setWantedPosition(d, d1, d2, 1.0); +- } +- } + } |