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.

Darki

Members
  • Joined

  • Last visited

Everything posted by Darki

  1. No I changed this. In the method addSlot I changed the player inv to the tileentity inv but now there is a nullpointer exception. It seems like that the inventory is null but: public InventoryBasic inv; private static int ID = 0; public TileEntityChemicalMixer(){ inv = new InventoryBasic("Chemical Mixer", false, 3); } the inv gets a new Inventory? Here the Error: [12:29:36] [server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.NullPointerException 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:24) [util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:738) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:683) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:155) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:532) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_101] Caused by: java.lang.NullPointerException at me.darki.chemmix.containers.ContainerChemicalMixer.<init>(ContainerChemicalMixer.java:18) ~[ContainerChemicalMixer.class:?] at me.darki.chemmix.guis.GuiHandler.getServerGuiElement(GuiHandler.java:19) ~[GuiHandler.class:?] at net.minecraftforge.fml.common.network.NetworkRegistry.getRemoteGuiContainer(NetworkRegistry.java:244) ~[NetworkRegistry.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:80) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2693) ~[EntityPlayer.class:?] at me.darki.chemmix.blocks.BlockChemicalMixer.onBlockActivated(BlockChemicalMixer.java:36) ~[blockChemicalMixer.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:473) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processRightClickBlock(NetHandlerPlayServer.java:706) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:68) ~[CPacketPlayerTryUseItem.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:13) ~[CPacketPlayerTryUseItem.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:23) ~[util.class:?] ... 5 more and here the updated constructor: public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) { this.tileentiy = tileentity; this.addSlotToContainer(new Slot(tileentity.inv, 0, 30, 17)); this.addSlotToContainer(new Slot(tileentity.inv, 1, 130, 17)); this.addSlotToContainer(new OutputSlot(tileentity.inv, 2, 80, 51)); // Player Inventory, Slot 9-35, Slot IDs 9-35 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142)); } }
  2. Oh I see it I have to make addSlot (tileentity.inventory...)
  3. No here the same the like before:
  4. Ok that wasnt in the Tutorial...now I added it: public class BlockChemicalMixer extends BasicBlock{ public BlockChemicalMixer() { super(Material.rock, "chemicalmixer", 10F, Tool.PICKAXE, HarvestLevel.IRON); isBlockContainer = true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEntityChemicalMixer(); } @Override public boolean hasTileEntity() { return true; } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!world.isRemote){ player.openGui(Main.INSTANCE, GuiHandler.GUI_ID, world, pos.getX(), pos.getY(), pos.getZ()); } return true; } } is it right now?
  5. Hm I didnt do this wrong so you said...I did it...or not? I watched a Tutorial...and this is the solution from the Tutorial
  6. Ok...Is it possible, when I save the Inventory of the GUI in the NBTList (in TileEntity Class) save also the Blockpos of the Machine...so that I can identify the Gui to the BlockPos
  7. Ok I try it. but i instantitate the TileEntity in the Container Class: private TileEntityChemicalMixer tileentiy; And then: public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) { this.tileentiy = tileentity; this.addSlotToContainer(new Slot(inv, 36, 30, 17)); this.addSlotToContainer(new Slot(inv, 37, 130, 17)); this.addSlotToContainer(new OutputSlot(inv, 38, 80, 51)); // Player Inventory, Slot 9-35, Slot IDs 9-35 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142)); } }
  8. Of Course I instantitate my TileEntity in the GUI Handler: public class GuiHandler implements IGuiHandler{ public static final int GUI_ID = 0; @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == GUI_ID) return new ContainerChemicalMixer(player.inventory, (TileEntityChemicalMixer) world.getTileEntity(new BlockPos(x, y, z))); else if (ID == GUI_ID + 1) return new ContainerGenerator(player.inventory, (TileEntityGenerator) world.getTileEntity(new BlockPos(x, y, z))); return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID == GUI_ID) return new GuiChemicalMixer(new ContainerChemicalMixer(player.inventory, (TileEntityChemicalMixer) world.getTileEntity(new BlockPos(x, y, z)))); else if (ID == GUI_ID + 1) return new GuiGenerator(new ContainerGenerator(player.inventory, (TileEntityGenerator) world.getTileEntity(new BlockPos(x, y, z)))); return null; } }
  9. This is my Block Class: public class BlockChemicalMixer extends BasicBlock{ public BlockChemicalMixer() { super(Material.rock, "chemicalmixer", 10F, Tool.PICKAXE, HarvestLevel.IRON); } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!world.isRemote){ player.openGui(Main.INSTANCE, GuiHandler.GUI_ID, world, pos.getX(), pos.getY(), pos.getZ()); } return true; } } Nothing special. When you ask for the BasicBlock class here: public class BasicBlock extends Block{ public BasicBlock(Material m, String name, float hardness, Tool tool, HarvestLevel level) { super(m); setUnlocalizedName(name); setRegistryName(name); setHardness(hardness); setCreativeTab(Main.chemTab); setHarvestLevel(tool.getToolClass(), level.getLevel()); } enum HarvestLevel{ WOOD(0), STONE(1), IRON(2), GOLD(0), DIAMOND(3); private int level; private HarvestLevel(int level) { this.level = level; } private int getLevel(){ return this.level; } } enum Tool{ PICKAXE("pickaxe"), AXE("axe"), HOE("hoe"), SHOVEL("shovel"); private String toolClass; private Tool(String toolClass) { this.toolClass = toolClass; } private String getToolClass(){ return this.toolClass; } } }
  10. Hi, I am making a machine. With a GUI Container, the Container is working and also the TileEntity but now I see that when you place the machine twice the machines have the same TileEntity, so that in both machine are the same Inventories and Items. Here my Codes: TileEntity: public class TileEntityChemicalMixer extends TileEntity{ public InventoryBasic INVENTORY; private static int ID = 0; public TileEntityChemicalMixer(){ INVENTORY = new InventoryBasic("Chemical Mixer", false, 3); } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList list = new NBTTagList(); for(int i = 0; i < INVENTORY.getSizeInventory(); i++){ if(INVENTORY.getStackInSlot(i) != null){ NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); INVENTORY.getStackInSlot(i).writeToNBT(tag); list.appendTag(tag); } } compound.setTag("ItemStacks-" + ID, list); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList list = compound.getTagList("ItemStacks-" + ID, 10); this.INVENTORY = new InventoryBasic("Chemical Mixer", false, 3); for(int i = 0; i < list.tagCount(); i++){ NBTTagCompound tag = list.getCompoundTagAt(i); byte b = tag.getByte("Slot"); if(b >= 0 && b < INVENTORY.getSizeInventory()){ INVENTORY.setInventorySlotContents(b, ItemStack.loadItemStackFromNBT(tag)); } } } } Container: public class ContainerChemicalMixer extends Container{ private TileEntityChemicalMixer tileentiy; public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) { this.tileentiy = tileentity; this.addSlotToContainer(new Slot(inv, 36, 30, 17)); this.addSlotToContainer(new Slot(inv, 37, 130, 17)); this.addSlotToContainer(new OutputSlot(inv, 38, 80, 51)); // Player Inventory, Slot 9-35, Slot IDs 9-35 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142)); } } @Override public boolean canInteractWith(EntityPlayer playerIn) { return true; } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) { ItemStack previous = null; Slot slot = (Slot) this.inventorySlots.get(fromSlot); if (slot != null && slot.getHasStack()) { ItemStack current = slot.getStack(); previous = current.copy(); if (fromSlot < 9) { // From TE Inventory to Player Inventory if (!this.mergeItemStack(current, 9, 37, true)) return null; } else { // From Player Inventory to TE Inventory if (!this.mergeItemStack(current, 0, 9, false)) return null; } if (current.stackSize == 0) slot.putStack((ItemStack) null); else slot.onSlotChanged(); if (current.stackSize == previous.stackSize) return null; slot.onPickupFromSlot(playerIn, current); } return previous; } }
  11. Ahhh thanks...wow that was a bit stupid
  12. I have a Bug with my GUI Container...I want to make a Machine but there is a Bug with the Slots. I have a little Video from the Bug, here you can see: And here is the Code: TileEntity: public class TileEntityChemicalMixer extends TileEntity{ public InventoryBasic INVENTORY; public TileEntityChemicalMixer(){ INVENTORY = new InventoryBasic("Chemical Mixer", false, 3); } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); NBTTagList list = new NBTTagList(); for(int i = 0; i < INVENTORY.getSizeInventory(); i++){ if(INVENTORY.getStackInSlot(i) != null){ NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); INVENTORY.getStackInSlot(i).writeToNBT(tag); list.appendTag(tag); } } compound.setTag("ItemStacks", list); } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList list = compound.getTagList("ItemStacks", 10); this.INVENTORY = new InventoryBasic("Chemical Mixer", false, 3); for(int i = 0; i < list.tagCount(); i++){ NBTTagCompound tag = list.getCompoundTagAt(i); byte b = tag.getByte("Slot"); if(b >= 0 && b < INVENTORY.getSizeInventory()){ INVENTORY.setInventorySlotContents(b, ItemStack.loadItemStackFromNBT(tag)); } } } } Container: public class ContainerChemicalMixer extends Container{ private TileEntityChemicalMixer tileentiy; public ContainerChemicalMixer(IInventory inv, TileEntityChemicalMixer tileentity) { this.tileentiy = tileentity; this.addSlotToContainer(new Slot(inv, 0, 30, 17)); this.addSlotToContainer(new Slot(inv, 0, 130, 17)); // Player Inventory, Slot 9-35, Slot IDs 9-35 for (int y = 0; y < 3; ++y) { for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x + y * 9 + 9, 8 + x * 18, 84 + y * 18)); } } // Player Inventory, Slot 0-8, Slot IDs 36-44 for (int x = 0; x < 9; ++x) { this.addSlotToContainer(new Slot(inv, x, 8 + x * 18, 142)); } } @Override public boolean canInteractWith(EntityPlayer playerIn) { return true; } } And GUI: public class GuiChemicalMixer extends GuiContainer{ public static final ResourceLocation BACKGROUND = new ResourceLocation(Main.MODID + ":textures/gui/chemicalmixergui.png"); public GuiChemicalMixer(Container inventorySlotsIn) { super(inventorySlotsIn); this.ySize = 166; this.xSize = 176; } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { mc.renderEngine.bindTexture(BACKGROUND); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; drawTexturedModalRect(k, l, 0, 0, xSize, ySize); } }
  13. I found it but the tnt makes only a half heart damage can I change it so that the player dies instantly
  14. How can I spawn a Primed TNT over Players head? I know that I have to do something like that: EntityTNTPrimed tnt = new EntityTNTPrimed(w); tnt.fuse = 0; w.spawnEntityInWorld(tnt); But with this the TNT will spawning anywhere
  15. I would like to know how can I change Items to another Item. E.g.: You have a Iron Ingot, then you right click it and the Iron Ingot will removed and a Gold Ingot is there where the Iron Ingot was
  16. Yeah...Thanks a lot to all people^^
  17. I know how programming works but I never do GUIs
  18. Yes but how can I find out the location and how I have to paste them in the addSlot method?!
  19. I mean the Locations where later the 2 slots should be in the GUI
  20. Yes but how can I do this? From where I have to start counting the pixels
  21. Yes but I dont know how to find the location.
  22. Hey I am working on a Generator and I took the Furnace Gui, but I deleted the Output slot. So my Question is, how can I add the two slots on this picture: I know I have to do something like that: for(j = 0; j < 3; j++){ for(k = 0; k < 3; k++){ this.addSlotToContainer(new Slot(tileEntity.inventory, index++, 29 + k * 16 , 17 + j * 18)); } } But I don't know how I write the right Slot pos like in the code after index++.
  23. Do someone know how I can use the RedstoneFlux API?! Is there a Tutorial or a Wiki? How can I transfer Energy throw my Pipes? And How can I connect Machines with the pipes? And How I make e.g. a solarpanel to a provider and a machine to a receiver
  24. Thanks. I think to make the Energy System I look into the Code of Team CoFH's RedstoneFlux API

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.