diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/LightningBolt.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/LightningBolt.java.patch | 349 |
1 files changed, 349 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/LightningBolt.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/LightningBolt.java.patch new file mode 100644 index 0000000000..316571091b --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/LightningBolt.java.patch @@ -0,0 +1,349 @@ +--- a/net/minecraft/world/entity/LightningBolt.java ++++ b/net/minecraft/world/entity/LightningBolt.java +@@ -1,6 +1,8 @@ + package net.minecraft.world.entity; + + import com.google.common.collect.Sets; ++import java.util.Collection; ++import java.util.Iterator; + import java.util.List; + import java.util.Optional; + import java.util.Set; +@@ -8,6 +10,8 @@ + import javax.annotation.Nullable; + import net.minecraft.advancements.CriteriaTriggers; + import net.minecraft.core.BlockPos; ++import net.minecraft.core.Direction; ++import net.minecraft.core.Vec3i; + import net.minecraft.nbt.CompoundTag; + import net.minecraft.server.level.ServerLevel; + import net.minecraft.server.level.ServerPlayer; +@@ -20,19 +24,23 @@ + 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.0; +- private static final double DETECTION_RADIUS = 15.0; +- private int life; ++ private static final double DAMAGE_RADIUS = 3.0D; ++ private static final double DETECTION_RADIUS = 15.0D; ++ 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(); +@@ -65,11 +73,13 @@ + } + + private void powerLightningRod() { +- BlockPos strikePosition = this.getStrikePosition(); +- BlockState blockState = this.level().getBlockState(strikePosition); +- if (blockState.is(Blocks.LIGHTNING_ROD)) { +- ((LightningRodBlock)blockState.getBlock()).onLightningStrike(blockState, this.level(), strikePosition); ++ BlockPos blockposition = this.getStrikePosition(); ++ IBlockData iblockdata = this.level().getBlockState(blockposition); ++ ++ if (iblockdata.is(Blocks.LIGHTNING_ROD)) { ++ ((LightningRodBlock) iblockdata.getBlock()).onLightningStrike(iblockdata, this.level(), blockposition); + } ++ + } + + @Override +@@ -77,31 +87,12 @@ + super.tick(); + if (this.life == 2) { + if (this.level().isClientSide()) { +- 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 +- ); ++ 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(); +- if (difficulty == Difficulty.NORMAL || difficulty == Difficulty.HARD) { ++ Difficulty enumdifficulty = this.level().getDifficulty(); ++ ++ if (enumdifficulty == Difficulty.NORMAL || enumdifficulty == Difficulty.HARD) { + this.spawnFire(4); + } + +@@ -111,148 +102,175 @@ + } + } + +- this.life--; ++ --this.life; ++ List list; ++ Iterator iterator; ++ + if (this.life < 0) { + if (this.flashes == 0) { + if (this.level() instanceof ServerLevel) { +- List<Entity> entities = this.level() +- .getEntities( +- this, +- new AABB( +- this.getX() - 15.0, this.getY() - 15.0, this.getZ() - 15.0, this.getX() + 15.0, this.getY() + 6.0 + 15.0, this.getZ() + 15.0 +- ), +- entity1 -> entity1.isAlive() && !this.hitEntities.contains(entity1) +- ); ++ 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((entityplayer) -> { ++ return entityplayer.distanceTo(this) < 256.0F; ++ }).iterator(); + +- for (ServerPlayer serverPlayer : ((ServerLevel)this.level()).getPlayers(player -> player.distanceTo(this) < 256.0F)) { +- CriteriaTriggers.LIGHTNING_STRIKE.trigger(serverPlayer, this, entities); ++ while (iterator.hasNext()) { ++ ServerPlayer entityplayer = (ServerPlayer) iterator.next(); ++ ++ CriteriaTriggers.LIGHTNING_STRIKE.trigger(entityplayer, this, list); + } + } + + this.discard(); + } else if (this.life < -this.random.nextInt(10)) { +- this.flashes--; ++ --this.flashes; + this.life = 1; + this.seed = this.random.nextLong(); + this.spawnFire(0); + } + } + +- 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) { +- List<Entity> entities = this.level() +- .getEntities( +- this, +- new AABB(this.getX() - 3.0, this.getY() - 3.0, this.getZ() - 3.0, this.getX() + 3.0, this.getY() + 6.0 + 3.0, this.getZ() + 3.0), +- Entity::isAlive +- ); ++ list = this.level().getEntities((Entity) this, new AABB(this.getX() - 3.0D, this.getY() - 3.0D, this.getZ() - 3.0D, this.getX() + 3.0D, this.getY() + 6.0D + 3.0D, this.getZ() + 3.0D), Entity::isAlive); ++ iterator = list.iterator(); + +- for (Entity entity : entities) { +- entity.thunderHit((ServerLevel)this.level(), this); ++ while (iterator.hasNext()) { ++ Entity entity = (Entity) iterator.next(); ++ ++ entity.thunderHit((ServerLevel) this.level(), this); + } + +- this.hitEntities.addAll(entities); ++ this.hitEntities.addAll(list); + if (this.cause != null) { +- CriteriaTriggers.CHANNELED_LIGHTNING.trigger(this.cause, entities); ++ CriteriaTriggers.CHANNELED_LIGHTNING.trigger(this.cause, (Collection) list); + } + } + } ++ + } + + private BlockPos getStrikePosition() { +- Vec3 vec3 = this.position(); +- return BlockPos.containing(vec3.x, vec3.y - 1.0E-6, vec3.z); ++ Vec3 vec3d = this.position(); ++ ++ return BlockPos.containing(vec3d.x, vec3d.y - 1.0E-6D, vec3d.z); + } + + private void spawnFire(int extraIgnitions) { + if (!this.visualOnly && !this.level().isClientSide && this.level().getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { +- BlockPos blockPos = this.blockPosition(); +- BlockState state = BaseFireBlock.getState(this.level(), blockPos); +- if (this.level().getBlockState(blockPos).isAir() && state.canSurvive(this.level(), blockPos)) { +- this.level().setBlockAndUpdate(blockPos, state); +- this.blocksSetOnFire++; ++ BlockPos blockposition = this.blockPosition(); ++ IBlockData iblockdata = BaseFireBlock.getState(this.level(), blockposition); ++ ++ 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 i = 0; i < extraIgnitions; i++) { +- BlockPos blockPos1 = blockPos.offset(this.random.nextInt(3) - 1, this.random.nextInt(3) - 1, this.random.nextInt(3) - 1); +- state = BaseFireBlock.getState(this.level(), blockPos1); +- if (this.level().getBlockState(blockPos1).isAir() && state.canSurvive(this.level(), blockPos1)) { +- this.level().setBlockAndUpdate(blockPos1, state); +- this.blocksSetOnFire++; ++ 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); ++ ++ 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 pos) { +- BlockState blockState = level.getBlockState(pos); +- BlockPos blockPos; +- BlockState blockState1; +- if (blockState.is(Blocks.LIGHTNING_ROD)) { +- blockPos = pos.relative(blockState.getValue(LightningRodBlock.FACING).getOpposite()); +- blockState1 = level.getBlockState(blockPos); ++ IBlockData iblockdata = level.getBlockState(pos); ++ BlockPos blockposition1; ++ IBlockData iblockdata1; ++ ++ if (iblockdata.is(Blocks.LIGHTNING_ROD)) { ++ blockposition1 = pos.relative(((Direction) iblockdata.getValue(LightningRodBlock.FACING)).getOpposite()); ++ iblockdata1 = level.getBlockState(blockposition1); + } else { +- blockPos = pos; +- blockState1 = blockState; ++ blockposition1 = pos; ++ iblockdata1 = iblockdata; + } + +- if (blockState1.getBlock() instanceof WeatheringCopper) { +- level.setBlockAndUpdate(blockPos, WeatheringCopper.getFirst(level.getBlockState(blockPos))); +- BlockPos.MutableBlockPos mutableBlockPos = pos.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 i1 = 0; i1 < i; i1++) { +- int i2 = level.random.nextInt(8) + 1; +- randomWalkCleaningCopper(level, blockPos, mutableBlockPos, i2); ++ for (int j = 0; j < i; ++j) { ++ int k = level.random.nextInt(8) + 1; ++ ++ randomWalkCleaningCopper(level, blockposition1, blockposition_mutableblockposition, k); + } ++ + } + } + + private static void randomWalkCleaningCopper(Level level, BlockPos pos, BlockPos.MutableBlockPos mutable, int steps) { + mutable.set(pos); + +- for (int i = 0; i < steps; i++) { ++ for (int j = 0; j < steps; ++j) { + Optional<BlockPos> optional = randomStepCleaningCopper(level, mutable); ++ + if (optional.isEmpty()) { + break; + } + +- mutable.set(optional.get()); ++ mutable.set((Vec3i) optional.get()); + } ++ + } + + private static Optional<BlockPos> randomStepCleaningCopper(Level level, BlockPos pos) { +- for (BlockPos blockPos : BlockPos.randomInCube(level.random, 10, pos, 1)) { +- BlockState blockState = level.getBlockState(blockPos); +- if (blockState.getBlock() instanceof WeatheringCopper) { +- WeatheringCopper.getPrevious(blockState).ifPresent(blockState1 -> level.setBlockAndUpdate(blockPos, blockState1)); +- level.levelEvent(3002, blockPos, -1); +- return Optional.of(blockPos); ++ Iterator iterator = BlockPos.randomInCube(level.random, 10, pos, 1).iterator(); ++ ++ BlockPos blockposition1; ++ IBlockData iblockdata; ++ ++ do { ++ if (!iterator.hasNext()) { ++ return Optional.empty(); + } +- } + +- return Optional.empty(); ++ blockposition1 = (BlockPos) iterator.next(); ++ iblockdata = level.getBlockState(blockposition1); ++ } while (!(iblockdata.getBlock() instanceof WeatheringCopper)); ++ ++ BlockPos blockposition1Final = blockposition1; // CraftBukkit - decompile error ++ WeatheringCopper.getPrevious(iblockdata).ifPresent((iblockdata1) -> { ++ level.setBlockAndUpdate(blockposition1Final, iblockdata1); // CraftBukkit - decompile error ++ }); ++ level.levelEvent(3002, blockposition1, -1); ++ return Optional.of(blockposition1); + } + + @Override + public boolean shouldRenderAtSqrDistance(double distance) { +- double d = 64.0 * getViewScale(); +- return distance < d * d; ++ double d1 = 64.0D * getViewScale(); ++ ++ return distance < d1 * d1; + } + + @Override +- protected void defineSynchedData() { +- } ++ protected void defineSynchedData() {} + + @Override +- protected void readAdditionalSaveData(CompoundTag compound) { +- } ++ protected void readAdditionalSaveData(CompoundTag compound) {} + + @Override +- protected void addAdditionalSaveData(CompoundTag compound) { +- } ++ protected void addAdditionalSaveData(CompoundTag compound) {} + + public int getBlocksSetOnFire() { + return this.blocksSetOnFire; |