aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/item/StandingAndWallBlockItem.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/item/StandingAndWallBlockItem.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/item/StandingAndWallBlockItem.java.patch103
1 files changed, 103 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/item/StandingAndWallBlockItem.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/item/StandingAndWallBlockItem.java.patch
new file mode 100644
index 0000000000..e6f2b4e97c
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/item/StandingAndWallBlockItem.java.patch
@@ -0,0 +1,103 @@
+--- a/net/minecraft/world/item/StandingAndWallBlockItem.java
++++ b/net/minecraft/world/item/StandingAndWallBlockItem.java
+@@ -4,59 +4,74 @@
+ import javax.annotation.Nullable;
+ import net.minecraft.core.BlockPos;
+ import net.minecraft.core.Direction;
++import net.minecraft.server.level.ServerPlayer;
+ import net.minecraft.world.item.context.BlockPlaceContext;
+ import net.minecraft.world.level.Level;
+ import net.minecraft.world.level.LevelReader;
+ import net.minecraft.world.level.block.Block;
+-import net.minecraft.world.level.block.state.BlockState;
++import net.minecraft.world.level.block.state.IBlockData;
+ import net.minecraft.world.phys.shapes.CollisionContext;
++import org.bukkit.craftbukkit.block.CraftBlock;
++import org.bukkit.craftbukkit.block.data.CraftBlockData;
++import org.bukkit.event.block.BlockCanBuildEvent;
++// CraftBukkit end
+
+ public class StandingAndWallBlockItem extends BlockItem {
+
+- protected final Block wallBlock;
++ public final Block wallBlock;
+ private final Direction attachmentDirection;
+
+- public StandingAndWallBlockItem(Block block, Block block1, Item.Properties item_properties, Direction direction) {
+- super(block, item_properties);
+- this.wallBlock = block1;
+- this.attachmentDirection = direction;
++ public StandingAndWallBlockItem(Block block, Block wallBlock, Item.Properties properties, Direction attachmentDirection) {
++ super(block, properties);
++ this.wallBlock = wallBlock;
++ this.attachmentDirection = attachmentDirection;
+ }
+
+- protected boolean canPlace(LevelReader levelreader, BlockState blockstate, BlockPos blockpos) {
+- return blockstate.canSurvive(levelreader, blockpos);
++ protected boolean canPlace(LevelReader level, IBlockData state, BlockPos pos) {
++ return state.canSurvive(level, pos);
+ }
+
+ @Nullable
+ @Override
+- @Override
+- protected BlockState getPlacementState(BlockPlaceContext blockplacecontext) {
+- BlockState blockstate = this.wallBlock.getStateForPlacement(blockplacecontext);
+- BlockState blockstate1 = null;
+- Level level = blockplacecontext.getLevel();
+- BlockPos blockpos = blockplacecontext.getClickedPos();
+- Direction[] adirection = blockplacecontext.getNearestLookingDirections();
+- int i = adirection.length;
++ protected IBlockData getPlacementState(BlockPlaceContext context) {
++ IBlockData iblockdata = this.wallBlock.getStateForPlacement(context);
++ IBlockData iblockdata1 = null;
++ Level world = context.getLevel();
++ BlockPos blockposition = context.getClickedPos();
++ Direction[] aenumdirection = context.getNearestLookingDirections();
++ int i = aenumdirection.length;
+
+ for (int j = 0; j < i; ++j) {
+- Direction direction = adirection[j];
++ Direction enumdirection = aenumdirection[j];
+
+- if (direction != this.attachmentDirection.getOpposite()) {
+- BlockState blockstate2 = direction == this.attachmentDirection ? this.getBlock().getStateForPlacement(blockplacecontext) : blockstate;
++ if (enumdirection != this.attachmentDirection.getOpposite()) {
++ IBlockData iblockdata2 = enumdirection == this.attachmentDirection ? this.getBlock().getStateForPlacement(context) : iblockdata;
+
+- if (blockstate2 != null && this.canPlace(level, blockstate2, blockpos)) {
+- blockstate1 = blockstate2;
++ if (iblockdata2 != null && this.canPlace(world, iblockdata2, blockposition)) {
++ iblockdata1 = iblockdata2;
+ break;
+ }
+ }
+ }
+
+- return blockstate1 != null && level.isUnobstructed(blockstate1, blockpos, CollisionContext.empty()) ? blockstate1 : null;
++ // CraftBukkit start
++ if (iblockdata1 != null) {
++ boolean defaultReturn = world.isUnobstructed(iblockdata1, blockposition, CollisionContext.empty());
++ org.bukkit.entity.Player player = (context.getPlayer() instanceof ServerPlayer) ? (org.bukkit.entity.Player) context.getPlayer().getBukkitEntity() : null;
++
++ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(world, blockposition), player, CraftBlockData.fromData(iblockdata1), defaultReturn);
++ context.getLevel().getCraftServer().getPluginManager().callEvent(event);
++
++ return (event.isBuildable()) ? iblockdata1 : null;
++ } else {
++ return null;
++ }
++ // CraftBukkit end
+ }
+
+ @Override
+- @Override
+- public void registerBlocks(Map<Block, Item> map, Item item) {
+- super.registerBlocks(map, item);
+- map.put(this.wallBlock, item);
++ public void registerBlocks(Map<Block, Item> blockToItemMap, Item item) {
++ super.registerBlocks(blockToItemMap, item);
++ blockToItemMap.put(this.wallBlock, item);
+ }
+ }