diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/entity/ambient/Bat.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/entity/ambient/Bat.java.patch | 274 |
1 files changed, 274 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/ambient/Bat.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/ambient/Bat.java.patch new file mode 100644 index 0000000000..4b6356a12b --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/ambient/Bat.java.patch @@ -0,0 +1,274 @@ +--- a/net/minecraft/world/entity/ambient/Bat.java ++++ b/net/minecraft/world/entity/ambient/Bat.java +@@ -16,18 +16,21 @@ + import net.minecraft.world.entity.AnimationState; + 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.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.targeting.TargetingConditions; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.level.Level; + import net.minecraft.world.level.LevelAccessor; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.phys.Vec3; ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++// CraftBukkit end + + public class Bat extends AmbientCreature { + +@@ -41,8 +44,8 @@ + @Nullable + private BlockPos targetPosition; + +- public Bat(EntityType<? extends Bat> entitytype, Level level) { +- super(entitytype, level); ++ public Bat(EntityType<? extends Bat> entityType, Level level) { ++ super(entityType, level); + if (!level.isClientSide) { + this.setResting(true); + } +@@ -50,61 +53,51 @@ + } + + @Override +- @Override + public boolean isFlapping() { + return !this.isResting() && (float) this.tickCount % 10.0F == 0.0F; + } + + @Override +- @Override + protected void defineSynchedData() { + super.defineSynchedData(); + this.entityData.define(Bat.DATA_ID_FLAGS, (byte) 0); + } + + @Override +- @Override + protected float getSoundVolume() { + return 0.1F; + } + + @Override +- @Override + public float getVoicePitch() { + return super.getVoicePitch() * 0.95F; + } + + @Nullable + @Override +- @Override + public SoundEvent getAmbientSound() { + return this.isResting() && this.random.nextInt(4) != 0 ? null : SoundEvents.BAT_AMBIENT; + } + + @Override +- @Override +- protected SoundEvent getHurtSound(DamageSource damagesource) { ++ protected SoundEvent getHurtSound(DamageSource damageSource) { + return SoundEvents.BAT_HURT; + } + + @Override +- @Override + protected SoundEvent getDeathSound() { + return SoundEvents.BAT_DEATH; + } + + @Override +- @Override + public boolean isPushable() { + return false; + } + + @Override +- @Override + protected void doPush(Entity entity) {} + + @Override +- @Override + protected void pushEntities() {} + + public static AttributeSupplier.Builder createAttributes() { +@@ -115,10 +108,10 @@ + return ((Byte) this.entityData.get(Bat.DATA_ID_FLAGS) & 1) != 0; + } + +- public void setResting(boolean flag) { ++ public void setResting(boolean isResting) { + byte b0 = (Byte) this.entityData.get(Bat.DATA_ID_FLAGS); + +- if (flag) { ++ if (isResting) { + this.entityData.set(Bat.DATA_ID_FLAGS, (byte) (b0 | 1)); + } else { + this.entityData.set(Bat.DATA_ID_FLAGS, (byte) (b0 & -2)); +@@ -127,7 +120,6 @@ + } + + @Override +- @Override + public void tick() { + super.tick(); + if (this.isResting()) { +@@ -141,30 +133,29 @@ + } + + @Override +- @Override + protected void customServerAiStep() { + super.customServerAiStep(); +- BlockPos blockpos = this.blockPosition(); +- BlockPos blockpos1 = blockpos.above(); ++ BlockPos blockposition = this.blockPosition(); ++ BlockPos blockposition1 = blockposition.above(); + + if (this.isResting()) { + boolean flag = this.isSilent(); + +- if (this.level().getBlockState(blockpos1).isRedstoneConductor(this.level(), blockpos)) { ++ if (this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition)) { + if (this.random.nextInt(200) == 0) { + this.yHeadRot = (float) this.random.nextInt(360); + } + +- if (this.level().getNearestPlayer(Bat.BAT_RESTING_TARGETING, this) != null) { ++ if (this.level().getNearestPlayer(Bat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent + this.setResting(false); + if (!flag) { +- this.level().levelEvent((Player) null, 1025, blockpos, 0); ++ this.level().levelEvent((Player) null, 1025, blockposition, 0); + } + } +- } else { ++ } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent + this.setResting(false); + if (!flag) { +- this.level().levelEvent((Player) null, 1025, blockpos, 0); ++ this.level().levelEvent((Player) null, 1025, blockposition, 0); + } + } + } else { +@@ -179,16 +170,16 @@ + double d0 = (double) this.targetPosition.getX() + 0.5D - this.getX(); + double d1 = (double) this.targetPosition.getY() + 0.1D - this.getY(); + double d2 = (double) this.targetPosition.getZ() + 0.5D - this.getZ(); +- Vec3 vec3 = this.getDeltaMovement(); +- Vec3 vec31 = vec3.add((Math.signum(d0) * 0.5D - vec3.x) * 0.10000000149011612D, (Math.signum(d1) * 0.699999988079071D - vec3.y) * 0.10000000149011612D, (Math.signum(d2) * 0.5D - vec3.z) * 0.10000000149011612D); ++ Vec3 vec3d = this.getDeltaMovement(); ++ Vec3 vec3d1 = vec3d.add((Math.signum(d0) * 0.5D - vec3d.x) * 0.10000000149011612D, (Math.signum(d1) * 0.699999988079071D - vec3d.y) * 0.10000000149011612D, (Math.signum(d2) * 0.5D - vec3d.z) * 0.10000000149011612D); + +- this.setDeltaMovement(vec31); +- float f = (float) (Mth.atan2(vec31.z, vec31.x) * 57.2957763671875D) - 90.0F; ++ this.setDeltaMovement(vec3d1); ++ float f = (float) (Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D) - 90.0F; + float f1 = Mth.wrapDegrees(f - this.getYRot()); + + this.zza = 0.5F; + this.setYRot(this.getYRot() + f1); +- if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockpos1).isRedstoneConductor(this.level(), blockpos1)) { ++ if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent + this.setResting(true); + } + } +@@ -196,63 +187,57 @@ + } + + @Override +- @Override + protected Entity.MovementEmission getMovementEmission() { + return Entity.MovementEmission.EVENTS; + } + + @Override +- @Override +- protected void checkFallDamage(double d0, boolean flag, BlockState blockstate, BlockPos blockpos) {} ++ protected void checkFallDamage(double y, boolean flag, IBlockData onGround, BlockPos state) {} + + @Override +- @Override + public boolean isIgnoringBlockTriggers() { + return true; + } + + @Override +- @Override +- public boolean hurt(DamageSource damagesource, float f) { +- if (this.isInvulnerableTo(damagesource)) { ++ public boolean hurt(DamageSource source, float amount) { ++ if (this.isInvulnerableTo(source)) { + return false; + } else { +- if (!this.level().isClientSide && this.isResting()) { ++ if (!this.level().isClientSide && this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent + this.setResting(false); + } + +- return super.hurt(damagesource, f); ++ return super.hurt(source, amount); + } + } + + @Override +- @Override +- public void readAdditionalSaveData(CompoundTag compoundtag) { +- super.readAdditionalSaveData(compoundtag); +- this.entityData.set(Bat.DATA_ID_FLAGS, compoundtag.getByte("BatFlags")); ++ public void readAdditionalSaveData(CompoundTag compound) { ++ super.readAdditionalSaveData(compound); ++ this.entityData.set(Bat.DATA_ID_FLAGS, compound.getByte("BatFlags")); + } + + @Override +- @Override +- public void addAdditionalSaveData(CompoundTag compoundtag) { +- super.addAdditionalSaveData(compoundtag); +- compoundtag.putByte("BatFlags", (Byte) this.entityData.get(Bat.DATA_ID_FLAGS)); ++ public void addAdditionalSaveData(CompoundTag compound) { ++ super.addAdditionalSaveData(compound); ++ compound.putByte("BatFlags", (Byte) this.entityData.get(Bat.DATA_ID_FLAGS)); + } + +- public static boolean checkBatSpawnRules(EntityType<Bat> entitytype, LevelAccessor levelaccessor, MobSpawnType mobspawntype, BlockPos blockpos, RandomSource randomsource) { +- if (blockpos.getY() >= levelaccessor.getSeaLevel()) { ++ public static boolean checkBatSpawnRules(EntityType<Bat> bat, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) { ++ if (pos.getY() >= level.getSeaLevel()) { + return false; + } else { +- int i = levelaccessor.getMaxLocalRawBrightness(blockpos); ++ int i = level.getMaxLocalRawBrightness(pos); + byte b0 = 4; + + if (isHalloween()) { + b0 = 7; +- } else if (randomsource.nextBoolean()) { ++ } else if (random.nextBoolean()) { + return false; + } + +- return i > randomsource.nextInt(b0) ? false : checkMobSpawnRules(entitytype, levelaccessor, mobspawntype, blockpos, randomsource); ++ return i > random.nextInt(b0) ? false : checkMobSpawnRules(bat, level, spawnType, pos, random); + } + } + +@@ -265,9 +250,8 @@ + } + + @Override +- @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions entitydimensions) { +- return entitydimensions.height / 2.0F; ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { ++ return size.height / 2.0F; + } + + private void setupAnimationStates() { |