aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch161
1 files changed, 161 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch
new file mode 100644
index 0000000000..1c2d36e14a
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch
@@ -0,0 +1,161 @@
+--- a/net/minecraft/world/level/block/ConcretePowderBlock.java
++++ b/net/minecraft/world/level/block/ConcretePowderBlock.java
+@@ -12,65 +12,85 @@
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.LevelAccessor;
+ import net.minecraft.world.level.block.state.BlockBehaviour;
+-import net.minecraft.world.level.block.state.BlockState;
++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 ConcretePowderBlock extends FallingBlock {
+
+ public static final MapCodec<ConcretePowderBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
+- return instance.group(BuiltInRegistries.BLOCK.byNameCodec().fieldOf("concrete").forGetter((concretepowderblock) -> {
+- return concretepowderblock.concrete;
++ return instance.group(BuiltInRegistries.BLOCK.byNameCodec().fieldOf("concrete").forGetter((blockconcretepowder) -> {
++ return blockconcretepowder.concrete;
+ }), propertiesCodec()).apply(instance, ConcretePowderBlock::new);
+ });
+ private final Block concrete;
+
+ @Override
+- @Override
+ public MapCodec<ConcretePowderBlock> codec() {
+ return ConcretePowderBlock.CODEC;
+ }
+
+- public ConcretePowderBlock(Block block, BlockBehaviour.Properties blockbehaviour_properties) {
+- super(blockbehaviour_properties);
+- this.concrete = block;
++ public ConcretePowderBlock(Block concrete, BlockBehaviour.Properties properties) {
++ super(properties);
++ this.concrete = concrete;
+ }
+
+ @Override
+- @Override
+- public void onLand(Level level, BlockPos blockpos, BlockState blockstate, BlockState blockstate1, FallingBlockEntity fallingblockentity) {
+- if (shouldSolidify(level, blockpos, blockstate1)) {
+- level.setBlock(blockpos, this.concrete.defaultBlockState(), 3);
++ public void onLand(Level level, BlockPos pos, IBlockData state, IBlockData replaceableState, FallingBlockEntity fallingBlock) {
++ if (shouldSolidify(level, pos, replaceableState)) {
++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, this.concrete.defaultBlockState(), 3); // CraftBukkit
+ }
+
+ }
+
+ @Override
+- @Override
+- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) {
+- Level level = blockplacecontext.getLevel();
+- BlockPos blockpos = blockplacecontext.getClickedPos();
+- BlockState blockstate = level.getBlockState(blockpos);
++ public IBlockData getStateForPlacement(BlockPlaceContext context) {
++ Level world = context.getLevel();
++ BlockPos blockposition = context.getClickedPos();
++ IBlockData iblockdata = world.getBlockState(blockposition);
+
+- return shouldSolidify(level, blockpos, blockstate) ? this.concrete.defaultBlockState() : super.getStateForPlacement(blockplacecontext);
++ // CraftBukkit start
++ if (!shouldSolidify(world, blockposition, iblockdata)) {
++ return super.getStateForPlacement(context);
++ }
++
++ // TODO: An event factory call for methods like this
++ CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockposition);
++ blockState.setData(this.concrete.defaultBlockState());
++
++ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
++ world.getServer().server.getPluginManager().callEvent(event);
++
++ if (!event.isCancelled()) {
++ return blockState.getHandle();
++ }
++
++ return super.getStateForPlacement(context);
++ // CraftBukkit end
+ }
+
+- private static boolean shouldSolidify(BlockGetter blockgetter, BlockPos blockpos, BlockState blockstate) {
+- return canSolidify(blockstate) || touchesLiquid(blockgetter, blockpos);
++ private static boolean shouldSolidify(BlockGetter level, BlockPos pos, IBlockData state) {
++ return canSolidify(state) || touchesLiquid(level, pos);
+ }
+
+- private static boolean touchesLiquid(BlockGetter blockgetter, BlockPos blockpos) {
++ private static boolean touchesLiquid(BlockGetter level, BlockPos pos) {
+ boolean flag = false;
+- BlockPos.MutableBlockPos blockpos_mutableblockpos = blockpos.mutable();
+- Direction[] adirection = Direction.values();
+- int i = adirection.length;
++ BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable();
++ Direction[] aenumdirection = Direction.values();
++ int i = aenumdirection.length;
+
+ for (int j = 0; j < i; ++j) {
+- Direction direction = adirection[j];
+- BlockState blockstate = blockgetter.getBlockState(blockpos_mutableblockpos);
++ Direction enumdirection = aenumdirection[j];
++ IBlockData iblockdata = level.getBlockState(blockposition_mutableblockposition);
+
+- if (direction != Direction.DOWN || canSolidify(blockstate)) {
+- blockpos_mutableblockpos.setWithOffset(blockpos, direction);
+- blockstate = blockgetter.getBlockState(blockpos_mutableblockpos);
+- if (canSolidify(blockstate) && !blockstate.isFaceSturdy(blockgetter, blockpos, direction.getOpposite())) {
++ if (enumdirection != Direction.DOWN || canSolidify(iblockdata)) {
++ blockposition_mutableblockposition.setWithOffset(pos, enumdirection);
++ iblockdata = level.getBlockState(blockposition_mutableblockposition);
++ if (canSolidify(iblockdata) && !iblockdata.isFaceSturdy(level, pos, enumdirection.getOpposite())) {
+ flag = true;
+ break;
+ }
+@@ -80,19 +100,35 @@
+ return flag;
+ }
+
+- private static boolean canSolidify(BlockState blockstate) {
+- return blockstate.getFluidState().is(FluidTags.WATER);
++ private static boolean canSolidify(IBlockData state) {
++ return state.getFluidState().is(FluidTags.WATER);
+ }
+
+ @Override
+- @Override
+- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) {
+- return touchesLiquid(levelaccessor, blockpos) ? this.concrete.defaultBlockState() : super.updateShape(blockstate, direction, blockstate1, levelaccessor, blockpos, blockpos1);
++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
++ // CraftBukkit start
++ if (touchesLiquid(level, currentPos)) {
++ // Suppress during worldgen
++ if (!(level instanceof Level)) {
++ return this.concrete.defaultBlockState();
++ }
++ CraftBlockState blockState = CraftBlockStates.getBlockState(level, currentPos);
++ blockState.setData(this.concrete.defaultBlockState());
++
++ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
++ ((Level) level).getCraftServer().getPluginManager().callEvent(event);
++
++ if (!event.isCancelled()) {
++ return blockState.getHandle();
++ }
++ }
++
++ return super.updateShape(state, facing, facingState, level, currentPos, facingPos);
++ // CraftBukkit end
+ }
+
+ @Override
+- @Override
+- public int getDustColor(BlockState blockstate, BlockGetter blockgetter, BlockPos blockpos) {
+- return blockstate.getMapColor(blockgetter, blockpos).col;
++ public int getDustColor(IBlockData state, BlockGetter reader, BlockPos pos) {
++ return state.getMapColor(reader, pos).col;
+ }
+ }