parent
8f1c0e4c92
commit
31bb3bbecc
|
@ -54,6 +54,7 @@ import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.MerchantMenu;
|
import net.minecraft.world.inventory.MerchantMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
|
@ -1591,7 +1592,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
|
||||||
if (this.player.gameMode.isCreative()) {
|
if (this.player.gameMode.isCreative()) {
|
||||||
final boolean flag = packetplayinsetcreativeslot.getSlotNum() < 0;
|
final boolean flag = packetplayinsetcreativeslot.getSlotNum() < 0;
|
||||||
ItemStack itemstack = packetplayinsetcreativeslot.getItem();
|
ItemStack itemstack = packetplayinsetcreativeslot.getItem();
|
||||||
final CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag");
|
final CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack);
|
||||||
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z")) {
|
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z")) {
|
||||||
BlockPos blockpos = BlockEntity.getPosFromTag(nbttagcompound);
|
BlockPos blockpos = BlockEntity.getPosFromTag(nbttagcompound);
|
||||||
BlockEntity blockentity = this.player.level.getBlockEntity(blockpos);
|
BlockEntity blockentity = this.player.level.getBlockEntity(blockpos);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
|
import net.minecraft.world.item.SolidBucketItem;
|
||||||
import net.minecraft.world.item.WaterLilyBlockItem;
|
import net.minecraft.world.item.WaterLilyBlockItem;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
@ -42,7 +43,7 @@ public abstract class BlockItemMixin {
|
||||||
@Inject(method = "place", locals = LocalCapture.CAPTURE_FAILHARD,
|
@Inject(method = "place", locals = LocalCapture.CAPTURE_FAILHARD,
|
||||||
at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/item/BlockItem;getPlacementState(Lnet/minecraft/world/item/context/BlockPlaceContext;)Lnet/minecraft/world/level/block/state/BlockState;"))
|
at = @At(value = "INVOKE", shift = At.Shift.AFTER, target = "Lnet/minecraft/world/item/BlockItem;getPlacementState(Lnet/minecraft/world/item/context/BlockPlaceContext;)Lnet/minecraft/world/level/block/state/BlockState;"))
|
||||||
private void arclight$prePlaceLilypad(BlockPlaceContext context, CallbackInfoReturnable<InteractionResult> cir, BlockPlaceContext context1) {
|
private void arclight$prePlaceLilypad(BlockPlaceContext context, CallbackInfoReturnable<InteractionResult> cir, BlockPlaceContext context1) {
|
||||||
if ((Object) this instanceof WaterLilyBlockItem) {
|
if ((Object) this instanceof WaterLilyBlockItem || (Object) this instanceof SolidBucketItem) {
|
||||||
this.arclight$state = CraftBlockStates.getBlockState(context1.getLevel(), context1.getClickedPos());
|
this.arclight$state = CraftBlockStates.getBlockState(context1.getLevel(), context1.getClickedPos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +58,9 @@ public abstract class BlockItemMixin {
|
||||||
org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent((ServerLevel) context1.getLevel(), context1.getPlayer(), context1.getHand(), state, pos.getX(), pos.getY(), pos.getZ());
|
org.bukkit.event.block.BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent((ServerLevel) context1.getLevel(), context1.getPlayer(), context1.getHand(), state, pos.getX(), pos.getY(), pos.getZ());
|
||||||
if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
|
if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
|
||||||
state.update(true, false);
|
state.update(true, false);
|
||||||
|
if ((Object) this instanceof SolidBucketItem) {
|
||||||
|
((ServerPlayerEntityBridge) context1.getPlayer()).bridge$getBukkitEntity().updateInventory();
|
||||||
|
}
|
||||||
cir.setReturnValue(InteractionResult.FAIL);
|
cir.setReturnValue(InteractionResult.FAIL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
import org.bukkit.craftbukkit.v.block.CraftBlock;
|
import org.bukkit.craftbukkit.v.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataContainer;
|
import org.bukkit.craftbukkit.v.persistence.CraftPersistentDataContainer;
|
||||||
|
@ -34,6 +35,7 @@ public abstract class BlockEntityMixin implements TileEntityBridge {
|
||||||
@Shadow public BlockPos getBlockPos() { return null; }
|
@Shadow public BlockPos getBlockPos() { return null; }
|
||||||
@Shadow public abstract boolean onlyOpCanSetNbt();
|
@Shadow public abstract boolean onlyOpCanSetNbt();
|
||||||
@Shadow protected static void setChanged(Level p_155233_, BlockPos p_155234_, BlockState p_155235_) { }
|
@Shadow protected static void setChanged(Level p_155233_, BlockPos p_155234_, BlockState p_155235_) { }
|
||||||
|
@Shadow public abstract BlockEntityType<?> getType();
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
@Inject(method = "load", at = @At("RETURN"))
|
@Inject(method = "load", at = @At("RETURN"))
|
||||||
|
|
|
@ -60,6 +60,6 @@ public abstract class ChestBlockEntityMixin extends LockableBlockEntityMixin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onlyOpCanSetNbt() {
|
public boolean onlyOpCanSetNbt() {
|
||||||
return true;
|
return this.getType().getRegistryName().getNamespace().equals("minecraft");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user