Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

rowan662

Members
  • Joined

  • Last visited

Everything posted by rowan662

  1. withConfiguration is also not a function for me. I'm using Forge 1.15.2 - 31.1.0
  2. This is the container class code package com.rowan662.infinitycraft.machines; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IContainerListener; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerCompressor extends Container { private final IInventory tileCompressor; private int workTime; private int totalWorkTime; private int compressorWorkTime; private int currentItemWorkTime; public ContainerCompressor(InventoryPlayer playerInventory, IInventory compressorInventory){ this.tileCompressor = compressorInventory; this.addSlotToContainer(new Slot(compressorInventory, 0, 56, 17)); this.addSlotToContainer(new SlotCompressorFuel(compressorInventory, 1, 56, 53)); this.addSlotToContainer(new SlotCompressorOutput(playerInventory.player, compressorInventory, 2, 116, 35)); for(int i = 0; i < 3; ++i){ for(int j = 0; j < 9; ++j){ this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for(int i = 0; i < 9; ++i){ this.addSlotToContainer(new Slot(playerInventory, i, 8 + i * 18, 142)); } } @Override public void addListener(IContainerListener listener){ super.addListener(listener); listener.sendAllWindowProperties(this, this.tileCompressor); } @Override public void detectAndSendChanges(){ super.detectAndSendChanges(); for(int i = 0; i < this.listeners.size(); ++i){ IContainerListener icontainerlistener = (IContainerListener)this.listeners.get(i); if(this.workTime != this.tileCompressor.getField(2)){ icontainerlistener.sendProgressBarUpdate(this, 2, this.tileCompressor.getField(2)); } if(this.compressorWorkTime != this.tileCompressor.getField(0)){ icontainerlistener.sendProgressBarUpdate(this, 0, this.tileCompressor.getField(0)); } if(this.currentItemWorkTime != this.tileCompressor.getField(1)){ icontainerlistener.sendProgressBarUpdate(this, 1, this.tileCompressor.getField(1)); } if(this.totalWorkTime != this.tileCompressor.getField(3)){ icontainerlistener.sendProgressBarUpdate(this, 3, this.tileCompressor.getField(3)); } } this.workTime = this.tileCompressor.getField(2); this.compressorWorkTime = this.tileCompressor.getField(0); this.currentItemWorkTime = this.tileCompressor.getField(1); this.totalWorkTime = this.tileCompressor.getField(3); } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int id, int data){ this.tileCompressor.setField(id, data); } @Override public boolean canInteractWith(EntityPlayer playerIn){ return this.tileCompressor.isUsableByPlayer(playerIn); } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = (Slot)this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index == 2) { if (!this.mergeItemStack(itemstack1, 3, 39, true)) { return ItemStack.EMPTY; } slot.onSlotChange(itemstack1, itemstack); } else if (index != 1 && index != 0) { if (!FurnaceRecipes.instance().getSmeltingResult(itemstack1).isEmpty()) { if (!this.mergeItemStack(itemstack1, 0, 1, false)) { return ItemStack.EMPTY; } } else if (TileEntityFurnace.isItemFuel(itemstack1)) { if (!this.mergeItemStack(itemstack1, 1, 2, false)) { return ItemStack.EMPTY; } } else if (index >= 3 && index < 30) { if (!this.mergeItemStack(itemstack1, 30, 39, false)) { return ItemStack.EMPTY; } } else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(playerIn, itemstack1); } return itemstack; } }
  3. When I want to acces my block, the slots of the container won't show. I got here a screenshot and the error. https://www.dropbox.com/s/631itzs3gcbnik3/2017-01-24_13.11.50.png?dl=0 [13:11:46] [Client thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.IndexOutOfBoundsException: Index: 36, Size: 36 at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_101] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_101] at net.minecraft.util.Util.runTask(Util.java:27) [util.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1109) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:407) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_101] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_101] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] Caused by: java.lang.IndexOutOfBoundsException: Index: 36, Size: 36 at java.util.ArrayList.rangeCheck(Unknown Source) ~[?:1.8.0_101] at java.util.ArrayList.get(Unknown Source) ~[?:1.8.0_101] at net.minecraft.inventory.Container.getSlot(Container.java:128) ~[Container.class:?] at net.minecraft.inventory.Container.setAll(Container.java:547) ~[Container.class:?] at net.minecraft.client.network.NetHandlerPlayClient.handleWindowItems(NetHandlerPlayClient.java:1305) ~[NetHandlerPlayClient.class:?] at net.minecraft.network.play.server.SPacketWindowItems.processPacket(SPacketWindowItems.java:72) ~[sPacketWindowItems.class:?] at net.minecraft.network.play.server.SPacketWindowItems.processPacket(SPacketWindowItems.java:13) ~[sPacketWindowItems.class:?] at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_101] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_101] at net.minecraft.util.Util.runTask(Util.java:26) ~[util.class:?] ... 15 more
  4. And how can I implement that? I also got an error for the void return type of public void writeToNBT @Override public void readFromNBT(NBTTagCompound compound){ super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("Items", 10); compressorItemStackArray = new ItemStack[getSizeInventory()]; for(int i = 0; i < nbttaglist.tagCount(); i++){ NBTTagCompound nbtTagCompound = nbttaglist.getCompoundTagAt(i); byte b0 = nbtTagCompound.getByte("Slot"); if(b0 >= 0 && b0 < compressorItemStackArray.length){ compressorItemStackArray[b0] = ItemStack.loadItemStackFromNBT(nbtTagCompound); } } timeCanWork = compound.getShort("WorkTime"); ticksCompressingItemSoFar = compound.getShort("CompressTime"); ticksPerItem = compound.getShort("CompressTimeTotal"); if(compound.hasKey("CustomName", ){ compressorCustomName = compound.getString("CustomName"); } } @Override public void writeToNBT(NBTTagCompound compound){ super.writeToNBT(compound); compound.setShort("WorkTime", (short)timeCanWork); compound.setShort("CompressTime", (short)ticksCompressingItemSoFar); compound.setShort("ticksPerItem", (short)ticksPerItem); NBTTagList nbttaglist = new NBTTagList(); for(int i = 0; i < compressorItemStackArray.length; i++){ if(compressorItemStackArray[i] != null){ NBTTagCompound nbtTagCompound = new NBTTagCompound(); nbtTagCompound.setByte("Slot", (byte)i); compressorItemStackArray[i].writeToNBT(nbtTagCompound); nbttaglist.appendTag(nbtTagCompound); } } compound.setTag("Items", nbttaglist); if(hasCustomName()){ compound.setString("CustomName", compressorCustomName); } }
  5. Does anyone knows how I can call ItemStack.loadItemStackFromNBT(); in 1.11.2? It seems like something has changed.
  6. That is what I was looking for, thanks!
  7. Hi guys, I just updated my mod from 1.8 to 1.8.9, but now that I updated it, my TileEntity doesn' t work anymore. There are no errors shown in eclipse, so I can' t figure out what it is. It supposed to be a machine (e.g. furnace) but when I put anything in it, there is no progress so I think it has something to do with the update function. Has anything changed in 1.8.9? Here is the code: package com.rowan662.infinitycraft.machines.tileentity; import com.rowan662.infinitycraft.machines.BlockCompressor; import com.rowan662.infinitycraft.machines.container.ContainerCompressor; import com.rowan662.infinitycraft.machines.recipes.CompressorRecipes; import net.minecraft.block.state.IBlockState; 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.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntityLockable; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityCompressor extends TileEntityLockable implements ISidedInventory { public enum slotEnum{ INPUT_SLOT, OUTPUT_SLOT } private static final int[] slotsTop = new int[]{slotEnum.INPUT_SLOT.ordinal()}; private static final int[] slotsBottom = new int[]{slotEnum.OUTPUT_SLOT.ordinal()}; private static final int[] slotsSides = new int[]{}; private ItemStack[] compressorItemStackArray = new ItemStack[2]; private int timeCanCompress; private int currentItemCompressTime; private int ticksCompressingItemSoFar; private int ticksPerItem; private String compressorCustomName; @Override public boolean shouldRefresh(World parWorld, BlockPos parPos, IBlockState parOldState, IBlockState parNewState){ return false; } @Override public int getSizeInventory(){ return compressorItemStackArray.length; } @Override public ItemStack getStackInSlot(int index){ return compressorItemStackArray[index]; } @Override public ItemStack decrStackSize(int index, int count){ if(compressorItemStackArray[index] != null){ ItemStack itemStack; if(compressorItemStackArray[index].stackSize <= count){ itemStack = compressorItemStackArray[index]; compressorItemStackArray[index] = null; return itemStack; } else { itemStack = compressorItemStackArray[index].splitStack(count); if(compressorItemStackArray[index].stackSize == 0){ compressorItemStackArray[index] = null; } return itemStack; } } else { return null; } } @Override public ItemStack removeStackFromSlot(int index) { if (this.compressorItemStackArray[index] != null) { ItemStack itemstack = this.compressorItemStackArray[index]; this.compressorItemStackArray[index] = null; return itemstack; } else { return null; } } @Override public void setInventorySlotContents(int index, ItemStack stack){ boolean isSameItemStackAlreadyInSlot = stack != null && stack.isItemEqual(compressorItemStackArray[index]) && ItemStack.areItemStackTagsEqual(stack, compressorItemStackArray[index]); compressorItemStackArray[index] = stack; if(stack != null && stack.stackSize > getInventoryStackLimit()){ stack.stackSize = getInventoryStackLimit(); } if(index == slotEnum.INPUT_SLOT.ordinal() && !isSameItemStackAlreadyInSlot){ ticksPerItem = timeToCompressOneItem(stack); ticksCompressingItemSoFar = 0; markDirty(); } } @Override public String getName(){ return hasCustomName() ? compressorCustomName : "container.compressor"; } @Override public boolean hasCustomName(){ return compressorCustomName != null && compressorCustomName.length() > 0; } public void setCustomInventoryName(String parCustomName){ compressorCustomName = parCustomName; } @Override public void readFromNBT(NBTTagCompound compound){ super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("items", 10); compressorItemStackArray = new ItemStack[getSizeInventory()]; for(int i = 0; i < nbttaglist.tagCount(); i++){ NBTTagCompound nbtTagCompound = nbttaglist.getCompoundTagAt(i); byte b0 = nbtTagCompound.getByte("Slot"); if(b0 >= 0 && b0 < compressorItemStackArray.length){ compressorItemStackArray[b0] = ItemStack.loadItemStackFromNBT(nbtTagCompound); } } timeCanCompress = compound.getShort("CompressTime"); ticksCompressingItemSoFar = compound.getShort("CookTime"); ticksPerItem = compound.getShort("CookTimeTotal"); if(compound.hasKey("CustomName", ){ compressorCustomName = compound.getString("CustomName"); } } @Override public void writeToNBT(NBTTagCompound compound){ super.writeToNBT(compound); compound.setShort("CompressTime", (short)timeCanCompress); compound.setShort("CookTime", (short)ticksCompressingItemSoFar); compound.setShort("CookTimeTotal", (short)ticksPerItem); NBTTagList nbttaglist = new NBTTagList(); for(int i = 0; i < compressorItemStackArray.length; i++){ if(compressorItemStackArray[i] != null){ NBTTagCompound nbtTagCompound = new NBTTagCompound(); nbtTagCompound.setByte("Slot", (byte)i); compressorItemStackArray[i].writeToNBT(nbtTagCompound); nbttaglist.appendTag(nbtTagCompound); } } compound.setTag("items", nbttaglist); if(hasCustomName()){ compound.setString("CustomName", compressorCustomName); } } @Override public int getInventoryStackLimit(){ return 64; } public boolean compressingSomething(){ return true; } @SideOnly(Side.CLIENT) public static boolean func_174903_a(IInventory parIInventory){ return true; } public void update(){ boolean hasBeenCompressing = compressingSomething(); boolean changedCompressingState = false; if(compressingSomething()){ --timeCanCompress; } if(!worldObj.isRemote){ if(compressorItemStackArray[slotEnum.INPUT_SLOT.ordinal()] != null){ //Start Compressing if(!compressingSomething() && canCompress()){ timeCanCompress = 150; if(compressingSomething()){ changedCompressingState = true; } } //Continue compressing if(compressingSomething() && canCompress()){ ++ticksCompressingItemSoFar; if(ticksCompressingItemSoFar == ticksPerItem){ ticksCompressingItemSoFar = 0; ticksPerItem = timeToCompressOneItem(compressorItemStackArray[0]); compressItem(); changedCompressingState = true; } } else { ticksCompressingItemSoFar = 0; } } if(hasBeenCompressing != compressingSomething()){ changedCompressingState = true; BlockCompressor.changeBlockBasedOnCompressingStatus(compressingSomething(), worldObj, pos); } } if(changedCompressingState){ markDirty(); } } public int timeToCompressOneItem(ItemStack parItemStack){ return 200; } private boolean canCompress(){ // if nothing in input slot if (compressorItemStackArray[slotEnum.INPUT_SLOT.ordinal()] == null) { return false; } else // check if it has a grinding recipe { ItemStack itemStackToOutput = CompressorRecipes.instance().getCompressingResult(compressorItemStackArray[slotEnum.INPUT_SLOT.ordinal()]); if (itemStackToOutput == null) return false; if (compressorItemStackArray[slotEnum.OUTPUT_SLOT.ordinal()] == null){ return true; } if (!compressorItemStackArray[slotEnum.OUTPUT_SLOT.ordinal()].isItemEqual(itemStackToOutput)){ return false; } int result = compressorItemStackArray[slotEnum.OUTPUT_SLOT.ordinal()].stackSize + itemStackToOutput.stackSize; return result <= getInventoryStackLimit() && result <= compressorItemStackArray[slotEnum.OUTPUT_SLOT.ordinal()].getMaxStackSize(); } } public void compressItem(){ if(canCompress()){ ItemStack itemstack = CompressorRecipes.instance().getCompressingResult(compressorItemStackArray[slotEnum.INPUT_SLOT.ordinal()]); if(compressorItemStackArray[slotEnum.OUTPUT_SLOT.ordinal()] == null){ compressorItemStackArray[slotEnum.OUTPUT_SLOT.ordinal()] = itemstack.copy(); } else if(compressorItemStackArray[slotEnum.OUTPUT_SLOT.ordinal()].getItem() == itemstack.getItem()){ compressorItemStackArray[slotEnum.OUTPUT_SLOT.ordinal()].stackSize += itemstack.stackSize; } --compressorItemStackArray[slotEnum.INPUT_SLOT.ordinal()].stackSize; if(compressorItemStackArray[slotEnum.INPUT_SLOT.ordinal()].stackSize <= 0){ compressorItemStackArray[slotEnum.INPUT_SLOT.ordinal()] = null; } } } @Override public boolean isUseableByPlayer(EntityPlayer playerIn){ return worldObj.getTileEntity(pos) != this ? false : playerIn.getDistanceSq(pos.getX()+0.5D, pos.getY()+0.5D, pos.getZ()+0.5D) <= 64.0D; } @Override public void openInventory(EntityPlayer playerIn){} @Override public void closeInventory(EntityPlayer playerIn){} @Override public boolean isItemValidForSlot(int index, ItemStack stack){ return index == slotEnum.INPUT_SLOT.ordinal() ? true : false; } @Override public int[] getSlotsForFace(EnumFacing side){ return side == EnumFacing.DOWN ? slotsBottom : (side == EnumFacing.UP ? slotsTop : slotsSides); } @Override public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction){ return isItemValidForSlot(index, itemStackIn); } @Override public boolean canExtractItem(int parSlotIndex, ItemStack parStack, EnumFacing parFacing){ return true; } @Override public String getGuiID(){ return "infinitycraft:compressor"; } @Override public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn){ //DEBUG System.out.println("TileEntityCompressor createContainer()"); return new ContainerCompressor(playerInventory, this); } @Override public int getField(int id){ switch(id){ case 0: return timeCanCompress; case 1: return currentItemCompressTime; case 2: return ticksCompressingItemSoFar; case 3: return ticksPerItem; default: return 0; } } @Override public void setField(int id, int value){ switch(id){ case 0: timeCanCompress = value; break; case 1: currentItemCompressTime = value; break; case 2: ticksCompressingItemSoFar = value; break; case 3: ticksPerItem = value; break; default: break; } } @Override public int getFieldCount(){ return 4; } @Override public void clear(){ for(int i = 0; i < compressorItemStackArray.length; i++){ compressorItemStackArray[i] = null; } } }
  8. And how to i show a text message with that?
  9. Yes, every time you load up a world and you need to see it every time
  10. Well, i've made a version checker for my mod, but is does check the version to match with the latest, but it doesn't show a text message when i load the world
  11. Hi, basically the title says it all. How can i show a chat message on world startup? Thanks!
  12. Hello, does anyone know how i can get my ore to drop 2 - 4 items? just like redstone. Thanks!
  13. Does anyone knows an answer yet?
  14. here you go: http://pastebin.com/7GK08w0L
  15. here is the full error log: http://pastebin.com/eTetV0sd
  16. rowan662 posted a topic in Modder Support
    Im getting this weird error when im trying to launch my mod: Can't free registry slot 165 occupied by net.minecraft.item.ItemBlock@6329dad4 can anyone help please?
  17. The tileentity is fixed, but now i get an error in my recipes code at line 75: http://pastebin.com/yb11FXQH please help
  18. here is the recipes class: http://pastebin.com/qC6VaaqC
  19. I really don't know how to fix it, here is the source code: http://pastebin.com/XwY5wCVd please help me
  20. So, i've made a custom furnace, but in my tile entity class it sais: The method getSmeltingResult(String) in the type Mod_Name is not applicable for the arguments (ItemStack) any help please?
  21. When i launch my mod, only the textures for the items work, not for the blocks. Has this anything to do with runDir? and if so, how do i fix it?

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.