Jump to content

Leomelonseeds

Forge Modder
  • Posts

    407
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Leomelonseeds

  1. *facepalm* Why am I so stupid. Big thanks to you both for helping!
  2. Oh, and by the way, I'm using an edited version of the chest texture, eg the spread out one, does that have any effect on my Grill..?
  3. Yes. I made a mod. I have posted it on planetminecraft and it has reached over 1000 downloads! Thank you to all the folks at planetminecraft and i would appreciate it if you could check it out: http://www.planetminecraft.com/mod/moar-stuff1102/
  4. Ok well. Main class: package com.leomelonseeds.moarstuff; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @Mod(modid = Main.MODID, name = Main.MODNAME, version = Main.VERSION) public class Main { public static final String MODID = "moarstuff"; public static final String MODNAME = "Moar Stuff"; public static final String VERSION = "1.0.0"; @Instance public static Main instance = new Main(); @SidedProxy(clientSide="com.leomelonseeds.moarstuff.ClientProxy", serverSide="com.leomelonseeds.moarstuff.ServerProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent e) { this.proxy.preInit(e); } @EventHandler public void init(FMLInitializationEvent e) { this.proxy.init(e); } @EventHandler public void postInit(FMLPostInitializationEvent e) { this.proxy.postInit(e); } }
  5. I used some code from MinecraftByExample bt The GrreyGhost and Bedrockminer's tutorials. CommonProxy: package com.leomelonseeds.moarstuff; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import com.leomelonseeds.moarstuff.blocks.Modblocks; import com.leomelonseeds.moarstuff.crafting.ModCrafting; import com.leomelonseeds.moarstuff.items.Moditems; import com.leomelonseeds.moarstuff.network.GUIHandlerGrill; import com.leomelonseeds.moarstuff.tileentity.ModTileEntities; public class CommonProxy { public void preInit(FMLPreInitializationEvent e) { Modblocks.createBlocks(); Moditems.createItems(); ModTileEntities.createTileEntities(); } public void init(FMLInitializationEvent e) { ModCrafting.initCrafting(); NetworkRegistry.INSTANCE.registerGuiHandler(Main.instance, new GUIHandlerGrill()); } public void postInit(FMLPostInitializationEvent e) { } } GuiHandler package com.leomelonseeds.moarstuff.network; import com.leomelonseeds.client.gui.GuiGrill; import com.leomelonseeds.moarstuff.guicontainer.ContainerGrill; import com.leomelonseeds.moarstuff.tileentity.Grill; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.network.IGuiHandler; public class GUIHandlerGrill implements IGuiHandler { private static final int GUIID_GRILL = 1; public static int getGuiID() {return GUIID_GRILL;} // Gets the server side element for the given gui id this should return a container @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID != getGuiID()) { System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID); } BlockPos xyz = new BlockPos(x, y, z); TileEntity tileEntity = world.getTileEntity(xyz); if (tileEntity instanceof Grill) { Grill tileGrill = (Grill) tileEntity; return new ContainerGrill(player.inventory, tileGrill); } return null; } // Gets the client side element for the given gui id this should return a gui @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { if (ID != getGuiID()) { System.err.println("Invalid ID: expected " + getGuiID() + ", received " + ID); } BlockPos xyz = new BlockPos(x, y, z); TileEntity tileEntity = world.getTileEntity(xyz); if (tileEntity instanceof Grill) { Grill tileGrill = (Grill) tileEntity; return new GuiGrill(player.inventory, tileGrill); } return null; } } If by the main class you mean the place where you register blocks, here it is: package com.leomelonseeds.moarstuff.blocks; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fml.common.registry.GameRegistry; public final class Modblocks { public static Block enderpearlBlock; public static Block lavaLamp; public static Block nuke; public static Block megatnt; public static BlockGrill grill; public static void createBlocks() { GameRegistry.registerBlock(lavaLamp = new LavaLamp("lava_lamp"), "lava_lamp"); GameRegistry.registerBlock(enderpearlBlock = new BasicBlock("ender_pearl_block"), "ender_pearl_block"); GameRegistry.registerBlock(nuke = new BlockNuke("nuke"), "nuke"); GameRegistry.registerBlock(megatnt = new BlockMegaTNT("megatnt"), "megatnt"); GameRegistry.registerBlock(grill = new BlockGrill("grill"), "grill"); } } Sorry for using deprecated version, the new one is complicated and I need to learn on it.
  6. Yes I did put one there, unfortunatly its not showing. We have a problem.
  7. Here is updated block class: package com.leomelonseeds.moarstuff.blocks; import javax.annotation.Nullable; import com.leomelonseeds.moarstuff.Main; import com.leomelonseeds.moarstuff.items.Moditems; import com.leomelonseeds.moarstuff.network.GUIHandlerGrill; import com.leomelonseeds.moarstuff.tileentity.Grill; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockGrill extends Block{ public BlockGrill(String unlocalizedName) { super(Material.ROCK); this.setUnlocalizedName("grill"); this.setCreativeTab(Moditems.moarStuff); this.isBlockContainer = true; } @Override public TileEntity createTileEntity(World worldIn, IBlockState state) { return new Grill(); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) return true; playerIn.openGui(Main.instance, GUIHandlerGrill.getGuiID(), worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof IInventory) { InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileEntity); } super.breakBlock(worldIn, pos, state); } public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) { super.eventReceived(state, worldIn, pos, id, param); TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity == null ? false : tileentity.receiveClientEvent(id, param); } @Override public boolean isOpaqueCube(IBlockState iBlockState) { return false; } public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; } public boolean isFullCube(IBlockState state) { return false; } public boolean hasTileEntity(IBlockState state) { return true; } } By the way, do you register the block for the tileentity the way you normally do?
  8. Please can someone help me. I've been working on this for weeks without success
  9. I will try that. The problem currently is that I put a system.println in the TESR, and it is not showing. UPDATE: I translated xyz and the problem persists
  10. Thanks for the quick reply! TESR: package com.leomelonseeds.moarstuff.client.render.blocks; import com.leomelonseeds.moarstuff.tileentity.Grill; import net.minecraft.block.Block; import net.minecraft.client.model.ModelChest; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class TileGrillRenderer extends TileEntitySpecialRenderer<Grill> { private static final ResourceLocation TEXTURE_BURNING = new ResourceLocation("moarstuff:textures/entity/grill/grill_on.png"); private static final ResourceLocation TEXTURE_NORMAL = new ResourceLocation("moarstuff:textures/entity/grill/grill_off.png"); private final ModelChest simpleChest = new ModelChest(); private boolean isBurning; public void renderTileEntityAt(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage) { System.out.println("RENDERING"); GlStateManager.enableDepth(); GlStateManager.depthFunc(515); GlStateManager.depthMask(true); int i; if (te.hasWorldObj()) { Block block = te.getBlockType(); i = te.getBlockMetadata(); } else { i = 0; } if (te.adjacentChestZNeg == null && te.adjacentChestXNeg == null) { ModelChest modelchest = null; if (te.adjacentChestXPos == null && te.adjacentChestZPos == null) { modelchest = this.simpleChest; if (destroyStage >= 0) { this.bindTexture(DESTROY_STAGES[destroyStage]); GlStateManager.matrixMode(5890); GlStateManager.pushMatrix(); GlStateManager.scale(4.0F, 4.0F, 1.0F); GlStateManager.translate(0.0625F, 0.0625F, 0.0625F); GlStateManager.matrixMode(5888); } else { this.bindTexture(TEXTURE_NORMAL); } } GlStateManager.pushMatrix(); GlStateManager.enableRescaleNormal(); if (destroyStage < 0) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); } GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F); GlStateManager.scale(1.0F, -1.0F, -1.0F); GlStateManager.translate(0.5F, 0.5F, 0.5F); int j = 0; if (i == 2) { j = 180; } if (i == 3) { j = 0; } if (i == 4) { j = 90; } if (i == 5) { j = -90; } if (i == 2 && te.adjacentChestXPos != null) { GlStateManager.translate(1.0F, 0.0F, 0.0F); } if (i == 5 && te.adjacentChestZPos != null) { GlStateManager.translate(0.0F, 0.0F, -1.0F); } GlStateManager.rotate((float)j, 0.0F, 1.0F, 0.0F); GlStateManager.translate(-0.5F, -0.5F, -0.5F); float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks; if (te.adjacentChestZNeg != null) { float f1 = te.adjacentChestZNeg.prevLidAngle + (te.adjacentChestZNeg.lidAngle - te.adjacentChestZNeg.prevLidAngle) * partialTicks; if (f1 > f) { f = f1; } } if (te.adjacentChestXNeg != null) { float f2 = te.adjacentChestXNeg.prevLidAngle + (te.adjacentChestXNeg.lidAngle - te.adjacentChestXNeg.prevLidAngle) * partialTicks; if (f2 > f) { f = f2; } } f = 1.0F - f; f = 1.0F - f * f * f; modelchest.chestLid.rotateAngleX = -(f * ((float)Math.PI / 2F)); modelchest.renderAll(); GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); if (destroyStage >= 0) { GlStateManager.matrixMode(5890); GlStateManager.popMatrix(); GlStateManager.matrixMode(5888); } } } } ClientProxy: package com.leomelonseeds.moarstuff; import com.leomelonseeds.moarstuff.blocks.BlockMegaTNT; import com.leomelonseeds.moarstuff.blocks.BlockNuke; import com.leomelonseeds.moarstuff.blocks.Modblocks; import com.leomelonseeds.moarstuff.client.render.blocks.BlockRenderRegister; import com.leomelonseeds.moarstuff.client.render.blocks.TileGrillRenderer; import com.leomelonseeds.moarstuff.client.render.entity.RenderMegaTNTPrimed; import com.leomelonseeds.moarstuff.client.render.entity.RenderNukePrimed; import com.leomelonseeds.moarstuff.client.render.items.ItemRenderRegister; import com.leomelonseeds.moarstuff.entity.MegaTNTPrimed; import com.leomelonseeds.moarstuff.entity.NukePrimed; import com.leomelonseeds.moarstuff.tileentity.Grill; import net.minecraft.block.properties.IProperty; import net.minecraft.client.renderer.block.statemap.StateMap; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.EntityRegistry; public class ClientProxy extends CommonProxy { @Override public void preInit(FMLPreInitializationEvent e){ super.preInit(e); ModelLoader.setCustomStateMapper(Modblocks.megatnt, (new StateMap.Builder()).ignore(new IProperty[] {BlockMegaTNT.EXPLODE}).build()); ModelLoader.setCustomStateMapper(Modblocks.nuke, (new StateMap.Builder()).ignore(new IProperty[] {BlockNuke.EXPLODE}).build()); RenderingRegistry.registerEntityRenderingHandler(NukePrimed.class, RenderNukePrimed::new); RenderingRegistry.registerEntityRenderingHandler(MegaTNTPrimed.class, RenderMegaTNTPrimed::new); } @Override public void init(FMLInitializationEvent e) { super.init(e); BlockRenderRegister.registerBlockRenderer(); ItemRenderRegister.registerItemRenderer(); EntityRegistry.registerModEntity(MegaTNTPrimed.class, "megatnt", 1, Main.instance, 160, 10, true); EntityRegistry.registerModEntity(NukePrimed.class, "nuke", 2, Main.instance, 160, 10, true); ClientRegistry.bindTileEntitySpecialRenderer(Grill.class, new TileGrillRenderer()); } @Override public void postInit(FMLPostInitializationEvent e) { super.postInit(e); } } Ignore the other stuff, just look at the init() section
  11. It still doesn't work. I have added the methods you provided and binded my TESR, with no result. Heres BlockGrill: package com.leomelonseeds.moarstuff.blocks; import javax.annotation.Nullable; import com.leomelonseeds.moarstuff.Main; import com.leomelonseeds.moarstuff.items.Moditems; import com.leomelonseeds.moarstuff.network.GUIHandlerGrill; import com.leomelonseeds.moarstuff.tileentity.Grill; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockGrill extends Block{ public BlockGrill(String unlocalizedName) { super(Material.ROCK); this.setUnlocalizedName("grill"); this.setCreativeTab(Moditems.moarStuff); this.isBlockContainer = true; } @Override public TileEntity createTileEntity(World worldIn, IBlockState state) { return new Grill(); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { // Uses the gui handler registered to your mod to open the gui for the given gui id // open on the server side only (not sure why you shouldn't open client side too... vanilla doesn't, so we better not either) if (worldIn.isRemote) return true; playerIn.openGui(Main.instance, GUIHandlerGrill.getGuiID(), worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } // This is where you can do something when the block is broken. In this case drop the inventory's contents @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof IInventory) { InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileEntity); } // Super MUST be called last because it removes the tile entity super.breakBlock(worldIn, pos, state); } public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) { super.eventReceived(state, worldIn, pos, id, param); TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity == null ? false : tileentity.receiveClientEvent(id, param); } // used by the renderer to control lighting and visibility of other blocks. //set to false becaus is block doesn't fill the entire 1x1x1 space @Override public boolean isOpaqueCube(IBlockState iBlockState) { return false; } public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; } public boolean isFullCube(IBlockState state) { return false; } public boolean hasTileEntity(IBlockState state) { return true; }
  12. Sorry for making it unclear, I am actually using a TESR, I copied some vanilla code from the chest. Meanwhile, I am going to try your fixes and see if they work. Thanks for the help!
  13. Hello, this is my first post so don't blame me if I do something wrong. My tileentity Grill renderes like an invisible cube with a name tag on it Here is my code: BlockGrill: package com.leomelonseeds.moarstuff.blocks; import javax.annotation.Nullable; import com.leomelonseeds.moarstuff.Main; import com.leomelonseeds.moarstuff.items.Moditems; import com.leomelonseeds.moarstuff.network.GUIHandlerGrill; import com.leomelonseeds.moarstuff.tileentity.Grill; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryHelper; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockGrill extends Block implements ITileEntityProvider { public BlockGrill(String unlocalizedName) { super(Material.ROCK); this.setUnlocalizedName("grill"); this.setCreativeTab(Moditems.moarStuff); this.isBlockContainer = true; } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new Grill(); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { // Uses the gui handler registered to your mod to open the gui for the given gui id // open on the server side only (not sure why you shouldn't open client side too... vanilla doesn't, so we better not either) if (worldIn.isRemote) return true; playerIn.openGui(Main.instance, GUIHandlerGrill.getGuiID(), worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } // This is where you can do something when the block is broken. In this case drop the inventory's contents @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof IInventory) { InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileEntity); } // Super MUST be called last because it removes the tile entity super.breakBlock(worldIn, pos, state); } public boolean eventReceived(IBlockState state, World worldIn, BlockPos pos, int id, int param) { super.eventReceived(state, worldIn, pos, id, param); TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity == null ? false : tileentity.receiveClientEvent(id, param); } // used by the renderer to control lighting and visibility of other blocks. //set to false becaus is block doesn't fill the entire 1x1x1 space @Override public boolean isOpaqueCube(IBlockState iBlockState) { return false; } public EnumBlockRenderType getRenderType(IBlockState state) { return EnumBlockRenderType.ENTITYBLOCK_ANIMATED; } public boolean isFullCube(IBlockState state) { return false; } public boolean hasTileEntity(IBlockState state) { return true; } } My modtileentities: package com.leomelonseeds.moarstuff.tileentity; import net.minecraftforge.fml.common.registry.GameRegistry; public final class ModTileEntities { public static Grill grill; public static void createTileEntities() { GameRegistry.registerTileEntity(Grill.class, "grill"); grill = new Grill(); } } Also, the console keeps looking for a blockstates.json file. Why is this happening?
×
×
  • Create New...

Important Information

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