diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch new file mode 100644 index 0000000000..2817e3b096 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/level/block/ConcretePowderBlock.java.patch @@ -0,0 +1,160 @@ +--- a/net/minecraft/world/level/block/ConcretePowderBlock.java ++++ b/net/minecraft/world/level/block/ConcretePowderBlock.java +@@ -2,7 +2,6 @@ + + import com.mojang.serialization.MapCodec; + import com.mojang.serialization.codecs.RecordCodecBuilder; +-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; + import net.minecraft.core.registries.BuiltInRegistries; +@@ -13,20 +12,26 @@ + 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 -> instance.group( +- BuiltInRegistries.BLOCK.byNameCodec().fieldOf("concrete").forGetter(concretePowderBlock -> concretePowderBlock.concrete), propertiesCodec() +- ) +- .apply(instance, ConcretePowderBlock::new) +- ); ++ ++ public static final MapCodec<ConcretePowderBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> { ++ return instance.group(BuiltInRegistries.BLOCK.byNameCodec().fieldOf("concrete").forGetter((blockconcretepowder) -> { ++ return blockconcretepowder.concrete; ++ }), propertiesCodec()).apply(instance, ConcretePowderBlock::new); ++ }); + private final Block concrete; + + @Override + public MapCodec<ConcretePowderBlock> codec() { +- return CODEC; ++ return ConcretePowderBlock.CODEC; + } + + public ConcretePowderBlock(Block concrete, BlockBehaviour.Properties properties) { +@@ -35,34 +40,57 @@ + } + + @Override +- public void onLand(Level level, BlockPos pos, BlockState state, BlockState replaceableState, FallingBlockEntity fallingBlock) { ++ public void onLand(Level level, BlockPos pos, IBlockData state, IBlockData replaceableState, FallingBlockEntity fallingBlock) { + if (shouldSolidify(level, pos, replaceableState)) { +- level.setBlock(pos, this.concrete.defaultBlockState(), 3); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, this.concrete.defaultBlockState(), 3); // CraftBukkit + } ++ + } + + @Override +- public BlockState getStateForPlacement(BlockPlaceContext context) { +- BlockGetter level = context.getLevel(); +- BlockPos clickedPos = context.getClickedPos(); +- BlockState blockState = level.getBlockState(clickedPos); +- return shouldSolidify(level, clickedPos, blockState) ? this.concrete.defaultBlockState() : super.getStateForPlacement(context); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ Level world = context.getLevel(); ++ BlockPos blockposition = context.getClickedPos(); ++ IBlockData iblockdata = world.getBlockState(blockposition); ++ ++ // 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 level, BlockPos pos, BlockState state) { ++ private static boolean shouldSolidify(BlockGetter level, BlockPos pos, IBlockData state) { + return canSolidify(state) || touchesLiquid(level, pos); + } + + private static boolean touchesLiquid(BlockGetter level, BlockPos pos) { + boolean flag = false; +- BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable(); ++ Direction[] aenumdirection = Direction.values(); ++ int i = aenumdirection.length; + +- for (Direction direction : Direction.values()) { +- BlockState blockState = level.getBlockState(mutableBlockPos); +- if (direction != Direction.DOWN || canSolidify(blockState)) { +- mutableBlockPos.setWithOffset(pos, direction); +- blockState = level.getBlockState(mutableBlockPos); +- if (canSolidify(blockState) && !blockState.isFaceSturdy(level, pos, direction.getOpposite())) { ++ for (int j = 0; j < i; ++j) { ++ Direction enumdirection = aenumdirection[j]; ++ IBlockData iblockdata = level.getBlockState(blockposition_mutableblockposition); ++ ++ 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; + } +@@ -72,19 +100,35 @@ + return flag; + } + +- private static boolean canSolidify(BlockState state) { ++ private static boolean canSolidify(IBlockData state) { + return state.getFluidState().is(FluidTags.WATER); + } + + @Override +- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) { +- return touchesLiquid(level, currentPos) +- ? this.concrete.defaultBlockState() +- : super.updateShape(state, facing, facingState, level, currentPos, facingPos); ++ 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 +- public int getDustColor(BlockState state, BlockGetter reader, BlockPos pos) { ++ public int getDustColor(IBlockData state, BlockGetter reader, BlockPos pos) { + return state.getMapColor(reader, pos).col; + } + } |