geforkt von Mirrors/Paper
SPIGOT-2770: Can Place Structure Blocks Even When Not Op
By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
Ursprung
1801a1d84a
Commit
5e5fe9d2ed
@ -224,7 +224,7 @@
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,63 +419,81 @@
|
@@ -280,63 +419,85 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,16 +238,36 @@
|
|||||||
+ EnumInteractionResult enuminteractionresult = EnumInteractionResult.FAIL;
|
+ EnumInteractionResult enuminteractionresult = EnumInteractionResult.FAIL;
|
||||||
+ if (blockdata.getBlock() != Blocks.AIR) {
|
+ if (blockdata.getBlock() != Blocks.AIR) {
|
||||||
+ boolean cancelledBlock = false;
|
+ boolean cancelledBlock = false;
|
||||||
+
|
|
||||||
|
- if (tileentity instanceof ITileInventory) {
|
||||||
|
- Block block = world.getType(blockposition).getBlock();
|
||||||
|
- ITileInventory itileinventory = (ITileInventory) tileentity;
|
||||||
+ if (this.gamemode == EnumGamemode.SPECTATOR) {
|
+ if (this.gamemode == EnumGamemode.SPECTATOR) {
|
||||||
+ TileEntity tileentity = world.getTileEntity(blockposition);
|
+ TileEntity tileentity = world.getTileEntity(blockposition);
|
||||||
+ cancelledBlock = !(tileentity instanceof ITileInventory || tileentity instanceof IInventory);
|
+ cancelledBlock = !(tileentity instanceof ITileInventory || tileentity instanceof IInventory);
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ if (!entityhuman.getBukkitEntity().isOp() && Block.asBlock(itemstack.getItem()) instanceof BlockCommand) {
|
- if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) {
|
||||||
|
- itileinventory = ((BlockChest) block).c(world, blockposition);
|
||||||
|
- }
|
||||||
|
+ if (itemstack.getItem() instanceof ItemBlock && !entityhuman.dk()) { // PAIL: creativeAndOp
|
||||||
|
+ Block block1 = ((ItemBlock) itemstack.getItem()).getBlock();
|
||||||
|
|
||||||
|
- if (itileinventory != null) {
|
||||||
|
- entityhuman.openContainer(itileinventory);
|
||||||
|
- return EnumInteractionResult.SUCCESS;
|
||||||
|
+ if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) {
|
||||||
+ cancelledBlock = true;
|
+ cancelledBlock = true;
|
||||||
+ }
|
}
|
||||||
+
|
- } else if (tileentity instanceof IInventory) {
|
||||||
|
- entityhuman.openContainer((IInventory) tileentity);
|
||||||
|
- return EnumInteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
- return EnumInteractionResult.PASS;
|
||||||
|
- } else {
|
||||||
|
- if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) {
|
||||||
|
- IBlockData iblockdata = world.getType(blockposition);
|
||||||
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock, enumhand);
|
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityhuman, Action.RIGHT_CLICK_BLOCK, blockposition, enumdirection, itemstack, cancelledBlock, enumhand);
|
||||||
+ firedInteract = true;
|
+ firedInteract = true;
|
||||||
+ interactResult = event.useItemInHand() == Event.Result.DENY;
|
+ interactResult = event.useItemInHand() == Event.Result.DENY;
|
||||||
@ -268,19 +288,11 @@
|
|||||||
+ Block block = world.getType(blockposition).getBlock();
|
+ Block block = world.getType(blockposition).getBlock();
|
||||||
+ ITileInventory itileinventory = (ITileInventory) tileentity;
|
+ ITileInventory itileinventory = (ITileInventory) tileentity;
|
||||||
|
|
||||||
- if (tileentity instanceof ITileInventory) {
|
- if (iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2)) {
|
||||||
- Block block = world.getType(blockposition).getBlock();
|
|
||||||
- ITileInventory itileinventory = (ITileInventory) tileentity;
|
|
||||||
-
|
|
||||||
- if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) {
|
|
||||||
- itileinventory = ((BlockChest) block).c(world, blockposition);
|
|
||||||
- }
|
|
||||||
+ if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) {
|
+ if (itileinventory instanceof TileEntityChest && block instanceof BlockChest) {
|
||||||
+ itileinventory = ((BlockChest) block).c(world, blockposition); // PAIL: rename
|
+ itileinventory = ((BlockChest) block).c(world, blockposition); // PAIL: rename
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
- if (itileinventory != null) {
|
|
||||||
- entityhuman.openContainer(itileinventory);
|
|
||||||
+ if (itileinventory != null) {
|
+ if (itileinventory != null) {
|
||||||
+ entityhuman.openContainer(itileinventory);
|
+ entityhuman.openContainer(itileinventory);
|
||||||
+ return EnumInteractionResult.SUCCESS;
|
+ return EnumInteractionResult.SUCCESS;
|
||||||
@ -289,49 +301,37 @@
|
|||||||
+ entityhuman.openContainer((IInventory) tileentity);
|
+ entityhuman.openContainer((IInventory) tileentity);
|
||||||
return EnumInteractionResult.SUCCESS;
|
return EnumInteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
- } else if (tileentity instanceof IInventory) {
|
|
||||||
- entityhuman.openContainer((IInventory) tileentity);
|
|
||||||
- return EnumInteractionResult.SUCCESS;
|
|
||||||
- }
|
- }
|
||||||
|
|
||||||
- return EnumInteractionResult.PASS;
|
|
||||||
- } else {
|
|
||||||
- if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) {
|
|
||||||
- IBlockData iblockdata = world.getType(blockposition);
|
|
||||||
+ return EnumInteractionResult.PASS;
|
|
||||||
+ } else {
|
|
||||||
+ if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) {
|
|
||||||
+ IBlockData iblockdata = world.getType(blockposition);
|
|
||||||
|
|
||||||
- if (iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2)) {
|
|
||||||
- return EnumInteractionResult.SUCCESS;
|
|
||||||
+ enuminteractionresult = iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (itemstack.isEmpty()) {
|
- if (itemstack.isEmpty()) {
|
||||||
- return EnumInteractionResult.PASS;
|
- return EnumInteractionResult.PASS;
|
||||||
- } else if (entityhuman.di().a(itemstack.getItem())) {
|
- } else if (entityhuman.di().a(itemstack.getItem())) {
|
||||||
- return EnumInteractionResult.PASS;
|
return EnumInteractionResult.PASS;
|
||||||
- } else {
|
} else {
|
||||||
- if (itemstack.getItem() instanceof ItemBlock && !entityhuman.dk()) {
|
- if (itemstack.getItem() instanceof ItemBlock && !entityhuman.dk()) {
|
||||||
- Block block1 = ((ItemBlock) itemstack.getItem()).getBlock();
|
- Block block1 = ((ItemBlock) itemstack.getItem()).getBlock();
|
||||||
+ if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764
|
+ if (!entityhuman.isSneaking() || entityhuman.getItemInMainHand().isEmpty() && entityhuman.getItemInOffHand().isEmpty()) {
|
||||||
+ int i = itemstack.getData();
|
+ IBlockData iblockdata = world.getType(blockposition);
|
||||||
+ int j = itemstack.getCount();
|
|
||||||
|
|
||||||
- if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) {
|
- if (block1 instanceof BlockCommand || block1 instanceof BlockStructure) {
|
||||||
- return EnumInteractionResult.FAIL;
|
- return EnumInteractionResult.FAIL;
|
||||||
- }
|
- }
|
||||||
- }
|
+ enuminteractionresult = iblockdata.getBlock().interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2) ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
||||||
+ enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
|
}
|
||||||
|
+ }
|
||||||
|
|
||||||
+ // The item count should not decrement in Creative mode.
|
- if (this.isCreative()) {
|
||||||
if (this.isCreative()) {
|
|
||||||
- int i = itemstack.getData();
|
- int i = itemstack.getData();
|
||||||
- int j = itemstack.getCount();
|
- int j = itemstack.getCount();
|
||||||
- EnumInteractionResult enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
|
- EnumInteractionResult enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
|
||||||
-
|
+ if (!itemstack.isEmpty() && enuminteractionresult != EnumInteractionResult.SUCCESS && !interactResult) { // add !interactResult SPIGOT-764
|
||||||
|
+ int i = itemstack.getData();
|
||||||
|
+ int j = itemstack.getCount();
|
||||||
|
|
||||||
|
+ enuminteractionresult = itemstack.placeItem(entityhuman, world, blockposition, enumhand, enumdirection, f, f1, f2);
|
||||||
|
+
|
||||||
|
+ // The item count should not decrement in Creative mode.
|
||||||
|
+ if (this.isCreative()) {
|
||||||
itemstack.setData(i);
|
itemstack.setData(i);
|
||||||
itemstack.setCount(j);
|
itemstack.setCount(j);
|
||||||
- return enuminteractionresult;
|
- return enuminteractionresult;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren