|
@@ -1,161 +0,0 @@
|
|
|
-package me.km.snuviscript;
|
|
|
-
|
|
|
-import me.km.Server;
|
|
|
-import me.km.utils.ReflectionUtils;
|
|
|
-import net.minecraft.entity.player.PlayerEntity;
|
|
|
-import net.minecraft.inventory.IInventory;
|
|
|
-import net.minecraft.inventory.container.ClickType;
|
|
|
-import net.minecraft.inventory.container.Container;
|
|
|
-import net.minecraft.inventory.container.ContainerType;
|
|
|
-import net.minecraft.inventory.container.IContainerListener;
|
|
|
-import net.minecraft.inventory.container.Slot;
|
|
|
-import net.minecraft.item.ItemStack;
|
|
|
-import net.minecraft.util.IIntArray;
|
|
|
-import net.minecraft.util.IntReferenceHolder;
|
|
|
-import net.minecraft.util.NonNullList;
|
|
|
-import net.minecraft.world.World;
|
|
|
-import net.minecraft.entity.player.ServerPlayerEntity;
|
|
|
-
|
|
|
-public class ModContainer extends Container {
|
|
|
- private final Container container;
|
|
|
-
|
|
|
- private static ContainerType<?> getType(Container c) {
|
|
|
- try {
|
|
|
- return c.getType();
|
|
|
- } catch(Exception ex) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public ModContainer(Container c) {
|
|
|
- super(getType(c), c.windowId);
|
|
|
- this.container = c;
|
|
|
- }
|
|
|
-
|
|
|
- public String getName() {
|
|
|
- return container.getClass().getSimpleName();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ItemStack slotClick(int slot, int dragType, ClickType ct, PlayerEntity p) {
|
|
|
- if(Server.scriptEvents.onContainerClick(this, slot, dragType, ct, p)) {
|
|
|
- Server.scheduler.scheduleTask(() -> {
|
|
|
- ((ServerPlayerEntity) p).sendAllContents(this, getInventory());
|
|
|
- });
|
|
|
- return ItemStack.EMPTY;
|
|
|
- }
|
|
|
- return container.slotClick(slot, dragType, ct, p);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean canInteractWith(PlayerEntity p) {
|
|
|
- return container.canInteractWith(p);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ContainerType<?> getType() {
|
|
|
- return container.getType();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected Slot addSlot(Slot slotIn) {
|
|
|
- return ReflectionUtils.addSlot(container, slotIn);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected IntReferenceHolder trackInt(IntReferenceHolder intIn) {
|
|
|
- return ReflectionUtils.trackInt(container, intIn);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void trackIntArray(IIntArray arrayIn) {
|
|
|
- ReflectionUtils.trackIntArray(container, arrayIn);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void addListener(IContainerListener listener) {
|
|
|
- container.addListener(listener);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public NonNullList<ItemStack> getInventory() {
|
|
|
- return container.getInventory();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void detectAndSendChanges() {
|
|
|
- container.detectAndSendChanges();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean enchantItem(PlayerEntity playerIn, int id) {
|
|
|
- return container.enchantItem(playerIn, id);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Slot getSlot(int slotId) {
|
|
|
- return container.getSlot(slotId);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) {
|
|
|
- return container.transferStackInSlot(playerIn, index);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean canMergeSlot(ItemStack stack, Slot slotIn) {
|
|
|
- return container.canMergeSlot(stack, slotIn);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onContainerClosed(PlayerEntity playerIn) {
|
|
|
- container.onContainerClosed(playerIn);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void clearContainer(PlayerEntity playerIn, World worldIn, IInventory inventoryIn) {
|
|
|
- ReflectionUtils.clearContainer(container, playerIn, worldIn, inventoryIn);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onCraftMatrixChanged(IInventory inventoryIn) {
|
|
|
- container.onCraftMatrixChanged(inventoryIn);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void putStackInSlot(int slotID, ItemStack stack) {
|
|
|
- container.putStackInSlot(slotID, stack);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void updateProgressBar(int id, int data) {
|
|
|
- container.updateProgressBar(id, data);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean getCanCraft(PlayerEntity player) {
|
|
|
- return container.getCanCraft(player);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void setCanCraft(PlayerEntity player, boolean canCraft) {
|
|
|
- container.setCanCraft(player, canCraft);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex,
|
|
|
- boolean reverseDirection) {
|
|
|
- return ReflectionUtils.mergeItemStack(container, stack, startIndex, endIndex,
|
|
|
- reverseDirection);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void resetDrag() {
|
|
|
- ReflectionUtils.resetDrag(container);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean canDragIntoSlot(Slot slotIn) {
|
|
|
- return container.canDragIntoSlot(slotIn);
|
|
|
- }
|
|
|
-}
|