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-spigotflower/net/minecraft/world/entity/LightningBolt.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-spigotflower/net/minecraft/world/entity/LightningBolt.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/entity/LightningBolt.java.patch | 296 |
1 files changed, 296 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/entity/LightningBolt.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/entity/LightningBolt.java.patch new file mode 100644 index 0000000000..0a431bb5f7 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/entity/LightningBolt.java.patch @@ -0,0 +1,296 @@ +--- a/net/minecraft/world/entity/LightningBolt.java ++++ b/net/minecraft/world/entity/LightningBolt.java +@@ -24,39 +24,41 @@ + import net.minecraft.world.level.block.Blocks; + import net.minecraft.world.level.block.LightningRodBlock; + import net.minecraft.world.level.block.WeatheringCopper; +-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.AABB; + import net.minecraft.world.phys.Vec3; ++// CraftBukkit start ++import org.bukkit.craftbukkit.event.CraftEventFactory; ++// CraftBukkit end + + public class LightningBolt extends Entity { + + private static final int START_LIFE = 2; + private static final double DAMAGE_RADIUS = 3.0D; + private static final double DETECTION_RADIUS = 15.0D; +- private int life; ++ public int life; + public long seed; +- private int flashes; +- private boolean visualOnly; ++ public int flashes; ++ public boolean visualOnly; + @Nullable + private ServerPlayer cause; + private final Set<Entity> hitEntities = Sets.newHashSet(); + private int blocksSetOnFire; + +- public LightningBolt(EntityType<? extends LightningBolt> entitytype, Level level) { +- super(entitytype, level); ++ public LightningBolt(EntityType<? extends LightningBolt> entityType, Level level) { ++ super(entityType, level); + this.noCulling = true; + this.life = 2; + this.seed = this.random.nextLong(); + this.flashes = this.random.nextInt(3) + 1; + } + +- public void setVisualOnly(boolean flag) { +- this.visualOnly = flag; ++ public void setVisualOnly(boolean visualOnly) { ++ this.visualOnly = visualOnly; + } + + @Override +- @Override + public SoundSource getSoundSource() { + return SoundSource.WEATHER; + } +@@ -66,22 +68,21 @@ + return this.cause; + } + +- public void setCause(@Nullable ServerPlayer serverplayer) { +- this.cause = serverplayer; ++ public void setCause(@Nullable ServerPlayer cause) { ++ this.cause = cause; + } + + private void powerLightningRod() { +- BlockPos blockpos = this.getStrikePosition(); +- BlockState blockstate = this.level().getBlockState(blockpos); ++ BlockPos blockposition = this.getStrikePosition(); ++ IBlockData iblockdata = this.level().getBlockState(blockposition); + +- if (blockstate.is(Blocks.LIGHTNING_ROD)) { +- ((LightningRodBlock) blockstate.getBlock()).onLightningStrike(blockstate, this.level(), blockpos); ++ if (iblockdata.is(Blocks.LIGHTNING_ROD)) { ++ ((LightningRodBlock) iblockdata.getBlock()).onLightningStrike(iblockdata, this.level(), blockposition); + } + + } + + @Override +- @Override + public void tick() { + super.tick(); + if (this.life == 2) { +@@ -89,9 +90,9 @@ + this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_THUNDER, SoundSource.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F, false); + this.level().playLocalSound(this.getX(), this.getY(), this.getZ(), SoundEvents.LIGHTNING_BOLT_IMPACT, SoundSource.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F, false); + } else { +- Difficulty difficulty = this.level().getDifficulty(); ++ Difficulty enumdifficulty = this.level().getDifficulty(); + +- if (difficulty == Difficulty.NORMAL || difficulty == Difficulty.HARD) { ++ if (enumdifficulty == Difficulty.NORMAL || enumdifficulty == Difficulty.HARD) { + this.spawnFire(4); + } + +@@ -111,14 +112,14 @@ + list = this.level().getEntities((Entity) this, new AABB(this.getX() - 15.0D, this.getY() - 15.0D, this.getZ() - 15.0D, this.getX() + 15.0D, this.getY() + 6.0D + 15.0D, this.getZ() + 15.0D), (entity) -> { + return entity.isAlive() && !this.hitEntities.contains(entity); + }); +- iterator = ((ServerLevel) this.level()).getPlayers((serverplayer) -> { +- return serverplayer.distanceTo(this) < 256.0F; ++ iterator = ((ServerLevel) this.level()).getPlayers((entityplayer) -> { ++ return entityplayer.distanceTo(this) < 256.0F; + }).iterator(); + + while (iterator.hasNext()) { +- ServerPlayer serverplayer = (ServerPlayer) iterator.next(); ++ ServerPlayer entityplayer = (ServerPlayer) iterator.next(); + +- CriteriaTriggers.LIGHTNING_STRIKE.trigger(serverplayer, this, list); ++ CriteriaTriggers.LIGHTNING_STRIKE.trigger(entityplayer, this, list); + } + } + +@@ -131,7 +132,7 @@ + } + } + +- if (this.life >= 0) { ++ if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.visualOnly + if (!(this.level() instanceof ServerLevel)) { + this.level().setSkyFlashTime(2); + } else if (!this.visualOnly) { +@@ -154,117 +155,122 @@ + } + + private BlockPos getStrikePosition() { +- Vec3 vec3 = this.position(); ++ Vec3 vec3d = this.position(); + +- return BlockPos.containing(vec3.x, vec3.y - 1.0E-6D, vec3.z); ++ return BlockPos.containing(vec3d.x, vec3d.y - 1.0E-6D, vec3d.z); + } + +- private void spawnFire(int i) { ++ private void spawnFire(int extraIgnitions) { + if (!this.visualOnly && !this.level().isClientSide && this.level().getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { +- BlockPos blockpos = this.blockPosition(); +- BlockState blockstate = BaseFireBlock.getState(this.level(), blockpos); ++ BlockPos blockposition = this.blockPosition(); ++ IBlockData iblockdata = BaseFireBlock.getState(this.level(), blockposition); + +- if (this.level().getBlockState(blockpos).isAir() && blockstate.canSurvive(this.level(), blockpos)) { +- this.level().setBlockAndUpdate(blockpos, blockstate); +- ++this.blocksSetOnFire; ++ if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) { ++ // CraftBukkit start - add "!visualOnly" ++ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) { ++ this.level().setBlockAndUpdate(blockposition, iblockdata); ++ ++this.blocksSetOnFire; ++ } ++ // CraftBukkit end + } + +- for (int j = 0; j < i; ++j) { +- BlockPos blockpos1 = blockpos.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); ++ for (int j = 0; j < extraIgnitions; ++j) { ++ BlockPos blockposition1 = blockposition.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); + +- blockstate = BaseFireBlock.getState(this.level(), blockpos1); +- if (this.level().getBlockState(blockpos1).isAir() && blockstate.canSurvive(this.level(), blockpos1)) { +- this.level().setBlockAndUpdate(blockpos1, blockstate); +- ++this.blocksSetOnFire; ++ iblockdata = BaseFireBlock.getState(this.level(), blockposition1); ++ if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) { ++ // CraftBukkit start - add "!visualOnly" ++ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition1, this).isCancelled()) { ++ this.level().setBlockAndUpdate(blockposition1, iblockdata); ++ ++this.blocksSetOnFire; ++ } ++ // CraftBukkit end + } + } + + } + } + +- private static void clearCopperOnLightningStrike(Level level, BlockPos blockpos) { +- BlockState blockstate = level.getBlockState(blockpos); +- BlockPos blockpos1; +- BlockState blockstate1; ++ private static void clearCopperOnLightningStrike(Level level, BlockPos pos) { ++ IBlockData iblockdata = level.getBlockState(pos); ++ BlockPos blockposition1; ++ IBlockData iblockdata1; + +- if (blockstate.is(Blocks.LIGHTNING_ROD)) { +- blockpos1 = blockpos.relative(((Direction) blockstate.getValue(LightningRodBlock.FACING)).getOpposite()); +- blockstate1 = level.getBlockState(blockpos1); ++ if (iblockdata.is(Blocks.LIGHTNING_ROD)) { ++ blockposition1 = pos.relative(((Direction) iblockdata.getValue(LightningRodBlock.FACING)).getOpposite()); ++ iblockdata1 = level.getBlockState(blockposition1); + } else { +- blockpos1 = blockpos; +- blockstate1 = blockstate; ++ blockposition1 = pos; ++ iblockdata1 = iblockdata; + } + +- if (blockstate1.getBlock() instanceof WeatheringCopper) { +- level.setBlockAndUpdate(blockpos1, WeatheringCopper.getFirst(level.getBlockState(blockpos1))); +- BlockPos.MutableBlockPos blockpos_mutableblockpos = blockpos.mutable(); ++ if (iblockdata1.getBlock() instanceof WeatheringCopper) { ++ level.setBlockAndUpdate(blockposition1, WeatheringCopper.getFirst(level.getBlockState(blockposition1))); ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable(); + int i = level.random.nextInt(3) + 3; + + for (int j = 0; j < i; ++j) { + int k = level.random.nextInt(8) + 1; + +- randomWalkCleaningCopper(level, blockpos1, blockpos_mutableblockpos, k); ++ randomWalkCleaningCopper(level, blockposition1, blockposition_mutableblockposition, k); + } + + } + } + +- private static void randomWalkCleaningCopper(Level level, BlockPos blockpos, BlockPos.MutableBlockPos blockpos_mutableblockpos, int i) { +- blockpos_mutableblockpos.set(blockpos); ++ private static void randomWalkCleaningCopper(Level level, BlockPos pos, BlockPos.MutableBlockPos mutable, int steps) { ++ mutable.set(pos); + +- for (int j = 0; j < i; ++j) { +- Optional<BlockPos> optional = randomStepCleaningCopper(level, blockpos_mutableblockpos); ++ for (int j = 0; j < steps; ++j) { ++ Optional<BlockPos> optional = randomStepCleaningCopper(level, mutable); + + if (optional.isEmpty()) { + break; + } + +- blockpos_mutableblockpos.set((Vec3i) optional.get()); ++ mutable.set((Vec3i) optional.get()); + } + + } + +- private static Optional<BlockPos> randomStepCleaningCopper(Level level, BlockPos blockpos) { +- Iterator iterator = BlockPos.randomInCube(level.random, 10, blockpos, 1).iterator(); ++ private static Optional<BlockPos> randomStepCleaningCopper(Level level, BlockPos pos) { ++ Iterator iterator = BlockPos.randomInCube(level.random, 10, pos, 1).iterator(); + +- BlockPos blockpos1; +- BlockState blockstate; ++ BlockPos blockposition1; ++ IBlockData iblockdata; + + do { + if (!iterator.hasNext()) { + return Optional.empty(); + } + +- blockpos1 = (BlockPos) iterator.next(); +- blockstate = level.getBlockState(blockpos1); +- } while (!(blockstate.getBlock() instanceof WeatheringCopper)); ++ blockposition1 = (BlockPos) iterator.next(); ++ iblockdata = level.getBlockState(blockposition1); ++ } while (!(iblockdata.getBlock() instanceof WeatheringCopper)); + +- WeatheringCopper.getPrevious(blockstate).ifPresent((blockstate1) -> { +- level.setBlockAndUpdate(blockpos1, blockstate1); ++ BlockPos blockposition1Final = blockposition1; // CraftBukkit - decompile error ++ WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> { ++ level.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error + }); +- level.levelEvent(3002, blockpos1, -1); +- return Optional.of(blockpos1); ++ level.levelEvent(3002, blockposition1, -1); ++ return Optional.of(blockposition1); + } + + @Override +- @Override +- public boolean shouldRenderAtSqrDistance(double d0) { ++ public boolean shouldRenderAtSqrDistance(double distance) { + double d1 = 64.0D * getViewScale(); + +- return d0 < d1 * d1; ++ return distance < d1 * d1; + } + + @Override +- @Override + protected void defineSynchedData() {} + + @Override +- @Override +- protected void readAdditionalSaveData(CompoundTag compoundtag) {} ++ protected void readAdditionalSaveData(CompoundTag compound) {} + + @Override +- @Override +- protected void addAdditionalSaveData(CompoundTag compoundtag) {} ++ protected void addAdditionalSaveData(CompoundTag compound) {} + + public int getBlocksSetOnFire() { + return this.blocksSetOnFire; |