Jump to content

Leomelonseeds

Forge Modder
  • Posts

    407
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Leomelonseeds

  1. Also, how do I get the particles to not be purple and black when I break the block?
  2. Here is my Grill update method(Not BlockGrill): @Override public void update() { // If there is nothing to smelt or there is no room in the output, reset cookTime and return if (canSmelt()) { BlockGrill.isBurning = true; int numberOfFuelBurning = burnFuel(); // If fuel is available, keep cooking the item, otherwise start "uncooking" it at double speed if (numberOfFuelBurning > 0) { cookTime += numberOfFuelBurning; } else { cookTime -= 2; } if (cookTime < 0) cookTime = 0; // If cookTime has reached maxCookTime smelt the item and reset cookTime if (cookTime >= COOK_TIME_FOR_COMPLETION) { smeltItem(); cookTime = 0; } } else { cookTime = 0; BlockGrill.isBurning = false; } } I copied some MInecraftByExample code.
  3. Diesieben07, isn't the minecraft TileEntityChestRenderer class a raw type? If not, can you point out which parts of code make it not raw?
  4. Yes, but when I place a lot of grills down, when one is burning, they all burn, or all of them don't.
  5. How would I use getBlockType to set my isBurning though? An if statement? A method? And thank you Draco18s for verifying that.
  6. Then what should I set it to? I don't know any thing I can getBlockType to.
  7. So I check of this.getBlockType != null, then set BlockGrill.isBurning to true?
  8. When I remove static, it says "cannot make static reference to non-static variable" or something. How do I fix that?
  9. Thanks! Just a question, I set a boolean isBurning for my Grill, which sets the texture to the burning texture when it's burning. The problem is, when I place 2 grills, the texture doesn't show for anyone of them if one of them is not burning, and one is.
  10. Ok ok... I will do it, and for IStateMapper, I just create a new class(like Draco18s') and implement it with ModelLoader.setCustomStateMapper in ClientProxy.preInit()?
  11. Here is BlockGrill(Implements IStateMapper): package com.leomelonseeds.moarstuff.blocks; import java.util.Collections; import java.util.Map; 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.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.IStateMapper; 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 IStateMapper{ public static boolean isBurning; public BlockGrill(String unlocalizedName, boolean isBurning) { super(Material.ROCK); this.setUnlocalizedName("grill"); this.setCreativeTab(Moditems.moarStuff); this.isBlockContainer = true; this.isBurning = isBurning; } @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; } @Override public Map<IBlockState, ModelResourceLocation> putStateModelLocations(Block blockIn) { // TODO Auto-generated method stub return Collections.emptyMap(); } } Here is my TESR: package com.leomelonseeds.moarstuff.client.render.blocks; import com.leomelonseeds.moarstuff.blocks.BlockGrill; 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(); public TileGrillRenderer(){ } public void renderTileEntityAt(Grill te, double x, double y, double z, float partialTicks, int destroyStage) { TileEntityChest tec = new TileEntityChest(); GlStateManager.enableDepth(); GlStateManager.depthFunc(515); GlStateManager.depthMask(true); int i; if (te.hasWorldObj()) { Block block = te.getBlockType(); i = te.getBlockMetadata(); } else { i = 0; } ModelChest 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 if(BlockGrill.isBurning == true){ this.bindTexture(TEXTURE_BURNING); } 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; } GlStateManager.rotate((float)j, 0.0F, 1.0F, 0.0F); GlStateManager.translate(-0.5F, -0.5F, -0.5F); float f = tec.prevLidAngle + (tec.lidAngle - tec.prevLidAngle) * partialTicks; 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); } } }
  12. Draco18s: Actually, my block is the tileentity BlockGrill, not BlockMegaTNT. Diesieben07: Hopefully I can correct those errors. Thanks for the help! Also, how do I get it to always return an empty map? Doesn't my current method already return an empty map? And, I don't see any generic types in my TESR posted above.
  13. Yes, but is the code posted above correct, if not can you tell me which parts to correct?
  14. Oh wait, I just noticed that my custom tnt already has setCustomStateMapper But how do I make it ignore blockstates.json Also, grill lid still doesnt open: package com.leomelonseeds.moarstuff.client.render.blocks; import com.leomelonseeds.moarstuff.blocks.BlockGrill; 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(); public void renderTileEntityAt(Grill te, double x, double y, double z, float partialTicks, int destroyStage) { TileEntityChest tec = new TileEntityChest(); GlStateManager.enableDepth(); GlStateManager.depthFunc(515); GlStateManager.depthMask(true); int i; if (te.hasWorldObj()) { Block block = te.getBlockType(); i = te.getBlockMetadata(); } else { i = 0; } ModelChest 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 if(BlockGrill.isBurning = true){ this.bindTexture(TEXTURE_BURNING); } 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; } GlStateManager.rotate((float)j, 0.0F, 1.0F, 0.0F); GlStateManager.translate(-0.5F, -0.5F, -0.5F); float f = tec.prevLidAngle + (tec.lidAngle - tec.prevLidAngle) * partialTicks; 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); } } } And it automatically sets the texture to burning, even though I said false to isBurning
  15. Here is ClientProxy: package com.leomelonseeds.moarstuff; import java.util.Collections; 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); ModelLoader.setCustomStateMapper(Modblocks.grill, null); } @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); } } And my BlockGrill: package com.leomelonseeds.moarstuff.blocks; import java.util.Collections; import java.util.Map; 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.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.IStateMapper; 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 IStateMapper{ public static boolean isBurning; public BlockGrill(String unlocalizedName, boolean isBurning) { super(Material.ROCK); this.setUnlocalizedName("grill"); this.setCreativeTab(Moditems.moarStuff); this.isBlockContainer = true; this.isBurning = isBurning; } @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; } @Override public Map<IBlockState, ModelResourceLocation> putStateModelLocations(Block blockIn) { // TODO Auto-generated method stub return Collections.emptyMap(); } } What should I change "null" in clientproxy to and is my blockgrill file correct?
  16. And in setCustomStateMapper, what do I put for IStateMapper mapper?
  17. For the second question, what method do you use to always return an empty map, and do you register it in CommonProxy or ClientProxy?
  18. Ohhhhhh... So thats what you mean. Thanks for helping!
  19. Sorry, but I don't understand your answer to the last question. What is a raw type, and what do you mean by: YOu need to use the TileEntity you get passed in.
  20. I know that 1.10 and 1.11 are pretty similar. If so, are there any changes in the code that I should take note of when updating my mod to 1.11.2?
  21. I mean for the Grill item, I used a json file. The texture to that file is a blank entity. Check assets.minecraft.model.item.chest.json. I copied off that one
  22. 3. You could also use a tile entity special renderer, if you want to make it really complicated.
  23. 2nd question: I used the minecraft json file, setting it as just a blank entity. If minecraft Can do it, i definitely can too.
  24. So My Grill worked, thanks to diesieben07 and Animefan8888 for helping. Now I need some bugfixing: 1. Currently my Grill is like 25% smaller then the collision box. 2. How do you make the grill render in the inventory, and how does vanilla minecraft do it? 3. Why does it keep asking me for blockstates.json for grill and why doesn't vanilla minecraft need one. 4.When I right-click the grill, it is supposed to open like a chest but it doesn't. Here is my 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.TileEntity; 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 { 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; @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) { TileEntityChest tec = new TileEntityChest(); 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; } ModelChest 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; } GlStateManager.rotate((float)j, 0.0F, 1.0F, 0.0F); GlStateManager.translate(-0.5F, -0.5F, -0.5F); float f = tec.prevLidAngle + (tec.lidAngle - tec.prevLidAngle) * partialTicks; 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); } } }
×
×
  • Create New...

Important Information

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