mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
102 lines
5.2 KiB
Diff
102 lines
5.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: granny <granny@purpurmc.org>
|
|
Date: Sun, 27 Aug 2023 02:08:38 -0700
|
|
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..977cb69f8ada7459a9d2308ef07e445706f243f6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/LightningBolt.java
|
|
@@ -83,6 +83,46 @@ public class LightningBolt extends Entity {
|
|
|
|
}
|
|
|
|
+ private void transformSandToGlass() {
|
|
+ BlockPos blockposition = this.getStrikePosition();
|
|
+ BlockState iblockdata = this.level().getBlockState(blockposition);
|
|
+
|
|
+ if (iblockdata.is(Blocks.LIGHTNING_ROD)) {
|
|
+ blockposition = blockposition.below();
|
|
+ iblockdata = this.level().getBlockState(blockposition);
|
|
+ }
|
|
+
|
|
+ if (iblockdata.is(Blocks.SAND)) {
|
|
+ level().setBlock(blockposition, Blocks.GLASS.defaultBlockState(), 2);
|
|
+ } else if (iblockdata.is(Blocks.STONE)) {
|
|
+ level().setBlock(blockposition, Blocks.OBSIDIAN.defaultBlockState(), 2);
|
|
+ } else if (iblockdata.is(Blocks.WATER)) {
|
|
+ level().setBlock(blockposition, Blocks.STONE.defaultBlockState(), 2);
|
|
+ } else {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ final BlockPos finalBlockposition = blockposition;
|
|
+ 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);
|
|
+ net.minecraft.world.level.material.FluidState fluid = blockList.getFluidState(blockposition1);
|
|
+
|
|
+ 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);
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
+ }
|
|
+ }, blockList);
|
|
+ }
|
|
+
|
|
@Override
|
|
public void tick() {
|
|
super.tick();
|
|
@@ -98,6 +138,7 @@ public class LightningBolt extends Entity {
|
|
}
|
|
|
|
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()) {
|