Update anvil code

This commit is contained in:
fullwall 2024-08-04 13:23:47 +08:00
parent 103ecfd369
commit c8f6e4f4ec

View File

@ -36,7 +36,7 @@ import org.bukkit.craftbukkit.v1_21_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_21_R1.event.CraftEventFactory; import org.bukkit.craftbukkit.v1_21_R1.event.CraftEventFactory;
import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryAnvil; import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryAnvil;
import org.bukkit.craftbukkit.v1_21_R1.inventory.CraftInventoryView; import org.bukkit.craftbukkit.v1_21_R1.inventory.view.CraftAnvilView;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.FishHook; import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -1202,7 +1202,7 @@ public class NMSImpl implements NMSBridge {
ServerPlayer handle = (ServerPlayer) getHandle(player); ServerPlayer handle = (ServerPlayer) getHandle(player);
final AnvilMenu container = new AnvilMenu(handle.nextContainerCounter(), handle.getInventory(), final AnvilMenu container = new AnvilMenu(handle.nextContainerCounter(), handle.getInventory(),
ContainerLevelAccess.create(handle.level(), new BlockPos(0, 0, 0))) { ContainerLevelAccess.create(handle.level(), new BlockPos(0, 0, 0))) {
private CraftInventoryView bukkitEntity; private CraftAnvilView bukkitEntity;
@Override @Override
protected void clearContainer(net.minecraft.world.entity.player.Player entityhuman, Container iinventory) { protected void clearContainer(net.minecraft.world.entity.player.Player entityhuman, Container iinventory) {
@ -1215,12 +1215,10 @@ public class NMSImpl implements NMSBridge {
} }
@Override @Override
public CraftInventoryView getBukkitView() { public CraftAnvilView getBukkitView() {
if (this.bukkitEntity == null) { if (this.bukkitEntity == null) {
this.bukkitEntity = new CraftInventoryView(this.player.getBukkitEntity(), this.bukkitEntity = new CraftAnvilView(this.player.getBukkitEntity(), new CitizensInventoryAnvil(
new CitizensInventoryAnvil(this.access.getLocation(), this.inputSlots, this.resultSlots, this.access.getLocation(), this.inputSlots, this.resultSlots, this, anvil), this);
this, anvil),
this);
} }
return this.bukkitEntity; return this.bukkitEntity;
} }
@ -1927,7 +1925,7 @@ public class NMSImpl implements NMSBridge {
public CitizensInventoryAnvil(Location location, Container inventory, Container resultInventory, public CitizensInventoryAnvil(Location location, Container inventory, Container resultInventory,
AnvilMenu container, Inventory wrapped) { AnvilMenu container, Inventory wrapped) {
super(location, inventory, resultInventory, container); super(location, inventory, resultInventory);
this.wrapped = wrapped; this.wrapped = wrapped;
} }