use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class ModularStorageTileEntity method writeBufferToNBT.
private void writeBufferToNBT(NBTTagCompound tagCompound) {
// If sendToClient is true we have to send dummy information to the client
// so that it can remotely open gui's.
boolean sendToClient = isServer() && isRemote();
NBTTagList bufferTagList = new NBTTagList();
if (sendToClient) {
RemoteStorageTileEntity storageTileEntity = getRemoteStorage(remoteId);
if (storageTileEntity != null) {
ItemStackList slots = storageTileEntity.findStacksForId(remoteId);
for (ItemStack stack : slots) {
NBTTagCompound nbtTagCompound = new NBTTagCompound();
if (!stack.isEmpty()) {
stack.writeToNBT(nbtTagCompound);
}
bufferTagList.appendTag(nbtTagCompound);
}
}
} else {
for (int i = ModularStorageContainer.SLOT_STORAGE; i < inventoryHelper.getCount(); i++) {
ItemStack stack = inventoryHelper.getStackInSlot(i);
NBTTagCompound nbtTagCompound = new NBTTagCompound();
if (!stack.isEmpty()) {
stack.writeToNBT(nbtTagCompound);
}
bufferTagList.appendTag(nbtTagCompound);
}
}
tagCompound.setTag("Items", bufferTagList);
}
use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class ModularStorageTileEntity method containsItem.
private boolean containsItem(int index) {
if (isStorageAvailableRemotely(index)) {
index -= ModularStorageContainer.SLOT_STORAGE;
RemoteStorageTileEntity storageTileEntity = getRemoteStorage(remoteId);
if (storageTileEntity == null) {
return false;
}
ItemStackList slots = storageTileEntity.findStacksForId(remoteId);
if (index >= slots.size()) {
return false;
}
return !slots.get(index).isEmpty();
} else {
return inventoryHelper.containsItem(index);
}
}
use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class ModularStorageTileEntity method updateStackCount.
private void updateStackCount() {
numStacks = 0;
if (isServer() && isRemote()) {
RemoteStorageTileEntity storageTileEntity = getRemoteStorage(remoteId);
if (storageTileEntity == null) {
return;
}
int si = storageTileEntity.findRemoteIndex(remoteId);
if (si == -1) {
return;
}
ItemStackList stacks = storageTileEntity.getRemoteStacks(si);
for (int i = 0; i < Math.min(maxSize, stacks.size()); i++) {
if (!stacks.get(i).isEmpty()) {
numStacks++;
}
}
storageTileEntity.updateCount(si, numStacks);
} else {
for (int i = ModularStorageContainer.SLOT_STORAGE; i < ModularStorageContainer.SLOT_STORAGE + maxSize; i++) {
if (inventoryHelper.containsItem(i)) {
numStacks++;
}
}
}
StorageModuleItem.updateStackSize(getStackInSlot(ModularStorageContainer.SLOT_STORAGE_MODULE), numStacks);
}
use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class ModularStorageTileEntity method getStackInSlot.
@Override
public ItemStack getStackInSlot(int index) {
if (index >= getSizeInventory()) {
return ItemStack.EMPTY;
}
if (isStorageAvailableRemotely(index)) {
index -= ModularStorageContainer.SLOT_STORAGE;
RemoteStorageTileEntity storageTileEntity = getRemoteStorage(remoteId);
if (storageTileEntity == null) {
return ItemStack.EMPTY;
}
ItemStackList slots = storageTileEntity.findStacksForId(remoteId);
if (index >= slots.size()) {
return ItemStack.EMPTY;
}
return slots.get(index);
}
return inventoryHelper.getStackInSlot(index);
}
use of mcjty.lib.varia.ItemStackList in project RFTools by McJty.
the class GuiCrafter method drawGhostSlots.
private void drawGhostSlots() {
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
GlStateManager.pushMatrix();
GlStateManager.translate(guiLeft, guiTop, 0.0F);
GlStateManager.color(1.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.enableRescaleNormal();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (short) 240 / 1.0F, 240.0f);
ItemStackList ghostSlots = tileEntity.getGhostSlots();
zLevel = 100.0F;
itemRender.zLevel = 100.0F;
GlStateManager.enableDepth();
GlStateManager.disableBlend();
GlStateManager.enableLighting();
for (int i = 0; i < ghostSlots.size(); i++) {
ItemStack stack = ghostSlots.get(i);
if (!stack.isEmpty()) {
int slotIdx;
if (i < CrafterContainer.BUFFER_SIZE) {
slotIdx = i + CrafterContainer.SLOT_BUFFER;
} else {
slotIdx = i + CrafterContainer.SLOT_BUFFEROUT - CrafterContainer.BUFFER_SIZE;
}
Slot slot = inventorySlots.getSlot(slotIdx);
if (!slot.getHasStack()) {
itemRender.renderItemAndEffectIntoGUI(stack, slot.xPos, slot.yPos);
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.disableDepth();
this.mc.getTextureManager().bindTexture(iconGuiElements);
RenderHelper.drawTexturedModalRect(slot.xPos, slot.yPos, 14 * 16, 3 * 16, 16, 16);
GlStateManager.enableDepth();
GlStateManager.disableBlend();
GlStateManager.enableLighting();
}
}
}
itemRender.zLevel = 0.0F;
zLevel = 0.0F;
GlStateManager.popMatrix();
net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting();
}
Aggregations