Fix aquaculture neptune bounty placement (#139 #228 #593)

This commit is contained in:
IzzelAliz 2022-06-21 20:56:21 +08:00
parent 8f1c0e4c92
commit 31bb3bbecc
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338
4 changed files with 10 additions and 3 deletions

View File

@ -54,6 +54,7 @@ import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MerchantMenu;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
@ -1591,7 +1592,7 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB
if (this.player.gameMode.isCreative()) {
final boolean flag = packetplayinsetcreativeslot.getSlotNum() < 0;
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")) {
BlockPos blockpos = BlockEntity.getPosFromTag(nbttagcompound);
BlockEntity blockentity = this.player.level.getBlockEntity(blockpos);

View File

@ -7,6 +7,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.SolidBucketItem;
import net.minecraft.world.item.WaterLilyBlockItem;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.block.Block;
@ -42,7 +43,7 @@ public abstract class BlockItemMixin {
@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;"))
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());
}
}
@ -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());
if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) {
state.update(true, false);
if ((Object) this instanceof SolidBucketItem) {
((ServerPlayerEntityBridge) context1.getPlayer()).bridge$getBukkitEntity().updateInventory();
}
cir.setReturnValue(InteractionResult.FAIL);
}
}

View File

@ -5,6 +5,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;
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 org.bukkit.craftbukkit.v.block.CraftBlock;
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 abstract boolean onlyOpCanSetNbt();
@Shadow protected static void setChanged(Level p_155233_, BlockPos p_155234_, BlockState p_155235_) { }
@Shadow public abstract BlockEntityType<?> getType();
// @formatter:on
@Inject(method = "load", at = @At("RETURN"))

View File

@ -60,6 +60,6 @@ public abstract class ChestBlockEntityMixin extends LockableBlockEntityMixin {
@Override
public boolean onlyOpCanSetNbt() {
return true;
return this.getType().getRegistryName().getNamespace().equals("minecraft");
}
}