diff options
author | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
commit | bee74680e607c2e29b038329f62181238911cd83 (patch) | |
tree | 708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-vineflower/net/minecraft/world/entity/ambient/Bat.java.patch | |
parent | 0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff) | |
download | Paper-softspoon.tar.gz Paper-softspoon.zip |
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/ambient/Bat.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/ambient/Bat.java.patch | 275 |
1 files changed, 275 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/ambient/Bat.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/ambient/Bat.java.patch new file mode 100644 index 0000000000..0132ee9d78 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/ambient/Bat.java.patch @@ -0,0 +1,275 @@ +--- a/net/minecraft/world/entity/ambient/Bat.java ++++ b/net/minecraft/world/entity/ambient/Bat.java +@@ -16,24 +16,29 @@ + 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 { ++ + public static final float FLAP_LENGTH_SECONDS = 0.5F; + public static final float TICKS_PER_FLAP = 10.0F; + private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(Bat.class, EntityDataSerializers.BYTE); + private static final int FLAG_RESTING = 1; +- private static final TargetingConditions BAT_RESTING_TARGETING = TargetingConditions.forNonCombat().range(4.0); ++ private static final TargetingConditions BAT_RESTING_TARGETING = TargetingConditions.forNonCombat().range(4.0D); + public final AnimationState flyAnimationState = new AnimationState(); + public final AnimationState restAnimationState = new AnimationState(); + @Nullable +@@ -44,17 +49,18 @@ + if (!level.isClientSide) { + this.setResting(true); + } ++ + } + + @Override + public boolean isFlapping() { +- return !this.isResting() && (float)this.tickCount % 10.0F == 0.0F; ++ return !this.isResting() && (float) this.tickCount % 10.0F == 0.0F; + } + + @Override + protected void defineSynchedData() { + super.defineSynchedData(); +- this.entityData.define(DATA_ID_FLAGS, (byte)0); ++ this.entityData.define(Bat.DATA_ID_FLAGS, (byte) 0); + } + + @Override +@@ -89,28 +95,28 @@ + } + + @Override +- protected void doPush(Entity entity) { +- } ++ protected void doPush(Entity entity) {} + + @Override +- protected void pushEntities() { +- } ++ protected void pushEntities() {} + + public static AttributeSupplier.Builder createAttributes() { +- return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 6.0); ++ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 6.0D); + } + + public boolean isResting() { +- return (this.entityData.get(DATA_ID_FLAGS) & 1) != 0; ++ return ((Byte) this.entityData.get(Bat.DATA_ID_FLAGS) & 1) != 0; + } + + public void setResting(boolean isResting) { +- byte b = this.entityData.get(DATA_ID_FLAGS); ++ byte b0 = (Byte) this.entityData.get(Bat.DATA_ID_FLAGS); ++ + if (isResting) { +- this.entityData.set(DATA_ID_FLAGS, (byte)(b | 1)); ++ this.entityData.set(Bat.DATA_ID_FLAGS, (byte) (b0 | 1)); + } else { +- this.entityData.set(DATA_ID_FLAGS, (byte)(b & -2)); ++ this.entityData.set(Bat.DATA_ID_FLAGS, (byte) (b0 & -2)); + } ++ + } + + @Override +@@ -118,9 +124,9 @@ + super.tick(); + if (this.isResting()) { + this.setDeltaMovement(Vec3.ZERO); +- this.setPosRaw(this.getX(), (double)Mth.floor(this.getY()) + 1.0 - (double)this.getBbHeight(), this.getZ()); ++ this.setPosRaw(this.getX(), (double) Mth.floor(this.getY()) + 1.0D - (double) this.getBbHeight(), this.getZ()); + } else { +- this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.6, 1.0)); ++ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.6D, 1.0D)); + } + + this.setupAnimationStates(); +@@ -129,59 +135,55 @@ + @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 isSilent = this.isSilent(); +- if (this.level().getBlockState(blockPos1).isRedstoneConductor(this.level(), blockPos)) { ++ boolean flag = this.isSilent(); ++ ++ if (this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition)) { + if (this.random.nextInt(200) == 0) { +- this.yHeadRot = (float)this.random.nextInt(360); ++ this.yHeadRot = (float) this.random.nextInt(360); + } + +- if (this.level().getNearestPlayer(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 (!isSilent) { +- this.level().levelEvent(null, 1025, blockPos, 0); ++ if (!flag) { ++ this.level().levelEvent((Player) null, 1025, blockposition, 0); + } + } +- } else { ++ } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent + this.setResting(false); +- if (!isSilent) { +- this.level().levelEvent(null, 1025, blockPos, 0); ++ if (!flag) { ++ this.level().levelEvent((Player) null, 1025, blockposition, 0); + } + } + } else { +- if (this.targetPosition != null +- && (!this.level().isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level().getMinBuildHeight())) { ++ if (this.targetPosition != null && (!this.level().isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level().getMinBuildHeight())) { + this.targetPosition = null; + } + +- if (this.targetPosition == null || this.random.nextInt(30) == 0 || this.targetPosition.closerToCenterThan(this.position(), 2.0)) { +- this.targetPosition = BlockPos.containing( +- this.getX() + (double)this.random.nextInt(7) - (double)this.random.nextInt(7), +- this.getY() + (double)this.random.nextInt(6) - 2.0, +- this.getZ() + (double)this.random.nextInt(7) - (double)this.random.nextInt(7) +- ); ++ if (this.targetPosition == null || this.random.nextInt(30) == 0 || this.targetPosition.closerToCenterThan(this.position(), 2.0D)) { ++ this.targetPosition = BlockPos.containing(this.getX() + (double) this.random.nextInt(7) - (double) this.random.nextInt(7), this.getY() + (double) this.random.nextInt(6) - 2.0D, this.getZ() + (double) this.random.nextInt(7) - (double) this.random.nextInt(7)); + } + +- double d = (double)this.targetPosition.getX() + 0.5 - this.getX(); +- double d1 = (double)this.targetPosition.getY() + 0.1 - this.getY(); +- double d2 = (double)this.targetPosition.getZ() + 0.5 - this.getZ(); +- Vec3 deltaMovement = this.getDeltaMovement(); +- Vec3 vec3 = deltaMovement.add( +- (Math.signum(d) * 0.5 - deltaMovement.x) * 0.1F, +- (Math.signum(d1) * 0.7F - deltaMovement.y) * 0.1F, +- (Math.signum(d2) * 0.5 - deltaMovement.z) * 0.1F +- ); +- this.setDeltaMovement(vec3); +- float f = (float)(Mth.atan2(vec3.z, vec3.x) * 180.0F / (float)Math.PI) - 90.0F; ++ 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 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(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); + } + } ++ + } + + @Override +@@ -190,8 +192,7 @@ + } + + @Override +- protected void checkFallDamage(double y, boolean onGround, BlockState state, BlockPos pos) { +- } ++ protected void checkFallDamage(double y, boolean flag, IBlockData onGround, BlockPos state) {} + + @Override + public boolean isIgnoringBlockTriggers() { +@@ -203,7 +204,7 @@ + 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); + } + +@@ -214,40 +215,42 @@ + @Override + public void readAdditionalSaveData(CompoundTag compound) { + super.readAdditionalSaveData(compound); +- this.entityData.set(DATA_ID_FLAGS, compound.getByte("BatFlags")); ++ this.entityData.set(Bat.DATA_ID_FLAGS, compound.getByte("BatFlags")); + } + + @Override + public void addAdditionalSaveData(CompoundTag compound) { + super.addAdditionalSaveData(compound); +- compound.putByte("BatFlags", this.entityData.get(DATA_ID_FLAGS)); ++ compound.putByte("BatFlags", (Byte) this.entityData.get(Bat.DATA_ID_FLAGS)); + } + +- public static boolean checkBatSpawnRules(EntityType<Bat> bat, LevelAccessor level, MobSpawnType spawnType, BlockPos pos, RandomSource random) { ++ public static boolean checkBatSpawnRules(EntityType<Bat> bat, LevelAccessor level, EnumMobSpawn spawnType, BlockPos pos, RandomSource random) { + if (pos.getY() >= level.getSeaLevel()) { + return false; + } else { +- int maxLocalRawBrightness = level.getMaxLocalRawBrightness(pos); +- int i = 4; ++ int i = level.getMaxLocalRawBrightness(pos); ++ byte b0 = 4; ++ + if (isHalloween()) { +- i = 7; ++ b0 = 7; + } else if (random.nextBoolean()) { + return false; + } + +- return maxLocalRawBrightness <= random.nextInt(i) && checkMobSpawnRules(bat, level, spawnType, pos, random); ++ return i > random.nextInt(b0) ? false : checkMobSpawnRules(bat, level, spawnType, pos, random); + } + } + + private static boolean isHalloween() { +- LocalDate localDate = LocalDate.now(); +- int i = localDate.get(ChronoField.DAY_OF_MONTH); +- int i1 = localDate.get(ChronoField.MONTH_OF_YEAR); +- return i1 == 10 && i >= 20 || i1 == 11 && i <= 3; ++ LocalDate localdate = LocalDate.now(); ++ int i = localdate.get(ChronoField.DAY_OF_MONTH); ++ int j = localdate.get(ChronoField.MONTH_OF_YEAR); ++ ++ return j == 10 && i >= 20 || j == 11 && i <= 3; + } + + @Override +- protected float getStandingEyeHeight(Pose pose, EntityDimensions size) { ++ protected float getStandingEyeHeight(EntityPose pose, EntityDimensions size) { + return size.height / 2.0F; + } + +@@ -259,5 +262,6 @@ + this.restAnimationState.stop(); + this.flyAnimationState.startIfStopped(this.tickCount); + } ++ + } + } |