Jump to content

gmod622

Members
  • Posts

    214
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    Some where, far, far away
  • Personal Text
    When life gives you lemons, you throw them away

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

gmod622's Achievements

Creeper Killer

Creeper Killer (4/8)

1

Reputation

  1. .. So something like this? @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return (T) this.furnaceItemStacks; } return super.getCapability(capability, facing); }
  2. One issue though, changing it from ISidedInventory gave me errors on these lines, what whould I change this to. net.minecraftforge.items.IItemHandler handlerTop = new net.minecraftforge.items.wrapper.SidedInvWrapper( this, net.minecraft.util.EnumFacing.UP); net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN); net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper( this, net.minecraft.util.EnumFacing.WEST);
  3. Hey all! So I was creating a 'coal generator' to create 'energy', however, I ran into some issues that I didn't know how to fix. Here are the issues: Not Burning Fuel On Reconnected, Items 'disappear' into your inventory, and cannot be interacted with, until you click the slot. NOTE: This is my attempt at creating a different TE and trying to learn from it. This was a learning experience, a lot of stuff WILL BE WRONG. Here is the TE package com.lambda.PlentifulMisc.blocks.tile; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.BlockFurnace; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.ContainerFurnace; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.inventory.SlotFurnaceFuel; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.item.ItemTool; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityLockable; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.datafix.FixTypes; import net.minecraft.util.datafix.walkers.ItemStackDataLists; import net.minecraft.util.math.MathHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class TileEntityCoalGenerator extends TileEntityLockable implements ITickable, ISidedInventory { private static final int[] SLOTS_FUEL = new int[] {0}; /** The ItemStacks that hold the items currently being used in the furnace */ private ItemStack[] furnaceItemStacks = new ItemStack[1]; /** The number of ticks that the furnace will keep burning */ private int fuelBurnTime; /** The number of ticks that a fresh copy of the currently-burning item would keep the furnace burning for */ private String coalGeneratorCustomName; public int currentEnergy; public int maxEnergy; public boolean canAcceptEnergy; /** * Returns the number of slots in the inventory. */ public int getSizeInventory() { return this.furnaceItemStacks.length; } public double fractionOfFuelRemaining(int fuelSlot) { double fraction = currentEnergy / (double)currentEnergy; return MathHelper.clamp_double(fraction, 0.0, 1.0); } public int secondsOfFuelRemaining(int fuelSlot) { if (currentEnergy <= 0 ) return 0; return currentEnergy / 20; // 20 ticks per second } /** * Returns the stack in the given slot. */ @Nullable public ItemStack getStackInSlot(int index) { return this.furnaceItemStacks[index]; } /** * Removes up to a specified number of items from an inventory slot and returns them in a new stack. */ @Nullable public ItemStack decrStackSize(int index, int count) { return ItemStackHelper.getAndSplit(this.furnaceItemStacks, index, count); } /** * Removes a stack from the given slot and returns it. */ @Nullable public ItemStack removeStackFromSlot(int index) { return ItemStackHelper.getAndRemove(this.furnaceItemStacks, index); } /** * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). */ public void setInventorySlotContents(int index, @Nullable ItemStack stack) { boolean flag = stack != null && stack.isItemEqual(this.furnaceItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks[index]); this.furnaceItemStacks[index] = stack; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } if (index == 0 && !flag) { this.markDirty(); } } /** * Get the name of this object. For players this returns their username */ public String getName() { return this.hasCustomName() ? this.coalGeneratorCustomName : "container.coalGenerator.name"; } /** * Returns true if this thing is named */ public boolean hasCustomName() { return this.coalGeneratorCustomName != null && !this.coalGeneratorCustomName.isEmpty(); } public void setCustomInventoryName(String p_145951_1_) { this.coalGeneratorCustomName = p_145951_1_; } public static void registerFixesFurnace(DataFixer fixer) { fixer.registerWalker(FixTypes.BLOCK_ENTITY, new ItemStackDataLists("Furnace", new String[] {"Items"})); } public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList nbttaglist = compound.getTagList("Items", 10); this.furnaceItemStacks = new ItemStack[this.getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound.getByte("Slot"); if (j >= 0 && j < this.furnaceItemStacks.length) { this.furnaceItemStacks[j] = ItemStack.loadItemStackFromNBT(nbttagcompound); } } this.fuelBurnTime = compound.getInteger("BurnTime"); this.currentEnergy = compound.getInteger("CurrentEnergy"); if (compound.hasKey("CustomName", ) { this.coalGeneratorCustomName = compound.getString("CustomName"); } } public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("BurnTime", this.fuelBurnTime); compound.setInteger("CurrentEnergy", this.currentEnergy); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.furnaceItemStacks.length; ++i) { if (this.furnaceItemStacks[i] != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("Slot", (byte)i); this.furnaceItemStacks[i].writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); } } compound.setTag("Items", nbttaglist); if (this.hasCustomName()) { compound.setString("CustomName", this.coalGeneratorCustomName); } return compound; } /** * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. */ public int getInventoryStackLimit() { return 64; } /** * Furnace isBurning */ public boolean isBurning() { return this.fuelBurnTime > 0; } @SideOnly(Side.CLIENT) public static boolean isBurning(IInventory inventory) { return inventory.getField(0) > 0; } /** * Like the old updateEntity(), except more generic. */ public void update() { boolean flag = this.isBurning(); boolean flag1 = false; if (this.isBurning()) { --this.fuelBurnTime; this.currentEnergy++; } if (!this.worldObj.isRemote) { if (this.isBurning()) { this.fuelBurnTime = getItemBurnTime(this.furnaceItemStacks[1]); if (this.isBurning()) { flag1 = true; if (this.furnaceItemStacks[1] != null) { --this.furnaceItemStacks[1].stackSize; if (this.furnaceItemStacks[1].stackSize == 0) { this.furnaceItemStacks[1] = furnaceItemStacks[1].getItem().getContainerItem(furnaceItemStacks[1]); } } } } if (flag != this.isBurning()) { flag1 = true; BlockFurnace.setState(this.isBurning(), this.worldObj, this.pos); } } if (flag1) { this.markDirty(); } } /** * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc. */ /* private boolean canSmelt() { if (this.furnaceItemStacks[0] == null) { return false; } else { ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStacks[0]); if (itemstack == null) return false; if (this.furnaceItemStacks[2] == null) return true; if (!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false; int result = furnaceItemStacks[2].stackSize + itemstack.stackSize; return result <= getInventoryStackLimit() && result <= this.furnaceItemStacks[2].getMaxStackSize(); //Forge BugFix: Make it respect stack sizes properly. } } */ /** * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't * fuel */ public static int getItemBurnTime(ItemStack stack) { if (stack == null) { return 0; } else { Item item = stack.getItem(); if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) { Block block = Block.getBlockFromItem(item); if (block == Blocks.WOODEN_SLAB) { return 150; } if (block.getDefaultState().getMaterial() == Material.WOOD) { return 300; } if (block == Blocks.COAL_BLOCK) { return 16000; } } if (item instanceof ItemTool && "WOOD".equals(((ItemTool)item).getToolMaterialName())) return 200; if (item instanceof ItemSword && "WOOD".equals(((ItemSword)item).getToolMaterialName())) return 200; if (item instanceof ItemHoe && "WOOD".equals(((ItemHoe)item).getMaterialName())) return 200; if (item == Items.STICK) return 100; if (item == Items.COAL) return 1600; if (item == Items.LAVA_BUCKET) return 20000; if (item == Item.getItemFromBlock(Blocks.SAPLING)) return 100; if (item == Items.BLAZE_ROD) return 2400; return net.minecraftforge.fml.common.registry.GameRegistry.getFuelValue(stack); } } public static boolean isItemFuel(ItemStack stack) { return getItemBurnTime(stack) > 0; } /** * Don't rename this method to canInteractWith due to conflicts with Container */ public boolean isUseableByPlayer(EntityPlayer player) { return this.worldObj.getTileEntity(this.pos) != this ? false : player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D; } public void openInventory(EntityPlayer player) { } public void closeInventory(EntityPlayer player) { } /** * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot. For * guis use Slot.isItemValid */ public boolean isItemValidForSlot(int index, ItemStack stack) { if (index == 2) { return false; } else if (index != 1) { return true; } else { ItemStack itemstack = this.furnaceItemStacks[1]; return isItemFuel(stack) || SlotFurnaceFuel.isBucket(stack) && (itemstack == null || itemstack.getItem() != Items.BUCKET); } } public int[] getSlotsForFace(EnumFacing side) { return side == EnumFacing.DOWN ? SLOTS_FUEL : (side == EnumFacing.UP ? SLOTS_FUEL : SLOTS_FUEL); } /** * Returns true if automation can insert the given item in the given slot from the given side. */ public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) { return this.isItemValidForSlot(index, itemStackIn); } /** * Returns true if automation can extract the given item in the given slot from the given side. */ public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) { if (direction == EnumFacing.DOWN && index == 1) { Item item = stack.getItem(); if (item != Items.WATER_BUCKET && item != Items.BUCKET) { return false; } } return true; } public String getGuiID() { return "minecraft:furnace"; } public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) { return new ContainerFurnace(playerInventory, this); } public int getField(int id) { switch (id) { case 0: return this.fuelBurnTime; case 1: return this.currentEnergy; default: return 0; } } public void setField(int id, int value) { switch (id) { case 0: this.fuelBurnTime = value; break; case 1: this.currentEnergy = value; } } public int getFieldCount() { return 4; } public void clear() { for (int i = 0; i < this.furnaceItemStacks.length; ++i) { this.furnaceItemStacks[i] = null; } } net.minecraftforge.items.IItemHandler handlerTop = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.UP); net.minecraftforge.items.IItemHandler handlerBottom = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.DOWN); net.minecraftforge.items.IItemHandler handlerSide = new net.minecraftforge.items.wrapper.SidedInvWrapper(this, net.minecraft.util.EnumFacing.WEST); @SuppressWarnings("unchecked") @Override public <T> T getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.util.EnumFacing facing) { if (facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) if (facing == EnumFacing.DOWN) return (T) handlerBottom; else if (facing == EnumFacing.UP) return (T) handlerTop; else return (T) handlerSide; return super.getCapability(capability, facing); } } and Container package com.lambda.PlentifulMisc.blocks.container; import javax.annotation.Nullable; import com.lambda.PlentifulMisc.blocks.tile.TileEnityCrystallizer; import com.lambda.PlentifulMisc.blocks.tile.TileEntityCoalGenerator; 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.inventory.SlotFurnaceFuel; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerCoalGenerator extends Container { private final TileEntityCoalGenerator tileCoalGenerator; private int fuelBurnTime; public int currentEnergy; public int maxEnergy; public boolean canAcceptEnergy; private final int HOTBAR_SLOT_COUNT = 9; private final int PLAYER_INVENTORY_ROW_COUNT = 3; private final int PLAYER_INVENTORY_COLUMN_COUNT = 9; private final int PLAYER_INVENTORY_SLOT_COUNT = PLAYER_INVENTORY_COLUMN_COUNT * PLAYER_INVENTORY_ROW_COUNT; private final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT; public final int FUEL_SLOTS_COUNT = 1; public final int FURNACE_SLOTS_COUNT = FUEL_SLOTS_COUNT; private final int VANILLA_FIRST_SLOT_INDEX = 0; private final int FIRST_FUEL_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT; private final int FIRST_FUEL_SLOT_NUMBER = 0; public ContainerCoalGenerator(InventoryPlayer invPlayer, TileEntityCoalGenerator tileInventoryFurnace) { this.tileCoalGenerator = tileInventoryFurnace; final int SLOT_X_SPACING = 18; final int SLOT_Y_SPACING = 18; final int HOTBAR_XPOS = 8; final int HOTBAR_YPOS = 183; // Add the players hotbar to the gui - the [xpos, ypos] location of each item for (int x = 0; x < HOTBAR_SLOT_COUNT; x++) { int slotNumber = x; addSlotToContainer(new Slot(invPlayer, slotNumber, HOTBAR_XPOS + SLOT_X_SPACING * x, HOTBAR_YPOS)); } final int PLAYER_INVENTORY_XPOS = 8; final int PLAYER_INVENTORY_YPOS = 125; // Add the rest of the players inventory to the gui for (int y = 0; y < PLAYER_INVENTORY_ROW_COUNT; y++) { for (int x = 0; x < PLAYER_INVENTORY_COLUMN_COUNT; x++) { int slotNumber = HOTBAR_SLOT_COUNT + y * PLAYER_INVENTORY_COLUMN_COUNT + x; int xpos = PLAYER_INVENTORY_XPOS + x * SLOT_X_SPACING; int ypos = PLAYER_INVENTORY_YPOS + y * SLOT_Y_SPACING; addSlotToContainer(new Slot(invPlayer, slotNumber, xpos, ypos)); } } final int FUEL_SLOTS_XPOS = 83; final int FUEL_SLOTS_YPOS = 60; // Add the tile fuel slots for (int x = 0; x < FUEL_SLOTS_COUNT; x++) { int slotNumber = x + FIRST_FUEL_SLOT_NUMBER; addSlotToContainer(new SlotFurnaceFuel(tileCoalGenerator, slotNumber, FUEL_SLOTS_XPOS + SLOT_X_SPACING * x, FUEL_SLOTS_YPOS)); } } public void addListener(IContainerListener listener) { super.addListener(listener); listener.sendAllWindowProperties(this, this.tileCoalGenerator); } /** * Looks for changes made in the container, sends them to every listener. */ public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.listeners.size(); ++i) { IContainerListener icontainerlistener = (IContainerListener)this.listeners.get(i); if (this.fuelBurnTime != this.tileCoalGenerator.getField(0)) { icontainerlistener.sendProgressBarUpdate(this, 0, this.tileCoalGenerator.getField(0)); } } this.fuelBurnTime = this.tileCoalGenerator.getField(0); this.currentEnergy = this.tileCoalGenerator.getField(1); } @SideOnly(Side.CLIENT) public void updateProgressBar(int id, int data) { this.tileCoalGenerator.setField(id, data); } /** * Determines whether supplied player can use this container */ public boolean canInteractWith(EntityPlayer playerIn) { return this.tileCoalGenerator.isUseableByPlayer(playerIn); } /** * Take a stack from the specified inventory slot. */ @Nullable public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { ItemStack itemstack = null; 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 null; } slot.onSlotChange(itemstack1, itemstack); } else if (index != 1 && index != 0) { if (TileEntityCoalGenerator.isItemFuel(itemstack1)) { if (!this.mergeItemStack(itemstack1, 1, 2, false)) { } } else if (index >= 3 && index < 30) { if (!this.mergeItemStack(itemstack1, 30, 39, false)) { return null; } } else if (index >= 30 && index < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)) { return null; } } else if (!this.mergeItemStack(itemstack1, 3, 39, false)) { return null; } if (itemstack1.stackSize == 0) { slot.putStack((ItemStack)null); } else { slot.onSlotChanged(); } if (itemstack1.stackSize == itemstack.stackSize) { return null; } slot.onPickupFromSlot(playerIn, itemstack1); } return itemstack; } } Thanks!
  4. NVM, had wrong name. EDIT 2: Still same error [19:52:04] [Client thread/FATAL]: Unreported exception thrown! java.lang.ClassCastException: com.lambda.PlentifulMisc.blocks.tile.TileEntityCoalGenerator cannot be cast to com.lambda.PlentifulMisc.blocks.tile.TileEnityCrystallizer at com.lambda.PlentifulMisc.client.gui.GuiHandler.getClientGuiElement(GuiHandler.java:59) ~[GuiHandler.class:?] at com.lambda.PlentifulMisc.client.gui.GuiRegistyHandler.getClientGuiElement(GuiRegistyHandler.java:37) ~[GuiRegistyHandler.class:?] at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:273) ~[NetworkRegistry.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:110) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2729) ~[EntityPlayer.class:?] at com.lambda.PlentifulMisc.blocks.BlockCoalGenerator.onBlockActivated(BlockCoalGenerator.java:45) ~[blockCoalGenerator.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:442) ~[PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1846) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:406) [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/:?] [19:52:04] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: ---- Minecraft Crash Report ---- // Don't be sad, have a hug! <3 Time: 11/21/16 7:52 PM Description: Unexpected error java.lang.ClassCastException: com.lambda.PlentifulMisc.blocks.tile.TileEntityCoalGenerator cannot be cast to com.lambda.PlentifulMisc.blocks.tile.TileEnityCrystallizer at com.lambda.PlentifulMisc.client.gui.GuiHandler.getClientGuiElement(GuiHandler.java:59) at com.lambda.PlentifulMisc.client.gui.GuiRegistyHandler.getClientGuiElement(GuiRegistyHandler.java:37) at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:273) at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:110) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2729) at com.lambda.PlentifulMisc.blocks.BlockCoalGenerator.onBlockActivated(BlockCoalGenerator.java:45) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:442) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1846) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118) at net.minecraft.client.Minecraft.run(Minecraft.java:406) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at com.lambda.PlentifulMisc.client.gui.GuiHandler.getClientGuiElement(GuiHandler.java:59) at com.lambda.PlentifulMisc.client.gui.GuiRegistyHandler.getClientGuiElement(GuiRegistyHandler.java:37) at net.minecraftforge.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:273) at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:110) at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2729) at com.lambda.PlentifulMisc.blocks.BlockCoalGenerator.onBlockActivated(BlockCoalGenerator.java:45) at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:442) at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1603) at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2281) at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2058) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player778'/299, l='MpServer', x=205.48, y=64.00, z=309.54]] Chunk stats: MultiplayerChunkCache: 573, 573 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: World: (32,64,256), Chunk: (at 0,4,0 in 2,16; contains blocks 32,0,256 to 47,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 99393 game time, 487 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 96 total; [EntityZombie['Zombie'/273, l='MpServer', x=220.50, y=59.00, z=232.50], EntitySpider['Spider'/274, l='MpServer', x=212.50, y=58.00, z=254.50], EntityCow['Cow'/275, l='MpServer', x=215.48, y=61.00, z=269.20], EntityZombie['Zombie'/276, l='MpServer', x=223.39, y=38.00, z=332.83], EntitySkeleton['Skeleton'/277, l='MpServer', x=221.46, y=51.00, z=351.70], EntitySheep['Sheep'/278, l='MpServer', x=216.82, y=62.49, z=371.94], EntityPig['Pig'/279, l='MpServer', x=210.13, y=63.00, z=387.16], EntityBat['Bat'/285, l='MpServer', x=228.45, y=36.87, z=245.50], EntityCow['Cow'/286, l='MpServer', x=224.53, y=59.00, z=264.82], EntityCow['Cow'/287, l='MpServer', x=238.69, y=66.00, z=261.81], EntityCow['Cow'/288, l='MpServer', x=238.59, y=70.00, z=300.82], EntitySheep['Sheep'/289, l='MpServer', x=233.58, y=63.00, z=330.45], EntitySheep['Sheep'/290, l='MpServer', x=233.52, y=63.00, z=329.23], EntitySkeleton['Skeleton'/291, l='MpServer', x=225.50, y=37.00, z=360.50], EntityZombie['Zombie'/292, l='MpServer', x=228.30, y=54.00, z=363.55], EntityZombie['Zombie'/293, l='MpServer', x=232.50, y=54.00, z=363.50], EntityZombie['Zombie'/294, l='MpServer', x=226.76, y=55.00, z=362.52], EntityZombie['Zombie'/295, l='MpServer', x=232.76, y=58.00, z=375.50], EntityZombie['Zombie'/296, l='MpServer', x=234.01, y=58.00, z=375.50], EntityCow['Cow'/341, l='MpServer', x=266.23, y=71.00, z=249.46], EntityCow['Cow'/342, l='MpServer', x=263.25, y=71.00, z=248.17], EntityCow['Cow'/343, l='MpServer', x=250.55, y=70.00, z=258.98], EntityCreeper['Creeper'/345, l='MpServer', x=246.50, y=37.00, z=255.50], EntityWitch['Witch'/346, l='MpServer', x=246.50, y=37.00, z=254.50], EntityCreeper['Creeper'/347, l='MpServer', x=242.50, y=37.00, z=248.50], EntityCreeper['Creeper'/348, l='MpServer', x=242.50, y=37.00, z=248.50], EntityCow['Cow'/349, l='MpServer', x=257.48, y=64.00, z=301.23], EntityZombie['entity.Zombie.name'/350, l='MpServer', x=252.50, y=27.00, z=314.50], EntitySheep['Sheep'/351, l='MpServer', x=252.51, y=77.00, z=316.81], EntityZombie['Zombie'/352, l='MpServer', x=279.24, y=18.00, z=278.51], EntityCreeper['Creeper'/353, l='MpServer', x=275.50, y=18.00, z=279.50], EntityCow['Cow'/354, l='MpServer', x=283.35, y=71.00, z=272.51], EntityCow['Cow'/355, l='MpServer', x=277.64, y=71.00, z=248.25], EntityCow['Cow'/356, l='MpServer', x=261.90, y=71.00, z=250.53], EntitySheep['Sheep'/361, l='MpServer', x=279.55, y=65.00, z=304.45], EntitySpider['Spider'/362, l='MpServer', x=258.50, y=20.00, z=326.50], EntityCow['Cow'/364, l='MpServer', x=257.45, y=75.00, z=315.55], EntityZombie['Zombie'/365, l='MpServer', x=247.51, y=20.00, z=333.12], EntityCow['Cow'/366, l='MpServer', x=254.45, y=62.53, z=328.37], EntitySheep['Sheep'/367, l='MpServer', x=257.49, y=77.00, z=356.74], EntitySheep['Sheep'/368, l='MpServer', x=276.67, y=70.00, z=334.20], EntitySheep['Sheep'/371, l='MpServer', x=262.18, y=80.00, z=368.22], EntitySkeleton['Skeleton'/372, l='MpServer', x=241.50, y=20.00, z=387.50], EntityCreeper['Creeper'/373, l='MpServer', x=280.50, y=45.00, z=365.50], EntityBat['Bat'/153, l='MpServer', x=123.24, y=39.01, z=294.37], EntityPlayerSP['Player778'/299, l='MpServer', x=205.48, y=64.00, z=309.54], EntityPig['Pig'/159, l='MpServer', x=127.30, y=63.00, z=366.41], EntitySkeleton['Skeleton'/168, l='MpServer', x=140.50, y=36.00, z=254.50], EntitySkeleton['Skeleton'/169, l='MpServer', x=143.50, y=36.00, z=256.50], EntityCow['Cow'/170, l='MpServer', x=135.80, y=67.00, z=257.17], EntityZombie['Zombie'/171, l='MpServer', x=136.55, y=42.00, z=281.76], EntityZombie['Zombie'/172, l='MpServer', x=139.31, y=11.00, z=299.61], EntitySkeleton['Skeleton'/173, l='MpServer', x=135.50, y=18.00, z=300.50], EntityZombie['Zombie'/174, l='MpServer', x=140.62, y=46.00, z=290.07], EntityZombie['Zombie'/175, l='MpServer', x=142.70, y=46.00, z=290.45], EntityZombie['Zombie'/176, l='MpServer', x=140.50, y=12.00, z=305.50], EntityCreeper['Creeper'/177, l='MpServer', x=142.19, y=35.00, z=314.23], EntityPig['Pig'/178, l='MpServer', x=137.29, y=65.00, z=315.23], EntityPig['Pig'/179, l='MpServer', x=135.29, y=64.00, z=309.49], EntitySheep['Sheep'/180, l='MpServer', x=133.43, y=63.00, z=344.21], EntityPig['Pig'/181, l='MpServer', x=129.49, y=63.00, z=387.76], EntityPig['Pig'/185, l='MpServer', x=158.14, y=71.00, z=267.19], EntityCow['Cow'/186, l='MpServer', x=147.13, y=73.00, z=276.14], EntityCreeper['Creeper'/187, l='MpServer', x=144.23, y=37.00, z=302.51], EntityZombie['Zombie'/188, l='MpServer', x=145.23, y=48.00, z=290.50], EntityCreeper['Creeper'/189, l='MpServer', x=151.50, y=37.00, z=305.50], EntityZombie['Zombie'/190, l='MpServer', x=153.57, y=49.00, z=305.77], EntityPig['Pig'/191, l='MpServer', x=146.79, y=65.00, z=309.49], EntityBat['Bat'/192, l='MpServer', x=164.76, y=32.40, z=346.25], EntitySpider['Spider'/198, l='MpServer', x=162.50, y=43.00, z=319.50], EntityZombie['Zombie'/199, l='MpServer', x=160.50, y=40.00, z=326.77], EntitySheep['Sheep'/200, l='MpServer', x=163.75, y=64.00, z=326.49], EntitySheep['Sheep'/201, l='MpServer', x=169.27, y=63.00, z=347.40], EntitySheep['Sheep'/202, l='MpServer', x=169.56, y=63.00, z=344.91], EntityCow['Cow'/214, l='MpServer', x=187.50, y=72.00, z=247.82], EntityCow['Cow'/215, l='MpServer', x=177.04, y=70.00, z=259.97], EntityCreeper['Creeper'/216, l='MpServer', x=189.50, y=29.00, z=327.50], EntityZombie['Zombie'/217, l='MpServer', x=186.79, y=29.00, z=329.48], EntityWitch['Witch'/218, l='MpServer', x=191.28, y=28.00, z=339.53], EntityCreeper['Creeper'/219, l='MpServer', x=189.79, y=27.00, z=341.59], EntityCow['Cow'/220, l='MpServer', x=179.82, y=64.00, z=344.62], EntitySheep['Sheep'/221, l='MpServer', x=183.45, y=64.00, z=339.35], EntityCreeper['Creeper'/222, l='MpServer', x=184.50, y=39.00, z=353.50], EntityBat['Bat'/237, l='MpServer', x=195.70, y=25.10, z=230.59], EntityZombie['Zombie'/241, l='MpServer', x=191.50, y=44.00, z=236.23], EntitySkeleton['Skeleton'/242, l='MpServer', x=195.30, y=57.00, z=236.50], EntitySkeleton['Skeleton'/243, l='MpServer', x=197.52, y=57.00, z=237.29], EntityCow['Cow'/244, l='MpServer', x=199.17, y=73.00, z=251.69], EntityItem['item.item.porkchopCooked'/245, l='MpServer', x=202.70, y=64.00, z=311.69], EntityCreeper['Creeper'/246, l='MpServer', x=193.50, y=29.00, z=324.50], EntityZombie['Zombie'/247, l='MpServer', x=198.93, y=25.41, z=350.70], EntitySheep['Sheep'/248, l='MpServer', x=195.12, y=62.37, z=347.47], EntityBat['Bat'/249, l='MpServer', x=205.43, y=23.05, z=362.03], EntityCreeper['Creeper'/250, l='MpServer', x=207.50, y=14.00, z=376.50], EntityPig['Pig'/251, l='MpServer', x=195.67, y=63.00, z=377.50], EntityPig['Pig'/252, l='MpServer', x=208.46, y=63.00, z=385.26]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:451) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2779) at net.minecraft.client.Minecraft.run(Minecraft.java:435) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.10.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_101, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 511411824 bytes (487 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP 9.32 Powered by Forge 12.18.2.2125 4 mods loaded, 4 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.2.2125.jar) UCHIJAAAA Forge{12.18.2.2125} [Minecraft Forge] (forgeSrc-1.10.2-12.18.2.2125.jar) UCHIJAAAA plentifulmisc{0.1a} [Plentiful Misc] (bin) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 375.70' Renderer: 'GeForce GTX 960/PCIe/SSE2' Launched Version: 1.10.2 LWJGL: 2.9.4 OpenGL: GeForce GTX 960/PCIe/SSE2 GL version 4.5.0 NVIDIA 375.70, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 6x AMD FX(tm)-6300 Six-Core Processor [19:52:04] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:649]: #@!@# Game crashed! Crash report saved to: #@!@# F:\Minecraft Workspace\1.10.x\Plentiful Misc Rewrite\run\.\crash-reports\crash-2016-11-21_19.52.04-client.txt AL lib: (EE) alc_cleanup: 1 device not closed here is the updated gui package com.lambda.PlentifulMisc.client.gui; import com.lambda.PlentifulMisc.blocks.container.ContainerCoalGenerator; import com.lambda.PlentifulMisc.blocks.container.ContainerCrate; import com.lambda.PlentifulMisc.blocks.container.ContainerCrystallizer; import com.lambda.PlentifulMisc.blocks.tile.TileEnityCrystallizer; import com.lambda.PlentifulMisc.blocks.tile.TileEntityCoalGenerator; import com.lambda.PlentifulMisc.blocks.tile.TileEntityCrate; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { private static final int GUIID_PM_223 = 223; public static int getGuiID() {return GUIID_PM_223;} // Gets the server side element for the given gui id- this should return a container @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID != getGuiID()) { System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID); } BlockPos xyz = new BlockPos(x, y, z); TileEntity tileEntity = world.getTileEntity(xyz); if (tileEntity instanceof TileEntityCrate) { TileEntityCrate tileEntityInventoryBasic = (TileEntityCrate) tileEntity; return new ContainerCrate(player.inventory, tileEntityInventoryBasic); } if (tileEntity instanceof TileEnityCrystallizer) { TileEnityCrystallizer tileInventoryFurnace = (TileEnityCrystallizer) tileEntity; return new ContainerCrystallizer(player.inventory, tileInventoryFurnace); } if (tileEntity instanceof TileEnityCrystallizer) { TileEntityCoalGenerator tileInventoryFurnace = (TileEntityCoalGenerator) tileEntity; return new ContainerCoalGenerator(player.inventory, tileInventoryFurnace); } return null; } // Gets the client side element for the given gui id- this should return a gui @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID != getGuiID()) { System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID); } BlockPos xyz = new BlockPos(x, y, z); TileEntity tileEntity = world.getTileEntity(xyz); if (tileEntity instanceof TileEntityCrate) { TileEntityCrate tileEntityInventoryBasic = (TileEntityCrate) tileEntity; return new GuiCrate(player.inventory, tileEntityInventoryBasic); } if (tileEntity instanceof TileEntity) { TileEnityCrystallizer tileInventoryFurnace = (TileEnityCrystallizer) tileEntity; return new GuiCrystallizer(player.inventory, tileInventoryFurnace); } if (tileEntity instanceof TileEntity) { TileEntityCoalGenerator tileEntityCoalFurnace = (TileEntityCoalGenerator) tileEntity; return new GuiCoalGenerator(player.inventory, tileEntityCoalFurnace); } return null; } }
  5. oh my bad: package com.lambda.PlentifulMisc.blocks; import javax.annotation.Nullable; import com.lambda.PlentifulMisc.PlentifulMisc; import com.lambda.PlentifulMisc.Reference; import com.lambda.PlentifulMisc.blocks.tile.TileEntityCoalGenerator; import com.lambda.PlentifulMisc.client.gui.GuiHandler; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BlockCoalGenerator extends BlockContainer { public BlockCoalGenerator() { super(Material.ROCK); setUnlocalizedName(Reference.PlentifulMiscBlocks.COALGENERATOR.getUnlocalizedName()); setRegistryName(Reference.PlentifulMiscBlocks.COALGENERATOR.getRegistryName()); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityCoalGenerator(); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { // Uses the gui handler registered to your mod to open the gui for the given gui id // open on the server side only (not sure why you shouldn't open client side too... vanilla doesn't, so we better not either) if (worldIn.isRemote) return true; playerIn.openGui(PlentifulMisc.instance, GuiHandler.getGuiID(), worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } // This is where you can do something when the block is broken. In this case drop the inventory's contents @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof IInventory) { InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileEntity); } } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.SOLID; } // used by the renderer to control lighting and visibility of other blocks. // set to false because this block doesn't fill the entire 1x1x1 space @Override public boolean isOpaqueCube(IBlockState iBlockState) { return false; } // used by the renderer to control lighting and visibility of other blocks, also by // (eg) wall or fence to control whether the fence joins itself to this block // set to false because this block doesn't fill the entire 1x1x1 space @Override public boolean isFullCube(IBlockState iBlockState) { return false; } // render using a BakedModel // required because the default (super method) is INVISIBLE for BlockContainers. @Override public EnumBlockRenderType getRenderType(IBlockState iBlockState) { return EnumBlockRenderType.MODEL; } }
  6. Hey all! So my gui isnt opening when I activate the block. I cant seem to find the problem. (No Log Report) GUI: package com.lambda.PlentifulMisc.client.gui; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.awt.*; import java.util.ArrayList; import java.util.List; import com.lambda.PlentifulMisc.blocks.tile.TileEntityCoalGenerator; import com.lambda.PlentifulMisc.blocks.container.ContainerCoalGenerator; /** * User: brandon3055 * Date: 06/01/2015 * * GuiInventoryAdvanced is a gui similar to that of a furnace. It has a progress bar and a burn time indicator. * Both indicators have mouse over text */ @SideOnly(Side.CLIENT) public class GuiCoalGenerator extends GuiContainer { // This is the resource location for the background image private static final ResourceLocation texture = new ResourceLocation("plentifulmisc", "textures/gui/guiCoalGenerator.png"); private TileEntityCoalGenerator tileEntity; public GuiCoalGenerator(InventoryPlayer invPlayer, TileEntityCoalGenerator tileInventoryFurnace) { super(new ContainerCoalGenerator(invPlayer, tileInventoryFurnace)); // Set the width and height of the gui xSize = 176; ySize = 207; this.tileEntity = tileInventoryFurnace; } final int FLAME_XPOS = 54; final int FLAME_YPOS = 80; final int FLAME_ICON_U = 178; // texture position of flame icon final int FLAME_ICON_V = 0; final int FLAME_WIDTH = 9; final int FLAME_HEIGHT = 15; final int FLAME_X_SPACING = 18; final int ENERGY_XPOS = -12; final int ENERGY_YPOS = 28; final int ENERGY_ICON_U = 176; // texture position of energy bar final int ENERGY_ICON_V = 21; final int ENERGY_WIDTH = 22; final int ENERGY_HEIGHT = 80; final int ENERGY_X_SPACING = 18; @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y) { // Bind the image texture Minecraft.getMinecraft().getTextureManager().bindTexture(texture); // Draw the image GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); // get cook progress as a double between 0 and 1 // draw the fuel remaining bar for each fuel slot flame double burnRemaining = tileEntity.fractionOfFuelRemaining(0); int yOffset = (int)((1.0 - burnRemaining) * FLAME_HEIGHT); drawTexturedModalRect(guiLeft + FLAME_XPOS + FLAME_X_SPACING, guiTop + FLAME_YPOS + yOffset, FLAME_ICON_U, FLAME_ICON_V + yOffset, FLAME_WIDTH, FLAME_HEIGHT - yOffset); // draw energy bar double energyRemain = tileEntity.energyDP; int energyMax = tileEntity.energyMax; int yOffsetEnergy = (int)((energyRemain - energyMax) * ENERGY_HEIGHT); drawTexturedModalRect(guiLeft + ENERGY_XPOS + ENERGY_X_SPACING, guiTop + ENERGY_YPOS + yOffset, ENERGY_ICON_U, ENERGY_ICON_V + yOffset, ENERGY_WIDTH, ENERGY_HEIGHT - yOffset); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { super.drawGuiContainerForegroundLayer(mouseX, mouseY); final int LABEL_XPOS = 5; final int LABEL_YPOS = 5; fontRendererObj.drawString(tileEntity.getDisplayName().getUnformattedText(), LABEL_XPOS, LABEL_YPOS, Color.darkGray.getRGB()); List<String> hoveringText = new ArrayList<String>(); // If the mouse is over one of the burn time indicator add the burn time indicator hovering text for (int i = 0; i < tileEntity.FUEL_SLOTS_COUNT; ++i) { if (isInRect(guiLeft + FLAME_XPOS + FLAME_X_SPACING * i, guiTop + FLAME_YPOS, FLAME_WIDTH, FLAME_HEIGHT, mouseX, mouseY)) { hoveringText.add("Fuel Time:"); hoveringText.add(tileEntity.secondsOfFuelRemaining(i) + "s"); } } if (isInRect(guiLeft + ENERGY_XPOS + ENERGY_X_SPACING, guiTop + ENERGY_YPOS, ENERGY_WIDTH, ENERGY_HEIGHT, mouseX, mouseY)) { hoveringText.add("Energy Amount:"); hoveringText.add(tileEntity.energyDP + " DP"); } // If hoveringText is not empty draw the hovering text if (!hoveringText.isEmpty()){ drawHoveringText(hoveringText, mouseX - guiLeft, mouseY - guiTop, fontRendererObj); } // // You must re bind the texture and reset the colour if you still need to use it after drawing a string // Minecraft.getMinecraft().getTextureManager().bindTexture(texture); // GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); } // Returns true if the given x,y coordinates are within the given rectangle public static boolean isInRect(int x, int y, int xSize, int ySize, int mouseX, int mouseY){ return ((mouseX >= x && mouseX <= x+xSize) && (mouseY >= y && mouseY <= y+ySize)); } } GUI Handler: package com.lambda.PlentifulMisc.client.gui; import com.lambda.PlentifulMisc.blocks.container.ContainerCoalGenerator; import com.lambda.PlentifulMisc.blocks.container.ContainerCrate; import com.lambda.PlentifulMisc.blocks.container.ContainerCrystallizer; import com.lambda.PlentifulMisc.blocks.tile.TileEnityCrystallizer; import com.lambda.PlentifulMisc.blocks.tile.TileEntityCoalGenerator; import com.lambda.PlentifulMisc.blocks.tile.TileEntityCrate; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler { private static final int GUIID_PM_223 = 223; public static int getGuiID() {return GUIID_PM_223;} // Gets the server side element for the given gui id- this should return a container @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID != getGuiID()) { System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID); } BlockPos xyz = new BlockPos(x, y, z); TileEntity tileEntity = world.getTileEntity(xyz); if (tileEntity instanceof TileEntityCrate) { TileEntityCrate tileEntityInventoryBasic = (TileEntityCrate) tileEntity; return new ContainerCrate(player.inventory, tileEntityInventoryBasic); } if (tileEntity instanceof TileEnityCrystallizer) { TileEnityCrystallizer tileInventoryFurnace = (TileEnityCrystallizer) tileEntity; return new ContainerCrystallizer(player.inventory, tileInventoryFurnace); } if (tileEntity instanceof TileEnityCrystallizer) { TileEntityCoalGenerator tileInventoryFurnace = (TileEntityCoalGenerator) tileEntity; return new ContainerCoalGenerator(player.inventory, tileInventoryFurnace); } return null; } // Gets the client side element for the given gui id- this should return a gui @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID != getGuiID()) { System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID); } BlockPos xyz = new BlockPos(x, y, z); TileEntity tileEntity = world.getTileEntity(xyz); if (tileEntity instanceof TileEntityCrate) { TileEntityCrate tileEntityInventoryBasic = (TileEntityCrate) tileEntity; return new GuiCrate(player.inventory, tileEntityInventoryBasic); } if (tileEntity instanceof TileEntity) { TileEnityCrystallizer tileInventoryFurnace = (TileEnityCrystallizer) tileEntity; return new GuiCrystallizer(player.inventory, tileInventoryFurnace); } if (tileEntity instanceof TileEntity) { TileEntityCoalGenerator tileInventoryFurnace = (TileEntityCoalGenerator) tileEntity; return new GuiCoalGenerator(player.inventory, tileInventoryFurnace); } return null; } } Registry of the TE + GUI: GameRegistry.registerTileEntity(TileEntityCrate.class, "plentifulmisc_crate"); GameRegistry.registerTileEntity(TileEnityCrystallizer.class, "plentifulmisc_crystallizer"); GameRegistry.registerTileEntity(TileEntitySolarGenerator.class, "plentifulmisc_solargenerator"); GameRegistry.registerTileEntity(TileEntityCoalGenerator.class, "plentifulmisc_coalgenerator"); NetworkRegistry.INSTANCE.registerGuiHandler(PlentifulMisc.instance, GuiRegistyHandler.getInstance()); GuiRegistyHandler.getInstance().registerGuiHandler(new GuiHandler(), GuiHandler.getGuiID()); NOTE: All of my other GUIS work, just not this one
  7. So this: public class BlockSolarGenerator extends Block { TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); public BlockSolarGenerator() { super(Material.ROCK); setUnlocalizedName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getUnlocalizedName()); setRegistryName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getRegistryName()); setHardness(2); } @Override public boolean hasTileEntity(IBlockState state) { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEnityCrystallizer(); } @Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { tileEntitySolarGenerator.neighborChanged(worldIn, pos); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY,float hitZ, int meta, EntityLivingBase placer, ItemStack stack) { tileEntitySolarGenerator.getStateForPlacement(world, pos); return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, stack); } //small upgrades, size of torches, act like torches. } Also, what should I be returning on getStateForPlacement in the te & block
  8. So just this in the block class: public class BlockSolarGenerator extends Block { TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); public BlockSolarGenerator() { super(Material.ROCK); setUnlocalizedName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getUnlocalizedName()); setRegistryName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getRegistryName()); setHardness(2); } @Override public boolean hasTileEntity() { return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { return new TileEnityCrystallizer(); } //small upgrades, size of torches, act like torches. } te just staying the same
  9. here is the updated te: package com.lambda.PlentifulMisc.blocks.tile; import com.lambda.PlentifulMisc.init.ModBlocks; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class TileEntitySolarGenerator extends TileEntity implements ITickable{ public int energyOutput; public int connectedTiles; public boolean canSendEnergy; @Override public void update() { System.out.println(connectedTiles); if(worldObj.isDaytime()) { canSendEnergy = true; } else { canSendEnergy = false; } } public void neighborChanged(World worldIn, BlockPos pos) { for (EnumFacing face : EnumFacing.values()) { BlockPos posN = getPos().offset(face); if (getWorld().getTileEntity(posN) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } } public IBlockState getStateForPlacement(World world, BlockPos pos) { for (EnumFacing face : EnumFacing.values()) { BlockPos posS = getPos().offset(face); if (getWorld().getTileEntity(posS) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } return null; } } and block package com.lambda.PlentifulMisc.blocks; import com.lambda.PlentifulMisc.Reference; import com.lambda.PlentifulMisc.blocks.tile.TileEntitySolarGenerator; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockSolarGenerator extends Block implements ITileEntityProvider{ TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); public BlockSolarGenerator() { super(Material.ROCK); setUnlocalizedName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getUnlocalizedName()); setRegistryName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getRegistryName()); setHardness(2); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntitySolarGenerator(); } //small upgrades, size of torches, act like torches. }
  10. So then : package com.lambda.PlentifulMisc.blocks.tile; import com.lambda.PlentifulMisc.init.ModBlocks; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class TileEntitySolarGenerator extends TileEntity implements ITickable{ public int energyOutput; public int connectedTiles; public boolean canSendEnergy; @Override public void update() { System.out.println(connectedTiles); if(worldObj.isDaytime()) { canSendEnergy = true; } else { canSendEnergy = false; } } public void updateFromNeighbor() { } public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { for (EnumFacing face : EnumFacing.values()) { BlockPos posN = getPos().offset(face); if (getWorld().getTileEntity(posN) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } } public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, ItemStack stack) { for (EnumFacing face : EnumFacing.values()) { BlockPos posState = getPos().offset(face); if (getWorld().getTileEntity(posState) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } return null; } }
  11. But the methods are Block methods, not TE.
  12. Okay, so I get a crash: [21:12:40] [server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: net.minecraft.util.ReportedException: Exception while updating neighbours 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:26) [util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:742) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_101] Caused by: net.minecraft.util.ReportedException: Exception while updating neighbours at net.minecraft.world.World.notifyBlockOfStateChange(World.java:605) ~[World.class:?] at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:531) ~[World.class:?] at net.minecraft.world.World.notifyNeighborsRespectDebug(World.java:482) ~[World.class:?] at net.minecraft.world.World.markAndNotifyBlock(World.java:421) ~[World.class:?] at net.minecraft.world.World.setBlockState(World.java:402) ~[World.class:?] at net.minecraft.block.Block.removedByPlayer(Block.java:1324) ~[block.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:298) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:292) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:339) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.onBlockClicked(PlayerInteractionManager.java:175) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:658) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:56) ~[CPacketPlayerDigging.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:12) ~[CPacketPlayerDigging.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:25) ~[util.class:?] ... 5 more Caused by: java.lang.NullPointerException at com.lambda.PlentifulMisc.blocks.tile.TileEntitySolarGenerator.updateFromNeighbor(TileEntitySolarGenerator.java:34) ~[TileEntitySolarGenerator.class:?] at com.lambda.PlentifulMisc.blocks.BlockSolarGenerator.neighborChanged(BlockSolarGenerator.java:35) ~[blockSolarGenerator.class:?] at net.minecraft.block.state.BlockStateContainer$StateImplementation.neighborChanged(BlockStateContainer.java:480) ~[blockStateContainer$StateImplementation.class:?] at net.minecraft.world.World.notifyBlockOfStateChange(World.java:584) ~[World.class:?] at net.minecraft.world.World.notifyNeighborsOfStateChange(World.java:531) ~[World.class:?] at net.minecraft.world.World.notifyNeighborsRespectDebug(World.java:482) ~[World.class:?] at net.minecraft.world.World.markAndNotifyBlock(World.java:421) ~[World.class:?] at net.minecraft.world.World.setBlockState(World.java:402) ~[World.class:?] at net.minecraft.block.Block.removedByPlayer(Block.java:1324) ~[block.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:298) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.removeBlock(PlayerInteractionManager.java:292) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.tryHarvestBlock(PlayerInteractionManager.java:339) ~[PlayerInteractionManager.class:?] at net.minecraft.server.management.PlayerInteractionManager.onBlockClicked(PlayerInteractionManager.java:175) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processPlayerDigging(NetHandlerPlayServer.java:658) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:56) ~[CPacketPlayerDigging.class:?] at net.minecraft.network.play.client.CPacketPlayerDigging.processPacket(CPacketPlayerDigging.java:12) ~[CPacketPlayerDigging.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:25) ~[util.class:?] ... 5 more 0 0 0 0 0 everytime I update it / place it. Also how would I tell if the TE is destroyed and minus connectedTile. here is the block class & te: package com.lambda.PlentifulMisc.blocks; import com.lambda.PlentifulMisc.Reference; import com.lambda.PlentifulMisc.blocks.tile.TileEntitySolarGenerator; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockSolarGenerator extends Block implements ITileEntityProvider{ TileEntitySolarGenerator tileEntitySolarGenerator = new TileEntitySolarGenerator(); public BlockSolarGenerator() { super(Material.ROCK); setUnlocalizedName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getUnlocalizedName()); setRegistryName(Reference.PlentifulMiscBlocks.SOLARGENERATOR.getRegistryName()); setHardness(2); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntitySolarGenerator(); } @Override public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { tileEntitySolarGenerator.updateFromNeighbor(); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, ItemStack stack) { tileEntitySolarGenerator.updateFromPlaced(); return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, stack); } //small upgrades, size of torches, act like torches. } package com.lambda.PlentifulMisc.blocks.tile; import com.lambda.PlentifulMisc.init.ModBlocks; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class TileEntitySolarGenerator extends TileEntity implements ITickable{ public int energyOutput; public int connectedTiles; public boolean canSendEnergy; @Override public void update() { System.out.println(connectedTiles); if(worldObj.isDaytime()) { canSendEnergy = true; } else { canSendEnergy = false; } } public void updateFromNeighbor() { for (EnumFacing face : EnumFacing.values()) { BlockPos pos = getPos().offset(face); if (getWorld().getTileEntity(pos) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } } public void updateFromPlaced() { for (EnumFacing face : EnumFacing.values()) { BlockPos pos = getPos().offset(face); if (getWorld().getTileEntity(pos) instanceof TileEnityCrystallizer) { connectedTiles += 1; } else { } } } }
  13. okay this is firing everytick, how would I put make it so it only updates when placed / when the TE is placed next to it, and have it reset if it is destroyed.
×
×
  • Create New...

Important Information

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