Add creative mode NBT permissions

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2019-02-25 19:26:56 +11:00
parent d16d3c3548
commit 6fcc9cce6d
5 changed files with 65 additions and 20 deletions

View File

@@ -66,7 +66,7 @@
BlockState iblockdata;
if (this.hasDelayedDestroy) {
@@ -146,11 +172,33 @@
@@ -146,15 +172,45 @@
if (action == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) {
if (!this.level.mayInteract(this.player, pos)) {
@@ -99,8 +99,20 @@
+
if (this.isCreative()) {
this.destroyAndAck(pos, sequence, "creative destroy");
+ return;
+ }
+
+ // Spigot start - handle debug stick left click for non-creative
+ if (this.player.getMainHandItem().is(net.minecraft.world.item.Items.DEBUG_STICK)
+ && ((net.minecraft.world.item.DebugStickItem) net.minecraft.world.item.Items.DEBUG_STICK).handleInteraction(this.player, this.level.getBlockState(pos), this.level, pos, false, this.player.getMainHandItem())) {
+ this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
return;
@@ -166,7 +214,19 @@
}
+ // Spigot end
if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) {
this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos)));
@@ -166,7 +222,19 @@
float f = 1.0F;
iblockdata = this.level.getBlockState(pos);
@@ -121,7 +133,7 @@
EnchantmentHelper.onHitBlock(this.level, this.player.getMainHandItem(), this.player, this.player, EquipmentSlot.MAINHAND, Vec3.atCenterOf(pos), iblockdata, (item) -> {
this.player.onEquippedItemBroken(item, EquipmentSlot.MAINHAND);
});
@@ -174,6 +234,26 @@
@@ -174,6 +242,26 @@
f = iblockdata.getDestroyProgress(this.player, this.player.level(), pos);
}
@@ -148,7 +160,7 @@
if (!iblockdata.isAir() && f >= 1.0F) {
this.destroyAndAck(pos, sequence, "insta mine");
} else {
@@ -218,13 +298,15 @@
@@ -218,13 +306,15 @@
} else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) {
this.isDestroyingBlock = false;
if (!Objects.equals(this.destroyPos, pos)) {
@@ -165,7 +177,7 @@
}
}
@@ -242,10 +324,65 @@
@@ -242,10 +332,65 @@
public boolean destroyBlock(BlockPos pos) {
BlockState iblockdata = this.level.getBlockState(pos);
@@ -232,7 +244,7 @@
BlockEntity tileentity = this.level.getBlockEntity(pos);
Block block = iblockdata.getBlock();
@@ -255,6 +392,10 @@
@@ -255,6 +400,10 @@
} else if (this.player.blockActionRestricted(this.level, pos, this.gameModeForPlayer)) {
return false;
} else {
@@ -243,7 +255,7 @@
BlockState iblockdata1 = block.playerWillDestroy(this.level, pos, iblockdata, this.player);
boolean flag = this.level.removeBlock(pos, false);
@@ -263,19 +404,32 @@
@@ -263,19 +412,32 @@
}
if (this.isCreative()) {
@@ -279,7 +291,7 @@
}
}
}
@@ -321,15 +475,54 @@
@@ -321,15 +483,54 @@
}
}
@@ -334,7 +346,7 @@
if (itileinventory != null) {
player.openMenu(itileinventory);
return InteractionResult.CONSUME;
@@ -359,7 +552,7 @@
@@ -359,7 +560,7 @@
}
}