mirror of
https://github.com/PurpurMC/Purpur.git
synced 2025-02-11 12:50:28 +08:00
make the diff smaller
This commit is contained in:
parent
df6a35d814
commit
9e753316c3
@ -5,40 +5,10 @@ Subject: [PATCH] lightning affects blocks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LightningBolt.java b/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
||||
index a01a8ba27534d2b0d544423bc2c48fd29d0a6d64..531538fdce8119aa59f341e50143f2518c914cb4 100644
|
||||
index a01a8ba27534d2b0d544423bc2c48fd29d0a6d64..977cb69f8ada7459a9d2308ef07e445706f243f6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
||||
@@ -17,19 +17,29 @@ import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
+import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.Difficulty;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseFireBlock;
|
||||
+import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
+import net.minecraft.world.level.block.BucketPickup;
|
||||
import net.minecraft.world.level.block.LightningRodBlock;
|
||||
+import net.minecraft.world.level.block.LiquidBlock;
|
||||
+import net.minecraft.world.level.block.SpongeBlock;
|
||||
import net.minecraft.world.level.block.WeatheringCopper;
|
||||
+import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
+import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
|
||||
+import org.bukkit.event.block.SpongeAbsorbEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class LightningBolt extends Entity {
|
||||
@@ -83,6 +93,95 @@ public class LightningBolt extends Entity {
|
||||
@@ -83,6 +83,46 @@ public class LightningBolt extends Entity {
|
||||
|
||||
}
|
||||
|
||||
@ -61,86 +31,71 @@ index a01a8ba27534d2b0d544423bc2c48fd29d0a6d64..531538fdce8119aa59f341e50143f251
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ BlockStateListPopulator blockList = new BlockStateListPopulator(level()); // CraftBukkit - Use BlockStateListPopulator
|
||||
+ final BlockPos finalBlockposition = blockposition;
|
||||
+ BlockPos.breadthFirstTraversal(blockposition, 3, 6, (blockposition1, consumer) -> { // Purpur
|
||||
+ Direction[] aenumdirection = Direction.values();
|
||||
+ int i = aenumdirection.length;
|
||||
+
|
||||
+ for (int j = 0; j < i; ++j) {
|
||||
+ Direction enumdirection = aenumdirection[j];
|
||||
+
|
||||
+ consumer.accept(blockposition1.relative(enumdirection));
|
||||
+ }
|
||||
+
|
||||
+ }, (blockposition1) -> {
|
||||
+ org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(level());
|
||||
+ net.minecraft.world.level.block.SpongeBlock.removeBlockBreadthFirstSearch(level(), blockposition, 3, 6, (blockposition1) -> {
|
||||
+ if (blockposition1.equals(finalBlockposition)) {
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ BlockState iblockdata2 = blockList.getBlockState(blockposition1);
|
||||
+ FluidState fluid = blockList.getFluidState(blockposition1);
|
||||
+ net.minecraft.world.level.material.FluidState fluid = blockList.getFluidState(blockposition1);
|
||||
+
|
||||
+ if (!iblockdata2.is(Blocks.SAND) && !iblockdata2.is(Blocks.STONE) && !fluid.is(FluidTags.WATER)) { // Purpur
|
||||
+ if (!iblockdata2.is(Blocks.SAND) && !iblockdata2.is(Blocks.STONE) && !fluid.is(net.minecraft.tags.FluidTags.WATER)) { // Purpur
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ if (iblockdata2.is(Blocks.SAND)) {
|
||||
+ blockList.setBlock(blockposition1, Blocks.GLASS.defaultBlockState(), 3);
|
||||
+ }// else if (iblockdata2.is(Blocks.STONE)) {
|
||||
+ // blockList.setBlock(blockposition1, Blocks.OBSIDIAN.defaultBlockState(), 3);
|
||||
+ // } else if (iblockdata2.is(Blocks.WATER)) {
|
||||
+ // blockList.setBlock(blockposition1, Blocks.STONE.defaultBlockState(), 3);
|
||||
+ // }
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ });
|
||||
+ // CraftBukkit start
|
||||
+ List<CraftBlockState> blocks = blockList.getList(); // Is a clone
|
||||
+ if (!blocks.isEmpty()) {
|
||||
+ final org.bukkit.block.Block bblock = level().getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+
|
||||
+ SpongeAbsorbEvent event = new SpongeAbsorbEvent(bblock, (List<org.bukkit.block.BlockState>) (List) blocks);
|
||||
+ level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (CraftBlockState block : blocks) {
|
||||
+ BlockPos blockposition1 = block.getPosition();
|
||||
+ BlockState iblockdata3 = level().getBlockState(blockposition1);
|
||||
+ FluidState fluid = level().getFluidState(blockposition1);
|
||||
+
|
||||
+ if (fluid.is(FluidTags.WATER)) {
|
||||
+ if (iblockdata3.getBlock() instanceof BucketPickup && !((BucketPickup) iblockdata3.getBlock()).pickupBlock(blockList, blockposition1, iblockdata3).isEmpty()) {
|
||||
+ // NOP
|
||||
+ } else if (iblockdata3.getBlock() instanceof LiquidBlock) {
|
||||
+ // NOP
|
||||
+ } else if (iblockdata3.is(Blocks.KELP) || iblockdata3.is(Blocks.KELP_PLANT) || iblockdata3.is(Blocks.SEAGRASS) || iblockdata3.is(Blocks.TALL_SEAGRASS)) {
|
||||
+ BlockEntity tileentity = iblockdata3.hasBlockEntity() ? level().getBlockEntity(blockposition1) : null;
|
||||
+
|
||||
+ // Paper start
|
||||
+ if (block.getHandle().isAir()) {
|
||||
+ Block.dropResources(iblockdata3, level(), blockposition1, tileentity);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ }
|
||||
+ }
|
||||
+ level().setBlock(blockposition1, block.getHandle(), block.getFlag());
|
||||
+ }
|
||||
+ }
|
||||
+ }, blockList);
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
@@ -97,6 +196,9 @@ public class LightningBolt extends Entity {
|
||||
this.spawnFire(4);
|
||||
@@ -98,6 +138,7 @@ public class LightningBolt extends Entity {
|
||||
}
|
||||
|
||||
+ this.transformSandToGlass(); // Purpur
|
||||
+ // this.transformWaterToGlass(); // Purpur
|
||||
+ // this.transformSandToGlass(); // Purpur
|
||||
this.powerLightningRod();
|
||||
+ this.transformSandToGlass(); // Purpur
|
||||
LightningBolt.clearCopperOnLightningStrike(this.level(), this.getStrikePosition(), this); // Paper - transmit LightningBolt instance to call EntityChangeBlockEvent
|
||||
this.gameEvent(GameEvent.LIGHTNING_STRIKE);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
|
||||
index 2276fed1feb4fea59b5bd49b5e4586d49478b3cc..a65abad0dbf08e16a8e00b3c9657687a051c1e18 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
|
||||
@@ -47,8 +47,11 @@ public class SpongeBlock extends Block {
|
||||
}
|
||||
|
||||
private boolean removeWaterBreadthFirstSearch(Level world, BlockPos pos) {
|
||||
- BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
|
||||
- BlockPos.breadthFirstTraversal(pos, world.purpurConfig.spongeAbsorptionRadius, world.purpurConfig.spongeAbsorptionArea, (blockposition1, consumer) -> { // Purpur
|
||||
+ return removeBlockBreadthFirstSearch(world, pos, world.purpurConfig.spongeAbsorptionRadius, world.purpurConfig.spongeAbsorptionArea, null, new BlockStateListPopulator(world));
|
||||
+ }
|
||||
+ public static boolean removeBlockBreadthFirstSearch(Level world, BlockPos pos, int maxDepth, int maxIterations, java.util.function.Predicate<BlockPos> callback, BlockStateListPopulator blockList) {
|
||||
+ // BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
|
||||
+ BlockPos.breadthFirstTraversal(pos, maxDepth, maxIterations, (blockposition1, consumer) -> { // Purpur
|
||||
Direction[] aenumdirection = SpongeBlock.ALL_DIRECTIONS;
|
||||
int i = aenumdirection.length;
|
||||
|
||||
@@ -58,7 +61,7 @@ public class SpongeBlock extends Block {
|
||||
consumer.accept(blockposition1.relative(enumdirection));
|
||||
}
|
||||
|
||||
- }, (blockposition1) -> {
|
||||
+ }, callback == null ? (blockposition1) -> { // Purpur
|
||||
if (blockposition1.equals(pos)) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -102,7 +105,7 @@ public class SpongeBlock extends Block {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
- });
|
||||
+ } : callback); // Purpur
|
||||
// CraftBukkit start
|
||||
List<CraftBlockState> blocks = blockList.getList(); // Is a clone
|
||||
if (!blocks.isEmpty()) {
|
||||
|
Loading…
Reference in New Issue
Block a user