Jump to content

syaak

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by syaak

  1. still using ISidedInventory. i couldnt find Capabilities. its just now the furnace wont cook
  2. actually now the errors are gone and i can open the furnace and put items and take them out without crashing. How do i make it so i can cook an item though (like recipes and stuff)?
  3. ive got it to open by setting the furnaceItemStack to empty instead of null but it still crashes when i put items in the slots
  4. by IInventory do you mean ISidedeInventory?
  5. so check if its remote or not?
  6. In TileMyFurnace? I dont see where it is
  7. when i do that i get [12:40:06] [main/INFO]: [com.syaak.myblocks.gui.GuiMyFurnace:<init>:28]: gui class: constructor print [12:40:06] [main/INFO]: [com.syaak.myblocks.modAssets.blocks.BlockMyFurnace:onBlockActivated:79]: block class: world isnt remote open gui print [12:40:06] [Server thread/INFO]: [com.syaak.myblocks.modAssets.blocks.BlockMyFurnace:onBlockActivated:71]: block activated [12:40:06] [Server thread/INFO]: [com.syaak.myblocks.handler.GuiHandler:getServerGuiElement:30]: gui handler: getServerGuiElement print [12:40:06] [Server thread/INFO]: [com.syaak.myblocks.container.ContainerMyFurnace:<init>:27]: container: constructor print [12:40:06] [Server thread/FATAL]: Error executing task java.util.concurrent.ExecutionException: java.lang.NullPointerException: The validated object is null at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_144] at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_144] at net.minecraft.util.Util.runTask(SourceFile:47) [Util.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:721) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:666) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:185) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_144] Caused by: java.lang.NullPointerException: The validated object is null at org.apache.commons.lang3.Validate.notNull(Validate.java:225) ~[commons-lang3-3.5.jar:3.5] at org.apache.commons.lang3.Validate.notNull(Validate.java:206) ~[commons-lang3-3.5.jar:3.5] at net.minecraft.util.NonNullList.add(SourceFile:56) ~[NonNullList.class:?] at java.util.AbstractList.add(Unknown Source) ~[?:1.8.0_144] at net.minecraft.inventory.Container.getInventory(Container.java:63) ~[Container.class:?] at net.minecraft.inventory.Container.addListener(Container.java:52) ~[Container.class:?] at com.syaak.myblocks.container.ContainerMyFurnace.addListener(ContainerMyFurnace.java:55) ~[ContainerMyFurnace.class:?] at net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:100) ~[FMLNetworkHandler.class:?] at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2546) ~[EntityPlayer.class:?] at com.syaak.myblocks.modAssets.blocks.BlockMyFurnace.onBlockActivated(BlockMyFurnace.java:78) ~[BlockMyFurnace.class:?] at net.minecraft.server.management.PlayerInteractionManager.processRightClickBlock(PlayerInteractionManager.java:446) ~[PlayerInteractionManager.class:?] at net.minecraft.network.NetHandlerPlayServer.processTryUseItemOnBlock(NetHandlerPlayServer.java:731) ~[NetHandlerPlayServer.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(SourceFile:55) ~[CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock.processPacket(SourceFile:11) ~[CPacketPlayerTryUseItemOnBlock.class:?] at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) ~[PacketThreadUtil$1.class:?] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_144] at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_144] at net.minecraft.util.Util.runTask(SourceFile:46) ~[Util.class:?] ... 5 more [12:40:06] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking player at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:771) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:666) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:185) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:524) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_144] Caused by: java.lang.NullPointerException at net.minecraft.item.ItemStack.areItemStacksEqual(ItemStack.java:432) ~[ItemStack.class:?] at net.minecraft.inventory.Container.detectAndSendChanges(Container.java:82) ~[Container.class:?] at com.syaak.myblocks.container.ContainerMyFurnace.detectAndSendChanges(ContainerMyFurnace.java:68) ~[ContainerMyFurnace.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdate(EntityPlayerMP.java:324) ~[EntityPlayerMP.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:1984) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:833) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntity(World.java:1946) ~[World.class:?] at net.minecraft.world.WorldServer.tickPlayers(WorldServer.java:643) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntities(World.java:1730) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:614) ~[WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:765) ~[MinecraftServer.class:?] ... 4 more
  8. so move it outside of the !world.isRemote block? or write another of the openGgui line outside of it and also keep that line?
  9. this is my log. I put a print msg in all of the classes i listed above and only the msg when i click the block (onBlockActivated) and in preinit of the main class get called. Which makes me think the issue is in GuiHandler class. 2017-09-29 11:33:12,823 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream [11:33:13] [main/INFO]: Extra: [] [11:33:13] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [11:33:13] [main/INFO]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker [11:33:13] [main/INFO]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker [11:33:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker [11:33:13] [main/INFO]: Forge Mod Loader version 14.22.1.2478 for Minecraft 1.12.1 loading [11:33:13] [main/INFO]: Java is Java HotSpot(TM) Client VM, version 1.8.0_144, running on Windows 8.1:x86:6.3, installed at C:\Program Files (x86)\Java\jre1.8.0_144 [11:33:13] [main/INFO]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation [11:33:13] [main/INFO]: Ignoring missing certificate for coremod FMLCorePlugin (net.minecraftforge.fml.relauncher.FMLCorePlugin), we are in deobf and it's a forge core plugin [11:33:13] [main/INFO]: Ignoring missing certificate for coremod FMLForgePlugin (net.minecraftforge.classloading.FMLForgePlugin), we are in deobf and it's a forge core plugin [11:33:13] [main/INFO]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker [11:33:13] [main/INFO]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin [11:33:13] [main/INFO]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin [11:33:13] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [11:33:13] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [11:33:13] [main/INFO]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [11:33:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [11:33:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker [11:33:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper 2017-09-29 11:33:15,323 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream 2017-09-29 11:33:16,440 main WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream [11:33:22] [main/ERROR]: FML appears to be missing any signature data. This is not a good thing [11:33:22] [main/INFO]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper [11:33:22] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker [11:33:24] [main/INFO]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker [11:33:24] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker [11:33:24] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker [11:33:24] [main/INFO]: Launching wrapped minecraft {net.minecraft.client.main.Main} [11:33:26] [main/INFO]: Setting user: Player734 [11:33:40] [main/WARN]: Skipping bad option: lastServer: [11:33:40] [main/INFO]: LWJGL Version: 2.9.4 [11:33:43] [main/INFO]: Replaced 1036 ore ingredients [11:33:45] [main/INFO]: Found 0 mods from the command line. Injecting into mod discoverer [11:33:46] [Thread-3/INFO]: Using sync timing. 200 frames of Display.update took 291349218 nanos [11:33:49] [main/INFO]: Forge Mod Loader has identified 5 mods to load [11:33:51] [main/INFO]: Attempting connection with missing mods [minecraft, mcp, FML, forge, myblocks] at CLIENT [11:33:51] [main/INFO]: Attempting connection with missing mods [minecraft, mcp, FML, forge, myblocks] at SERVER [11:33:54] [main/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:Syaak's Mod [11:33:54] [main/INFO]: Processing ObjectHolder annotations [11:33:54] [main/INFO]: Found 1168 ObjectHolder annotations [11:33:54] [main/INFO]: Identifying ItemStackHolder annotations [11:33:54] [main/INFO]: Found 0 ItemStackHolder annotations [11:33:55] [main/INFO]: Configured a dormant chunk cache size of 0 [11:33:55] [Forge Version Check/INFO]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json [11:33:55] [main/INFO]: [com.syaak.myblocks.myblocks:preInit:37]: Syaak's Mod is loading! [11:33:55] [main/INFO]: [com.syaak.myblocks.myblocks:preInit:40]: main class: print aftert registering gui [11:33:55] [main/INFO]: Applying holder lookups [11:33:55] [main/INFO]: Holder lookups applied [11:33:55] [main/INFO]: Applying holder lookups [11:33:55] [main/INFO]: Holder lookups applied [11:33:55] [main/INFO]: Applying holder lookups [11:33:55] [main/INFO]: Holder lookups applied [11:33:55] [main/INFO]: Applying holder lookups [11:33:55] [main/INFO]: Holder lookups applied [11:33:55] [main/INFO]: Injecting itemstacks [11:33:55] [main/INFO]: Itemstack injection complete [11:33:55] [Forge Version Check/INFO]: [forge] Found status: UP_TO_DATE Target: null [11:34:11] [Sound Library Loader/INFO]: Starting up SoundSystem... [11:34:11] [Thread-5/INFO]: Initializing LWJGL OpenAL [11:34:11] [Thread-5/INFO]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [11:34:12] [Thread-5/INFO]: OpenAL initialized. [11:34:12] [Sound Library Loader/INFO]: Sound engine started [11:34:36] [main/INFO]: Max texture size: 8192 [11:34:37] [main/INFO]: Created: 512x512 textures-atlas [11:34:49] [main/INFO]: Applying holder lookups [11:34:49] [main/INFO]: Holder lookups applied [11:34:49] [main/INFO]: Injecting itemstacks [11:34:49] [main/INFO]: Itemstack injection complete [11:34:50] [main/INFO]: Forge Mod Loader has successfully loaded 5 mods [11:34:50] [main/WARN]: Skipping bad option: lastServer: [11:34:50] [main/INFO]: Narrator library for x86 successfully loaded [11:34:58] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id [11:35:11] [Server thread/INFO]: Starting integrated minecraft server version 1.12.1 [11:35:11] [Server thread/INFO]: Generating keypair [11:35:11] [Server thread/INFO]: Injecting existing registry data into this server instance [11:35:14] [Server thread/INFO]: Applying holder lookups [11:35:14] [Server thread/INFO]: Holder lookups applied [11:35:14] [Server thread/INFO]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@4eabf2) [11:35:18] [Server thread/INFO]: Loaded 488 advancements [11:35:19] [Server thread/INFO]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@4eabf2) [11:35:19] [Server thread/INFO]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@4eabf2) [11:35:19] [Server thread/INFO]: Preparing start region for level 0 [11:35:21] [Server thread/INFO]: Preparing spawn area: 0% [11:35:23] [Server thread/INFO]: Preparing spawn area: 5% [11:35:24] [Server thread/INFO]: Preparing spawn area: 50% [11:35:27] [Server thread/INFO]: Changing view distance to 5, from 10 [11:35:30] [Server thread/WARN]: Can't keep up! Did the system time change, or is the server overloaded? Running 2790ms behind, skipping 55 tick(s) [11:35:41] [Netty Local Client IO #0/INFO]: Server protocol version 2 [11:35:41] [Netty Server IO #1/INFO]: Client protocol version 2 [11:35:41] [Netty Server IO #1/INFO]: Client attempting to join with 5 mods : [email protected],[email protected],[email protected],[email protected],[email protected] [11:35:41] [Netty Local Client IO #0/INFO]: [Netty Local Client IO #0] Client side modded connection established [11:35:41] [Server thread/INFO]: [Server thread] Server side modded connection established [11:35:41] [Server thread/INFO]: Player734[local:E:987a83ef] logged in with entity id 217 at (734.1129797904031, 5.25, -1785.7891725614281) [11:35:41] [Server thread/INFO]: Player734 joined the game [11:35:41] [Server thread/INFO]: Player734 has made the advancement [Stone Age] [11:35:44] [Server thread/INFO]: Saving and pausing game... [11:35:44] [Server thread/INFO]: Saving chunks for level 'New World'/overworld [11:35:46] [main/INFO]: [CHAT] Player734 has made the advancement [Stone Age] [11:35:46] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether [11:35:46] [Server thread/INFO]: Saving chunks for level 'New World'/the_end [11:35:48] [main/INFO]: Loaded 37 advancements [11:35:50] [main/INFO]: [com.syaak.myblocks.modAssets.blocks.BlockMyFurnace:onBlockActivated:71]: block activated [11:35:50] [main/INFO]: [com.syaak.myblocks.modAssets.blocks.BlockMyFurnace:onBlockActivated:71]: block activated [11:35:50] [Server thread/INFO]: [com.syaak.myblocks.modAssets.blocks.BlockMyFurnace:onBlockActivated:71]: block activated [11:35:50] [main/INFO]: [com.syaak.myblocks.modAssets.blocks.BlockMyFurnace:onBlockActivated:71]: block activated [11:35:50] [Server thread/INFO]: [com.syaak.myblocks.modAssets.blocks.BlockMyFurnace:onBlockActivated:71]: block activated [11:35:50] [Server thread/INFO]: [com.syaak.myblocks.modAssets.blocks.BlockMyFurnace:onBlockActivated:71]: block activated [11:35:52] [Server thread/INFO]: Saving and pausing game... [11:35:52] [Server thread/INFO]: Saving chunks for level 'New World'/overworld [11:35:53] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether [11:35:53] [Server thread/INFO]: Saving chunks for level 'New World'/the_end [11:35:53] [Server thread/INFO]: Saving and pausing game... [11:35:53] [Server thread/INFO]: Saving chunks for level 'New World'/overworld [11:35:54] [Server thread/INFO]: Saving chunks for level 'New World'/the_nether [11:35:55] [Server thread/INFO]: Saving chunks for level 'New World'/the_end
  10. ammended. Does it appear to be missing anything?
  11. I have made a GUI but it wont show in game. This is my code, can you see anything wrong with it? below is my code. i get no messages in the log. This is my preinit method in my main class @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { System.out.println(Reference.NAME + " is loading!"); proxy.preInit(event); } which is in CommonProxy public void preInit(FMLPreInitializationEvent e) { NetworkRegistry.INSTANCE.registerGuiHandler(MyBlocks.instance, new GuiHandler()); GameRegistry.registerTileEntity(TileMyFurance.class, "myrblocks_myfurnace"); } this is my GuiHandler public class GuiHandler implements IGuiHandler { @Override public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { switch(id) { case Reference.MY_GUI: return new GuiMyFurnace(player.inventory, (TileMyFurnace) world.getTileEntity(new BlockPos(x,y,z))); } return null; } @Override public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { switch(id) { case Reference.MY_GUI: return new ContainerMyFurnace(player.inventory, (TileMyFurnace) world.getTileEntity(new BlockPos(x,y,z))); } return null; } } This is my ContainerMyFurnace public class ContainerMyFurnace extends Container { private TileMyFurnace tileMyFurnace; private int cookTime; private int totalCookTime; private int furnaceBurnTime; private int currentItemBurnTime; public ContainerMyFurnace(InventoryPlayer inventoryPlayer, TileMyFurnace tileMyFurnace) { this.tileMyFurnace = tileMyFurnace; this.addSlotToContainer(new Slot(tileMyFurnace, 0, 56, 17)); this.addSlotToContainer(new Slot(tileMyFurnace, 1, 56, 53)); this.addSlotToContainer(new SlotFurnaceOutput(inventoryPlayer.player, tileMyFurnace, 2, 116, 35)); for(int i = 0; i < 3; ++i) { for(int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(inventoryPlayer, j+i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for(int i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); } } @Override public void addListener(IContainerListener listener) { super.addListener(listener); listener.sendAllWindowProperties(this, this.tileMyFurnace); } @SideOnly(Side.CLIENT) public void updateProgressBar(int id, int data) { this.tileMyFurnace.setField(id, data); } @Override public void detectAndSendChanges(){ super.detectAndSendChanges(); for (int i = 0; i < this.listeners.size(); ++i) { IContainerListener icontainerlistener = this.listeners.get(i); if (this.cookTime != this.tileMyFurnace.getField(2)) { icontainerlistener.sendWindowProperty(this, 2, this.tileMyFurnace.getField(2)); } if (this.furnaceBurnTime != this.tileMyFurnace.getField(0)) { icontainerlistener.sendWindowProperty(this, 0, this.tileMyFurnace.getField(0)); } if (this.currentItemBurnTime != this.tileMyFurnace.getField(1)) { icontainerlistener.sendWindowProperty(this, 1, this.tileMyFurnace.getField(1)); } if (this.totalCookTime != this.tileMyFurnace.getField(3)) { icontainerlistener.sendWindowProperty(this, 3, this.tileMyFurnace.getField(3)); } } this.cookTime = this.tileMyFurnace.getField(2); this.furnaceBurnTime = this.tileMyFurnace.getField(0); this.currentItemBurnTime = this.tileMyFurnace.getField(1); this.totalCookTime = this.tileMyFurnace.getField(3); } @Override public boolean canInteractWith(EntityPlayer player) { return this.tileMyFurnace.isUsableByPlayer(player); } @Override public ItemStack transferStackInSlot(EntityPlayer player, int par2){ ItemStack itemstack = null; Slot slot = (Slot) this.inventorySlots.get(par2); if(slot != null && slot.getHasStack()){ ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if(par2 == 2){ if(!this.mergeItemStack(itemstack1, 3, 39, true)){ return null; } slot.onSlotChange(itemstack1, itemstack); }else if(par2 != 1 && par2 != 0){ if(FurnaceRecipes.instance().getSmeltingResult(itemstack1) != null){ if(!this.mergeItemStack(itemstack1, 0, 1, false)){ return null; } }else if(TileMyFurnace.isItemFuel(itemstack1)){ if(!this.mergeItemStack(itemstack1, 1, 2, false)){ return null; } }else if(par2 >=3 && par2 < 30){ if(!this.mergeItemStack(itemstack1, 30, 39, false)){ return null; } }else if(par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)){ return null; } }else if(!this.mergeItemStack(itemstack1, 3, 39, false)){ return null; } if(itemstack1.getCount() == 0){ slot.putStack((ItemStack)null); }else{ slot.onSlotChanged(); } if(itemstack1.getCount() == itemstack.getCount()){ return null; } slot.onTake(player, itemstack1); } return itemstack; } } This is my GuiMyFurnace class @SideOnly(Side.CLIENT) public class GuiMyFurnace extends GuiContainer { private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/furnace.png"); private TileMyFurnace tileMyFurnace; public GuiMyFurnace(InventoryPlayer invPlayer, TileMyFurnace tile) { super(new ContainerMyFurnace(invPlayer, tile)); this.tileMyFurnace = tile; System.out.println("gui class: constructor print"); } protected void drawGuiContainerForegroundLayer(int arg0,int arg1) { System.out.println("draing gui"); String str = this.tileMyFurnace.hasCustomName() ? this.tileMyFurnace.getName() : I18n.format(this.tileMyFurnace.getName(), new Object[0]); //TODO what is this magic number? this.fontRenderer.drawString(str, this.xSize/2-this.fontRenderer.getStringWidth(str), 6, 4210752); this.fontRenderer.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 94, 4210752); super.drawGuiContainerForegroundLayer(arg0, arg1); } protected void drawGuiContainerBackgroundLayer(float arg0, int arg1, int arg2) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); this.mc.getTextureManager().bindTexture(furnaceGuiTextures); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); int i1; if(this.tileMyFurnace.isBurning()) { i1 = this.tileMyFurnace.getBurnTimeRemainingScale(12); this.drawTexturedModalRect(k + 56, l+36+12-i1, 176, 12-i1, 14, i1+2); } i1 = this.tileMyFurnace.getCookProgressSacled(24); this.drawTexturedModalRect(k+79, l+34, 126, 14, i1+1, 16); } } This is my TileMyFurnace public class TileMyFurnace extends TileEntity implements ITickable, ISidedInventory { private static final int[] slotsTop = new int[] {0}; private static final int[] slotsBottom = new int[] {2, 1}; private static final int[] slotsSides = new int[] {1}; private ItemStack[] furnaceItemStack = new ItemStack[3]; public int furnaceBurnTime; public int currentBurnTime; public int furnaceCookTime; private String furnaceName; @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList tagList = compound.getTagList("Items", 10); this.furnaceItemStack = new ItemStack[this.getSizeInventory()]; for(int i = 0; i < tagList.tagCount(); ++i) { NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); byte byte0 = tagCompound.getByte("Slot"); if(byte0 >= 0 && byte0 < this.furnaceItemStack.length) { this.furnaceItemStack[byte0] = new ItemStack(tagCompound); } } this.furnaceBurnTime = compound.getShort("BurnTime"); this.furnaceCookTime = compound.getShort("CookTime"); this.currentBurnTime = getItemBurnTime(this.furnaceItemStack[1]); if(compound.hasKey("CustomName", 8)) { this.furnaceName = compound.getString("CustomName"); } } public boolean isBurning() { return this.furnaceBurnTime > 0; } public void updateEntity() { boolean flag = this.furnaceBurnTime > 0; boolean flagl = false; if(this.furnaceBurnTime > 0) { --this.furnaceBurnTime; } if(!this.world.isRemote) { if(this.furnaceBurnTime == 0 && this.canSmelt()) { this.currentBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStack[1]); if(this.furnaceBurnTime > 0) { flagl = true; if(this.furnaceItemStack[1] != null) { this.furnaceItemStack[1].setCount(this.furnaceItemStack[1].getCount()-1); if(this.furnaceItemStack[1].getCount() == 0 ) { this.furnaceItemStack[1] = furnaceItemStack[1].getItem().getContainerItem(this.furnaceItemStack[1]); } } } } if(this.isBurning() && this.canSmelt()) { ++this.furnaceCookTime; if(this.furnaceCookTime == 200) { this.furnaceCookTime = 0; this.smeltItem(); flagl = true; } } else { this.furnaceCookTime = 0; } } if(flag != this.furnaceBurnTime > 0) { flagl = true; } if(flagl) { this.markDirty(); } } public static boolean isItemFuel(ItemStack itemStack) { return getItemBurnTime(itemStack) > 0; } public static int getItemBurnTime(ItemStack itemStack) { if(itemStack == null) { return 0; } else { Item item = itemStack.getItem(); if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR) { Block block = Block.getBlockFromItem(item); //TODO blocks and materials in here.. /*if(block == Blocks.ACACIA_FENCE) { return 200; } if(block.getMaterial() == Material.ROCK) { return 300; } */ } if(item == Items.APPLE) { return 300; } //etc return 300; } } public void smeltItem() { if(this.canSmelt()) { ItemStack itemStack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStack[0]); if(this.furnaceItemStack[2] == null) { this.furnaceItemStack[2] = itemStack.copy(); } else if(this.furnaceItemStack[2].getItem() == itemStack.getItem()) { this.furnaceItemStack[2].setCount(this.furnaceItemStack[2].getCount() + itemStack.getCount()); } } } private boolean canSmelt() { if(this.furnaceItemStack[0] == null) { return false; } else { ItemStack itemStack = FurnaceRecipes.instance().getSmeltingResult(this.furnaceItemStack[0]); if(itemStack == null) { return false; } if(this.furnaceItemStack[2] == null) { return true; } if(!this.furnaceItemStack[2].isItemEqual(itemStack)) { return false; } int result = furnaceItemStack[2].getCount() + itemStack.getCount(); return result <= getInventoryStackLimit() && result <= this.furnaceItemStack[2].getMaxStackSize(); } } @SideOnly(Side.CLIENT) public int getCookProgressSacled(int arg0) { return this.furnaceCookTime * arg0 / 200; } @SideOnly(Side.CLIENT) public int getBurnTimeRemainingScale(int arg0) { if(this.currentBurnTime == 0) { this.currentBurnTime = 200; } return this.furnaceBurnTime * arg0 / this.currentBurnTime; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setShort("BurnTime", (short)this.furnaceBurnTime); compound.setShort("CookTime", (short)this.furnaceCookTime); NBTTagList tagList = new NBTTagList(); for(int i = 0; i < this.furnaceItemStack.length; ++i) { if(this.furnaceItemStack[i] != null) { NBTTagCompound tagCompound = new NBTTagCompound(); tagCompound.setByte("Slot", (byte) i); this.furnaceItemStack[i].writeToNBT(tagCompound); tagList.appendTag(tagCompound); } } compound.setTag("Items", tagList); if(this.hasCustomName()) { compound.setString("CustomName", this.furnaceName); } return compound; } @Override public ItemStack decrStackSize(int arg0, int arg1) { if(this.furnaceItemStack[arg0] != null) { ItemStack itemStack; if(this.furnaceItemStack[arg0].getCount() <= arg1) { itemStack = this.furnaceItemStack[arg0]; this.furnaceItemStack[arg0] = null; return itemStack; } else { itemStack = this.furnaceItemStack[arg0].splitStack(arg1); if(this.furnaceItemStack[arg0].getCount() == 0) { this.furnaceItemStack[arg0] = null; } return itemStack; } } else { return null; } } @Override public int getInventoryStackLimit() { return 64; } @Override public int getSizeInventory() { return this.furnaceItemStack.length; } @Override public ItemStack getStackInSlot(int slot) { return this.furnaceItemStack[slot]; } @Override public boolean isEmpty() { // TODO Auto-generated method stub return false; } @Override public boolean isItemValidForSlot(int arg0, ItemStack itemStack) { return arg0 == 2 ? false : (arg0 == 1 ? isItemFuel(itemStack) : true); } @Override public boolean isUsableByPlayer(EntityPlayer player) { return this.world.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; } @Override public boolean canExtractItem(int arg0, ItemStack itemStack, EnumFacing arg1) { return arg0 != 1 || itemStack.getItem() == Items.BUCKET; } @Override public boolean canInsertItem(int arg0, ItemStack itemStack, EnumFacing arg1) { return this.isItemValidForSlot(arg0, itemStack); } @Override public void clear() { // TODO Auto-generated method stub } @Override public void closeInventory(EntityPlayer arg0) { } @Override public void openInventory(EntityPlayer arg0) { // TODO Auto-generated method stub } @Override public ItemStack removeStackFromSlot(int arg0) { // TODO Auto-generated method stub return null; } @Override public void setField(int arg0, int arg1) { // TODO Auto-generated method stub } @Override public void setInventorySlotContents(int slot, ItemStack itemStack) { this.furnaceItemStack[slot] = itemStack; if(itemStack != null && itemStack.getCount() > this.getInventoryStackLimit()) { itemStack.setCount(this.getInventoryStackLimit()); } } @Override public String getName() { return this.hasCustomName() ? this.furnaceName : "My Custom Furnace"; } @Override public boolean hasCustomName() { return this.furnaceName != null && this.furnaceName.length() > 0; } @Override public int[] getSlotsForFace(EnumFacing arg0) { // TODO Auto-generated method stub return null; } @Override public void update() { // TODO Auto-generated method stub } @Override public int getField(int arg0) { // TODO Auto-generated method stub return 0; } @Override public int getFieldCount() { // TODO Auto-generated method stub return 0; } } And this is my BlockMyFurnace public class BlockMyFurnace extends BlockBase { private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0f, 0f, 0f, 1f, 0.25f, 1f); boolean hasTileEntity = true; public BlockMyFurnace(String name, Material material, SoundType sound, float hardness, float resistance, int flamabilitiy, boolean isFlamable, boolean isFireSource, boolean isFullBlock, boolean isFullCube, boolean isOpaqueCube, BlockRenderLayer blockLayer, CreativeTabs tab) { super(name, material, sound, hardness, resistance, flamabilitiy, isFlamable, isFireSource, isFullBlock, isFullCube, isOpaqueCube, blockLayer, tab); } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return BOUNDING_BOX; } @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB col, List<AxisAlignedBB> colList, Entity entity, boolean addColToList) { super.addCollisionBoxToList(pos,col,colList, BOUNDING_BOX); } @Override public boolean hasTileEntity(IBlockState state) { // TODO Auto-generated method stub return true; } @Override public TileEntity createTileEntity(World world, IBlockState state) { // TODO Auto-generated method stub return new TileMyFurnace(); } @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { System.out.println("block activated"); if (!world.isRemote) { TileEntity te = world.getTileEntity(pos); if (!(te instanceof TileMyFurnace)) { return false; } player.openGui(MyBlocks.instance, Reference.MY_GUI, world, pos.getX(), pos.getY(), pos.getZ()); } return true; } @Override public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity tileMyFurnace = world.getTileEntity(pos); return tileMyFurnace == null || !(tileMyFurnace instanceof TileMyFurnace) || !((TileMyFurnace)tileMyFurnace).isBurning() ? 0 : 14; } private void spawnParticle(World world, BlockPos pos, Random rand, boolean isFire) { double x = pos.getX() + 0.375d + (rand.nextDouble() * 0.25d); double y = pos.getY() + 0.25d + (rand.nextDouble() * 0.125d); double z = pos.getZ() + 0.375d + (rand.nextDouble() * 0.25d); EnumParticleTypes smoke = EnumParticleTypes.SMOKE_NORMAL; EnumParticleTypes flame = EnumParticleTypes.FLAME; world.spawnParticle(smoke, x, y, z, 0, 0, 0); world.spawnParticle(flame, x, y, z, 0, 0, 0); } @SideOnly(Side.CLIENT) @Override public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random random) { world.scheduleUpdate(pos, this, this.tickRate(world)); world.checkLightFor(EnumSkyBlock.BLOCK, pos); //This is where the particles are spawned when cooking TileEntity tileMyFurnace = world.getTileEntity(pos); if(tileMyFurnace == null) return; boolean cooking = ((TileMyFurnace) tileMyFurnace).isBurning(); if(cooking) { //Spawns between 2 and 5 fire particles for(int i = 0; i < random.nextInt(3) + 1; i++) spawnParticle(world, pos, random, true); //Spawns between 0 and 3 smoke particles for(int i = 1; i < random.nextInt(4); i++) spawnParticle(world, pos, random, false); } } }
  12. hi, im trying to create some subblocks. i wanted to use the same model and two different textures per type the blocks are showing as purple and black instead of one sandstone and stone Firstly this is my Blockstate JSON: file is called bs_sandstone { "forge_marker": 1, "defaults": { "model": "myblocks:myblock", "uvlock": false }, "variants": { "facing": { "north": { "y": 180 }, "south": { }, "east" : { "y" : 270 }, "west" : { "y" : 90 } }, "inventory": [{}], "type": { "sandstone" : { "textures": { "0": "blocks/sandstone_top", "1": "blocks/sandstone_normal"} }, "stone" : { "textures": { "0": "blocks/stone_slab_top", "1": "blocks/stone_slab_side"} } } } needs to have facing as i need it to be orientable Next, this is my stone and sandstone model JSON, as you can see below the model has 2 textures by default { "parent": "block/block", "textures": { "0": "blocks/sandstone_top", "1": "blocks/sandstone_normal" }, "display": { "gui": { "rotation": [ 30, 225, 0 ], "translation": [ 0, 0, 0], "scale":[ 0.625, 0.625, 0.625 ] }, "ground": { "rotation": [ 0, 0, 0 ], "translation": [ 0, 3, 0], "scale":[ 0.25, 0.25, 0.25 ] }, "fixed": { "rotation": [ 0, 0, 0 ], "translation": [ 0, 0, 0], "scale":[ 0.5, 0.5, 0.5 ] }, "thirdperson_righthand": { "rotation": [ 75, 45, 0 ], "translation": [ 0, 2.5, 0], "scale": [ 0.375, 0.375, 0.375 ] }, "firstperson_righthand": { "rotation": [ 0, 45, 0 ], "translation": [ 0, 0, 0 ], "scale": [ 0.40, 0.40, 0.40 ] }, "firstperson_lefthand": { "rotation": [ 0, 225, 0 ], "translation": [ 0, 0, 0 ], "scale": [ 0.40, 0.40, 0.40 ] } }, "elements": [ { //blahh... } ] } Next is the item JSON, again all variants are the same except texture { "parent": "myblocks/items/myblock", "textures": { "layer0": "blocks/sandstone_normal" } } This is my enum class for the block types: public enum EnumBlockType implements IStringSerializable{ STONE(0, "stone"), SANDSTONE(1,"sandstone"), SAND(2, "sand"), DIRT(3, "dirt"); private final int id; private final String name; private static final EnumBlockType[] META_LOOKUP = new EnumBlockType[values().length]; EnumBlockType(int id, String name) { this.id = id; this.name = name; } public static EnumBlockType byMetaData(int meta) { if(meta < 0 || meta >= META_LOOKUP.length) { meta = 0; } return META_LOOKUP[meta]; } static { for(EnumBlockType type : values()) { META_LOOKUP[type.getId()] = type; } } @Override public String toString() { return getName(); } public int getId() { return id; } @Override public String getName() { return name; } } This is my ModBlocks class where i create the block: public class ModBlocks { public static BlockBase blockWithVariants = new MyCustomBlock("bs_sandstone", Material.ROCK, 2f, 0.75f, false,false,false, BlockRenderLayer.SOLID, CreativeTabs.MATERIALS); public static List<Block> BLOCKS = new ArrayList<Block>(); public static void register(RegistryEvent.Register<Block> event){ BLOCKS.add(blockWithVariants); for(Block block : BLOCKS){ event.getRegistry().register(block); } } public static void registerItemBlocks(RegistryEvent.Register<Item> event) { for(Block block : BLOCKS){ event.getRegistry().register(new ItemBlock(block) .setRegistryName(block.getRegistryName()) .setMaxStackSize(64)); } } public static void registerModels() { blockWithVariants.registerItemModel(Item.getItemFromBlock(blockWithVariants)); } Finally, this is my MyCustomBlock class that each block uses: public class MyCustomBlock extends BlockBase { public static final PropertyEnum<EnumBlockType> BLOCK_TYPE = PropertyEnum.<EnumBlockType>create("type", EnumBlockType.class); private static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0f, 0f, 0f, 1f, 1f, 0.5f); boolean isFullBlock = false; boolean isFullCube = false; boolean isOpaqueCube = false; BlockRenderLayer blockLayer; public MyCustomBlock(String name, Material material, float hardness, float resistance, boolean isFullBlock, boolean isFullCube, boolean isOpaqueCube, BlockRenderLayer blockLayer, CreativeTabs tab) { super(material,name); this.isFullBlock = isFullBlock; this.isFullCube = isFullCube; this.isOpaqueCube = isOpaqueCube; this.blockLayer = blockLayer; setCreativeTab(tab); setUnlocalizedName(name); setHardness(hardness); setResistance(resistance); setDefaultState(this.blockState.getBaseState().withProperty(BlockHorizontal.FACING, EnumFacing.NORTH) .withProperty(BLOCK_TYPE, EnumBlockType.SANDSTONE)); } @Override public int damageDropped(IBlockState state){ EnumBlockType enumType = (EnumBlockType)state.getValue(BLOCK_TYPE); return enumType.getId(); } @Override @SideOnly(Side.CLIENT) public void getSubBlocks(CreativeTabs tabs, NonNullList<ItemStack> list) { EnumBlockType[] allTypes = EnumBlockType.values(); for(EnumBlockType type : allTypes){ list.add(new ItemStack(this, 1, type.getId())); } super.getSubBlocks(tabs, list); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { // TODO getStateForPlacement is depreciated EnumBlockType type = EnumBlockType.byMetaData(meta); IBlockState state = super.getStateForPlacement(world,pos,facing,hitX,hitY,hitZ,meta,placer); return state.withProperty(BlockHorizontal.FACING, placer.getHorizontalFacing()).withProperty(BLOCK_TYPE, type); } @Override public int getMetaFromState(IBlockState state) { EnumBlockType type = (EnumBlockType)state.getValue(BLOCK_TYPE); return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); } @Override public IBlockState getStateFromMeta(int meta) { EnumBlockType type = EnumBlockType.byMetaData(meta); return getDefaultState().withProperty(BlockHorizontal.FACING,EnumFacing.getHorizontal(meta)); } @Override protected BlockStateContainer createBlockState() { //may not be like this... return new BlockStateContainer(this, new IProperty[] {BlockHorizontal.FACING, BLOCK_TYPE}); } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return BOUNDING_BOX; } @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB col, List<AxisAlignedBB> colList, Entity entity, boolean addColToList) { super.addCollisionBoxToList(pos,col,colList, BOUNDING_BOX); } @Override public boolean isFullCube(IBlockState state) { return isFullCube; //only for full cube blocks } @Override public boolean isFullBlock(IBlockState state) { return isFullBlock; //only for full block blocks } @Override public boolean isOpaqueCube(IBlockState state) { return isOpaqueCube; //only for opaque blocks } @Override public BlockRenderLayer getBlockLayer() { return blockLayer; //change depending on type of block } } so the items are showing up in game, but just as the purple blocks and there seems to be more than i actually coded into the enum and the json (about 4)
×
×
  • Create New...

Important Information

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