Merge pull request #1521 from 70000hp/NEI-schenanigans

NEI schenanigans
This commit is contained in:
HbmMods 2024-07-11 08:44:58 +02:00 committed by GitHub
commit 6951c73aa4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
26 changed files with 395 additions and 381 deletions

View File

@ -9,11 +9,12 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerAutocrafter extends Container {
public class ContainerAutocrafter extends ContainerBase {
private TileEntityMachineAutocrafter autocrafter;
public ContainerAutocrafter(InventoryPlayer invPlayer, TileEntityMachineAutocrafter tedf) {
super(invPlayer, tedf);
autocrafter = tedf;
/* TEMPLATE */
@ -25,25 +26,14 @@ public class ContainerAutocrafter extends Container {
this.addSlotToContainer(new SlotPattern(tedf, 9, 116, 40));
/* RECIPE */
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
this.addSlotToContainer(new Slot(tedf, j + i * 3 + 10, 44 + j * 18, 86 + i * 18));
}
}
addSlots(tedf,10, 44, 86, 3, 3);
this.addSlotToContainer(new Slot(tedf, 19, 116, 104));
//Battery
this.addSlotToContainer(new Slot(tedf, 20, 17, 99));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 158 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 216));
}
playerInv(invPlayer,8,158,216);
}
@Override
@ -90,7 +80,7 @@ public class ContainerAutocrafter extends Container {
}
slot.onSlotChanged();
autocrafter.initPattern(slot.getStack(), index);
autocrafter.matcher.initPatternSmart(autocrafter.getWorldObj(), slot.getStack(), index);
autocrafter.updateTemplateGrid();
return ret;
@ -101,9 +91,4 @@ public class ContainerAutocrafter extends Container {
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
return null;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return autocrafter.isUseableByPlayer(player);
}
}

View File

@ -0,0 +1,81 @@
package com.hbm.inventory.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
/**For now, only used for stuff with filters and crates as a reference implementation,
* because I really needed to get the te from a container
* But you should very much use this to kill the giant amount of boilerplate in container classes
* @author 70k **/
public class ContainerBase extends Container {
public IInventory te;
public ContainerBase (InventoryPlayer invPlayer, IInventory tedf){
te = tedf;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return te.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
ItemStack var3 = null;
Slot var4 = (Slot) this.inventorySlots.get(par2);
if(var4 != null && var4.getHasStack()) {
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if(par2 <= te.getSizeInventory() - 1) {
if(!this.mergeItemStack(var5, te.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
} else if(!this.mergeItemStack(var5, 0, te.getSizeInventory(), false)) {
return null;
}
if(var5.stackSize == 0) {
var4.putStack(null);
} else {
var4.onSlotChanged();
}
var4.onPickupFromSlot(p_82846_1_, var5);
}
return var3;
}
/**Used to quickly set up the player inventory*/
public void playerInv(InventoryPlayer invPlayer, int playerInvX, int playerInvY, int playerHotbarY){
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, playerInvX + j * 18, playerInvY + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, playerInvX + i * 18, playerHotbarY));
}
}
// I'm gonna make a farken helper function for this shit, why was it done the old way for 9 whole ass years?
//- Mellow, 1884
/**Used to add several conventional inventory slots at a time
* @param inv the inventory to add the slots to
* @param from the slot index to start from*/
public void addSlots(IInventory inv, int from, int x, int y, int rows, int cols) {
int slotSize = 18;
for(int row = 0; row < rows; row++) {
for(int col = 0; col < cols; col++) {
this.addSlotToContainer(new Slot(inv, col + row * cols + from, x + col * slotSize, y + row * slotSize));
}
}
}
}

View File

@ -1,5 +1,6 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotPattern;
import com.hbm.tileentity.network.TileEntityRadioTorchCounter;
import net.minecraft.entity.player.EntityPlayer;
@ -8,35 +9,22 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerCounterTorch extends Container {
public class ContainerCounterTorch extends ContainerBase {
protected TileEntityRadioTorchCounter radio;
public ContainerCounterTorch(InventoryPlayer invPlayer, TileEntityRadioTorchCounter radio) {
super(invPlayer, radio);
this.radio = radio;
for(int i = 0; i < 3; i++) {
this.addSlotToContainer(new Slot(radio, i, 138, 18 + 44 * i));
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 12 + j * 18, 156 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 12 + i * 18, 214));
this.addSlotToContainer(new SlotPattern(radio, i, 138, 18 + 44 * i));
}
playerInv(invPlayer, 12, 156, 214);
}
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { return null; }
@Override
public boolean canInteractWith(EntityPlayer player) {
return radio.isUseableByPlayer(player);
}
@Override
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {

View File

@ -11,11 +11,12 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerCraneExtractor extends Container {
public class ContainerCraneExtractor extends ContainerBase {
protected TileEntityCraneExtractor extractor;
public ContainerCraneExtractor(InventoryPlayer invPlayer, TileEntityCraneExtractor extractor) {
super(invPlayer, extractor);
this.extractor = extractor;
//filter
@ -24,27 +25,22 @@ public class ContainerCraneExtractor extends Container {
this.addSlotToContainer(new SlotPattern(extractor, j + i * 3, 71 + j * 18, 17 + i * 18));
}
}
/*
//buffer
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
this.addSlotToContainer(new Slot(extractor, 9 + j + i * 3, 8 + j * 18, 17 + i * 18));
}
}
}*/
addSlots(extractor,9,8,17,3,3);
//upgrades
this.addSlotToContainer(new SlotUpgrade(extractor, 18, 152, 23));
this.addSlotToContainer(new SlotUpgrade(extractor, 19, 152, 47));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 103 + i * 18));
}
}
playerInv(invPlayer, 8, 103, 161);
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 161));
}
}
@Override
@ -91,11 +87,6 @@ public class ContainerCraneExtractor extends Container {
return var3;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return extractor.isUseableByPlayer(player);
}
@Override
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {

View File

@ -11,11 +11,13 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerCraneGrabber extends Container {
public class ContainerCraneGrabber extends ContainerBase {
protected TileEntityCraneGrabber grabber;
public ContainerCraneGrabber(InventoryPlayer invPlayer, TileEntityCraneGrabber grabber) {
super(invPlayer, grabber);
this.grabber = grabber;
//filter
@ -29,15 +31,7 @@ public class ContainerCraneGrabber extends Container {
this.addSlotToContainer(new SlotUpgrade(grabber, 9, 121, 23));
this.addSlotToContainer(new SlotUpgrade(grabber, 10, 121, 47));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 103 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 161));
}
playerInv(invPlayer, 8, 103, 161);
}
@Override
@ -82,11 +76,6 @@ public class ContainerCraneGrabber extends Container {
return var3;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return grabber.isUseableByPlayer(player);
}
@Override
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {

View File

@ -9,11 +9,12 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerCraneRouter extends Container {
public class ContainerCraneRouter extends ContainerBase {
private TileEntityCraneRouter router;
public ContainerCraneRouter(InventoryPlayer invPlayer, TileEntityCraneRouter router) {
super(invPlayer, router);
this.router = router;
for(int j = 0; j < 2; j++) {
@ -23,16 +24,7 @@ public class ContainerCraneRouter extends Container {
}
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 47 + j * 18, 119 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 47 + i * 18, 177));
}
playerInv(invPlayer, 47, 119, 177);
}
@Override
@ -78,9 +70,4 @@ public class ContainerCraneRouter extends Container {
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
return null;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return router.isUseableByPlayer(player);
}
}

View File

@ -1,57 +1,25 @@
package com.hbm.inventory.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerCrateBase extends Container {
protected IInventory crate;
public class ContainerCrateBase extends ContainerBase {
public ContainerCrateBase(IInventory tedf) {
crate = tedf;
crate.openInventory();
//just there so prev stuff doesnt break
protected IInventory crate = te;
public ContainerCrateBase(InventoryPlayer invPlayer, IInventory tedf) {
super(invPlayer, tedf);
te.openInventory();
}
@Override
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2) {
ItemStack var3 = null;
Slot var4 = (Slot) this.inventorySlots.get(par2);
if(var4 != null && var4.getHasStack()) {
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if(par2 <= crate.getSizeInventory() - 1) {
if(!this.mergeItemStack(var5, crate.getSizeInventory(), this.inventorySlots.size(), true)) {
return null;
}
} else if(!this.mergeItemStack(var5, 0, crate.getSizeInventory(), false)) {
return null;
}
if(var5.stackSize == 0) {
var4.putStack((ItemStack) null);
} else {
var4.onSlotChanged();
}
var4.onPickupFromSlot(p_82846_1_, var5);
}
return var3;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return crate.isUseableByPlayer(player);
}
@Override
public void onContainerClosed(EntityPlayer p_75134_1_) {
super.onContainerClosed(p_75134_1_);
this.crate.closeInventory();
te.closeInventory();
}
}

View File

@ -7,7 +7,7 @@ import net.minecraft.inventory.Slot;
public class ContainerCrateDesh extends ContainerCrateBase {
public ContainerCrateDesh(InventoryPlayer invPlayer, IInventory tedf) {
super(tedf);
super(invPlayer,tedf);
for(int i = 0; i < 8; i++) {
for(int j = 0; j < 13; j++) {
@ -15,14 +15,7 @@ public class ContainerCrateDesh extends ContainerCrateBase {
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 44 + j * 18, 174 + i * 18));
}
}
this.playerInv(invPlayer,44, 174, 232);
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 44 + i * 18, 232));
}
}
}

View File

@ -9,22 +9,13 @@ import net.minecraft.inventory.Slot;
public class ContainerCrateIron extends ContainerCrateBase {
public ContainerCrateIron(InventoryPlayer invPlayer, TileEntityCrateIron tedf) {
super(tedf);
super(invPlayer,tedf);
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(tedf, j + i * 9, 8 + j * 18, 18 + i * 18));
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 20));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 20));
}
this.playerInv(invPlayer, 8, 84 + 20, 142 + 20);
}
}

View File

@ -8,7 +8,7 @@ import net.minecraft.inventory.Slot;
public class ContainerCrateSteel extends ContainerCrateBase {
public ContainerCrateSteel(InventoryPlayer invPlayer, IInventory tedf) {
super(tedf);
super(invPlayer,tedf);
for(int i = 0; i < 6; i++) {
for(int j = 0; j < 9; j++) {
@ -16,14 +16,6 @@ public class ContainerCrateSteel extends ContainerCrateBase {
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + (18 * 3) + 2));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + (18 * 3) + 2));
}
this.playerInv(invPlayer,8, 84 + (18 * 3) + 2, 142 + (18 * 3) + 2);
}
}

View File

@ -8,7 +8,7 @@ import net.minecraft.inventory.Slot;
public class ContainerCrateTemplate extends ContainerCrateBase {
public ContainerCrateTemplate(InventoryPlayer invPlayer, TileEntityCrateTemplate tedf) {
super(tedf);
super(invPlayer,tedf);
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
@ -16,14 +16,6 @@ public class ContainerCrateTemplate extends ContainerCrateBase {
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 86 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 144));
}
this.playerInv(invPlayer,8, 86, 144);
}
}

View File

@ -9,7 +9,7 @@ import net.minecraft.inventory.Slot;
public class ContainerCrateTungsten extends ContainerCrateBase {
public ContainerCrateTungsten(InventoryPlayer invPlayer, TileEntityCrateTungsten te) {
super(te);
super(invPlayer,te);
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
@ -17,14 +17,6 @@ public class ContainerCrateTungsten extends ContainerCrateBase {
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 32 + i * 18 + (18 * 3)));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 90 + (18 * 3)));
}
this.playerInv(invPlayer,8, 32 + 18 * 3, 90 + (18 * 3));
}
}

View File

@ -8,7 +8,7 @@ import net.minecraft.inventory.Slot;
public class ContainerDroneDock extends ContainerCrateBase {
public ContainerDroneDock(InventoryPlayer invPlayer, TileEntityDroneDock tedf) {
super(tedf);
super(invPlayer,tedf);
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
@ -16,14 +16,6 @@ public class ContainerDroneDock extends ContainerCrateBase {
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 103 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 161));
}
this.playerInv(invPlayer, 8, 103, 161);
}
}

View File

@ -8,7 +8,7 @@ import net.minecraft.inventory.Slot;
public class ContainerDroneProvider extends ContainerCrateBase {
public ContainerDroneProvider(InventoryPlayer invPlayer, TileEntityDroneProvider tedf) {
super(tedf);
super(invPlayer,tedf);
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
@ -16,14 +16,6 @@ public class ContainerDroneProvider extends ContainerCrateBase {
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 103 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 161));
}
this.playerInv(invPlayer, 8, 103, 161);
}
}

View File

@ -9,10 +9,10 @@ import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerDroneRequester extends ContainerCrateBase {
public ContainerDroneRequester(InventoryPlayer invPlayer, TileEntityDroneRequester tedf) {
super(tedf);
super(invPlayer,tedf);
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 3; j++) {
this.addSlotToContainer(new SlotPattern(tedf, j + i * 3, 98 + j * 18, 17 + i * 18));
@ -25,15 +25,7 @@ public class ContainerDroneRequester extends ContainerCrateBase {
}
}
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 103 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 161));
}
this.playerInv(invPlayer, 8, 103, 161);
}
@Override
@ -44,7 +36,7 @@ public class ContainerDroneRequester extends ContainerCrateBase {
if(var4 != null && var4.getHasStack()) {
ItemStack var5 = var4.getStack();
var3 = var5.copy();
if(par2 < 9) return null; //ignore filters
if(par2 <= crate.getSizeInventory() - 1) {
@ -69,18 +61,18 @@ public class ContainerDroneRequester extends ContainerCrateBase {
@Override
public ItemStack slotClick(int index, int button, int mode, EntityPlayer player) {
//L/R: 0
//M3: 3
//SHIFT: 1
//DRAG: 5
if(index < 0 || index > 8) {
return super.slotClick(index, button, mode, player);
}
Slot slot = this.getSlot(index);
ItemStack ret = null;
ItemStack held = player.inventory.getItemStack();
TileEntityDroneRequester requester = (TileEntityDroneRequester) crate;

View File

@ -10,27 +10,21 @@ import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerMassStorage extends Container {
public class ContainerMassStorage extends ContainerBase {
private TileEntityMassStorage storage;
public ContainerMassStorage(InventoryPlayer invPlayer, TileEntityMassStorage te) {
super(invPlayer,te);
this.storage = te;
this.storage.openInventory();
this.addSlotToContainer(new Slot(storage, 0, 61, 17));
this.addSlotToContainer(new SlotPattern(storage, 1, 61, 53));
this.addSlotToContainer(new SlotTakeOnly(storage, 2, 61, 89));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 139 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 197));
}
playerInv(invPlayer,8,139,197);
}
@Override

View File

@ -38,14 +38,14 @@ public class GUIAutocrafter extends GuiInfoContainer {
for(int i = 0; i < 9; ++i) {
Slot slot = (Slot) this.inventorySlots.inventorySlots.get(i);
if(this.isMouseOverSlot(slot, x, y) && diFurnace.modes[i] != null) {
if(this.isMouseOverSlot(slot, x, y) && diFurnace.matcher.modes[i] != null) {
String label = EnumChatFormatting.YELLOW + "";
switch(diFurnace.modes[i]) {
switch(diFurnace.matcher.modes[i]) {
case "exact": label += "Item and meta match"; break;
case "wildcard": label += "Item matches"; break;
default: label += "Ore dict key matches: " + diFurnace.modes[i]; break;
default: label += "Ore dict key matches: " + diFurnace.matcher.modes[i]; break;
}
this.func_146283_a(Arrays.asList(new String[] { EnumChatFormatting.RED + "Right click to change", label }), x, y - 30);

View File

@ -1,10 +1,17 @@
package com.hbm.inventory.gui;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.*;
import codechicken.nei.VisiblityData;
import codechicken.nei.api.INEIGuiHandler;
import codechicken.nei.api.TaggedInventoryArea;
import com.hbm.inventory.SlotPattern;
import com.hbm.inventory.container.ContainerBase;
import com.hbm.packet.NBTControlPacket;
import com.hbm.packet.PacketDispatcher;
import cpw.mods.fml.common.Optional;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
@ -25,8 +32,9 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
public abstract class GuiInfoContainer extends GuiContainer {
@Optional.Interface(iface = "codechicken.nei.api.INEIGuiHandler", modid = "NotEnoughItems")
public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHandler {
static final ResourceLocation guiUtil = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_utility.png");
public GuiInfoContainer(Container p_i1072_1_) {
@ -106,6 +114,22 @@ public abstract class GuiInfoContainer extends GuiContainer {
protected boolean isMouseOverSlot(Slot slot, int x, int y) {
return this.func_146978_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, x, y);
}
//whoever made this private on the super deserves to eat a bowl of wasps
public Slot getSlotAtPosition(int p_146975_1_, int p_146975_2_)
{
for (int k = 0; k < this.inventorySlots.inventorySlots.size(); ++k)
{
Slot slot = (Slot)this.inventorySlots.inventorySlots.get(k);
if (this.isMouseOverSlot(slot, p_146975_1_, p_146975_2_))
{
return slot;
}
}
return null;
}
protected boolean checkClick(int x, int y, int left, int top, int sizeX, int sizeY) {
return guiLeft + left <= x && guiLeft + left + sizeX > x && guiTop + top < y && guiTop + top + sizeY >= y;
@ -136,6 +160,7 @@ public abstract class GuiInfoContainer extends GuiContainer {
return this.fontRendererObj;
}
protected void drawItemStack(ItemStack stack, int x, int y, String label) {
GL11.glTranslatef(0.0F, 0.0F, 32.0F);
this.zLevel = 200.0F;
@ -266,4 +291,51 @@ public abstract class GuiInfoContainer extends GuiContainer {
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
}
}
///NEI drag and drop support
@Override
@Optional.Method(modid = "NotEnoughItems")
public boolean handleDragNDrop(GuiContainer gui, int x, int y, ItemStack stack, int button) {
if(gui instanceof GuiInfoContainer && stack != null){
Slot slot = getSlotAtPosition(x,y);
if(slot instanceof SlotPattern){
if(inventorySlots instanceof ContainerBase) {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("slot", slot.slotNumber);
//Item IDs are usually dangerous, but this is only getting called from clientside, while ingame anyway
//if someone somehow gets an ID shift with this i will eat my shoe - 70k
tag.setInteger("id", Item.getIdFromItem(stack.getItem()));
tag.setInteger("meta", stack.getItemDamage());
TileEntity te = (TileEntity) ((ContainerBase) inventorySlots).te;
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(tag, te.xCoord, te.yCoord, te.zCoord));
return true;
}
}
}
return false;
}
//all credits for impl to GTNH's EnderCore fork
@Override
@Optional.Method(modid = "NotEnoughItems")
public boolean hideItemPanelSlot(GuiContainer gc, int x, int y, int w, int h) {
return false;
}
@Override
@Optional.Method(modid = "NotEnoughItems")
public VisiblityData modifyVisiblity(GuiContainer gc, VisiblityData vd) {
return vd;
}
@Override
@Optional.Method(modid = "NotEnoughItems")
public Iterable<Integer> getItemSpawnSlots(GuiContainer gc, ItemStack is) {
return null;
}
@Override
@Optional.Method(modid = "NotEnoughItems")
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gc) {
return Collections.emptyList();
}
}

View File

@ -0,0 +1,17 @@
package com.hbm.tileentity;
import com.hbm.interfaces.IControlReceiver;
import net.minecraft.nbt.NBTTagCompound;
public interface IFilterable extends IControlReceiver {
void nextMode(int i);
@Override
default void receiveControl(NBTTagCompound data) {
if(data.hasKey("slot")){
setFilterContents(data);
}
}
void setFilterContents(NBTTagCompound nbt);
}

View File

@ -6,6 +6,8 @@ import java.util.List;
import com.hbm.inventory.container.ContainerAutocrafter;
import com.hbm.inventory.gui.GUIAutocrafter;
import com.hbm.lib.Library;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.IFilterable;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.BufferUtil;
@ -20,106 +22,34 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityMachineAutocrafter extends TileEntityMachineBase implements IEnergyReceiverMK2, IGUIProvider {
public class TileEntityMachineAutocrafter extends TileEntityMachineBase implements IEnergyReceiverMK2, IGUIProvider, IFilterable {
public static final String MODE_EXACT = "exact";
public static final String MODE_WILDCARD = "wildcard";
public String[] modes = new String[9];
public List<IRecipe> recipes = new ArrayList();
public int recipeIndex;
public int recipeCount;
public ModulePatternMatcher matcher;
public TileEntityMachineAutocrafter() {
super(21);
this.matcher = new ModulePatternMatcher(9);
}
public void initPattern(ItemStack stack, int i) {
if(worldObj.isRemote) return;
if(stack == null) {
modes[i] = null;
return;
}
List<String> names = ItemStackUtil.getOreDictNames(stack);
if(iterateAndCheck(names, i ,"ingot")) return;
if(iterateAndCheck(names, i ,"block")) return;
if(iterateAndCheck(names, i ,"dust")) return;
if(iterateAndCheck(names, i ,"nugget")) return;
if(iterateAndCheck(names, i ,"plate")) return;
if(stack.getHasSubtypes()) {
modes[i] = MODE_EXACT;
} else {
modes[i] = MODE_WILDCARD;
}
}
private boolean iterateAndCheck(List<String> names, int i, String prefix) {
for(String s : names) {
if(s.startsWith(prefix)) {
modes[i] = s;
return true;
}
}
return false;
}
@Override
public void nextMode(int i) {
if(worldObj.isRemote) return;
ItemStack stack = slots[i];
if(stack == null) {
modes[i] = null;
return;
}
if(modes[i] == null) {
modes[i] = MODE_EXACT;
} else if(MODE_EXACT.equals(modes[i])) {
modes[i] = MODE_WILDCARD;
} else if(MODE_WILDCARD.equals(modes[i])) {
List<String> names = ItemStackUtil.getOreDictNames(stack);
if(names.isEmpty()) {
modes[i] = MODE_EXACT;
} else {
modes[i] = names.get(0);
}
} else {
List<String> names = ItemStackUtil.getOreDictNames(stack);
if(names.size() < 2 || modes[i].equals(names.get(names.size() - 1))) {
modes[i] = MODE_EXACT;
} else {
for(int j = 0; j < names.size() - 1; j++) {
if(modes[i].equals(names.get(j))) {
modes[i] = names.get(j + 1);
return;
}
}
}
}
this.matcher.nextMode(worldObj, slots[i], i);
}
public void nextTemplate() {
if(worldObj.isRemote) return;
@ -203,14 +133,7 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
public void serialize(ByteBuf buf) {
super.serialize(buf);
buf.writeLong(power);
for(int i = 0; i < 9; i++) {
if(modes[i] != null) {
buf.writeBoolean(true);
BufferUtil.writeString(buf, modes[i]);
} else
buf.writeBoolean(false);
}
matcher.serialize(buf);
buf.writeInt(recipeCount);
buf.writeInt(recipeIndex);
}
@ -219,12 +142,7 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
power = buf.readLong();
modes = new String[9];
for(int i = 0; i < 9; i++) {
if(buf.readBoolean()) modes[i] = BufferUtil.readString(buf);
}
matcher.deserialize(buf);
recipeCount = buf.readInt();
recipeIndex = buf.readInt();
}
@ -270,15 +188,10 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
if(i > 9 && i < 19) {
ItemStack filter = slots[i - 10];
String mode = modes[i - 10];
if(filter == null || mode == null || mode.isEmpty()) return true;
if(isValidForFilter(filter, mode, stack)) {
return false;
}
return true;
if(filter == null) return true;
return !matcher.isValidForFilter(filter, i, stack);
}
return false;
@ -303,11 +216,8 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
List<Integer> validSlots = new ArrayList();
for(int i = 0; i < 9; i++) {
ItemStack filter = slots[i];
String mode = modes[i];
if(filter == null || mode == null || mode.isEmpty()) continue;
if(isValidForFilter(filter, mode, stack)) {
if(matcher.isValidForFilter(filter, i, stack)) {
validSlots.add(i + 10);
//if the current slot is valid and has no item in it, shortcut to true [*]
@ -345,17 +255,6 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
return true;
}
private boolean isValidForFilter(ItemStack filter, String mode, ItemStack input) {
switch(mode) {
case MODE_EXACT: return input.isItemEqual(filter) && ItemStack.areItemStackTagsEqual(input, filter);
case MODE_WILDCARD: return input.getItem() == filter.getItem() && ItemStack.areItemStackTagsEqual(input, filter);
default:
List<String> keys = ItemStackUtil.getOreDictNames(input);
return keys.contains(mode);
}
}
public InventoryCrafting getTemplateGrid() {
this.craftingInventory.loadIventory(slots, 0);
return this.craftingInventory;
@ -365,7 +264,7 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
this.craftingInventory.loadIventory(slots, 10);
return this.craftingInventory;
}
public static class InventoryCraftingAuto extends InventoryCrafting {
public InventoryCraftingAuto(int width, int height) {
@ -412,13 +311,7 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.power = nbt.getLong("power");
for(int i = 0; i < 9; i++) {
if(nbt.hasKey("mode" + i)) {
modes[i] = nbt.getString("mode" + i);
}
}
matcher.readFromNBT(nbt);
this.recipes = getMatchingRecipes(this.getTemplateGrid());
this.recipeCount = recipes.size();
this.recipeIndex = nbt.getInteger("rec");
@ -434,13 +327,7 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setLong("power", power);
for(int i = 0; i < 9; i++) {
if(modes[i] != null) {
nbt.setString("mode" + i, modes[i]);
}
}
matcher.writeToNBT(nbt);
nbt.setInteger("rec", this.recipeIndex);
}
@ -454,4 +341,18 @@ public class TileEntityMachineAutocrafter extends TileEntityMachineBase implemen
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUIAutocrafter(player.inventory, this);
}
@Override
public boolean hasPermission(EntityPlayer player) {
return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 20;
}
@Override
public void setFilterContents(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
setInventorySlotContents(
slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot);
markChanged();
}
}

View File

@ -4,6 +4,7 @@ import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.container.ContainerMassStorage;
import com.hbm.inventory.gui.GUIMassStorage;
import com.hbm.items.ModItems;
import com.hbm.tileentity.IFilterable;
import com.hbm.tileentity.INBTPacketReceiver;
import cpw.mods.fml.relauncher.Side;
@ -11,12 +12,13 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPacketReceiver, IControlReceiver {
public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPacketReceiver, IFilterable {
private int stack = 0;
public boolean output = false;
@ -156,6 +158,11 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPa
nbt.setByte("redstone", (byte) redstone);
}
@Override
public void nextMode(int i) {
}
@Override
public void receiveControl(NBTTagCompound data) {
if(data.hasKey("provide") && slots[1] != null) {
@ -185,6 +192,19 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements INBTPa
if(data.hasKey("toggle")) {
this.output = !output;
}
if(data.hasKey("slot")){
setFilterContents(data);
}
}
@Override
public void setFilterContents(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
setInventorySlotContents(
slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot);
markDirty();
}
@Override

View File

@ -7,6 +7,7 @@ import com.hbm.inventory.container.ContainerCraneExtractor;
import com.hbm.inventory.gui.GUICraneExtractor;
import com.hbm.items.ModItems;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.IFilterable;
import com.hbm.tileentity.IGUIProvider;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -17,6 +18,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -25,7 +27,7 @@ import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGUIProvider, IControlReceiver {
public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGUIProvider, IControlReceiver, IFilterable {
public boolean isWhitelist = false;
public ModulePatternMatcher matcher;
@ -195,7 +197,8 @@ public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGU
return false;
}
@Override
public void nextMode(int i) {
this.matcher.nextMode(worldObj, slots[i], i);
}
@ -250,5 +253,17 @@ public class TileEntityCraneExtractor extends TileEntityCraneBase implements IGU
if(data.hasKey("whitelist")) {
this.isWhitelist = !this.isWhitelist;
}
if(data.hasKey("slot")){
setFilterContents(data);
}
}
@Override
public void setFilterContents(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
setInventorySlotContents(
slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot);
markChanged();
}
}

View File

@ -8,6 +8,7 @@ import com.hbm.inventory.container.ContainerCraneGrabber;
import com.hbm.inventory.gui.GUICraneGrabber;
import com.hbm.items.ModItems;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.IFilterable;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.util.InventoryUtil;
@ -19,6 +20,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -29,7 +31,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import java.util.List;
public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIProvider, IControlReceiver {
public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIProvider, IFilterable {
public boolean isWhitelist = false;
public ModulePatternMatcher matcher;
@ -38,7 +40,8 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP
super(11);
this.matcher = new ModulePatternMatcher(9);
}
@Override
public void nextMode(int i) {
this.matcher.nextMode(worldObj, slots[i], i);
}
@ -194,5 +197,17 @@ public class TileEntityCraneGrabber extends TileEntityCraneBase implements IGUIP
if(data.hasKey("whitelist")) {
this.isWhitelist = !this.isWhitelist;
}
if(data.hasKey("slot")){
setFilterContents(data);
}
}
@Override
public void setFilterContents(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
setInventorySlotContents(
slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot);
markChanged();
}
}

View File

@ -4,6 +4,7 @@ import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.container.ContainerCraneRouter;
import com.hbm.inventory.gui.GUICraneRouter;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.IFilterable;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
@ -12,12 +13,13 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class TileEntityCraneRouter extends TileEntityMachineBase implements IGUIProvider, IControlReceiver {
public class TileEntityCraneRouter extends TileEntityMachineBase implements IGUIProvider, IFilterable {
public ModulePatternMatcher[] patterns = new ModulePatternMatcher[6]; //why did i make six matchers???
public int[] modes = new int[6];
@ -76,7 +78,7 @@ public class TileEntityCraneRouter extends TileEntityMachineBase implements IGUI
public GuiScreen provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
return new GUICraneRouter(player.inventory, this);
}
@Override
public void nextMode(int index) {
int matcher = index / 5;
@ -123,9 +125,23 @@ public class TileEntityCraneRouter extends TileEntityMachineBase implements IGUI
@Override
public void receiveControl(NBTTagCompound data) {
int i = data.getInteger("toggle");
modes[i]++;
if(modes[i] > 3)
modes [i] = 0;
if(data.hasKey("toggle")) {
int i = data.getInteger("toggle");
modes[i]++;
if (modes[i] > 3)
modes[i] = 0;
}
if(data.hasKey("slot")){
setFilterContents(data);
}
}
@Override
public void setFilterContents(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
setInventorySlotContents(
slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot);
markChanged();
}
}

View File

@ -3,12 +3,14 @@ package com.hbm.tileentity.network;
import java.util.ArrayList;
import java.util.List;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.RecipesCommon.AStack;
import com.hbm.inventory.RecipesCommon.ComparableStack;
import com.hbm.inventory.RecipesCommon.OreDictStack;
import com.hbm.inventory.container.ContainerDroneRequester;
import com.hbm.inventory.gui.GUIDroneRequester;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.IFilterable;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.INBTPacketReceiver;
import com.hbm.tileentity.network.RequestNetwork.PathNode;
@ -20,12 +22,14 @@ import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
public class TileEntityDroneRequester extends TileEntityRequestNetworkContainer implements INBTPacketReceiver, IGUIProvider {
public class TileEntityDroneRequester extends TileEntityRequestNetworkContainer implements INBTPacketReceiver, IGUIProvider, IFilterable {
public ModulePatternMatcher matcher;
@ -55,7 +59,8 @@ public class TileEntityDroneRequester extends TileEntityRequestNetworkContainer
public void networkUnpack(NBTTagCompound nbt) {
this.matcher.readFromNBT(nbt);
}
@Override
public void nextMode(int i) {
this.matcher.nextMode(worldObj, slots[i], i);
}
@ -122,4 +127,19 @@ public class TileEntityDroneRequester extends TileEntityRequestNetworkContainer
}
return new RequestNode(pos, this.reachableNodes, request);
}
@Override
public boolean hasPermission(EntityPlayer player) {
return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 20;
}
@Override
public void setFilterContents(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
setInventorySlotContents(
slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot);
markChanged();
}
}

View File

@ -2,17 +2,19 @@ package com.hbm.tileentity.network;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.module.ModulePatternMatcher;
import com.hbm.tileentity.IFilterable;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.Compat;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityRadioTorchCounter extends TileEntityMachineBase implements IControlReceiver {
public class TileEntityRadioTorchCounter extends TileEntityMachineBase implements IFilterable {
public String[] channel;
public int[] lastCount;
@ -31,6 +33,10 @@ public class TileEntityRadioTorchCounter extends TileEntityMachineBase implement
public String getName() {
return "container.rttyCounter";
}
@Override
public void nextMode(int i) {
this.matcher.nextMode(worldObj, slots[i], i);
}
@Override
public void updateEntity() {
@ -123,5 +129,18 @@ public class TileEntityRadioTorchCounter extends TileEntityMachineBase implement
}
this.markChanged();
}
if(data.hasKey("slot")){
setFilterContents(data);
}
}
@Override
public void setFilterContents(NBTTagCompound nbt) {
int slot = nbt.getInteger("slot");
setInventorySlotContents(
slot,
new ItemStack(Item.getItemById(nbt.getInteger("id")), 1, nbt.getInteger("meta")));
nextMode(slot);
markChanged();
}
}