Browse Source

fixed dynamic inventories, new use of slot id 3, bugfixes

Kajetan Johannes Hammerle 5 years ago
parent
commit
ee3a3c9974

+ 153 - 0
src/main/java/me/km/Client.java

@@ -168,4 +168,157 @@ public class Client
             }
         }
     }
+    
+    /*private static int[] counter = new int[5];
+    private static final double BASE_ARRAY_SIZE = 16 * 256 * 16 * 16 + 32;
+    
+    @SubscribeEvent
+    public void test(net.minecraftforge.client.event.ClientChatEvent e)
+    {
+        net.minecraft.world.chunk.Chunk c = Minecraft.getInstance().player.world.getChunkAt(Minecraft.getInstance().player.getPosition());
+        
+        if(e.getMessage().equals("run"))
+        {
+            countRun(Minecraft.getInstance().player.world, 
+                    c.getPos().getXStart(), c.getPos().getZStart(), 
+                    c.getPos().getXStart() + 16, c.getPos().getZStart() + 16);
+            return;
+        }
+        if(!e.getMessage().equals("octree"))
+        {
+            return;
+        }
+        
+        counter[0] = 0; // 16
+        counter[1] = 0; // 8
+        counter[2] = 0; // 4
+        counter[3] = 0; // 2
+        counter[4] = 0; // 1
+        
+        for(int i = 0; i < 256; i += 16)
+        {
+            count(Minecraft.getInstance().player.world, 
+                    c.getPos().getXStart(), i, c.getPos().getZStart(), 
+                    c.getPos().getXStart() + 16, i + 16, c.getPos().getZStart() + 16, 
+                    0);
+        }
+        
+        System.out.println("16: " + counter[0]);
+        System.out.println("8: " + counter[1]);
+        System.out.println("4: " + counter[2]);
+        System.out.println("2: " + counter[3]);
+        System.out.println("1: " + counter[4]);
+        
+        int size = 16 + 32 * 16;
+        int a = 16 - counter[0];
+        size += a * 264;
+        
+        a *= 8;
+        a -= counter[1];
+        size += a * 264;
+        
+        a *= 8;
+        a -= counter[2];
+        size += a * 264;
+        
+        a *= 8;
+        a -= counter[3];
+        size += a * 128;
+        
+        a *= 8;
+        a -= counter[4];
+        
+        System.out.println("Size: " + size + " Bit check " + a);
+        System.out.println("Compression: " + (BASE_ARRAY_SIZE / size));
+    }
+    
+    private static void countRun(net.minecraft.world.World w, int minX, int minZ, int maxX, int maxZ)
+    {
+        int groups = 0;
+        for(int x = minX; x < maxX; x++)
+        {
+            for(int z = minZ; z < maxZ; z++)
+            {
+                groups += countTower(w, x, z);
+            }
+        }
+        
+        int size = groups * (16 + 8 + 32);
+        int doubleSize = groups * (16 + 8 + 32 * 2);
+        
+        System.out.println("Size 1: " + size);
+        System.out.println("Size 2: " + doubleSize);
+        System.out.println("Compression 1: " + (BASE_ARRAY_SIZE / size));
+        System.out.println("Compression 2: " + (BASE_ARRAY_SIZE / doubleSize));
+    }
+    
+    private static int countTower(net.minecraft.world.World w, int x, int z)
+    {
+        net.minecraft.util.math.BlockPos.MutableBlockPos pos = new net.minecraft.util.math.BlockPos.MutableBlockPos();
+        pos.setPos(x, 255, z);
+        net.minecraft.block.Block b = w.getBlockState(pos).getBlock();
+        int groups = 1;
+        for(int y = 255; y >= 0; y--)
+        {
+            pos.setPos(x, y, z);
+            net.minecraft.block.Block ob = w.getBlockState(pos).getBlock();
+            if(b != ob)
+            {
+                groups++;
+                b = ob;
+            }
+        }
+        return groups;
+    }
+    
+    private static void count(net.minecraft.world.World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int depth)
+    {
+        if(isSameBlock(w, minX, minY, minZ, maxX, maxY, maxZ))
+        {
+            counter[depth]++;
+            return;
+        }
+        if(depth == 4)
+        {
+            counter[4]++;
+            return;
+        }
+        
+        int midX = (minX + maxX) >> 1;
+        int midY = (minY + maxY) >> 1;
+        int midZ = (minZ + maxZ) >> 1;
+        
+        depth++;
+        count(w, minX, minY, minZ, midX, midY, midZ, depth);
+        count(w, midX, minY, minZ, maxX, midY, midZ, depth);
+        count(w, minX, minY, midZ, midX, midY, maxZ, depth);
+        count(w, midX, minY, midZ, maxX, midY, maxZ, depth);
+        
+        count(w, minX, midY, minZ, midX, maxY, midZ, depth);
+        count(w, midX, midY, minZ, maxX, maxY, midZ, depth);
+        count(w, minX, midY, midZ, midX, maxY, maxZ, depth);
+        count(w, midX, midY, midZ, maxX, maxY, maxZ, depth);
+    }
+    
+    private static boolean isSameBlock(net.minecraft.world.World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
+    {
+        net.minecraft.util.math.BlockPos.MutableBlockPos pos = new net.minecraft.util.math.BlockPos.MutableBlockPos();
+        pos.setPos(minX, minY, minZ);
+        net.minecraft.block.Block b = w.getBlockState(pos).getBlock();
+        for(int x = minX; x < maxX; x++)
+        {
+            for(int y = minY; y < maxY; y++)
+            {
+                for(int z = minZ; z < maxZ; z++)
+                {
+                    pos.setPos(x, y, z);
+                    if(b != w.getBlockState(pos).getBlock())
+                    {
+                        return false;
+                    }
+                }
+            }
+        }
+        return true;
+    }*/
 }

+ 231 - 61
src/main/java/me/km/inventory/CustomContainer.java

@@ -1,68 +1,263 @@
 package me.km.inventory;
 
-import me.hammerle.snuviscript.code.ISnuviScheduler;
+import me.hammerle.snuviscript.code.Script;
+import me.km.networking.ModPacketHandler;
 import net.minecraft.entity.player.PlayerEntity;
 import net.minecraft.entity.player.ServerPlayerEntity;
+import net.minecraft.entity.player.PlayerInventory;
 import net.minecraft.inventory.container.ClickType;
+import net.minecraft.inventory.container.Container;
+import net.minecraft.inventory.container.Slot;
 import net.minecraft.item.ItemStack;
-import net.minecraft.util.text.ITextComponent;
+import net.minecraft.util.text.TextFormatting;
+import net.minecraft.util.text.TranslationTextComponent;
 
-public class CustomContainer extends CustomContainerBase
+public class CustomContainer extends Container
 {
-    private boolean canBeClosed;
-    
-    private final ISnuviScheduler scheduler;
-    
-    public CustomContainer(ISnuviScheduler scheduler, InventoryBase inv, ServerPlayerEntity p, ITextComponent title) 
+    private final ModInventory inv;
+    private final int numRows;
+
+    public CustomContainer(int id, PlayerInventory pInv, ModInventory inv)
     {
-        super(inv, p, title);
-        canBeClosed = true;
-        this.scheduler = scheduler;
+        super(null, id);
+        // basic stuff
+        this.inv = inv;
+        this.numRows = inv.getRows();
+        inv.openInventory(pInv.player);
+        int i = (this.numRows - 4) * 18;
+        
+        // inventory slots
+        int counter = 0;
+        for(int y = 0; y < this.numRows; y++)
+        {
+            for(int x = 0; x < 9; x++)
+            {
+                if(inv.isSlotValid(x, y))
+                {
+                    addSlot(new Slot(inv, counter, 8 + x * 18, 18 + y * 18));
+                    counter++;
+                }
+            }
+        }
+
+        // plaver inventory slots
+        for(int y = 0; y < 3; y++)
+        {
+            for(int x = 0; x < 9; x++)
+            {
+                addSlot(new Slot(pInv, x + y * 9 + 9, 8 + x * 18, 103 + y * 18 + i));
+            }
+        }
+
+        for(int x = 0; x < 9; x++)
+        {
+            addSlot(new Slot(pInv, x, 8 + x * 18, 161 + i));
+        }
+    }
+
+    public ModInventory getInventoryBase() 
+    {
+        return inv;
     }
     
-    public CustomContainer(InventoryBase inv, PlayerEntity p, ITextComponent title, int id) 
+    public boolean onButtonClick(int slot, int dragType, ClickType click, PlayerEntity p)
     {
-        super(inv, p, title, id);
-        canBeClosed = true;
-        this.scheduler = null;
+        return false;
     }
     
-    @Override
-    public void closeSafe()
+    public static void openForPlayer(ServerPlayerEntity p, ModInventory inv, String title, Script sc)
     {
-        if(canBeClosed)
+        // taken from ServerPlayerEntity.openContainer
+        if(p.isSpectator())
         {
-            super.closeSafe();
+            p.sendStatusMessage((new TranslationTextComponent("container.spectatorCantOpen")).applyTextStyle(TextFormatting.RED), true);
+            return;
         }
-        else if(isServerSide && scheduler != null)
+        if(p.openContainer != p.container)
         {
-            scheduler.scheduleTask(() -> 
+            p.closeScreen();
+        }
+
+        p.getNextWindowId();
+        Container container = new ServerCustomContainer(p.currentWindowId, p.inventory, inv, title, sc);
+        ModPacketHandler.sendCustomInventory(p, p.currentWindowId, title, inv);
+        container.addListener(p);
+        p.openContainer = container;
+    }
+
+    @Override
+    public boolean canInteractWith(PlayerEntity p)
+    {
+        return this.inv.isUsableByPlayer(p);
+    }
+
+    @Override
+    public ItemStack transferStackInSlot(PlayerEntity p, int index)
+    {
+        // taken from ChestContainer, changed size
+        ItemStack stack = ItemStack.EMPTY;
+        Slot slot = this.inventorySlots.get(index);
+        int size = inv.getSizeInventory();
+        if(slot != null && slot.getHasStack())
+        {
+            ItemStack slotStack = slot.getStack();
+            stack = slotStack.copy();
+            if(index < size)
             {
-                if(viewer.openContainer.windowId == this.windowId)
+                if(!this.mergeItemStack(slotStack, size, this.inventorySlots.size(), true))
                 {
-                    super.closeSafe();
+                    return ItemStack.EMPTY;
                 }
-            });
+            }
+            else if(!this.mergeItemStack(slotStack, 0, size, false))
+            {
+                return ItemStack.EMPTY;
+            }
+
+            if(slotStack.isEmpty())
+            {
+                slot.putStack(ItemStack.EMPTY);
+            }
+            else
+            {
+                slot.onSlotChanged();
+            }
         }
+        return stack;
     }
     
     @Override
-    public void openForPlayer()
+    public boolean canMergeSlot(ItemStack stack, Slot slot)
     {
-        // opening container on next tick to prevent closing during noClicking or onCanceledClick
-        if(isServerSide && scheduler != null)
+        return inv.getSlotStatus(slot.slotNumber) == 1;
+    }
+    
+    @Override
+    public boolean canDragIntoSlot(Slot slot)
+    {
+        return inv.getSlotStatus(slot.slotNumber) == 1;
+    }
+    
+    @Override
+    protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection)
+    {
+        boolean flag = false;
+        int i = startIndex;
+        if(reverseDirection)
+        {
+            i = endIndex - 1;
+        }
+
+        if(stack.isStackable())
         {
-            if(viewer.openContainer instanceof CustomContainer)
+            while(!stack.isEmpty())
             {
-                CustomContainer cc = (CustomContainer) viewer.openContainer;
-                if(!cc.canBeClosed)
+                if(reverseDirection)
                 {
-                    scheduler.scheduleTask(() -> openForPlayer());
-                    return;
+                    if(i < startIndex)
+                    {
+                        break;
+                    }
+                }
+                else if(i >= endIndex)
+                {
+                    break;
+                }
+
+                if(inv.getSlotStatus(i) == 1)
+                {
+                    Slot slot = this.inventorySlots.get(i);
+                    ItemStack itemstack = slot.getStack();
+                    if(!itemstack.isEmpty() && areItemsAndTagsEqual(stack, itemstack))
+                    {
+                        int j = itemstack.getCount() + stack.getCount();
+                        int maxSize = Math.min(slot.getSlotStackLimit(), stack.getMaxStackSize());
+                        if(j <= maxSize)
+                        {
+                            stack.setCount(0);
+                            itemstack.setCount(j);
+                            slot.onSlotChanged();
+                            flag = true;
+                        }
+                        else if(itemstack.getCount() < maxSize)
+                        {
+                            stack.shrink(maxSize - itemstack.getCount());
+                            itemstack.setCount(maxSize);
+                            slot.onSlotChanged();
+                            flag = true;
+                        }
+                    }
+                }
+
+                if(reverseDirection)
+                {
+                    --i;
+                }
+                else
+                {
+                    ++i;
                 }
             }
-            super.openForPlayer();
         }
+
+        if(!stack.isEmpty())
+        {
+            if(reverseDirection)
+            {
+                i = endIndex - 1;
+            }
+            else
+            {
+                i = startIndex;
+            }
+
+            while(true)
+            {
+                if(reverseDirection)
+                {
+                    if(i < startIndex)
+                    {
+                        break;
+                    }
+                }
+                else if(i >= endIndex)
+                {
+                    break;
+                }
+
+                if(inv.getSlotStatus(i) == 1)
+                {
+                    Slot slot1 = this.inventorySlots.get(i);
+                    ItemStack itemstack1 = slot1.getStack();
+                    if(itemstack1.isEmpty() && slot1.isItemValid(stack))
+                    {
+                        if(stack.getCount() > slot1.getSlotStackLimit())
+                        {
+                            slot1.putStack(stack.split(slot1.getSlotStackLimit()));
+                        }
+                        else
+                        {
+                            slot1.putStack(stack.split(stack.getCount()));
+                        }
+
+                        slot1.onSlotChanged();
+                        flag = true;
+                        break;
+                    }
+                }
+
+                if(reverseDirection)
+                {
+                    --i;
+                }
+                else
+                {
+                    ++i;
+                }
+            }
+        }
+
+        return flag;
     }
     
     @Override
@@ -77,35 +272,10 @@ public class CustomContainer extends CustomContainerBase
             case 0: return ItemStack.EMPTY;
             case 1: return super.slotClick(slotId, dragType, clickTypeIn, p);
             case 2: 
-                if(isServerSide)
-                {
-                    //System.out.println("Button was pressed");
-                    ServerPlayerEntity player = (ServerPlayerEntity) p;
-                    canBeClosed = false;
-                    onButtonClick(slotId, dragType, clickTypeIn, player);
-                    canBeClosed = true;
-                }
-                return ItemStack.EMPTY;
             case 3:
-                if(isServerSide)
-                {
-                    //System.out.println("Button was pressed, serverside cancel possible");
-                    ServerPlayerEntity player = (ServerPlayerEntity) p;
-                    canBeClosed = false;
-                    if(onButtonClick(slotId, dragType, clickTypeIn, player))
-                    {
-                        canBeClosed = true;
-                        return ItemStack.EMPTY;
-                    }
-                    canBeClosed = true;
-                }
-                return super.slotClick(slotId, dragType, clickTypeIn, p);
+                onButtonClick(slotId, dragType, clickTypeIn, p);
+                return ItemStack.EMPTY;
         }
         return ItemStack.EMPTY;
-    }  
-    
-    public boolean onButtonClick(int slotId, int dragType, ClickType clickTypeIn, ServerPlayerEntity player)
-    {
-        return false;
     }
-}
+}

+ 0 - 314
src/main/java/me/km/inventory/CustomContainerBase.java

@@ -1,314 +0,0 @@
-package me.km.inventory;
-
-import me.km.networking.ModPacketHandler;
-import net.minecraft.advancements.CriteriaTriggers;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.ServerPlayerEntity;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.inventory.container.Container;
-import net.minecraft.inventory.container.IContainerListener;
-import net.minecraft.inventory.container.Slot;
-import net.minecraft.inventory.container.CraftingResultSlot;
-import net.minecraft.item.ItemStack;
-import net.minecraft.network.play.server.SSetSlotPacket;
-import net.minecraft.network.play.server.SWindowItemsPacket;
-import net.minecraft.util.NonNullList;
-import net.minecraft.util.text.ITextComponent;
-
-public abstract class CustomContainerBase extends Container
-{
-    protected final PlayerEntity viewer;
-    protected final boolean isServerSide;
-    protected final InventoryBase inv;
-    private final int numRows;
-    private final ITextComponent title;
-
-    private static int getId(ServerPlayerEntity p)
-    {
-        p.getNextWindowId();
-        return p.currentWindowId;
-    }
-    
-    protected CustomContainerBase(InventoryBase inv, PlayerEntity viewer, ITextComponent title, int id)
-    {
-        super(null, id);
-        // basic stuff
-        this.title = title;
-        this.viewer = viewer;
-        this.isServerSide = viewer instanceof ServerPlayerEntity;
-        this.inv = inv;
-        this.numRows = inv.getRows();
-        int i = (this.numRows - 4) * 18;
-        
-        // inventory slots
-        int counter = 0;
-        for(int y = 0; y < this.numRows; y++)
-        {
-            for(int x = 0; x < 9; x++)
-            {
-                if(inv.isSlotValid(x, y))
-                {
-                    super.addSlot(new Slot(inv, counter, 8 + x * 18, 18 + y * 18));
-                    counter++;
-                }
-            }
-        }
-
-        PlayerInventory pInv = this.viewer.inventory;
-        // plaver inventory slots
-        for(int y = 0; y < 3; y++)
-        {
-            for(int x = 0; x < 9; x++)
-            {
-                super.addSlot(new Slot(pInv, x + y * 9 + 9, 8 + x * 18, 103 + y * 18 + i));
-            }
-        }
-        for(int x = 0; x < 9; x++)
-        {
-            super.addSlot(new Slot(pInv, x, 8 + x * 18, 161 + i));
-        }
-    }
-    
-    protected CustomContainerBase(InventoryBase inv, ServerPlayerEntity viewer, ITextComponent title)
-    {
-        this(inv, viewer, title, getId(viewer));
-    }
-
-    public ITextComponent getTitle()
-    {
-        return title;
-    }
-
-    public InventoryBase getInventoryBase() 
-    {
-        return inv;
-    }
-    
-    public void closeSafe()
-    {
-        viewer.closeScreen();
-    }
-    
-    public void openForPlayer()
-    {
-        if(isServerSide)
-        {
-            ServerPlayerEntity p = (ServerPlayerEntity) viewer;
-            if(p.openContainer != p.container)
-            {
-                p.closeScreen();
-            }
-            p.openContainer = this;
-            ModPacketHandler.sendCustomInventory(p, windowId, title, inv);
-            p.openContainer.addListener(new IContainerListener() 
-            {
-                @Override
-                public void sendAllContents(Container containerToSend, NonNullList<ItemStack> itemsList) 
-                {
-                    p.connection.sendPacket(new SWindowItemsPacket(containerToSend.windowId, itemsList));
-                    p.connection.sendPacket(new SSetSlotPacket(-1, -1, p.inventory.getItemStack()));
-                }
-
-                @Override
-                public void sendSlotContents(Container containerToSend, int slotInd, ItemStack stack) 
-                {
-                    if(!(containerToSend.getSlot(slotInd) instanceof CraftingResultSlot))
-                    {
-                        if(containerToSend == p.container)
-                        {
-                            CriteriaTriggers.INVENTORY_CHANGED.trigger(p, p.inventory);
-                        }
-                        if(!p.isChangingQuantityOnly)
-                        {
-                            p.connection.sendPacket(new SSetSlotPacket(containerToSend.windowId, slotInd, stack));
-                        }
-                    }
-                }
-
-                @Override
-                public void sendWindowProperty(Container containerIn, int varToUpdate, int newValue) 
-                {
-                }
-            });
-        }
-    }
-
-    @Override
-    public boolean canInteractWith(PlayerEntity p)
-    {
-        return this.inv.isUsableByPlayer(p);
-    }
-
-    // ignore special slots stuff
-    @Override
-    public ItemStack transferStackInSlot(PlayerEntity p, int index)
-    {
-        ItemStack stack = ItemStack.EMPTY;
-        Slot slot = this.inventorySlots.get(index);
-        int size = inv.getSizeInventory();
-        
-        if(slot != null && slot.getHasStack())
-        {
-            ItemStack slotStack = slot.getStack();
-            stack = slotStack.copy();
-            if(index < size)
-            {
-                if(!this.mergeItemStack(slotStack, size, this.inventorySlots.size(), true))
-                {
-                    return ItemStack.EMPTY;
-                }
-            }
-            else if(!this.mergeItemStack(slotStack, 0, size, false))
-            {
-                return ItemStack.EMPTY;
-            }
-            if(slotStack.isEmpty())
-            {
-                slot.putStack(ItemStack.EMPTY);
-            }
-            else
-            {
-                slot.onSlotChanged();
-            }
-        }
-        return stack;
-    }
-    
-    @Override
-    public boolean canMergeSlot(ItemStack stack, Slot slot)
-    {
-        return inv.getSlotStatus(slot.slotNumber) == 1;
-    }
-    
-    @Override
-    public boolean canDragIntoSlot(Slot slot)
-    {
-        return inv.getSlotStatus(slot.slotNumber) == 1;
-    }
-    
-    @Override
-    protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection)
-    {
-        boolean flag = false;
-        int i = startIndex;
-
-        if (reverseDirection)
-        {
-            i = endIndex - 1;
-        }
-
-        if (stack.isStackable())
-        {
-            while (!stack.isEmpty())
-            {
-                if (reverseDirection)
-                {
-                    if (i < startIndex)
-                    {
-                        break;
-                    }
-                }
-                else if (i >= endIndex)
-                {
-                    break;
-                }
-                
-                if(inv.getSlotStatus(i) == 1)
-                {
-                    Slot slot = this.inventorySlots.get(i);
-                    ItemStack itemstack = slot.getStack();
-
-                    if (!itemstack.isEmpty() && ItemStack.areItemStackTagsEqual(stack, itemstack))
-                    {
-                        int j = itemstack.getCount() + stack.getCount();
-                        int maxSize = Math.min(slot.getSlotStackLimit(), stack.getMaxStackSize());
-
-                        if (j <= maxSize)
-                        {
-                            stack.setCount(0);
-                            itemstack.setCount(j);
-                            slot.onSlotChanged();
-                            flag = true;
-                        }
-                        else if (itemstack.getCount() < maxSize)
-                        {
-                            stack.shrink(maxSize - itemstack.getCount());
-                            itemstack.setCount(maxSize);
-                            slot.onSlotChanged();
-                            flag = true;
-                        }
-                    }
-                }
-
-                if (reverseDirection)
-                {
-                    --i;
-                }
-                else
-                {
-                    ++i;
-                }
-            }
-        }
-
-        if (!stack.isEmpty())
-        {
-            if (reverseDirection)
-            {
-                i = endIndex - 1;
-            }
-            else
-            {
-                i = startIndex;
-            }
-
-            while (true)
-            {
-                if (reverseDirection)
-                {
-                    if (i < startIndex)
-                    {
-                        break;
-                    }
-                }
-                else if (i >= endIndex)
-                {
-                    break;
-                }
-
-                if(inv.getSlotStatus(i) == 1)
-                {
-                    Slot slot1 = this.inventorySlots.get(i);
-                    ItemStack itemstack1 = slot1.getStack();
-
-                    if (itemstack1.isEmpty() && slot1.isItemValid(stack))
-                    {
-                        if (stack.getCount() > slot1.getSlotStackLimit())
-                        {
-                            slot1.putStack(stack.split(slot1.getSlotStackLimit()));
-                        }
-                        else
-                        {
-                            slot1.putStack(stack.split(stack.getCount()));
-                        }
-
-                        slot1.onSlotChanged();
-                        flag = true;
-                        break;
-                    }
-                }
-
-                if (reverseDirection)
-                {
-                    --i;
-                }
-                else
-                {
-                    ++i;
-                }
-            }
-        }
-
-        return flag;
-    }
-}

+ 69 - 62
src/main/java/me/km/inventory/InventoryBase.java → src/main/java/me/km/inventory/ModInventory.java

@@ -1,22 +1,22 @@
 package me.km.inventory;
 
 import java.util.Arrays;
-import net.minecraft.entity.Entity;
 import net.minecraft.inventory.Inventory;
 import net.minecraft.item.ItemStack;
 
-public class InventoryBase extends Inventory
+public class ModInventory extends Inventory
 {
-    private final Entity owner;
+    private static int modIds = 0;
+    private final int modId;
     private final int allSlots;
     private final int rows;
     private final byte[] data;
     private final byte[] smallData;
     
-    public InventoryBase(byte[] data, int slots, int allSlots, Entity owner) 
+    public ModInventory(byte[] data, int slots, int allSlots) 
     {
         super(slots);
-        this.owner = owner;
+        this.modId = modIds++;
         this.allSlots = allSlots;
         this.rows = allSlots / 9 + (allSlots % 9 == 0 ? 0 : 1);
         this.data = data;
@@ -72,11 +72,11 @@ public class InventoryBase extends Inventory
         return b;
     }
     
-    public InventoryBase(String slots, Entity owner) 
+    public ModInventory(String slots) 
     {
         super(Math.min(54, slots.length() - countZeros(slots)));
-        this.owner = owner;
         
+        this.modId = modIds++;
         allSlots = Math.min(54, slots.length());
         this.rows = allSlots / 9 + (allSlots % 9 == 0 ? 0 : 1);
 
@@ -110,10 +110,10 @@ public class InventoryBase extends Inventory
         this.smallData = deleteZeros(data);
     }
     
-    public InventoryBase(int slots, Entity owner) 
+    public ModInventory(int slots) 
     {
         super(Math.max(9, Math.min(54, ((slots / 9) + ((slots % 9) == 0 ? 0 : 1)) * 9)));
-        this.owner = owner;
+        this.modId = modIds++;
         this.allSlots = super.getSizeInventory();
         this.rows = allSlots / 9;
         this.data = new byte[14];
@@ -126,26 +126,6 @@ public class InventoryBase extends Inventory
     {
         return data;
     }
-
-    public Entity getOwner() 
-    {
-        return owner;
-    }
-    
-    public void setContents(Iterable<? extends ItemStack> stacks)
-    {
-        int counter = 0;
-        int size = super.getSizeInventory();
-        for(ItemStack stack : stacks)
-        {
-            this.setInventorySlotContents(counter, stack);
-            counter++;
-            if(counter >= size)
-            {
-                return;
-            }
-        }
-    }
     
     public int getRows()
     {
@@ -183,11 +163,6 @@ public class InventoryBase extends Inventory
         return 0;
     }
     
-    public boolean isSlotValid(int slot)
-    {
-        return getSlotStatus(slot) != 0;
-    }
-    
     public boolean isSlotValid(int x, int y)
     {
         return getSlotStatus(x, y) != 0;
@@ -199,51 +174,83 @@ public class InventoryBase extends Inventory
         return  status == 0 || status == 2; 
     }
     
+    public boolean shouldRenderDarker(int x, int y)
+    {
+        return  getSlotStatus(x, y) == 3; 
+    }
+
+    public int getModId()
+    {
+        return modId;
+    }
+    
     @Override
-    public ItemStack addItem(ItemStack itemstack)
+    public ItemStack addItem(ItemStack stack)
+    {
+        stack = stack.copy();
+        this.moveToEqualItemStack(stack);
+        if(stack.isEmpty())
+        {
+            return ItemStack.EMPTY;
+        }
+        else
+        {
+            this.moveToEmptySlot(stack);
+            return stack.isEmpty() ? ItemStack.EMPTY : stack;
+        }
+    }
+    
+    private void moveToEqualItemStack(ItemStack stack)
     {
-        ItemStack stack = itemstack.copy();
-        for(int i = 0; i < this.getSizeInventory(); i++)
+        for(int i = 0; i < getSizeInventory(); i++)
         {
             // ignore special fields
             if(getSlotStatus(i) != 1)
             {
                 continue;
             }
-            ItemStack slotStack = this.getStackInSlot(i);
-            
-            if(slotStack.isEmpty())
-            {
-                this.setInventorySlotContents(i, stack);
-                this.markDirty();
-                return ItemStack.EMPTY;
-            }
-
+            ItemStack slotStack = getStackInSlot(i);
             if(ItemStack.areItemsEqual(slotStack, stack))
             {
-                int j = Math.min(this.getInventoryStackLimit(), slotStack.getMaxStackSize());
-                int k = Math.min(stack.getCount(), j - slotStack.getCount());
-
-                if (k > 0)
+                this.mergeItemStacks(stack, slotStack);
+                if(stack.isEmpty())
                 {
-                    slotStack.grow(k);
-                    stack.shrink(k);
-
-                    if (stack.isEmpty())
-                    {
-                        this.markDirty();
-                        return ItemStack.EMPTY;
-                    }
+                    return;
                 }
             }
         }
 
-        if (stack.getCount() != stack.getCount())
+    }
+    
+    private void mergeItemStacks(ItemStack stack, ItemStack slotStack)
+    {
+        int maxSize = Math.min(getInventoryStackLimit(), slotStack.getMaxStackSize());
+        int maxMoveable = Math.min(stack.getCount(), maxSize - slotStack.getCount());
+        if(maxMoveable > 0)
         {
-            this.markDirty();
+            slotStack.grow(maxMoveable);
+            stack.shrink(maxMoveable);
+            markDirty();
+        }
+    }
+    
+    private void moveToEmptySlot(ItemStack stack)
+    {
+        for(int i = 0; i < getSizeInventory(); i++)
+        {
+            // ignore special fields
+            if(getSlotStatus(i) != 1)
+            {
+                continue;
+            }
+            ItemStack slotStack = getStackInSlot(i);
+            if(slotStack.isEmpty())
+            {
+                setInventorySlotContents(i, stack.copy());
+                stack.setCount(0);
+                return;
+            }
         }
-
-        return stack;
     }
     
     public int getAllSlots()

+ 40 - 0
src/main/java/me/km/inventory/ServerCustomContainer.java

@@ -0,0 +1,40 @@
+package me.km.inventory;
+
+import me.hammerle.snuviscript.code.Script;
+import me.km.Server;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.entity.player.PlayerInventory;
+import net.minecraft.inventory.container.ClickType;
+import net.minecraft.util.text.ITextComponent;
+import net.minecraft.util.text.StringTextComponent;
+
+public class ServerCustomContainer extends CustomContainer
+{
+    private final Script script;
+    private final ITextComponent name;
+    
+    public ServerCustomContainer(int id, PlayerInventory pInv, ModInventory inv, String name, Script sc)
+    {
+        super(id, pInv, inv);
+        this.script = sc;
+        this.name = new StringTextComponent(name);
+    }
+    
+    @Override
+    public void onContainerClosed(PlayerEntity p) 
+    {
+        Server.scriptEvents.onInventoryClose(script, name, getInventoryBase(), p);
+        super.onContainerClosed(p);
+    }
+    
+    @Override
+    public boolean onButtonClick(int slot, int dragType, ClickType click, PlayerEntity p)
+    {
+        return Server.scriptEvents.onInventoryClick(script, name, getInventoryBase(), slot, click, p);
+    }
+    
+    public ITextComponent getName()
+    {
+        return name;
+    }
+}

+ 7 - 10
src/main/java/me/km/networking/CustomInventory.java

@@ -2,11 +2,10 @@ package me.km.networking;
 
 import java.nio.charset.StandardCharsets;
 import java.util.function.Supplier;
-import me.km.inventory.InventoryBase;
+import me.km.inventory.CustomContainer;
+import me.km.inventory.ModInventory;
 import net.minecraft.client.Minecraft;
-import net.minecraft.client.entity.player.ClientPlayerEntity;
 import net.minecraft.network.PacketBuffer;
-import net.minecraft.util.text.ITextComponent;
 import net.minecraft.util.text.StringTextComponent;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
@@ -29,10 +28,10 @@ public class CustomInventory
         data = new byte[14];
     }
     
-    public CustomInventory(int id, ITextComponent title, InventoryBase inv) 
+    public CustomInventory(int id, String title, ModInventory inv) 
     {
         windowId = id;
-        windowTitle = title.getFormattedText();
+        windowTitle = title;
         slotCount = (byte) inv.getSizeInventory();
         allSlots = (byte) inv.getAllSlots();
         data = inv.getData();
@@ -76,11 +75,9 @@ public class CustomInventory
         context.get().enqueueWork(() -> 
         {
             Minecraft mc = Minecraft.getInstance();
-            ClientPlayerEntity p = mc.player;
-            mc.displayGuiScreen(new CustomInventoryGui(
-                    new InventoryBase(ci.data, ci.slotCount, ci.allSlots, p),
-                    new StringTextComponent(ci.windowTitle),
-                    ci.windowId));
+            CustomContainer cc = new CustomContainer(ci.windowId, mc.player.inventory, new ModInventory(ci.data, ci.slotCount, ci.allSlots));
+            mc.player.openContainer = cc;
+            mc.displayGuiScreen(new CustomInventoryScreen(cc, mc.player.inventory, new StringTextComponent(ci.windowTitle))); 
         });
         context.get().setPacketHandled(true);
     }

+ 0 - 73
src/main/java/me/km/networking/CustomInventoryGui.java

@@ -1,73 +0,0 @@
-package me.km.networking;
-
-import com.mojang.blaze3d.platform.GlStateManager;
-import me.km.KajetansMod;
-import me.km.inventory.CustomContainer;
-import me.km.inventory.InventoryBase;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.screen.inventory.ContainerScreen;
-import net.minecraft.entity.player.PlayerInventory;
-import net.minecraft.util.ResourceLocation;
-import net.minecraft.util.text.ITextComponent;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
-
-@OnlyIn(Dist.CLIENT)
-public class CustomInventoryGui extends ContainerScreen
-{
-    /** The ResourceLocation containing the chest GUI texture. */
-    private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
-    private static final ResourceLocation EMPTY_TILE = new ResourceLocation(KajetansMod.MODID, "textures/gui/container/empty_tile.png");
-    private final PlayerInventory pInv;
-    private final InventoryBase inv;
-    private final int inventoryRows;
-
-    public CustomInventoryGui(InventoryBase inv, ITextComponent text, int id)
-    {
-        super(new CustomContainer(inv, Minecraft.getInstance().player, text, id), Minecraft.getInstance().player.inventory, text);
-        this.pInv = Minecraft.getInstance().player.inventory;
-        this.inv = inv;
-        this.passEvents = false;
-        this.inventoryRows = inv.getRows();
-        this.ySize = 114 + this.inventoryRows * 18;
-    }
-
-    @Override
-    public void render(int mouseX, int mouseY, float partialTicks)
-    {
-        this.renderBackground();
-        super.render(mouseX, mouseY, partialTicks);
-        this.renderHoveredToolTip(mouseX, mouseY);
-    }
-
-    @Override
-    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
-    {
-        this.font.drawString(title.getFormattedText(), 8, 6, 4210752);
-        this.font.drawString(this.pInv.getDisplayName().getFormattedText(), 8, this.ySize - 96 + 2, 4210752);
-    }
-
-    @Override
-    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
-    {
-        GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
-        minecraft.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
-        int i = (this.width - this.xSize) / 2;
-        int j = (this.height - this.ySize) / 2;
-        blit(i, j, 0, 0, this.xSize, this.inventoryRows * 18 + 17);
-        blit(i, j + this.inventoryRows * 18 + 17, 0, 126, this.xSize, 96);
-        i += 7;
-        j += 17;
-        minecraft.getTextureManager().bindTexture(EMPTY_TILE);
-        for(int x = 0; x < 9; x++)
-        {
-            for(int y = 0; y < inventoryRows; y++)
-            {
-                if(inv.shouldRenderOverlay(x, y))
-                {
-                    blit(i + 18 * x, j + 18 * y, 0, 0, 18, 18);
-                }
-            }
-        }
-    }
-}

+ 107 - 0
src/main/java/me/km/networking/CustomInventoryScreen.java

@@ -0,0 +1,107 @@
+package me.km.networking;
+
+import com.mojang.blaze3d.platform.GlStateManager;
+import me.km.KajetansMod;
+import me.km.inventory.CustomContainer;
+import me.km.inventory.ModInventory;
+import net.minecraft.client.gui.IHasContainer;
+import net.minecraft.client.gui.screen.inventory.ContainerScreen;
+import net.minecraft.client.renderer.BufferBuilder;
+import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
+import net.minecraft.entity.player.PlayerInventory;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.text.ITextComponent;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+
+@OnlyIn(Dist.CLIENT)
+public class CustomInventoryScreen extends ContainerScreen<CustomContainer> implements IHasContainer<CustomContainer>
+{
+    /** The ResourceLocation containing the chest GUI texture. */
+    private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
+    private static final ResourceLocation EMPTY_TILE = new ResourceLocation(KajetansMod.MODID, "textures/gui/container/empty_tile.png");
+    
+    private final int inventoryRows;
+
+    public CustomInventoryScreen(CustomContainer cc, PlayerInventory pInv, ITextComponent title)
+    {
+        super(cc, pInv, title);
+        passEvents = false;
+        inventoryRows = cc.getInventoryBase().getRows();
+        ySize = 114 + inventoryRows * 18;
+    }
+
+    @Override
+    public void render(int mouseX, int mouseY, float partialTicks)
+    {
+        this.renderBackground();
+        super.render(mouseX, mouseY, partialTicks);
+        this.renderHoveredToolTip(mouseX, mouseY);
+    }
+
+    @Override
+    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
+    {
+        this.font.drawString(title.getFormattedText(), 8.0f, 6.0f, 4210752);
+        this.font.drawString(playerInventory.getDisplayName().getFormattedText(), 8.0f, ySize - 94, 4210752);
+    }
+
+    @Override
+    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
+    {
+        GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
+        minecraft.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
+        int i = (width - xSize) / 2;
+        int j = (height - ySize) / 2;
+        blit(i, j, 0, 0, this.xSize, inventoryRows * 18 + 17);
+        blit(i, j + inventoryRows * 18 + 17, 0, 126, xSize, 96);
+        
+        i += 7;
+        j += 17;
+        minecraft.getTextureManager().bindTexture(EMPTY_TILE);
+        ModInventory base = this.getContainer().getInventoryBase();
+        for(int x = 0; x < 9; x++)
+        {
+            for(int y = 0; y < inventoryRows; y++)
+            {
+                if(base.shouldRenderOverlay(x, y))
+                {
+                    blit(i + 18 * x, j + 18 * y, 0, 0, 18, 18, 64, 64);
+                }
+                else if(base.shouldRenderDarker(x, y))
+                {
+                    blit(i + 18 * x, j + 18 * y, 18, 0, 18, 18, 64, 64);
+                }
+            }
+        }
+    }
+    
+    /*public void blit(int startX, int startY, int tStartX, int tStartY, int width, int height)
+    {
+        blit(startX, startY, this.blitOffset, tStartX, tStartY, width, height, 256, 256);
+    }
+
+    public static void blit(int startX, int startY, int z, float tStartX, float tStartY, int width, int height, int rWidth, int rHeight)
+    {
+        innerBlit(startX, startX + width, startY, startY + height, z, width, height, tStartX, tStartY, rHeight, rWidth);
+    }
+    
+    private static void innerBlit(int minX, int maxX, int minY, int maxY, int z, int tWidth, int tHight, float tStartX, float tStartY, int rWidth, int rHeight)
+    {
+        innerBlit(minX, maxX, minY, maxY, z, 
+                tStartX / rWidth, (tStartX + tWidth) / rWidth, 
+                tStartY / rHeight, (tStartY + tHight) / rHeight);
+    }
+
+    protected static void innerBlit(int minX, int maxX, int minY, int maxY, int z, float tMinX, float tMaxX, float tMinY, float tMaxY)
+    {
+        Tessellator tessellator = Tessellator.getInstance();
+        BufferBuilder bufferbuilder = tessellator.getBuffer();
+        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
+        bufferbuilder.pos(minX, maxY, z).tex(tMinX, tMaxY).endVertex();
+        bufferbuilder.pos(maxX, maxY, z).tex(tMaxX, tMaxY).endVertex();
+        bufferbuilder.pos(maxX, minY, z).tex(tMaxX, tMinY).endVertex();
+        bufferbuilder.pos(minX, minY, z).tex(tMinX, tMinY).endVertex();
+        tessellator.draw();
+    }*/
+}

+ 2 - 2
src/main/java/me/km/networking/ModPacketHandler.java

@@ -2,7 +2,7 @@ package me.km.networking;
 
 import me.km.KajetansMod;
 import me.km.entities.EntityHuman;
-import me.km.inventory.InventoryBase;
+import me.km.inventory.ModInventory;
 import net.minecraft.entity.player.ServerPlayerEntity;
 import net.minecraft.util.ResourceLocation;
 import net.minecraft.util.text.ITextComponent;
@@ -68,7 +68,7 @@ public class ModPacketHandler
         sendToServer(new FunctionKey(key));
     }
     
-    public static void sendCustomInventory(ServerPlayerEntity p, int id, ITextComponent title, InventoryBase inv)
+    public static void sendCustomInventory(ServerPlayerEntity p, int id, String title, ModInventory inv)
     {
         sendToPlayer(p, new CustomInventory(id, title, inv));
     }

+ 7 - 18
src/main/java/me/km/snuviscript/MinecraftFunctions.java

@@ -43,6 +43,7 @@ import net.minecraft.world.World;
 import me.km.events.CustomEventCaller;
 import me.km.events.PlayerMoveData;
 import me.km.inventory.CustomContainer;
+import me.km.inventory.ModInventory;
 import me.km.networking.ModPacketHandler;
 import me.km.overrides.ModEntityPlayerMP;
 import me.km.permissions.PermissionManager;
@@ -2101,9 +2102,8 @@ public class MinecraftFunctions
         // ---------------------------------------------------------------------  
         // Inventory-library   
         // ---------------------------------------------------------------------
-        sm.registerFunction("inv.new", (sc, in) -> new SnuviInventory(in[1].getString(sc), in[0].getString(sc), inventoryIds++)); 
-        sm.registerAlias("inv.new", "inv.newdynamic");
-        sm.registerFunction("inv.getid", (sc, in) -> (double) ((SnuviInventory) in[0].get(sc)).getId()); 
+        sm.registerFunction("inv.new", (sc, in) -> new ModInventory(in[0].getString(sc))); 
+        sm.registerFunction("inv.getid", (sc, in) -> (double) ((ModInventory) in[0].get(sc)).getModId()); 
         sm.registerFunction("inv.loadblock", (sc, in) -> 
         { 
             Location l = (Location) in[0].get(sc);
@@ -2115,7 +2115,7 @@ public class MinecraftFunctions
                 size++;
                 size *= 9;
             }
-            SnuviInventory inv = new SnuviInventory(in[1].getString(sc), size, inventoryIds++); 
+            ModInventory inv = new ModInventory(size); 
             for(int i = 0; i < chest.getSizeInventory(); i++)
             {
                 inv.setInventorySlotContents(i, chest.getStackInSlot(i).copy());
@@ -2130,23 +2130,12 @@ public class MinecraftFunctions
         sm.registerFunction("inv.getitem", (sc, in) -> ((IInventory) in[0].get(sc)).getStackInSlot(in[1].getInt(sc)));
         sm.registerFunction("inv.open", (sc, in) -> 
         { 
-            SnuviInventory si = (SnuviInventory) in[0].get(sc);
-            ScriptInventoryHolder sih = new ScriptInventoryHolder(scheduler, si, 
-                    (ServerPlayerEntity) in[1].get(sc), new StringTextComponent(si.getTitle()), sc);
-            sih.openForPlayer(); 
+            CustomContainer.openForPlayer((ServerPlayerEntity) in[1].get(sc), (ModInventory) in[0].get(sc), in[2].getString(sc), sc);
             return Void.TYPE; 
         });
         sm.registerFunction("inv.close", (sc, in) -> 
         { 
-            PlayerEntity p = (PlayerEntity) in[0].get(sc);
-            if(p.openContainer instanceof CustomContainer)
-            {
-                ((CustomContainer) p.openContainer).closeSafe();
-            }
-            else
-            {
-                p.closeScreen();
-            }
+            ((PlayerEntity) in[0].get(sc)).closeScreen();
             return Void.TYPE; 
         });      
         sm.registerFunction("inv.update", (sc, in) ->  
@@ -2174,7 +2163,7 @@ public class MinecraftFunctions
             if(s.startsWith("{"))
             {
                 String left = SnuviUtils.connect(sc, in, 1);
-                return ItemStackUtils.getStackFromNbtString((s + left).replace('\'', '"'));
+                return ItemStackUtils.getStackFromNbtString(s + left);
             }
             Item item = Mapper.getItem(s);
             int amount = in.length >= 2 ? in[1].getInt(sc) : 1;

+ 7 - 4
src/main/java/me/km/snuviscript/ScriptEvents.java

@@ -13,6 +13,7 @@ import me.km.entities.EntityHuman;
 import me.km.entities.EntityItemProjectile;
 import me.km.events.CommandEvent;
 import me.km.events.PlayerTabListNameEvent;
+import me.km.inventory.ModInventory;
 import me.km.permissions.PermissionManager;
 import me.km.utils.Location;
 import net.minecraft.command.ICommandSource;
@@ -134,12 +135,13 @@ public class ScriptEvents
         });
     }
     
-    public boolean onInventoryClick(Script script, ITextComponent text, SnuviInventory inv, int slot, ClickType click, PlayerEntity p)
+    public boolean onInventoryClick(Script script, ITextComponent text, ModInventory inv, int slot, ClickType click, PlayerEntity p)
     {
         scripts.getScriptManager().callEvent("inv_click", script, sc -> 
         {
             ScriptVars.setPlayerVars(sc, p); 
-            sc.setVar("inv_id", (double) inv.getId());
+            sc.setVar("inv", inv);
+            sc.setVar("inv_id", (double) inv.getModId());
             sc.setVar("inv_name", text.getFormattedText());
             sc.setVar("inv_slot", (double) slot);
             ScriptVars.setItemVars(sc, inv.getStackInSlot(slot));
@@ -149,12 +151,13 @@ public class ScriptEvents
         return v != null && v.getBoolean(script);
     }
 
-    public void onInventoryClose(Script script, ITextComponent text, SnuviInventory inv, PlayerEntity p)
+    public void onInventoryClose(Script script, ITextComponent text, ModInventory inv, PlayerEntity p)
     {
         scripts.getScriptManager().callEvent("inv_close", script, sc -> 
         {
             ScriptVars.setPlayerVars(sc, p); 
-            sc.setVar("inv_id", (double) inv.getId());
+            sc.setVar("inv", inv);
+            sc.setVar("inv_id", (double) inv.getModId());
             sc.setVar("inv_name", text.getFormattedText());
         }, null);
     }

+ 0 - 34
src/main/java/me/km/snuviscript/ScriptInventoryHolder.java

@@ -1,34 +0,0 @@
-package me.km.snuviscript;
-
-import me.hammerle.snuviscript.code.ISnuviScheduler;
-import me.hammerle.snuviscript.code.Script;
-import me.km.Server;
-import me.km.inventory.CustomContainer;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.entity.player.ServerPlayerEntity;
-import net.minecraft.inventory.container.ClickType;
-import net.minecraft.util.text.ITextComponent;
-
-public class ScriptInventoryHolder extends CustomContainer
-{
-    private final Script sc;
-
-    public ScriptInventoryHolder(ISnuviScheduler scheduler, SnuviInventory inv, ServerPlayerEntity p, ITextComponent title, Script qd) 
-    {
-        super(scheduler, inv, p, title);
-        this.sc = qd;
-    }
-
-    @Override
-    public boolean onButtonClick(int slot, int dragType, ClickType click, ServerPlayerEntity p)
-    {
-        return Server.scriptEvents.onInventoryClick(sc, getTitle(), (SnuviInventory) inv, slot, click, p);
-    }
-
-    @Override
-    public void onContainerClosed(PlayerEntity p) 
-    {
-        Server.scriptEvents.onInventoryClose(sc, getTitle(), (SnuviInventory) inv, p);
-        super.onContainerClosed(p);
-    }
-}

+ 0 - 33
src/main/java/me/km/snuviscript/SnuviInventory.java

@@ -1,33 +0,0 @@
-package me.km.snuviscript;
-
-import me.km.inventory.InventoryBase;
-
-public class SnuviInventory extends InventoryBase
-{
-    private final int id;
-    private final String title;
-    
-    public SnuviInventory(String title, int slotCount, int id) 
-    {
-        super(slotCount, null);
-        this.id = id;
-        this.title = title;
-    }
-    
-    public SnuviInventory(String title, String slots, int id) 
-    {
-        super(slots, null);
-        this.id = id;
-        this.title = title;
-    }
-    
-    public int getId()
-    {
-        return id;
-    }
-    
-    public String getTitle()
-    {
-        return title;
-    }
-}

+ 1 - 1
src/main/resources/META-INF/mods.toml

@@ -2,7 +2,7 @@ modLoader="javafml"
 loaderVersion="[28,)"
 [[mods]]
 modId="km"
-version="0.0.38"
+version="0.0.39"
 displayName="Kajetans Mod"
 credits="kajetanjohannes"
 authors="kajetanjohannes"

BIN
src/main/resources/assets/km/textures/gui/container/empty_tile.png