#877: Improve and simplify CraftBlockState

By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
CraftBukkit/Spigot
2021-09-29 18:56:16 +10:00
parent 65625f410c
commit f27c8f74f8
47 changed files with 591 additions and 977 deletions

View File

@@ -1,18 +1,19 @@
--- a/net/minecraft/world/level/block/BlockConcretePowder.java
+++ b/net/minecraft/world/level/block/BlockConcretePowder.java
@@ -13,6 +13,11 @@
@@ -13,6 +13,12 @@
import net.minecraft.world.level.block.state.BlockBase;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlockState;
+import org.bukkit.craftbukkit.block.CraftBlockStates;
+import org.bukkit.event.block.BlockFormEvent;
+// CraftBukkit end
+
public class BlockConcretePowder extends BlockFalling {
private final IBlockData concrete;
@@ -25,7 +30,7 @@
@@ -25,7 +31,7 @@
@Override
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) {
if (canHarden(world, blockposition, iblockdata1)) {
@@ -21,7 +22,7 @@
}
}
@@ -36,7 +41,24 @@
@@ -36,7 +42,24 @@
BlockPosition blockposition = blockactioncontext.getClickPosition();
IBlockData iblockdata = world.getType(blockposition);
@@ -32,7 +33,7 @@
+ }
+
+ // TODO: An event factory call for methods like this
+ CraftBlockState blockState = CraftBlockState.getBlockState(world, blockposition);
+ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition);
+ blockState.setData(this.concrete);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
@@ -47,7 +48,7 @@
}
private static boolean canHarden(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
@@ -72,7 +94,25 @@
@@ -72,7 +95,25 @@
@Override
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
@@ -58,7 +59,7 @@
+ if (!(generatoraccess instanceof World)) {
+ return this.concrete;
+ }
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
+ CraftBlockState blockState = CraftBlockStates.getBlockState(generatoraccess, blockposition);
+ blockState.setData(this.concrete);
+
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);