#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

@@ -84,6 +84,7 @@ import org.bukkit.craftbukkit.CraftStatistic;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.block.CraftBlockState;
import org.bukkit.craftbukkit.block.CraftBlockStates;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
@@ -734,7 +735,7 @@ public class CraftEventFactory {
* BlockFadeEvent
*/
public static BlockFadeEvent callBlockFadeEvent(GeneratorAccess world, BlockPosition pos, IBlockData newBlock) {
CraftBlockState state = CraftBlockState.getBlockState(world, pos);
CraftBlockState state = CraftBlockStates.getBlockState(world, pos);
state.setData(newBlock);
BlockFadeEvent event = new BlockFadeEvent(state.getBlock(), state);
@@ -743,7 +744,7 @@ public class CraftEventFactory {
}
public static boolean handleMoistureChangeEvent(World world, BlockPosition pos, IBlockData newBlock, int flag) {
CraftBlockState state = CraftBlockState.getBlockState(world, pos, flag);
CraftBlockState state = CraftBlockStates.getBlockState(world, pos, flag);
state.setData(newBlock);
MoistureChangeEvent event = new MoistureChangeEvent(state.getBlock(), state);
@@ -766,7 +767,7 @@ public class CraftEventFactory {
return true;
}
CraftBlockState state = CraftBlockState.getBlockState(world, target, flag);
CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag);
state.setData(block);
BlockSpreadEvent event = new BlockSpreadEvent(state.getBlock(), CraftBlock.at(world, source), state);
@@ -1532,7 +1533,7 @@ public class CraftEventFactory {
}
public static boolean handleBlockFormEvent(World world, BlockPosition pos, IBlockData block, int flag, @Nullable Entity entity) {
CraftBlockState blockState = CraftBlockState.getBlockState(world, pos, flag);
CraftBlockState blockState = CraftBlockStates.getBlockState(world, pos, flag);
blockState.setData(block);
BlockFormEvent event = (entity == null) ? new BlockFormEvent(blockState.getBlock(), blockState) : new EntityBlockFormEvent(entity.getBukkitEntity(), blockState.getBlock(), blockState);