Jump to content

TrekkieCub314

Members
  • Posts

    68
  • Joined

  • Last visited

Everything posted by TrekkieCub314

  1. Two of the three problems are now solved: To render the custom fluid correctly, instead of calling getFluid().getStillIcon, I used getFluid().getBlock().getBlockTextureFromSide(0) and it worked for both the gui and the block renderer. The icon for the block was mostly copy-paste from RenderBlocks.renderBlockAsItem() with the metadata being passed in being modified with the corresponding block's getIcon() function being modified to accommodate. I am still unsure how to render the icon for the item being processed on top of the fluid and item slot I'm rendering when the block is updated.
  2. Looking at Render_Immersion_Tank.java line 37, I see the call to renderFaceXNeg. renderer.renderFaceXNeg(block, x, y, z, newIcon); Only two things could possibly be null here: block or newIcon . My bet is on newIcon . Insert some debug statements to figure out which path through your if statement the code is taking and what value newIcon has at each step. Work backwards until you figure out where the null is coming from and why. It couldn't be block. The error starts in the RenderBlocks class, at this line: double d3 = (double)p_147798_8_.getInterpolatedU(this.renderMinZ * 16.0D); The only thing that could be null in this case is the p_147798_8, which is the IIcon passed into the function renderFaceXNeg. A null value had to be passed into the renderFaceXNeg function. Looking back at the Render_Immersion_Tank file, we see the icon is set to the icon of water when it is created. I then check some conditions to see if I should render a default face instead of a liquid. The only other change that occurs with the icon is when that if statement doesn't go through and it falls to the else statement below. Since there was no null pointer error here, the tile entity, its FluidTank, and that FluidTank's fluid were not null. The only place the null value could come from was the getStillIcon() function. Looking back at the fluid file, the getStillIcon() function calls the getIcon function, with parameters passed to ensure the flowing icon gets returned. The only way to get a null value out of that is if the getStillIcon() function is being called before the registerBlockIcons function, and I'm not sure how that is happening. Changing the getStillIcon function to get the stillIcon item directly doesn't help.
  3. I didn't include a crash report because this isn't the first time I've programmed and I know how to parse error messages. A NullPointer exception comes up when trying to use a method or access a property of a field which isn't instantiated or is set to null. Hence why I explained where the error is coming from in the OP. But if you want the crash report, here it is: [spoiler=crash report] java.lang.NullPointerException: Unexpected error at net.minecraft.client.renderer.RenderBlocks.renderFaceXNeg(RenderBlocks.java:7652) at com.trekkiecub.allthethings.Render_Immersion_Tank.renderWorldBlock(Render_Immersion_Tank.java:37) at cpw.mods.fml.client.registry.RenderingRegistry.renderWorldBlock(RenderingRegistry.java:118) at net.minecraft.src.FMLRenderAccessLibrary.renderWorldBlock(FMLRenderAccessLibrary.java:53) at net.minecraft.client.renderer.RenderBlocks.renderBlockByRenderType(RenderBlocks.java:386) at net.minecraft.client.renderer.WorldRenderer.updateRenderer(WorldRenderer.java:206) at net.minecraft.client.renderer.RenderGlobal.updateRenderers(RenderGlobal.java:1610) at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1251) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1086) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1010) at net.minecraft.client.Minecraft.run(Minecraft.java:898) at net.minecraft.client.main.Main.main(Main.java:112) 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:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
  4. So, I seem to be having some problems when it comes to Icons. 1: I have a machine that renders the icon of the fluid it contains, but this is only working for vanilla fluids. I have one custom fluid created so far, but when I try to render the icon, I get a NullPointer Exception, and where it's being called from is telling me that I'm getting a null value for the still icon in the fluid. I rearranged my main mod file to see if the problem was in the order I was instantiating the blocks/fluids and registering them, but that didn't seem to work (unless I messed that up) [spoiler=Mod File] package com.trekkiecub.allthethings; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.FMLEventChannel; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; @Mod(modid="TrekkieCub_AllTheThings", name = "Trekkie Cub's All The Things", version = "alpha") public class mod_TCAllTheThings { // // Create an instance of the mod // @Instance("mod_TCAllTheThings") public static mod_TCAllTheThings instance; // // Creative Mode Tab // public static CreativeTabs allTheThingsTab = new CreativeTabs("allTheThings"){ @Override public Item getTabIconItem() { return Items.emerald; } }; // // Item Declarations // public static Item Paper_Bowl, Shard_Diamond, Shard_Stone, Powdered_Diamond, Powdered_Stone, Fried_Egg, Burial_Wraps, Bread_Slice, Toast, Crouton, Paper_Mushroom_Stew, Lettuce, Bucket_Boiling_Water, Nugget_Iron, Throwing_Star, Throwing_Star_anim, Boomerang_anim, Boomerang, Wood_Board, Amber; // // Block Declarations // public static Block Rock_Crusher, dummy_Rock_Crusher, Immersion_Tank, Light_Stone, Block_Boiling_Water, Block_Amber; // // Fluid Declarations // public Fluid Boiling_Water; // // Proxy Definitions // @SidedProxy(clientSide = "com.trekkiecub.allthethings.Proxy_Client", serverSide = "com.trekkiecub.allthethings.Proxy_Server") public static Proxy_Common commonProxy; public static Proxy_Client clientProxy = new Proxy_Client(); public static final String channelName = "TCAllTheThingsChannel"; // // Pre-Initialization Event // @EventHandler public void preInit(FMLPreInitializationEvent e) { this.clientProxy.preInit(e); // // Item Definitions // Paper_Bowl = new Item_Paper_Bowl().setCreativeTab(allTheThingsTab).setUnlocalizedName("paper_bowl").setTextureName("trekkiecub:paper_bowl"); Shard_Diamond = new Item_Shard_Diamond(); Shard_Stone = new Item_Shard_Stone().setCreativeTab(allTheThingsTab).setUnlocalizedName("shard_stone").setTextureName("trekkiecub:shard_rock"); Powdered_Diamond = new Item_Powdered_Diamond().setCreativeTab(allTheThingsTab).setUnlocalizedName("powdered_diamond").setTextureName("trekkiecub:powdered_diamond"); Powdered_Stone = new Item_Powdered_Stone().setCreativeTab(allTheThingsTab).setUnlocalizedName("powdered_stone").setTextureName("trekkiecub:powdered_stone"); Fried_Egg = new Item_Fried_Egg(6, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("fried_egg").setTextureName("trekkiecub:fried_egg"); Bread_Slice = new Item_Slice_Bread(1, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("bread_slice").setTextureName("trekkiecub:bread_slice"); Burial_Wraps = new Item_Burial_Wraps().setCreativeTab(allTheThingsTab).setUnlocalizedName("burial_wraps").setTextureName("trekkiecub:burial_wraps"); Toast = new Item_Toast(1, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("toast").setTextureName("trekkiecub:toast"); Crouton = new Item_Crouton().setCreativeTab(allTheThingsTab).setUnlocalizedName("crouton").setTextureName("trekkiecub:crouton"); Paper_Mushroom_Stew = new Item_Disp_Mushroom_Stew(6, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("paper_mushroom_stew").setTextureName("trekkiecub:paper_mushroom_stew"); Lettuce = new Item_Lettuce(2, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("lettuce").setTextureName("trekkiecub:lettuce"); Nugget_Iron = new Item_Nugget_Iron().setCreativeTab(allTheThingsTab).setUnlocalizedName("nugget_iron").setTextureName("trekkiecub:nugget_iron"); Throwing_Star = new Item_Throwing_Star().setCreativeTab(allTheThingsTab).setUnlocalizedName("throwing_star").setTextureName("trekkiecub:throwing_star"); Throwing_Star_anim = new Item_Throwing_Star_Spin().setTextureName("trekkiecub:throwing_star_spin").setCreativeTab(null); Boomerang_anim = new Item_Boomerang_Spin().setTextureName("trekkiecub:boomerang_spin").setCreativeTab(null); Boomerang = new Item_Boomerang().setTextureName("trekkiecub:boomerang").setCreativeTab(allTheThingsTab).setUnlocalizedName("boomerang"); Wood_Board = new Item_Wood_Board().setTextureName("trekkiecub:wood_board").setCreativeTab(allTheThingsTab).setUnlocalizedName("wood_board"); Amber = new Amber().setCreativeTab(allTheThingsTab).setUnlocalizedName("amber").setTextureName("trekkiecub:amber"); // // Item Registry // GameRegistry.registerItem(Paper_Bowl, "paper_bowl"); GameRegistry.registerItem(Shard_Diamond, "shard_diamond"); GameRegistry.registerItem(Powdered_Diamond, "powdered_diamond"); GameRegistry.registerItem(Powdered_Stone, "powdered_stone"); GameRegistry.registerItem(Shard_Stone, "shard_stone"); GameRegistry.registerItem(Fried_Egg, "fried_egg"); GameRegistry.registerItem(Burial_Wraps, "burial_wraps"); GameRegistry.registerItem(Bread_Slice, "bread_slice"); GameRegistry.registerItem(Toast, "toast"); GameRegistry.registerItem(Crouton, "crouton"); GameRegistry.registerItem(Paper_Mushroom_Stew, "paper_mushroom_stew"); GameRegistry.registerItem(Lettuce, "lettuce"); GameRegistry.registerItem(Nugget_Iron, "nugget_iron"); GameRegistry.registerItem(Throwing_Star, "throwing_star"); GameRegistry.registerItem(Throwing_Star_anim, "throwing_star_anim"); GameRegistry.registerItem(Boomerang_anim, "boomerang_anim"); GameRegistry.registerItem(Boomerang, "boomerang"); GameRegistry.registerItem(Wood_Board, "wood_board"); GameRegistry.registerItem(Amber, "amber"); // // Block Definitions // Rock_Crusher = new Block_Rock_Crusher(Material.rock, false).setStepSound(Block.soundTypeStone).setBlockName("block_rock_crusher").setCreativeTab(allTheThingsTab).setBlockTextureName("trekkiecub:rock_crusher"); dummy_Rock_Crusher = new Block_Rock_Crusher(Material.rock, true).setStepSound(Block.soundTypeStone).setBlockName("block_rock_crusher").setBlockTextureName("trekkiecub:rock_crusher").setLightLevel((float)1/15); Light_Stone = new Block_Light_Stone(Material.rock).setStepSound(Block.soundTypeStone).setBlockName("block_light_stone").setCreativeTab(allTheThingsTab).setBlockTextureName("stone_slab_top"); Block_Amber = new Block_Amber(Material.iron).setBlockName("block_amber").setCreativeTab(allTheThingsTab).setBlockTextureName("trekkiecub:block_amber").setHardness(3.0F).setResistance(10.0F).setStepSound(Block.soundTypeStone); // // Block Registry // GameRegistry.registerBlock(Rock_Crusher, "block_rock_crusher"); GameRegistry.registerBlock(dummy_Rock_Crusher, "lit_block_rock_crusher"); GameRegistry.registerBlock(Light_Stone, "block_light_stone"); GameRegistry.registerBlock(Block_Amber, "block_amber"); // // Entity Registry // int ID_Mummy = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(Entity_Mummy.class, "Mummy", ID_Mummy); EntityRegistry.registerModEntity(Entity_Mummy.class, "Mummy", ID_Mummy, this, 80, 1, true); EntityRegistry.addSpawn(Entity_Mummy.class, 2, 0, 1, EnumCreatureType.monster, BiomeGenBase.desert); EntityList.entityEggs.put(Integer.valueOf(ID_Mummy), new EntityList.EntityEggInfo(ID_Mummy, 0xe9e5c3, 0xc6c57b)); int ID_Throwing_Star = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(Entity_Throwing_Star.class, "Throwing Star", ID_Throwing_Star); EntityRegistry.registerModEntity(Entity_Throwing_Star.class, "Throwing Star", ID_Throwing_Star, this, 64, 10, true); int ID_Boomerang = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(Entity_Boomerang.class, "Boomerang", ID_Boomerang); EntityRegistry.registerModEntity(Entity_Boomerang.class, "Boomerang", ID_Boomerang, this, 64, 1, true); // // Fluid Stuff // Boiling_Water = new Fluid("boiling_water"); FluidRegistry.registerFluid(Boiling_Water); Block_Boiling_Water = new Fluid_Boiling_Water(Boiling_Water, Material.water).setBlockName("block_boiling_water"); GameRegistry.registerBlock(Block_Boiling_Water, "block_boiling_water"); Boiling_Water.setUnlocalizedName(Block_Boiling_Water.getUnlocalizedName()); Bucket_Boiling_Water = new Item_Bucket_Boiling_Water(Block_Boiling_Water).setCreativeTab(allTheThingsTab).setUnlocalizedName("bucket_boiling_water").setContainerItem(Items.bucket).setTextureName("trekkiecub:bucket_boiling_water"); GameRegistry.registerItem(Bucket_Boiling_Water, "bucket_boiling_water"); FluidContainerRegistry.registerFluidContainer(Boiling_Water, new ItemStack(Bucket_Boiling_Water), new ItemStack(Items.bucket)); Handler_Bucket.INSTANCE.buckets.put(Block_Boiling_Water, Bucket_Boiling_Water); MinecraftForge.EVENT_BUS.register(Handler_Bucket.INSTANCE); // // Fluid-reliant Items/Blocks // Immersion_Tank = new Block_Immersion_Tank(Material.rock).setStepSound(Block.soundTypeStone).setBlockName("block_immersion_tank").setCreativeTab(allTheThingsTab).setBlockTextureName("trekkiecub:immersion_tank"); GameRegistry.registerBlock(Immersion_Tank, "block_immersion_tank"); // // Crafting Recipes // GameRegistry.addRecipe(new ItemStack(Paper_Bowl, 10), "p p", " p ", 'p', Items.paper); GameRegistry.addRecipe(new ItemStack(Rock_Crusher), "cpc", "p p", "cpc", 'c', Blocks.cobblestone, 'p', Blocks.piston); GameRegistry.addRecipe(new ItemStack(Items.spawn_egg, 1, 50), "ggg", "geg", "ggg", 'g', Items.gunpowder, 'e', Items.egg); GameRegistry.addRecipe(new ItemStack(Items.spawn_egg, 1, ID_Mummy), "www", "wew", "www", 'w', Burial_Wraps, 'e', Items.egg); GameRegistry.addRecipe(new ItemStack(Immersion_Tank), "i i", "ici", "iii", 'i', Items.iron_ingot, 'c', Blocks.chest); GameRegistry.addRecipe(new ItemStack(Blocks.cobblestone), "rr", "rr", 'r', Shard_Stone); GameRegistry.addShapelessRecipe(new ItemStack(Bread_Slice, , new ItemStack(Items.bread)); GameRegistry.addShapelessRecipe(new ItemStack(Immersion_Tank), new ItemStack(Blocks.cauldron), new ItemStack(Blocks.chest)); GameRegistry.addShapelessRecipe(new ItemStack(Crouton, 4), new ItemStack(Toast)); GameRegistry.addShapelessRecipe(new ItemStack(Paper_Mushroom_Stew),new ItemStack(Paper_Bowl), new ItemStack(Blocks.red_mushroom), new ItemStack(Blocks.brown_mushroom)); GameRegistry.addShapelessRecipe(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.stone_slab, 1, 3), new ItemStack(Blocks.stone_slab, 1, 3)); // Make separate block GameRegistry.addShapelessRecipe(new ItemStack(Blocks.brick_block), new ItemStack(Blocks.stone_slab, 1, 4), new ItemStack(Blocks.stone_slab, 1, 4)); GameRegistry.addShapelessRecipe(new ItemStack(Blocks.stonebrick), new ItemStack(Blocks.stone_slab, 1, 5), new ItemStack(Blocks.stone_slab, 1, 5)); GameRegistry.addShapelessRecipe(new ItemStack(Blocks.nether_brick), new ItemStack(Blocks.stone_slab, 1, 6), new ItemStack(Blocks.stone_slab, 1, 6)); GameRegistry.addShapelessRecipe(new ItemStack(Blocks.quartz_block), new ItemStack(Blocks.stone_slab, 1, 7), new ItemStack(Blocks.stone_slab, 1, 7)); GameRegistry.addShapelessRecipe(new ItemStack(Light_Stone), new ItemStack(Blocks.stone_slab, 1, 0), new ItemStack(Blocks.stone_slab, 1, 0)); GameRegistry.addShapelessRecipe(new ItemStack(Nugget_Iron, 9), new ItemStack(Items.iron_ingot)); GameRegistry.addRecipe(new ItemStack(Throwing_Star, 4), " f ", "fif", " f ", 'f', Items.flint, 'i', Items.iron_ingot); GameRegistry.addRecipe(new ItemStack(Blocks.planks), "ww", "ww", 'w', Wood_Board); GameRegistry.addRecipe(new ItemStack(Boomerang), " w ", "w w", 'w', Wood_Board); // // Smelting Recipes // GameRegistry.addSmelting(Items.egg, new ItemStack(Fried_Egg), 0); GameRegistry.addSmelting(Bread_Slice, new ItemStack(Toast), 0); GameRegistry.addSmelting(Powdered_Stone, new ItemStack(Shard_Stone), 0); GameRegistry.addSmelting(Items.water_bucket, new ItemStack(Bucket_Boiling_Water), 0); // // Proxy Functions // clientProxy.registerRenderThings(); // GameRegistry.registerTileEntity(TileEntity_ImmersionTank.class, "immersion_tank"); } // // Initialization Event // @EventHandler public void Init(FMLInitializationEvent e) { this.clientProxy.init(e); } // // Post-Initialization Event // @EventHandler public void postInit(FMLPostInitializationEvent e) { this.clientProxy.postInit(e); // // Network Registry // NetworkRegistry.INSTANCE.registerGuiHandler(this, new Handler_Gui()); } } [spoiler=Liquid File] package com.trekkiecub.allthethings; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class Fluid_Boiling_Water extends BlockFluidClassic { @SideOnly(Side.CLIENT) protected IIcon stillIcon, flowingIcon; public Fluid_Boiling_Water(Fluid fluid, Material material) { super(fluid, material); // TODO Auto-generated constructor stub } @Override public IIcon getIcon(int side, int meta) { return (side == 0 || side == 1) ? stillIcon : flowingIcon; } //@SideOnly(Side.CLIENT) @Override public void registerBlockIcons(IIconRegister register) { stillIcon = register.registerIcon("trekkiecub:still_boiling_water"); flowingIcon = register.registerIcon("trekkiecub:flow_boiling_water"); } @Override public boolean canDisplace(IBlockAccess world, int x, int y, int z) { if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; return super.canDisplace(world, x, y, z); } @Override public boolean displaceIfPossible(World world, int x, int y, int z) { if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; return super.displaceIfPossible(world, x, y, z); } public IIcon getStillIcon() { return getIcon(0, 0); } public IIcon getFlowingIcon() { return getIcon(1, 0); } } [spoiler=Block Renderer] package com.trekkiecub.allthethings; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import com.trekkiecub.allthethings.Block_Immersion_Tank; public class Render_Immersion_Tank implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { // TODO Auto-generated method stub } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { if (Proxy_Client.renderPass == 0) { TileEntity_ImmersionTank tileEnt = (TileEntity_ImmersionTank) world.getTileEntity(x, y, z); IIcon newIcon = FluidRegistry.WATER.getIcon(); if (tileEnt.getFluid() == null || tileEnt.getFluid().getFluid() == null || tileEnt.getFluid().amount == 0) { newIcon = ((Block_Immersion_Tank) block).front_fluid; } else newIcon = tileEnt.getFluid().getFluid().getStillIcon(); renderer.renderFaceXNeg(block, x, y, z, newIcon); renderer.renderFaceXPos(block, x, y, z, newIcon); renderer.renderFaceZNeg(block, x, y, z, newIcon); renderer.renderFaceZPos(block, x, y, z, newIcon); renderer.renderFaceYNeg(block, x, y, z, newIcon); renderer.renderFaceYPos(block, x, y, z, newIcon); //renderer.renderStandardBlock(Blocks.flowing_water, x, y, z); } else { renderer.renderStandardBlock(mod_TCAllTheThings.Immersion_Tank, x, y, z); } return true; } @Override public boolean shouldRender3DInInventory(int modelId) { // TODO Auto-generated method stub return false; } @Override public int getRenderId() { return Proxy_Client.immersionTankRenderType; } } 2: Because I am using a custom renderer, I'm not sure how to go about rendering the icon for the block while in the inventory. Currently it's using the block's top face, but I'd like it to render like a furnace might. 3: I am using a GUI for my block that renders the icon of the fluid as a large box in the center of the gui, but I also wanted to have the graphic for an item slot appear on top of that. As such, I rendered the fluid, then the graphic on top of that. Unfortunately, when working, the icon for the item I place in the slot disappears as it's being rendered over by the fluid and the graphic. I was thinking about getting the icon for the item in the appropriate slot from the tile entity that was passed in, but I can't get further than getting the item. I'm not sure how to get the icon from the item, and the item passed in can either be a regular Item or an item obtained from a Block. [spoiler=GUI] package com.trekkiecub.allthethings; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; public class Gui_ImmersionTank extends GuiContainer { private TileEntity_ImmersionTank tileTank; public Gui_ImmersionTank(InventoryPlayer invPlayer, TileEntity_ImmersionTank tileImmTank) { super(new Container_ImmersionTank(invPlayer, tileImmTank)); this.tileTank = tileImmTank; } @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { fontRendererObj.drawString("Immersion Tank", 8, 6, 4210752); fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize-96+2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { this.mc.renderEngine.bindTexture(new ResourceLocation("trekkiecub:textures/gui/immersion_tank.png")); int x = (this.width - this.xSize)/2; int y = (this.height - this.ySize)/2; this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); // Soak Progress Bar int startPoint = this.tileTank.getSoakProgressScaled(54); this.drawTexturedModalRect(x+62, x+69, 2, 176, startPoint+1, 5); // Fluid FluidStack fluid = tileTank.getFluid(); IIcon drawThis; if (fluid == null) { drawThis = FluidRegistry.WATER.getStillIcon(); } else drawThis = fluid.getFluid().getStillIcon(); mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); GL11.glColor3f(1.0F,1.0F,1.0F); int rectHeight = this.tileTank.getFluidAmountScaled(37); this.drawTexturedModelRectFromIcon(x+65, y+27+(37-rectHeight), drawThis, 48, rectHeight); // max 63 // Draw slot item on top of fluid texture this.mc.renderEngine.bindTexture(new ResourceLocation("trekkiecub:textures/gui/immersion_tank.png")); GL11.glColor3f(1.0F, 1.0F, 1.0F); this.drawTexturedModalRect(x+79, y+36, 79, 36, 18, 18); // Figure out how to draw item icon here // Draw progress bar int i1 = this.tileTank.getSoakProgressScaled(54); this.drawTexturedModalRect(x+63, y+69, 3, 167, i1, 5); } } If anyone knows how to help me with these and is willing to provide said help, I'd greatly appreciate it!
  5. I've now got (mostly) everything working when it comes to NBT. The machine is working correctly. The only problem I still have is items/fluids and such are not being saved when the world exits, despite the fact that it is being saved to an NBT tag. I'm guessing I need to save to a different NBT tag, but I don't know where such a tag would be located. Does anyone know what I need to do to get NBT to save stuff to the computer?
  6. The most recent problem with this has been fixed, but I'm now having a problem I think with the Container file. Should I continue this thread or should I start a new one?
  7. You can set up the container's constructor to pass a tile entity and then only add slot objects if it's supposed to.
  8. Sorry about that. Meant to include that with the update statement if the spoiler thing in the previous post didn't indicate that. [spoiler=writeNBT] public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < itemStacks.length; ++i) { if (itemStacks[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); itemStacks[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } tag.setTag("Items", nbttaglist); tag.setInteger("progress", progress); if (theFluid.getFluid() == null || theFluid.getFluidAmount() == 0) { tag.setInteger("FluidID", -1); } else tag.setInteger("FluidID", theFluid.getFluid().fluidID); tag.setInteger("FluidAmount", theFluid.getFluidAmount()); } [spoiler=ReadNBT] public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); NBTTagList nbttaglist = tag.getTagList("Items", 3); itemStacks = new ItemStack[getSizeInventory()]; progress = tag.getInteger("progress"); if (tag.getInteger("FluidID") >= 0) { Fluid storedFluid = FluidRegistry.getFluid(tag.getInteger("FluidID")); int fluidAmt = tag.getInteger("FluidAmount"); theFluid.setFluid(new FluidStack(storedFluid, fluidAmt)); } for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound tag1 = nbttaglist.getCompoundTagAt(i); int j = tag1.getByte("Slot") & 255; if (j >= 0 && j < itemStacks.length) { itemStacks[j] = ItemStack.loadItemStackFromNBT(tag1); } } worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } Some of the code from updateEntity() was commented out so I could test stuff. This is what is running. [spoiler=updateEntity] @Override public void updateEntity() { if (!this.worldObj.isRemote) { if (this.canFill()) { fillTank(); } if (theFluid != null && theFluid.getFluid() != null && theFluid.getFluidAmount() > 0) { itemStacks[2] = new ItemStack(Items.cake); } if (this.worldObj != null) { this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } markDirty(); } }
  9. It seems I'm still having some interesting problems. I was having problems equating item stacks but that has now been resolved. Fluids are being input into the machine correctly, but when I go to the GUI, the items appear to be invisible. I can click on the locations where the items are supposed to be at and get the items, but they don't appear in the GUI. Items are still not being saved when exiting the world. My NBT and Update functions are the only ones that changed [spoiler=NBT and Update functions] public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < itemStacks.length; ++i) { if (itemStacks[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); itemStacks[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } tag.setTag("Items", nbttaglist); tag.setInteger("progress", progress); if (theFluid.getFluid() == null || theFluid.getFluidAmount() == 0) { tag.setInteger("FluidID", -1); } else tag.setInteger("FluidID", theFluid.getFluid().fluidID); tag.setInteger("FluidAmount", theFluid.getFluidAmount()); }
  10. This is the TileEntity file I have now. Right now items are not being kept between exiting the world and going back in. This is the only file that has changed other than registering the tile entity with the main mod file. [spoiler=TileEntity] package com.trekkiecub.allthethings; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Random; import com.trekkiecub.allthethings.TileEntity_RockCrusher.crushEntry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; public class TileEntity_ImmersionTank extends TileEntity implements IInventory, ISidedInventory { private ItemStack[] itemStacks; private FluidTank theFluid; private ArrayList processingEntries = new ArrayList(); private ArrayList fillList = new ArrayList(); private ArrayList drainList = new ArrayList(); public int progress, soakTime; class soakEntry { ItemStack item_in; FluidStack fluid_in; ItemStack item_out; FluidStack fluid_out; int num_ticks; public soakEntry (ItemStack item_in, ItemStack item_out, FluidStack fluid_in, FluidStack fluid_out, int num_ticks) { this.item_in = item_in; this.item_out = item_out; this.fluid_in = fluid_in; this.fluid_out = fluid_out; this.num_ticks = 200; } public soakEntry() { this.item_in = null; this.item_out = null; this.fluid_in = null; this.fluid_out = null; this.num_ticks = 200; } public ItemStack getItemInput() {return this.item_in;} public ItemStack getItemOutput() {return this.item_out;} public FluidStack getFluidInput() {return this.fluid_in;} public FluidStack getFluidOutput() {return this.fluid_out;} } class fillEntry { ItemStack item_input; FluidStack fluid_input; FluidStack fluid_output; ItemStack item_output; public fillEntry (ItemStack item_in, ItemStack item_out, FluidStack fluid_out) { this.item_input = item_in; this.item_output = item_out; this.fluid_input = null; this.fluid_output = fluid_out; } } class drainEntry { ItemStack item_input; FluidStack fluid_input; FluidStack fluid_output; ItemStack item_output; public drainEntry (ItemStack item_in, ItemStack item_out, FluidStack fluid_in) { this.item_input = item_in; this.item_output = item_out; this.fluid_input = fluid_in; this.fluid_output = null; } } public TileEntity_ImmersionTank() { itemStacks = new ItemStack[3]; theFluid = new FluidTank(1000); theFluid.setFluid(new FluidStack(FluidRegistry.WATER, 1000)); itemStacks[1] = new ItemStack(Blocks.cobblestone, 1); if (worldObj != null) { worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } markDirty(); fillList.add(new fillEntry(new ItemStack(Items.water_bucket, 1), new ItemStack(Items.bucket, 1), new FluidStack(FluidRegistry.WATER, 1000))); processingEntries.add(new soakEntry(new ItemStack(Blocks.cobblestone, 1), new ItemStack(Blocks.mossy_cobblestone, 1), new FluidStack(FluidRegistry.WATER, 1000), null, 200)); } public FluidStack getFluid() { return this.theFluid.getFluid(); } public void setFluid(FluidStack newFluid) { this.theFluid.setFluid(newFluid); } @Override public int[] getAccessibleSlotsFromSide(int var1) { // TODO Auto-generated method stub return null; } @Override public boolean canInsertItem(int var1, ItemStack var2, int var3) { // TODO Auto-generated method stub return false; } @Override public boolean canExtractItem(int var1, ItemStack var2, int var3) { // TODO Auto-generated method stub return false; } @Override public int getSizeInventory() { return itemStacks.length; } @Override public ItemStack getStackInSlot(int var1) { return itemStacks[var1]; } @Override public ItemStack decrStackSize(int slot, int amount) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amount) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amount); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { itemStacks[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public String getInventoryName() { // TODO Auto-generated method stub return null; } @Override public boolean hasCustomInventoryName() { // TODO Auto-generated method stub return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public void openInventory() { } @Override public void closeInventory() { } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { switch (slot) { case 0: fillEntry fill = null; // Get the crushEntry for the corresponding item in the input slot for (int p = 0; p < fillList.size() && fill == null; p++) { if (((fillEntry) fillList.get(p)).item_input == this.itemStacks[0]) { fill = (fillEntry) fillList.get(p); } } // Return can't crush if the item doesn't have a recipe if (fill == null) return false; else return true; case 1: return true; case 2: drainEntry drain = null; for (int p = 0; p < drainList.size() && drain == null; p++) { drainEntry currentEntry = (drainEntry) drainList.get(p); if (currentEntry.item_input == this.itemStacks[2] && currentEntry.fluid_input == this.theFluid.getFluid()) { drain = currentEntry; } } if (drain == null) return false; else return true; default: return false; } } @SideOnly(Side.CLIENT) public int getSoakProgressScaled(int newMax) { if (this.soakTime == 0) {return 0;} return this.progress * newMax / soakTime; } @SideOnly(Side.CLIENT) public int getFluidAmountScaled(int newMax) { if (this.theFluid.getFluid() == null) return 0; return this.theFluid.getFluidAmount() * newMax / this.theFluid.getCapacity(); } @Override public void updateEntity() { if (!this.worldObj.isRemote) { if (this.canProcess()) { this.progress++; if (this.progress == soakTime) { this.progress = 0; this.soakTime = 1; this.processItem(); if (worldObj != null) { worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } markDirty(); } } else if (this.progress != 0) { this.progress = 0; if (worldObj != null) { worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } markDirty(); } if (this.canFill()) { fillTank(); if (worldObj != null) { worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } markDirty(); } if (this.canDrain()) { drainTank(); if (worldObj != null) { worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } markDirty(); } } } private boolean canFill() { if (this.itemStacks[0] == null || (this.theFluid.getFluid() != null && this.theFluid.getFluidAmount() != 0)) { return false; } else { fillEntry fill = null; for (int p = 0; p < fillList.size() && fill == null; p++) { fillEntry currentEntry = (fillEntry) fillList.get(p); if (currentEntry.item_input == this.itemStacks[0]) { fill = currentEntry; } } if (fill == null) return false; else return true; } } private boolean canDrain() { if (this.itemStacks[2] == null || this.theFluid.getFluid() == null || this.theFluid.getFluidAmount() == 0) { return false; } else { drainEntry drain = null; for (int p = 0; p < drainList.size() && drain == null; p++) { drainEntry currentEntry = (drainEntry) drainList.get(p); if (currentEntry.item_input == this.itemStacks[2] && currentEntry.fluid_input == this.theFluid.getFluid()) { drain = currentEntry; } } if (drain == null) return false; else return true; } } private boolean canProcess() { if (this.itemStacks[1] == null) { return false; } else { // Get the crushEntry for the corresponding item in the input slot soakEntry resultEntry = null; for (int p = 0; p < processingEntries.size() && resultEntry == null; p++) { if (((soakEntry) processingEntries.get(p)).getItemInput() == this.itemStacks[1]) { if (((soakEntry) processingEntries.get(p)).getFluidInput() == this.theFluid.getFluid()) { resultEntry = (soakEntry) processingEntries.get(p); } } } // Return can't crush if the item doesn't have a recipe if (resultEntry == null) return false; else return true; } } public void fillTank() { if (this.canFill()) { fillEntry fill = null; for (int p = 0; p < fillList.size() && fill == null; p++) { fillEntry currentEntry = (fillEntry) fillList.get(p); if (currentEntry.item_input == this.itemStacks[0]) { fill = currentEntry; } } if (fill != null) { this.theFluid.setFluid(fill.fluid_output); this.itemStacks[0] = fill.item_output; } } } public void drainTank() { if (this.canDrain()) { drainEntry drain = null; for (int p = 0; p < drainList.size() && drain == null; p++) { drainEntry currentEntry = (drainEntry) drainList.get(p); if (currentEntry.item_input == this.itemStacks[2] && currentEntry.fluid_input == this.theFluid.getFluid()) { drain = currentEntry; } } if (drain != null) { this.theFluid.setFluid(null); this.itemStacks[0] = drain.item_output; } } } public void processItem() { if (this.canProcess()) { // Get the correct soak entry for the inputs soakEntry resultEntry = null; for (int p = 0; p < processingEntries.size() && resultEntry == null; p++) { if (((soakEntry) processingEntries.get(p)).getItemInput() == this.itemStacks[1]) { if (((soakEntry) processingEntries.get(p)).getFluidInput() == this.theFluid.getFluid()) { resultEntry = (soakEntry) processingEntries.get(p); } } } if (resultEntry != null) { this.itemStacks[1] = resultEntry.getItemOutput(); this.theFluid.setFluid(resultEntry.getFluidOutput()); } } } public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); NBTTagList nbttaglist = tag.getTagList("Items", 10); itemStacks = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound tag1 = nbttaglist.getCompoundTagAt(i); int j = tag1.getByte("Slot") & 255; if (j >= 0 && j < itemStacks.length) { itemStacks[j] = ItemStack.loadItemStackFromNBT(tag1); } } } public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < itemStacks.length; ++i) { if (itemStacks != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); itemStacks.writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } } } @Override public Packet getDescriptionPacket() { NBTTagCompound nbtTag = new NBTTagCompound(); writeToNBT(nbtTag); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbtTag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { readFromNBT(packet.func_148857_g()); } }
  11. I just wanna ask again, as it seems you replied before my edit. Are there any functions I have to call manually in my code when things need to get saved and updated?
  12. What about more complex data types, like ItemStacks and FluidStacks? I seem to be having trouble with those. This is the code I have for my NBT functions so far: [spoiler=NBT Functions] public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); itemStacks[0].readFromNBT(tag.getCompoundTag("slot0Stack")); itemStacks[1].readFromNBT(tag.getCompoundTag("slot1Stack")); itemStacks[2].readFromNBT(tag.getCompoundTag("slot2Stack")); theFluid.readFromNBT(tag.getCompoundTag("fluidStack")); progress = tag.getInteger("progress"); } public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setTag("slot0Stack", itemStacks[0].stackTagCompound); tag.setTag("slot1Stack", itemStacks[1].stackTagCompound); tag.setTag("slot2Stack", itemStacks[2].stackTagCompound); tag.setTag("fluidStack", theFluid.getFluid().tag); tag.setLong("progress", progress); } Am I doing this completely wrong? Edit: I was having a null pointer exception, but I think I figured it out. Now that I've got the NBT and packet functions added, do I need to call any of them manually? It seems my updateEntity() function is still not working, so some of the functions aren't being called automatically.
  13. I haven't worked with NBT stuff before, so I'm not sure how to use them. I'm guessing to get my problem fixed, I need to use the functions Draco mentioned, but is there anything more I need to do?
  14. I've been trying to implement some kind of packet handling in case this is the issue but I can't find a decent packet handling tutorial anywhere. I keep finding outdated and contradictory information and I don't know which directions to follow and which ones not to for my particular Minecraft and Forge versions. I have Minecraft 1.7.2, Forge 10.12.1.1060, FML 7.2.156.1060, MCP 9.01-pre
  15. As I said, the problem seems to be in TileEntity_ImmersionTank's updateEntity function. I had a set of statements which would toggle the fluid in the Immersion Tank between water and lava every time the updateEntity function was called, and these statements worked when they were put at the beginning of the updateEntity function, before any other code. Once they were put in the if (!world.isRemote) block, they stopped working. So I'm fairly certain that I'm getting true at that point.
  16. I'm having an odd problem with a couple of machines (well, only one really) that I've added to the game. One is a rock crusher, the other is an immersion tank. The rock crusher is working perfectly, while the immersion tank is having an odd problem. After messing around with the blocks a while, it seems that the problem is in the corresponding TileEntity's updateEntity function. Specifically, when checking to see if the world is remote or not, the rock crusher gets one result whereas the immersion tank gets a different result. I've been looking through the code for all of the files I've made and can't find where the difference between the blocks is at. I thought maybe it was due to how the external textures are being handled by either block (rock crusher is using the vanilla furnace method where the block is replaced with a slightly different block while processing an item, whereas the immersion tank is using a custom renderer), but after modifying the latter to match the former, I'm still having the same problem. Has this happened to anyone else? Does anyone know how to fix this? Since I'm not sure where the problem is, I'm including every file even remotely related to the machines. [spoiler=Block_Rock_Crusher] package com.trekkiecub.allthethings; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import com.trekkiecub.allthethings.TileEntity_RockCrusher; public class Block_Rock_Crusher extends BlockContainer { public IIcon front_on, front_off, top, side; protected static boolean changing = false; protected Block_Rock_Crusher(Material p_i45394_1_, boolean working) { super(p_i45394_1_); this.changing = working; } @Override public void registerBlockIcons(IIconRegister reg) { this.front_on = reg.registerIcon(this.textureName + "_front_on"); this.front_off = reg.registerIcon(this.textureName + "_front_off"); this.top = reg.registerIcon(this.textureName + "_top"); this.side = reg.registerIcon(this.textureName + "_side"); } @Override public IIcon getIcon(int dir, int meta) { if (meta > 5) meta = 5; if (dir == 4 && meta == 0) { return (this.lightValue > 0?this.front_on:this.front_off); } if (dir == 1) return this.top; if (meta == -1 || dir == meta) { return (this.lightValue > 0?this.front_on:this.front_off); } return this.side; } @Override public void onBlockAdded(World world, int xcoord, int ycoord, int zcoord) { super.onBlockAdded(world, xcoord, ycoord, zcoord); setRotatedMetadata(world, xcoord, ycoord, zcoord); } public void onBlockPlacedBy(World world, int xcoord, int ycoord, int zcoord, EntityLivingBase player, ItemStack theBlock) { int direction = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; switch (direction) { case 0: world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, 2, 2); break; case 1: world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, 5, 2); break; case 2: world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, 3, 2); break; case 3: world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, 4, 2); break; } } private void setRotatedMetadata(World world, int xcoord, int ycoord, int zcoord) { if (!world.isRemote) { Block north = world.getBlock(xcoord, ycoord, zcoord-1); Block south = world.getBlock(xcoord, ycoord, zcoord+1); Block east = world.getBlock(xcoord-1, ycoord, zcoord); Block west = world.getBlock(xcoord+1, ycoord, zcoord); byte newMeta = 3; if (north.func_149730_j() && !south.func_149730_j()) { newMeta = 3; } if (south.func_149730_j() && !north.func_149730_j()) { newMeta = 2; } if (east.func_149730_j() && !west.func_149730_j()) { newMeta = 5; } if (west.func_149730_j() && !east.func_149730_j()) { newMeta = 4; } world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, newMeta, 2); } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float a, float b, float c) { TileEntity tileEntity = world.getTileEntity(x, y, z); if (tileEntity == null || player.isSneaking()) return false; player.openGui("TrekkieCub_AllTheThings", 0, world, x, y, z); return true; } @Override public void breakBlock(World world, int x, int y, int z, Block block, int par6) { dropItems(world, x, y, z); super.breakBlock(world, x, y, z, block, par6); } private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getTileEntity(x, y, z); if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); if (item != null && item.stackSize > 0) { float randX = rand.nextFloat() * 0.8F + 0.1F; float randY = rand.nextFloat() * 0.8F + 0.1F; float randZ = rand.nextFloat() * 0.8F + 0.1F; EntityItem entityItem = new EntityItem(world, x+randX, y+randY, z+randZ, new ItemStack(item.getItem(), item.stackSize, item.getItemDamage())); if (item.hasTagCompound()) { entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy()); } float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; world.spawnEntityInWorld(entityItem); item.stackSize = 0; } } } @Override public TileEntity createNewTileEntity(World var1, int var2) { // TODO Auto-generated method stub return new TileEntity_RockCrusher(); } public static void updateCrusherStatus(boolean turnOn, World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); TileEntity tileEnt = world.getTileEntity(x, y, z); world.removeTileEntity(x, y, z); changing = true; if (turnOn) { world.setBlock(x, y, z, mod_TCAllTheThings.dummy_Rock_Crusher); } else { world.setBlock(x, y, z, mod_TCAllTheThings.Rock_Crusher); } changing = false; world.setBlockMetadataWithNotify(x, y, z, meta, 2); if (tileEnt != null) { tileEnt.validate(); world.setTileEntity(x, y, z, tileEnt); } } } [spoiler=TileEntity_RockCrusher] package com.trekkiecub.allthethings; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Random; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class TileEntity_RockCrusher extends TileEntity implements IInventory, ISidedInventory { private ItemStack[] itemStacks; private int[] slots_top = new int[] {0}; private int[] slots_bottom = new int[] {1,2,3}; private int[] slots_side = new int[] {1,2,3}; private Map crushingList = new HashMap(); public int crushTime; class crushEntry { Item out_pri, out_sec, out_tert; double numResources; public crushEntry(Item out_pri, Item out_sec, Item out_tert, double numResources) { this.out_pri = out_pri; this.out_sec = out_sec; this.out_tert = out_tert; this.numResources = numResources; } public void setResources(int num) { this.numResources = num; } } public TileEntity_RockCrusher() { itemStacks = new ItemStack[4]; crushingList.put(Items.diamond_axe, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 3)); crushingList.put(Items.diamond_boots, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 4)); crushingList.put(Items.diamond_chestplate, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, ); crushingList.put(Items.diamond_helmet, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 5)); crushingList.put(Items.diamond_hoe, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 2)); crushingList.put(Items.diamond_horse_armor, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 6)); crushingList.put(Items.diamond_leggings, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 7)); crushingList.put(Items.diamond_pickaxe, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 3)); crushingList.put(Items.diamond_shovel, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 1)); crushingList.put(Items.diamond_sword, new crushEntry(Items.diamond, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 2)); crushingList.put(Items.diamond, new crushEntry(null, mod_TCAllTheThings.Shard_Diamond, mod_TCAllTheThings.Powdered_Diamond, 1)); crushingList.put(mod_TCAllTheThings.Shard_Diamond, new crushEntry(null, null, mod_TCAllTheThings.Powdered_Diamond, 0.25)); } @Override public int getSizeInventory() { // TODO Auto-generated method stub return itemStacks.length; } @Override public ItemStack getStackInSlot(int var1) { // TODO Auto-generated method stub return itemStacks[var1]; } @Override public ItemStack decrStackSize(int slot, int amount) { // TODO Auto-generated method stub ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amount) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amount); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { itemStacks[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public String getInventoryName() { // TODO Auto-generated method stub return null; } @Override public boolean hasCustomInventoryName() { // TODO Auto-generated method stub return false; } @Override public int getInventoryStackLimit() { // TODO Auto-generated method stub return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { // TODO Auto-generated method stub return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public void openInventory() { // TODO Auto-generated method stub } @Override public void closeInventory() { // TODO Auto-generated method stub } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { switch (slot) { case 0: //Input { if (crushingList.get(stack.getItem()) != null) { return true; } else return false; } default: return false; } } /** * Returns an integer between 0 and the passed value representing how close the current item is to being completely * cooked */ @SideOnly(Side.CLIENT) public int getCrushProgressScaled(int p_145953_1_) { return this.crushTime * p_145953_1_ / 200; } public boolean isWorking() { return this.crushTime > 0; } @Override public void updateEntity() { if (!this.worldObj.isRemote) { if (this.canProcess()) { this.crushTime++; if (this.crushTime == 200) { this.crushTime = 0; this.processItem(); Block_Rock_Crusher.updateCrusherStatus(false, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } else if (this.crushTime == 1) { Block_Rock_Crusher.updateCrusherStatus(true, this.worldObj, this.xCoord, this.yCoord, this.zCoord); } } else this.crushTime = 0; } } private boolean canProcess() { if (this.itemStacks[0] == null) { return false; } else { // Get the crushEntry for the corresponding item in the input slot crushEntry resultEntry = (crushEntry) crushingList.get(this.itemStacks[0].getItem()); // Return can't crush if the item doesn't have a recipe if (resultEntry == null) return false; // Create temporary new resource amounts int newResourceAmount = (int) (resultEntry.numResources * 4); if (this.itemStacks[0].getItem().getMaxDamage() != 0) { float percentDamaged = (float) this.itemStacks[0].getItemDamage() / this.itemStacks[0].getItem().getMaxDamage(); newResourceAmount = MathHelper.floor_float((1 - percentDamaged) * newResourceAmount); } boolean firstPasses, secondPasses, thirdPasses; if (resultEntry.out_pri == null) { firstPasses = true; } else { if (this.itemStacks[1] == null || (this.itemStacks[1].getItem() == resultEntry.out_pri && this.itemStacks[1].stackSize + (newResourceAmount - newResourceAmount%4)/4 <= this.itemStacks[1].getMaxStackSize())) { firstPasses = true; } else return false; } if (this.itemStacks[2] == null || resultEntry.out_sec == null) { secondPasses = true; } else if (this.itemStacks[2].getItem() == resultEntry.out_sec && newResourceAmount + this.itemStacks[2].stackSize <= this.itemStacks[2].getMaxStackSize()) { secondPasses = true; } else return false; if (this.itemStacks[3] == null || resultEntry.out_tert == null) { thirdPasses = true; } else if (this.itemStacks[3].getItem() == resultEntry.out_tert && newResourceAmount + this.itemStacks[3].stackSize <= this.itemStacks[3].getMaxStackSize()) { thirdPasses = true; } else return false; return firstPasses && secondPasses && thirdPasses; } } public void processItem() { if (this.canProcess()) { Random rand = new Random(); // Get the crush entry for the corresponding item in the input slot crushEntry result = ((crushEntry) crushingList.get(this.itemStacks[0].getItem())); // Create temporary new resource amounts int newResourceAmount = (int) (result.numResources * 4); if (this.itemStacks[0].getItem().getMaxDamage() != 0) { float percentDamaged = (float) this.itemStacks[0].getItemDamage() / this.itemStacks[0].getItem().getMaxDamage(); newResourceAmount = MathHelper.floor_float((1 - percentDamaged) * newResourceAmount); } boolean spawnedPrimary = false; int chance; for (int p = 0; p < newResourceAmount; p++) { spawnedPrimary = false; if (p%4 == 0 && result.out_pri != null) { chance = rand.nextInt(4); if (chance == 0) { if (this.itemStacks[1] == null) { this.itemStacks[1] = new ItemStack(result.out_pri, 1); } else { this.itemStacks[1].stackSize += 1; } p += 3; // This forces an increment of 4 instead of 1 spawnedPrimary = true; } } if (!spawnedPrimary) { chance = rand.nextInt(4); if (chance == 0 && result.out_sec != null) { if (this.itemStacks[2] == null) { this.itemStacks[2] = new ItemStack(result.out_sec, 1); } else this.itemStacks[2].stackSize += 1; } else if (result.out_tert != null) { if (this.itemStacks[3] == null) { this.itemStacks[3] = new ItemStack(result.out_tert, 1); } else this.itemStacks[3].stackSize += 1; } } } this.itemStacks[0].stackSize--; if (this.itemStacks[0].stackSize <= 0) { this.itemStacks[0] = null; } } } @Override public int[] getAccessibleSlotsFromSide(int par1) { return par1 == 0 ? slots_bottom : (par1 == 1 ? slots_top : slots_side); } @Override public boolean canInsertItem(int par1, ItemStack par2ItemStack, int par3) { return this.isItemValidForSlot(par1, par2ItemStack); } @Override public boolean canExtractItem(int var1, ItemStack var2, int var3) { if (var1 == 0 || var3 == 1) { return false; } return true; } } [spoiler=Container_Rock_Crusher] package com.trekkiecub.allthethings; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.inventory.SlotFurnace; import net.minecraft.item.ItemStack; public class Container_RockCrusher extends Container { protected TileEntity_RockCrusher tileEntity; int prevCrushTime = 0; public Container_RockCrusher(InventoryPlayer inventoryPlayer, TileEntity_RockCrusher rcE) { tileEntity = rcE; addSlotToContainer(new Slot(tileEntity, 0, 56, 35)); for (int i = 0; i < 3; i++) { addSlotToContainer(new SlotFurnace(inventoryPlayer.player, tileEntity, i+1, 116, 17 + i*18)); } bindPlayerInventory(inventoryPlayer); } @Override public void addCraftingToCrafters(ICrafting craftingThing) { super.addCraftingToCrafters(craftingThing); craftingThing.sendProgressBarUpdate(this, 0, this.tileEntity.crushTime); } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.crafters.size(); ++i) { ICrafting icrafting = (ICrafting)this.crafters.get(i); if (this.prevCrushTime != this.tileEntity.crushTime) { icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.crushTime); } } this.prevCrushTime = this.tileEntity.crushTime; } @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { this.tileEntity.crushTime = par2; } @Override public boolean canInteractWith(EntityPlayer var1) { // TODO Auto-generated method stub return tileEntity.isUseableByPlayer(var1); } protected void bindPlayerInventory(InventoryPlayer invPlayer) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(invPlayer, i, 8+i*18, 142)); } } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot) inventorySlots.get(slot); if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); if (slot < 9) { if (!this.mergeItemStack(stackInSlot, 0, 35, true)) { return null; } } else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) { return null; } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else { slotObject.onSlotChanged(); } if (stackInSlot.stackSize == stack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return stack; } } [spoiler=Gui_RockCrusher] package com.trekkiecub.allthethings; import org.lwjgl.opengl.GL11; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class Gui_RockCrusher extends GuiContainer { private TileEntity_RockCrusher tileCrusher; public Gui_RockCrusher(InventoryPlayer inventoryPlayer, TileEntity_RockCrusher tileRockCrusher) { super(new Container_RockCrusher(inventoryPlayer, tileRockCrusher)); this.tileCrusher = tileRockCrusher; } @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { fontRendererObj.drawString("Rock Crusher", 8, 6, 4210752); fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize-96+2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { this.mc.renderEngine.bindTexture(new ResourceLocation("trekkiecub:textures/gui/rock_crusher.png")); int x = (this.width - this.xSize)/2; int y = (this.height - this.ySize)/2; this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); int i1 = this.tileCrusher.getCrushProgressScaled(24); this.drawTexturedModalRect(x + 79, y + 34, 176, 14, i1 + 1, 16); FluidStack afluid = new FluidStack(FluidRegistry.WATER, 1000); mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); GL11.glColor3f(1.0F, 1.0F, 1.0F); this.drawTexturedModelRectFromIcon(x+5, y+20, afluid.getFluid().getIcon(afluid), 20, 20); } } [spoiler=Block_Immersion_Tank] package com.trekkiecub.allthethings; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; public class Block_Immersion_Tank extends BlockContainer { public IIcon front_trans, front_fluid, top, side; protected Block_Immersion_Tank(Material p_i45386_1_) { super(p_i45386_1_); // TODO Auto-generated constructor stub } @Override public void registerBlockIcons(IIconRegister reg) { this.front_trans = reg.registerIcon(this.textureName + "_front_transparent"); this.front_fluid = reg.registerIcon(this.textureName + "_front_default"); this.top = reg.registerIcon(this.textureName + "_top"); this.side = reg.registerIcon(this.textureName + "_side"); } @Override public boolean renderAsNormalBlock() { return false; } @Override public int getRenderType() { return Proxy_Client.immersionTankRenderType; } @Override public boolean canRenderInPass(int pass) { Proxy_Client.renderPass = pass; return true; } @Override public int getRenderBlockPass() {return 1;} @Override public IIcon getIcon(int dir, int meta) { if (meta > 5) meta = 5; if (dir == 4 && meta == 0) { //return (this.lightValue > 0?this.front_on:this.front_off); return this.front_trans; } if (dir == 1) return this.top; if (meta == -1 || dir == meta) { //return (this.lightValue > 0?this.front_on:this.front_off); return this.front_trans; } return this.side; } @Override public void onBlockAdded(World world, int xcoord, int ycoord, int zcoord) { super.onBlockAdded(world, xcoord, ycoord, zcoord); setRotatedMetadata(world, xcoord, ycoord, zcoord); } public void onBlockPlacedBy(World world, int xcoord, int ycoord, int zcoord, EntityLivingBase player, ItemStack theBlock) { int direction = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; switch (direction) { case 0: world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, 2, 2); break; case 1: world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, 5, 2); break; case 2: world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, 3, 2); break; case 3: world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, 4, 2); break; } } private void setRotatedMetadata(World world, int xcoord, int ycoord, int zcoord) { if (!world.isRemote) { Block north = world.getBlock(xcoord, ycoord, zcoord-1); Block south = world.getBlock(xcoord, ycoord, zcoord+1); Block east = world.getBlock(xcoord-1, ycoord, zcoord); Block west = world.getBlock(xcoord+1, ycoord, zcoord); byte newMeta = 3; if (north.func_149730_j() && !south.func_149730_j()) { newMeta = 3; } if (south.func_149730_j() && !north.func_149730_j()) { newMeta = 2; } if (east.func_149730_j() && !west.func_149730_j()) { newMeta = 5; } if (west.func_149730_j() && !east.func_149730_j()) { newMeta = 4; } world.setBlockMetadataWithNotify(xcoord, ycoord, zcoord, newMeta, 2); } } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float a, float b, float c) { TileEntity tileEntity = world.getTileEntity(x, y, z); if (tileEntity == null || player.isSneaking()) return false; player.openGui("TrekkieCub_AllTheThings", 1, world, x, y, z); return true; } @Override public void breakBlock(World world, int x, int y, int z, Block block, int par6) { dropItems(world, x, y, z); super.breakBlock(world, x, y, z, block, par6); } private void dropItems(World world, int x, int y, int z) { Random rand = new Random(); TileEntity tileEntity = world.getTileEntity(x, y, z); if (!(tileEntity instanceof IInventory)) { return; } IInventory inventory = (IInventory) tileEntity; for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack item = inventory.getStackInSlot(i); if (item != null && item.stackSize > 0) { float randX = rand.nextFloat() * 0.8F + 0.1F; float randY = rand.nextFloat() * 0.8F + 0.1F; float randZ = rand.nextFloat() * 0.8F + 0.1F; EntityItem entityItem = new EntityItem(world, x+randX, y+randY, z+randZ, new ItemStack(item.getItem(), item.stackSize, item.getItemDamage())); if (item.hasTagCompound()) { entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy()); } float factor = 0.05F; entityItem.motionX = rand.nextGaussian() * factor; entityItem.motionY = rand.nextGaussian() * factor + 0.2F; entityItem.motionZ = rand.nextGaussian() * factor; world.spawnEntityInWorld(entityItem); item.stackSize = 0; } } } @Override public TileEntity createNewTileEntity(World var1, int var2) { // TODO Auto-generated method stub return new TileEntity_ImmersionTank(); } public static void updateTank(World world, int x, int y, int z) { TileEntity entity = world.getTileEntity(x, y, z); int meta = world.getBlockMetadata(x, y, z); world.removeTileEntity(x, y, z); world.setBlock(x, y, z, mod_TCAllTheThings.Immersion_Tank); world.setBlockMetadataWithNotify(x, y, z, meta, 2); if (entity != null) { entity.validate(); world.setTileEntity(x, y, z, entity); } world.markBlockForUpdate(x, y, z); } } [spoiler=TileEntity_ImmersionTank] package com.trekkiecub.allthethings; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Random; import com.trekkiecub.allthethings.TileEntity_RockCrusher.crushEntry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; public class TileEntity_ImmersionTank extends TileEntity implements IInventory, ISidedInventory { private ItemStack[] itemStacks; private FluidTank theFluid; private ArrayList processingEntries = new ArrayList(); private ArrayList fillList = new ArrayList(); private ArrayList drainList = new ArrayList(); public int progress, soakTime; public boolean fluidToggle = false; class soakEntry { ItemStack item_in; FluidStack fluid_in; ItemStack item_out; FluidStack fluid_out; int num_ticks; public soakEntry (ItemStack item_in, ItemStack item_out, FluidStack fluid_in, FluidStack fluid_out, int num_ticks) { this.item_in = item_in; this.item_out = item_out; this.fluid_in = fluid_in; this.fluid_out = fluid_out; this.num_ticks = 200; } public soakEntry() { this.item_in = null; this.item_out = null; this.fluid_in = null; this.fluid_out = null; this.num_ticks = 200; } public ItemStack getItemInput() {return this.item_in;} public ItemStack getItemOutput() {return this.item_out;} public FluidStack getFluidInput() {return this.fluid_in;} public FluidStack getFluidOutput() {return this.fluid_out;} } class fillEntry { ItemStack item_input; FluidStack fluid_input; FluidStack fluid_output; ItemStack item_output; public fillEntry (ItemStack item_in, ItemStack item_out, FluidStack fluid_out) { this.item_input = item_in; this.item_output = item_out; this.fluid_input = null; this.fluid_output = fluid_out; } } class drainEntry { ItemStack item_input; FluidStack fluid_input; FluidStack fluid_output; ItemStack item_output; public drainEntry (ItemStack item_in, ItemStack item_out, FluidStack fluid_in) { this.item_input = item_in; this.item_output = item_out; this.fluid_input = fluid_in; this.fluid_output = null; } } public TileEntity_ImmersionTank() { itemStacks = new ItemStack[3]; theFluid = new FluidTank(1000); fillList.add(new fillEntry(new ItemStack(Items.water_bucket, 1), new ItemStack(Items.bucket, 1), new FluidStack(FluidRegistry.WATER, 1000))); processingEntries.add(new soakEntry(new ItemStack(Blocks.cobblestone, 1), new ItemStack(Blocks.mossy_cobblestone, 1), new FluidStack(FluidRegistry.WATER, 1000), null, 200)); } public FluidStack getFluid() { return this.theFluid.getFluid(); } public void setFluid(FluidStack newFluid) { this.theFluid.setFluid(newFluid); } @Override public int[] getAccessibleSlotsFromSide(int var1) { // TODO Auto-generated method stub return null; } @Override public boolean canInsertItem(int var1, ItemStack var2, int var3) { // TODO Auto-generated method stub return false; } @Override public boolean canExtractItem(int var1, ItemStack var2, int var3) { // TODO Auto-generated method stub return false; } @Override public int getSizeInventory() { return itemStacks.length; } @Override public ItemStack getStackInSlot(int var1) { return itemStacks[var1]; } @Override public ItemStack decrStackSize(int slot, int amount) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize <= amount) { setInventorySlotContents(slot, null); } else { stack = stack.splitStack(amount); if (stack.stackSize == 0) { setInventorySlotContents(slot, null); } } } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null) { setInventorySlotContents(slot, null); } return stack; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { itemStacks[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) { stack.stackSize = getInventoryStackLimit(); } } @Override public String getInventoryName() { // TODO Auto-generated method stub return null; } @Override public boolean hasCustomInventoryName() { // TODO Auto-generated method stub return false; } @Override public int getInventoryStackLimit() { return 64; } @Override public boolean isUseableByPlayer(EntityPlayer player) { return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64; } @Override public void openInventory() { } @Override public void closeInventory() { } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { switch (slot) { case 0: fillEntry fill = null; // Get the crushEntry for the corresponding item in the input slot for (int p = 0; p < fillList.size() && fill == null; p++) { if (((fillEntry) fillList.get(p)).item_input == this.itemStacks[0]) { fill = (fillEntry) fillList.get(p); } } // Return can't crush if the item doesn't have a recipe if (fill == null) return false; else return true; case 1: return true; case 2: drainEntry drain = null; for (int p = 0; p < drainList.size() && drain == null; p++) { drainEntry currentEntry = (drainEntry) drainList.get(p); if (currentEntry.item_input == this.itemStacks[2] && currentEntry.fluid_input == this.theFluid.getFluid()) { drain = currentEntry; } } if (drain == null) return false; else return true; default: return false; } } @SideOnly(Side.CLIENT) public int getSoakProgressScaled(int newMax) { if (this.soakTime == 0) {return 0;} return this.progress * newMax / soakTime; } @SideOnly(Side.CLIENT) public int getFluidAmountScaled(int newMax) { if (this.theFluid.getFluid() == null) return 0; return this.theFluid.getFluidAmount() * newMax / this.theFluid.getCapacity(); } @Override public void updateEntity() { if (!this.worldObj.isRemote) { if (this.canProcess()) { this.progress++; if (this.progress == soakTime) { this.progress = 0; this.soakTime = 1; this.processItem(); } } else this.progress = 0; if (this.canFill()) { fillTank(); } if (this.canDrain()) { drainTank(); } this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } } private boolean canFill() { if (this.itemStacks[0] == null || (this.theFluid.getFluid() != null && this.theFluid.getFluidAmount() != 0)) { return false; } else { fillEntry fill = null; for (int p = 0; p < fillList.size() && fill == null; p++) { fillEntry currentEntry = (fillEntry) fillList.get(p); if (currentEntry.item_input == this.itemStacks[0]) { fill = currentEntry; } } if (fill == null) return false; else return true; } } private boolean canDrain() { if (this.itemStacks[2] == null || this.theFluid.getFluid() == null || this.theFluid.getFluidAmount() == 0) { return false; } else { drainEntry drain = null; for (int p = 0; p < drainList.size() && drain == null; p++) { drainEntry currentEntry = (drainEntry) drainList.get(p); if (currentEntry.item_input == this.itemStacks[2] && currentEntry.fluid_input == this.theFluid.getFluid()) { drain = currentEntry; } } if (drain == null) return false; else return true; } } private boolean canProcess() { if (this.itemStacks[1] == null) { return false; } else { // Get the crushEntry for the corresponding item in the input slot soakEntry resultEntry = null; for (int p = 0; p < processingEntries.size() && resultEntry == null; p++) { if (((soakEntry) processingEntries.get(p)).getItemInput() == this.itemStacks[1]) { if (((soakEntry) processingEntries.get(p)).getFluidInput() == this.theFluid.getFluid()) { resultEntry = (soakEntry) processingEntries.get(p); } } } // Return can't crush if the item doesn't have a recipe if (resultEntry == null) return false; else return true; } } public void fillTank() { if (this.canFill()) { fillEntry fill = null; for (int p = 0; p < fillList.size() && fill == null; p++) { fillEntry currentEntry = (fillEntry) fillList.get(p); if (currentEntry.item_input == this.itemStacks[0]) { fill = currentEntry; } } if (fill != null) { this.theFluid.setFluid(fill.fluid_output); this.itemStacks[0] = fill.item_output; } } } public void drainTank() { if (this.canDrain()) { drainEntry drain = null; for (int p = 0; p < drainList.size() && drain == null; p++) { drainEntry currentEntry = (drainEntry) drainList.get(p); if (currentEntry.item_input == this.itemStacks[2] && currentEntry.fluid_input == this.theFluid.getFluid()) { drain = currentEntry; } } if (drain != null) { this.theFluid.setFluid(null); this.itemStacks[0] = drain.item_output; } } } public void processItem() { if (this.canProcess()) { // Get the correct soak entry for the inputs soakEntry resultEntry = null; for (int p = 0; p < processingEntries.size() && resultEntry == null; p++) { if (((soakEntry) processingEntries.get(p)).getItemInput() == this.itemStacks[1]) { if (((soakEntry) processingEntries.get(p)).getFluidInput() == this.theFluid.getFluid()) { resultEntry = (soakEntry) processingEntries.get(p); } } } if (resultEntry != null) { this.itemStacks[1] = resultEntry.getItemOutput(); this.theFluid.setFluid(resultEntry.getFluidOutput()); } } } } [spoiler=Container_ImmersionTank] package com.trekkiecub.allthethings; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; public class Container_ImmersionTank extends Container{ protected TileEntity_ImmersionTank tileEntity; int prevProgress = 0; public Container_ImmersionTank(InventoryPlayer invPlay, TileEntity_ImmersionTank tile) { this.tileEntity = tile; addSlotToContainer(new Slot(tileEntity, 0, 16, 37)); addSlotToContainer(new Slot(tileEntity, 1, 80, 37)); addSlotToContainer(new Slot(tileEntity, 2, 145, 37)); bindPlayerInventory(invPlay); } protected void bindPlayerInventory(InventoryPlayer invPlayer) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; i++) { addSlotToContainer(new Slot(invPlayer, i, 8+i*18, 142)); } } @Override public void addCraftingToCrafters(ICrafting craftingThing) { super.addCraftingToCrafters(craftingThing); craftingThing.sendProgressBarUpdate(this, 0, this.tileEntity.progress); } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); for (int i = 0; i < this.crafters.size(); ++i) { ICrafting icrafting = (ICrafting)this.crafters.get(i); if (this.prevProgress != this.tileEntity.progress) { icrafting.sendProgressBarUpdate(this, 0, this.tileEntity.progress); } } this.prevProgress = this.tileEntity.progress; } @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { this.tileEntity.progress = par2; } @Override public boolean canInteractWith(EntityPlayer var1) { // TODO Auto-generated method stub return tileEntity.isUseableByPlayer(var1); } @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot) inventorySlots.get(slot); if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); if (slot < 3) { if (!this.mergeItemStack(stackInSlot, 0, 35, true)) { return null; } } else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) { return null; } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else slotObject.onSlotChanged(); if (stackInSlot.stackSize == stack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return stack; } } [spoiler=Gui_ImmersionTank] package com.trekkiecub.allthethings; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; public class Gui_ImmersionTank extends GuiContainer { private TileEntity_ImmersionTank tileTank; public Gui_ImmersionTank(InventoryPlayer invPlayer, TileEntity_ImmersionTank tileImmTank) { super(new Container_ImmersionTank(invPlayer, tileImmTank)); this.tileTank = tileImmTank; } @Override protected void drawGuiContainerForegroundLayer(int param1, int param2) { fontRendererObj.drawString("Immersion Tank", 8, 6, 4210752); fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize-96+2, 4210752); } @Override protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) { this.mc.renderEngine.bindTexture(new ResourceLocation("trekkiecub:textures/gui/immersion_tank.png")); int x = (this.width - this.xSize)/2; int y = (this.height - this.ySize)/2; this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); // Soak Progress Bar int startPoint = this.tileTank.getSoakProgressScaled(54); this.drawTexturedModalRect(x+62, x+69, 2, 176, startPoint+1, 5); // Fluid FluidStack fluid = tileTank.getFluid(); IIcon drawThis; if (fluid == null) { drawThis = FluidRegistry.WATER.getStillIcon(); } else drawThis = fluid.getFluid().getStillIcon(); mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture); GL11.glColor3f(1.0F,1.0F,1.0F); int rectHeight = this.tileTank.getFluidAmountScaled(37); this.drawTexturedModelRectFromIcon(x+65, y+27+(37-rectHeight), drawThis, 48, rectHeight); // max 63 this.mc.renderEngine.bindTexture(new ResourceLocation("trekkiecub:textures/gui/immersion_tank.png")); GL11.glColor3f(1.0F, 1.0F, 1.0F); this.drawTexturedModalRect(x+79, y+36, 79, 36, 18, 18); } } [spoiler=Render_Immersion_Tank] package com.trekkiecub.allthethings; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.init.Blocks; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import com.trekkiecub.allthethings.Block_Immersion_Tank; public class Render_Immersion_Tank implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { // TODO Auto-generated method stub } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { if (Proxy_Client.renderPass == 0) { IIcon newIcon; TileEntity_ImmersionTank tileEnt = (TileEntity_ImmersionTank) world.getTileEntity(x, y, z); if (tileEnt.getFluid() == null || tileEnt.getFluid().amount == 0) { newIcon = ((Block_Immersion_Tank) block).front_fluid; } else newIcon = tileEnt.getFluid().getFluid().getStillIcon(); renderer.renderFaceXNeg(block, x, y, z, newIcon); renderer.renderFaceXPos(block, x, y, z, newIcon); renderer.renderFaceZNeg(block, x, y, z, newIcon); renderer.renderFaceZPos(block, x, y, z, newIcon); renderer.renderFaceYNeg(block, x, y, z, newIcon); renderer.renderFaceYPos(block, x, y, z, newIcon); //renderer.renderStandardBlock(Blocks.flowing_water, x, y, z); } else { renderer.renderStandardBlock(mod_TCAllTheThings.Immersion_Tank, x, y, z); } return true; } @Override public boolean shouldRender3DInInventory(int modelId) { // TODO Auto-generated method stub return false; } @Override public int getRenderId() { return Proxy_Client.immersionTankRenderType; } } [spoiler=GuiHandler] package com.trekkiecub.allthethings; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import cpw.mods.fml.common.network.IGuiHandler; public class GuiHandler implements IGuiHandler{ @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); switch (ID) { case 0: return (tileEntity instanceof TileEntity_RockCrusher ? new Container_RockCrusher(player.inventory, (TileEntity_RockCrusher) tileEntity) : null); case 1: return (tileEntity instanceof TileEntity_ImmersionTank ? new Container_ImmersionTank(player.inventory, (TileEntity_ImmersionTank) tileEntity) : null); default: return null; } } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity tileEntity = world.getTileEntity(x, y, z); switch (ID) { case 0: return (tileEntity instanceof TileEntity_RockCrusher ? new Gui_RockCrusher(player.inventory, (TileEntity_RockCrusher) tileEntity) : null); case 1: return (tileEntity instanceof TileEntity_ImmersionTank ? new Gui_ImmersionTank(player.inventory, (TileEntity_ImmersionTank) tileEntity) : null); } return null; } } [spoiler=Proxy_Client] package com.trekkiecub.allthethings; import cpw.mods.fml.client.registry.RenderingRegistry; public class Proxy_Client extends Proxy_Common { public static int renderPass; public static int immersionTankRenderType; @Override public void registerRenderThings() { immersionTankRenderType = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerEntityRenderingHandler(Entity_Mummy.class, new Render_Mummy(new Model_Mummy(), 0.5f)); RenderingRegistry.registerBlockHandler(new Render_Immersion_Tank()); } } [spoiler=Proxy_Common] package com.trekkiecub.allthethings; public class Proxy_Common { public void registerRenderThings() { } } [spoiler=Main mod file] package com.trekkiecub.allthethings; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.network.NetworkRegistry; @Mod(modid="TrekkieCub_AllTheThings", name = "Trekkie Cub's All The Things", version = "alpha") public class mod_TCAllTheThings { // // Create an instance of the mod // @Instance("mod_TCAllTheThings") public static mod_TCAllTheThings instance; // // Creative Mode Tab // public static CreativeTabs allTheThingsTab = new CreativeTabs("allTheThings"){ @Override public Item getTabIconItem() { return Items.emerald; } }; // // Item Declarations // public static Item Paper_Bowl, Shard_Diamond, Shard_Stone, Powdered_Diamond, Powdered_Stone, Fried_Egg, Burial_Wraps; // // Block Declarations // public static Block Rock_Crusher, dummy_Rock_Crusher, Immersion_Tank; // // Proxy Definitions // @SidedProxy(clientSide = "com.trekkiecub.allthethings.Proxy_Client", serverSide = "com.trekkiecub.allthethings.Proxy_Common") public static Proxy_Common commonProxy; public static Proxy_Client clientProxy; // // Pre-Initialization Event // @EventHandler public void preInit(FMLPreInitializationEvent e) { clientProxy = new Proxy_Client(); // // Constants // int ID_Mummy = EntityRegistry.findGlobalUniqueEntityId(); // // Item Definitions // Paper_Bowl = new Item_Paper_Bowl().setCreativeTab(allTheThingsTab).setUnlocalizedName("paper_bowl").setTextureName("trekkiecub:paper_bowl"); Shard_Diamond = new Item_Shard_Diamond(); Shard_Stone = new Item_Shard_Stone().setCreativeTab(allTheThingsTab).setUnlocalizedName("shard_stone").setTextureName("trekkiecub:shard_rock"); Powdered_Diamond = new Item_Powdered_Diamond().setCreativeTab(allTheThingsTab).setUnlocalizedName("powdered_diamond").setTextureName("trekkiecub:powdered_diamond"); Powdered_Stone = new Item_Powdered_Stone().setCreativeTab(allTheThingsTab).setUnlocalizedName("powdered_stone").setTextureName("trekkiecub:powdered_stone"); Fried_Egg = new Item_Fried_Egg(6, 0.6F).setCreativeTab(allTheThingsTab).setUnlocalizedName("fried_egg").setTextureName("trekkiecub:fried_egg"); Burial_Wraps = new Item_Burial_Wraps().setCreativeTab(allTheThingsTab).setUnlocalizedName("burial_wraps").setTextureName("trekkiecub:burial_wraps"); // // Item Registry // GameRegistry.registerItem(Paper_Bowl, "paper_bowl"); GameRegistry.registerItem(Shard_Diamond, "shard_diamond"); GameRegistry.registerItem(Powdered_Diamond, "powdered_diamond"); GameRegistry.registerItem(Powdered_Stone, "powdered_stone"); GameRegistry.registerItem(Shard_Stone, "shard_stone"); GameRegistry.registerItem(Fried_Egg, "fried_egg"); GameRegistry.registerItem(Burial_Wraps, "burial_wraps"); // // Block Definitions // Rock_Crusher = new Block_Rock_Crusher(Material.rock, false).setStepSound(Block.soundTypeStone).setBlockName("block_rock_crusher").setCreativeTab(allTheThingsTab).setBlockTextureName("trekkiecub:rock_crusher"); dummy_Rock_Crusher = new Block_Rock_Crusher(Material.rock, true).setStepSound(Block.soundTypeStone).setBlockName("block_rock_crusher").setBlockTextureName("trekkiecub:rock_crusher").setLightLevel((float)1/15); Immersion_Tank = new Block_Immersion_Tank(Material.rock).setStepSound(Block.soundTypeStone).setBlockName("block_immersion_tank").setCreativeTab(allTheThingsTab).setBlockTextureName("trekkiecub:immersion_tank"); // // Block Registry // GameRegistry.registerBlock(Rock_Crusher, "block_rock_crusher"); GameRegistry.registerBlock(dummy_Rock_Crusher, "lit_block_rock_crusher"); GameRegistry.registerBlock(Immersion_Tank, "block_immersion_tank"); // // Entity Registry // EntityRegistry.registerGlobalEntityID(Entity_Mummy.class, "Mummy", ID_Mummy); EntityRegistry.registerModEntity(Entity_Mummy.class, "Mummy", ID_Mummy, this, 80, 1, true); EntityRegistry.addSpawn(Entity_Mummy.class, 2, 0, 1, EnumCreatureType.monster, BiomeGenBase.desert); EntityList.entityEggs.put(Integer.valueOf(ID_Mummy), new EntityList.EntityEggInfo(ID_Mummy, 0xe9e5c3, 0xc6c57b)); // // Crafting Recipes // GameRegistry.addRecipe(new ItemStack(Paper_Bowl, 10), "p p", " p ", 'p', Items.paper); GameRegistry.addRecipe(new ItemStack(Rock_Crusher), "cpc", "p p", "cpc", 'c', Blocks.cobblestone, 'p', Blocks.piston); GameRegistry.addRecipe(new ItemStack(Items.spawn_egg, 1, 50), "ggg", "geg", "ggg", 'g', Items.gunpowder, 'e', Items.egg); GameRegistry.addRecipe(new ItemStack(Items.spawn_egg, 1, ID_Mummy), "www", "wew", "www", 'w', Burial_Wraps, 'e', Items.egg); GameRegistry.addRecipe(new ItemStack(Immersion_Tank), "i i", "ici", "iii", 'i', Items.iron_ingot, 'c', Blocks.chest); GameRegistry.addShapelessRecipe(new ItemStack(Immersion_Tank), new ItemStack(Blocks.cauldron), new ItemStack(Blocks.chest)); // // Smelting Recipes // GameRegistry.addSmelting(Items.egg, new ItemStack(Fried_Egg), 0); // // Proxy Functions // clientProxy.registerRenderThings(); } // // Initialization Event // @EventHandler public void Init(FMLInitializationEvent e) { } // // Post-Initialization Event // @EventHandler public void postInit(FMLPostInitializationEvent e) { // // Network Registry // NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); } }
×
×
  • Create New...

Important Information

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