mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
well that was stupid
This commit is contained in:
parent
775126f0ba
commit
8113546777
@ -182,14 +182,14 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa
|
||||
this.zLevel = 0.0F;
|
||||
itemRender.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
|
||||
public static final ItemStack TEMPLATE_FOLDER = new ItemStack(ModItems.template_folder);
|
||||
|
||||
|
||||
/** Standardsized item rendering from GUIScreenRecipeSelector */
|
||||
public void renderItem(ItemStack stack, int x, int y) {
|
||||
renderItem(stack, x, y, 100F);
|
||||
}
|
||||
|
||||
|
||||
public void renderItem(ItemStack stack, int x, int y, float layer) {
|
||||
FontRenderer font = stack.getItem().getFontRenderer(stack);
|
||||
if(font == null) font = fontRendererObj;
|
||||
@ -323,11 +323,11 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void click() {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
|
||||
|
||||
public void clickSendFlag(TileEntity tile, int x, int y, int left, int top, int sizeX, int sizeY, String name) {
|
||||
if(checkClick(x, y, left, top, sizeX, sizeY)) {
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
@ -336,29 +336,14 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa
|
||||
PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, tile.xCoord, tile.yCoord, tile.zCoord));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///NEI drag and drop support
|
||||
@Override
|
||||
@Optional.Method(modid = "NotEnoughItems")
|
||||
public boolean handleDragNDrop(GuiContainer gui, int x, int y, ItemStack stack, int button) {
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
// BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD! BALD!
|
||||
|
||||
/*if(gui instanceof GuiInfoContainer && stack != null){
|
||||
|
||||
if(gui instanceof GuiInfoContainer && stack != null){
|
||||
Slot slot = getSlotAtPosition(x,y);
|
||||
if(slot instanceof SlotPattern){
|
||||
if(inventorySlots instanceof ContainerBase) {
|
||||
@ -374,7 +359,7 @@ public abstract class GuiInfoContainer extends GuiContainer implements INEIGuiHa
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//all credits for impl to GTNH's EnderCore fork
|
||||
|
||||
@ -27,7 +27,7 @@ public abstract class TileEntityPneumaticStorageBase extends TileEntityMachineBa
|
||||
|
||||
public FluidTank compair;
|
||||
public SlotMonitor[] monitors;
|
||||
|
||||
|
||||
protected PneumaticNode node;
|
||||
protected boolean wasAvailable = false;
|
||||
|
||||
@ -35,7 +35,7 @@ public abstract class TileEntityPneumaticStorageBase extends TileEntityMachineBa
|
||||
super(slots);
|
||||
this.compair = new FluidTank(Fluids.AIR, 4_000).withPressure(1);
|
||||
this.monitors = new SlotMonitor[slots];
|
||||
|
||||
|
||||
for(int i = 0; i < monitors.length; i++) this.monitors[i] = new SlotMonitor(i, this);
|
||||
}
|
||||
|
||||
@ -58,43 +58,43 @@ public abstract class TileEntityPneumaticStorageBase extends TileEntityMachineBa
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
|
||||
boolean isAvailable = this.isAvailable();
|
||||
|
||||
|
||||
if(isAvailable != wasAvailable) {
|
||||
this.wasAvailable = isAvailable;
|
||||
for(SlotMonitor monitor : monitors) monitor.availabilityHasChanged();
|
||||
}
|
||||
|
||||
|
||||
if(this.node == null || this.node.expired) {
|
||||
this.node = (PneumaticNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
||||
|
||||
|
||||
if(this.node == null || this.node.expired) {
|
||||
this.node = (PneumaticNode) new PneumaticNode(new BlockPos(xCoord, yCoord, zCoord)).setStandardConnections(xCoord, yCoord, zCoord);
|
||||
UniNodespace.createNode(worldObj, this.node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(node != null && !node.expired && node.hasValidNet()) {
|
||||
this.node.net.storages.add(this);
|
||||
}
|
||||
|
||||
|
||||
if(worldObj.getTotalWorldTime() % 10 == 0) for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
this.trySubscribe(compair.getTankType(), worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
}
|
||||
|
||||
|
||||
if(this.compair.getFill() > 0) {
|
||||
int consumption = (int) Math.ceil(this.compair.getFill() * 9 / this.compair.getMaxFill()) + 1;
|
||||
this.compair.setFill(Math.max(this.compair.getFill() - consumption, 0));
|
||||
}
|
||||
|
||||
|
||||
this.updateMonitors();
|
||||
this.networkPackNT(15);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isAvailable() {
|
||||
return this.isLoaded && !this.isInvalid() && this.compair.getFill() > 0;
|
||||
}
|
||||
@ -104,30 +104,30 @@ public abstract class TileEntityPneumaticStorageBase extends TileEntityMachineBa
|
||||
super.invalidate();
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
|
||||
for(SlotMonitor monitor : this.monitors) {
|
||||
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||
}
|
||||
|
||||
|
||||
if(this.node != null) {
|
||||
|
||||
|
||||
if(node.hasValidNet()) {
|
||||
this.node.net.storages.remove(this);
|
||||
}
|
||||
|
||||
|
||||
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, PneumaticNetworkProvider.THE_PROVIDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
|
||||
|
||||
for(SlotMonitor monitor : this.monitors) {
|
||||
for(CacheSlot cache : monitor.viewedBy) cache.removeMonitor(monitor);
|
||||
}
|
||||
|
||||
|
||||
if(node != null && node.hasValidNet()) {
|
||||
this.node.net.storages.remove(this);
|
||||
}
|
||||
|
||||
@ -14,13 +14,15 @@ import api.hbm.redstoneoverradio.IRORInteractive;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
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.minecraft.world.World;
|
||||
|
||||
public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineBase implements IRORInteractive, IControlReceiver, IControlReceiverFilter {
|
||||
|
||||
|
||||
/** If requests should be pulled repeatedly every tick */
|
||||
public boolean continuousRequest = false;
|
||||
/** If ROR configuration has taken place, ignore manually defined filters entirely */
|
||||
@ -39,9 +41,9 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
public static final int MODE_FULL_STACK = 1;
|
||||
/** All request slots try to pull the desired quantities simultaneously */
|
||||
public static final int MODE_FULL_REQUEST = 2;
|
||||
|
||||
|
||||
public boolean lastRedstone = false;
|
||||
|
||||
|
||||
public int[] SLOT_ACCESS = new int[] {9, 10, 11, 12, 13, 14, 15, 16, 17};
|
||||
|
||||
public TileEntityPneumoStorageExporter() {
|
||||
@ -59,45 +61,45 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
|
||||
if(!worldObj.isRemote) {
|
||||
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
if(slotDelay[i] > 0) slotDelay[i]--;
|
||||
}
|
||||
|
||||
boolean redstone = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||
|
||||
|
||||
if(continuousRequest) {
|
||||
this.doRequest(false);
|
||||
} else {
|
||||
if(redstone && !lastRedstone) this.doRequest(true);
|
||||
}
|
||||
|
||||
|
||||
this.lastRedstone = redstone;
|
||||
|
||||
|
||||
this.networkPackNT(15);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void doRequest(boolean force) {
|
||||
|
||||
|
||||
if(this.requestMode != MODE_FULL_REQUEST) {
|
||||
// handle all filters individually
|
||||
for(int i = 0; i < 9; i++) if(!requestSlot(i, force)) this.slotDelay[i] = SLOT_DELAY;
|
||||
} else {
|
||||
|
||||
|
||||
// check filter delay if forced pulls aren't active
|
||||
if(!force) for(int i = 0; i < 9; i++) {
|
||||
short[] filter = this.getFilter(i);
|
||||
if(filter != null && slotDelay[i] > 0) return;
|
||||
}
|
||||
|
||||
|
||||
// check if filter demands are met and space is free
|
||||
for(int i = 0; i < 9; i++) {
|
||||
short[] filter = this.getFilter(i);
|
||||
if(filter == null) continue;
|
||||
|
||||
|
||||
int itemId = filter[0];
|
||||
Item item = Item.getItemById(itemId);
|
||||
int meta = filter[1];
|
||||
@ -105,7 +107,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
|
||||
int existingSize = 0;
|
||||
ItemStack existingStack = slots[i + 9];
|
||||
|
||||
|
||||
if(existingStack != null) {
|
||||
if(existingStack.getItem() == item && existingStack.getItemDamage() == meta && !existingStack.hasTagCompound()) {
|
||||
existingSize = existingStack.stackSize;
|
||||
@ -114,21 +116,21 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ItemStack newStack = new ItemStack(item, 1, meta);
|
||||
int capacityLeft = newStack.getMaxStackSize() - existingSize;
|
||||
|
||||
|
||||
if(capacityLeft < requestSize || getAvailability(itemId, meta) < requestSize) {
|
||||
this.slotDelay[i] = SLOT_DELAY;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// everything is good, pull items. continues should not happen, but are in place nonetheless
|
||||
for(int i = 0; i < 9; i++) {
|
||||
short[] filter = this.getFilter(i);
|
||||
if(filter == null) continue;
|
||||
|
||||
|
||||
int itemId = filter[0];
|
||||
Item item = Item.getItemById(itemId);
|
||||
int meta = filter[1];
|
||||
@ -137,40 +139,40 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
int existingSize = 0;
|
||||
ItemStack existingStack = slots[i + 9];
|
||||
if(existingStack != null) existingSize = existingStack.stackSize;
|
||||
|
||||
|
||||
ItemStack newStack = new ItemStack(item, 1, meta);
|
||||
|
||||
|
||||
long hash = StackCache.getStackIdentity(itemId, meta, null);
|
||||
if(hash == this.cache.getNullIdentity()) continue; // safeguard
|
||||
|
||||
|
||||
CacheSlot cacheSlot = this.cache.cacheSlots.get(hash);
|
||||
if(cacheSlot == null) continue; // safeguard
|
||||
|
||||
|
||||
slots[i + 9] = newStack;
|
||||
slots[i + 9].stackSize = existingSize + (int) this.cache.consumeItemsAndReturnQuantity(newStack, requestSize);
|
||||
}
|
||||
|
||||
|
||||
this.markChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Returns false if the slot delay should be reset (unsuccessful) or true of not (successful or delay still active) */
|
||||
public boolean requestSlot(int slot, boolean force) {
|
||||
|
||||
|
||||
if(!force && slotDelay[slot] > 0) return true;
|
||||
if(this.cache == null || this.cache.hasExpired) return false;
|
||||
|
||||
|
||||
short[] filter = this.getFilter(slot);
|
||||
if(filter == null) return false;
|
||||
|
||||
|
||||
int itemId = filter[0];
|
||||
Item item = Item.getItemById(itemId);
|
||||
int meta = filter[1];
|
||||
int requestSize = filter[2];
|
||||
|
||||
|
||||
int existingSize = 0;
|
||||
ItemStack existingStack = slots[slot + 9];
|
||||
|
||||
|
||||
if(existingStack != null) {
|
||||
if(existingStack.getItem() == item && existingStack.getItemDamage() == meta && !existingStack.hasTagCompound()) {
|
||||
existingSize = existingStack.stackSize;
|
||||
@ -178,31 +180,31 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ItemStack newStack = new ItemStack(item, 1, meta);
|
||||
int capacityLeft = newStack.getMaxStackSize() - existingSize;
|
||||
|
||||
|
||||
// any non-AMAP mode will fail if it can't insert that much before we even check availability from the pneumo sys
|
||||
if(capacityLeft < requestSize && this.requestMode != MODE_AS_MUCH_AS_POSSIBLE) return false;
|
||||
long hash = StackCache.getStackIdentity(itemId, meta, null);
|
||||
if(hash == this.cache.getNullIdentity()) return false;
|
||||
|
||||
|
||||
CacheSlot cacheSlot = this.cache.cacheSlots.get(hash);
|
||||
if(cacheSlot == null) return false;
|
||||
|
||||
|
||||
// any non-AMAP mode will fail if the system doesn't have the requested amount
|
||||
if(cacheSlot.stacksize < requestSize && this.requestMode != MODE_AS_MUCH_AS_POSSIBLE) return false;
|
||||
if(cacheSlot.stacksize <= 0) return false;
|
||||
|
||||
|
||||
int toPull = (int) BobMathUtil.min(requestSize, cacheSlot.stacksize, capacityLeft);
|
||||
|
||||
|
||||
slots[slot + 9] = newStack;
|
||||
slots[slot + 9].stackSize = existingSize + (int) this.cache.consumeItemsAndReturnQuantity(newStack, toPull);
|
||||
this.markChanged();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** Returns item id, meta and request size for the given filter. Returns null if no filter is specified */
|
||||
public short[] getFilter(int slot) {
|
||||
if(rorConfiguredMode) {
|
||||
@ -216,7 +218,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public long getAvailability(int item, int meta) {
|
||||
if(this.cache == null || this.cache.hasExpired) return 0;
|
||||
long hash = this.cache.getStackIdentity(item, meta, null);
|
||||
@ -255,7 +257,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
|
||||
this.continuousRequest = nbt.getBoolean("continuousRequest");
|
||||
this.rorConfiguredMode = nbt.getBoolean("rorConfiguredMode");
|
||||
this.requestMode = nbt.getByte("requestMode");
|
||||
@ -264,7 +266,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
rorFilters[i][1] = nbt.getShort("filter_" + i + "_1");
|
||||
rorFilters[i][2] = nbt.getShort("filter_" + i + "_2");
|
||||
}
|
||||
|
||||
|
||||
this.lastRedstone = nbt.getBoolean("lastRedstone");
|
||||
this.slotDelay = nbt.getIntArray("slotDelay");
|
||||
}
|
||||
@ -276,7 +278,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
nbt.setBoolean("continuousRequest", continuousRequest);
|
||||
nbt.setBoolean("rorConfiguredMode", rorConfiguredMode);
|
||||
nbt.setByte("requestMode", (byte) requestMode);
|
||||
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
nbt.setShort("filter_" + i + "_0", (short) rorFilters[i][0]);
|
||||
nbt.setShort("filter_" + i + "_1", (short) rorFilters[i][1]);
|
||||
@ -318,6 +320,18 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
@Override
|
||||
public void nextMode(int i) { }
|
||||
|
||||
@Override
|
||||
public void setFilterContents(NBTTagCompound nbt) {
|
||||
TileEntity tile = (TileEntity) this;
|
||||
IInventory inv = (IInventory) this;
|
||||
int slot = nbt.getInteger("slot");
|
||||
NBTTagCompound stack = nbt.getCompoundTag("stack");
|
||||
ItemStack item = ItemStack.loadItemStackFromNBT(stack);
|
||||
inv.setInventorySlotContents(slot, item);
|
||||
nextMode(slot);
|
||||
tile.getWorldObj().markTileEntityChunkModified(tile.xCoord, tile.yCoord, tile.zCoord, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getFunctionInfo() {
|
||||
return new String[] {
|
||||
@ -331,7 +345,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
|
||||
@Override
|
||||
public String runRORFunction(String name, String[] params) {
|
||||
|
||||
|
||||
if((PREFIX_FUNCTION + "setfilter").equals(name) && params.length == 4) {
|
||||
int slot = IRORInteractive.parseInt(params[0], 1, 9) - 1;
|
||||
int itemId = IRORInteractive.parseInt(params[1], 0, Short.MAX_VALUE);
|
||||
@ -344,25 +358,25 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
this.markChanged();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if((PREFIX_FUNCTION + "setcontinuous").equals(name) && params.length == 1) {
|
||||
if("on".equals(params[0])) this.continuousRequest = true;
|
||||
if("off".equals(params[0])) this.continuousRequest = false;
|
||||
this.markChanged();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if((PREFIX_FUNCTION + "request").equals(name)) {
|
||||
this.doRequest(true);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if((PREFIX_FUNCTION + "requestslot").equals(name) && params.length == 1) {
|
||||
int slot = IRORInteractive.parseInt(params[0], 1, 9) - 1;
|
||||
if(!this.requestSlot(slot, true)) this.slotDelay[slot] = SLOT_DELAY;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if((PREFIX_FUNCTION + "checkavailability").equals(name) && params.length == 3) {
|
||||
int itemId = IRORInteractive.parseInt(params[0], 0, Short.MAX_VALUE);
|
||||
int meta = IRORInteractive.parseInt(params[1], 0, Short.MAX_VALUE);
|
||||
@ -371,7 +385,7 @@ public class TileEntityPneumoStorageExporter extends TileEntityPneumaticMachineB
|
||||
RTTYSystem.broadcast(worldObj, ret, availability + "");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,18 +12,20 @@ import api.hbm.ntl.ISlotMonitorProvider;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileEntityPneumoStorageMono extends TileEntityPneumaticStorageBase implements IPneumaticConnector, IFluidStandardReceiverMK2, ISlotMonitorProvider, IControlReceiver, IGUIProvider, IControlReceiverFilter {
|
||||
|
||||
public static final int CAPACITY = 100_000;
|
||||
public int[] amounts;
|
||||
|
||||
|
||||
public TileEntityPneumoStorageMono() {
|
||||
super(3);
|
||||
|
||||
|
||||
this.amounts = new int[this.monitors.length];
|
||||
}
|
||||
|
||||
@ -65,10 +67,30 @@ public class TileEntityPneumoStorageMono extends TileEntityPneumaticStorageBase
|
||||
public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
return new GUIPneumoStorageMono(player.inventory, this);
|
||||
}
|
||||
|
||||
|
||||
@Override public long getAmountAt(int index) { return amounts[index]; }
|
||||
@Override public boolean allowTypeSetting() { return false; }
|
||||
|
||||
@Override
|
||||
public void receiveControl(NBTTagCompound data) {
|
||||
super.receiveControl(data);
|
||||
if(data.hasKey("slot")){
|
||||
setFilterContents(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterContents(NBTTagCompound nbt) {
|
||||
TileEntity tile = (TileEntity) this;
|
||||
IInventory inv = (IInventory) this;
|
||||
int slot = nbt.getInteger("slot");
|
||||
NBTTagCompound stack = nbt.getCompoundTag("stack");
|
||||
ItemStack item = ItemStack.loadItemStackFromNBT(stack);
|
||||
inv.setInventorySlotContents(slot, item);
|
||||
nextMode(slot);
|
||||
tile.getWorldObj().markTileEntityChunkModified(tile.xCoord, tile.yCoord, tile.zCoord, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long useUpItem(int index, long amount) {
|
||||
if(amounts[index] <= 0) return amount;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user