Posted August 14, 201510 yr I've been working on a tileentity with a custom model, but the block stops rendering less than a second after I place it in the game. When I place it it renders properly, then the block becomes invisible, but remains in the world. I added a System.out.println() call to my renderTileEntityAt method right after this.model.render is called, and the output only gets printed a few times right when the block is placed, then stops when the block stops rendering. The tileentity continues to function when the block is invisible, so the problem must be with whereever the renderer is called from, but I'm not sure where that is. Help?
August 14, 201510 yr Do you have any code to show? It makes this process of helping a lot of easier. If my post helped you, please press that "Thank You"-button to show your appreciation. Also if you don't know Java, I would suggest you read the official tutorials by Oracle to get an idea of how to do this. Thanks, and good modding! Also if you haven't, set up a Git repo for your mod not only for convinience but also to make it easier to help you.
August 14, 201510 yr Author These still have a few things that are just for testing, but here they are: Renderer Class package arcane_engineering.client.render; import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.FMLClientHandler; import arcane_engineering.blocks.tiles.TileEntityDestabilizer; import arcane_engineering.client.models.ModelDestabilizer; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class RenderDestabilizer extends TileEntitySpecialRenderer { private final ModelDestabilizer model = new ModelDestabilizer(); private final ResourceLocation texture = new ResourceLocation("arcane_engineering", "textures/blocks/destabilizer.png"); public RenderDestabilizer() { //model = new ModelDestabilizer(); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { bindTexture(texture); GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); GL11.glPushMatrix(); model.render(); GL11.glPopMatrix(); GL11.glPopMatrix(); } private void adjustLightFixture(World world, int i, int j, int k, Block block) { Tessellator tess = Tessellator.instance; float brightness = block.getLightOpacity(world, i, j, k); int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int modulousModifier = skyLight % 65536; int divModifier = skyLight / 65536; tess.setColorOpaque_F(brightness, brightness, brightness); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); } } Block Class package arcane_engineering.blocks; import arcane_engineering.blocks.tiles.TileEntityDestabilizer; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class BlockDestabilizer extends AEBlockContainer { public BlockDestabilizer() { super(Material.iron, "destabilizer"); } @Override public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { if (side == ForgeDirection.DOWN) {return true;} return false; } @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { return new TileEntityDestabilizer(); } } TileEntity Class package arcane_engineering.blocks.tiles; import arcane_engineering.client.render.RenderDestabilizer; import thaumcraft.api.nodes.INode; import thaumcraft.api.nodes.NodeType; import cofh.api.energy.EnergyStorage; import cofh.api.energy.IEnergyReceiver; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; public class TileEntityDestabilizer extends TileEntity implements IEnergyReceiver { public EnergyStorage energyStorage = new EnergyStorage(6400000); @Override public boolean canConnectEnergy(ForgeDirection from) { if (from != null && from == ForgeDirection.DOWN) { return true; } return false; } @Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { if(worldObj.isRemote) { return 0; } int r = energyStorage.receiveEnergy(maxReceive, simulate); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); markDirty(); return r; } @Override public int getEnergyStored(ForgeDirection from) { return energyStorage.getEnergyStored(); } @Override public int getMaxEnergyStored(ForgeDirection from) { return energyStorage.getMaxEnergyStored(); } @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag); } @Override public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); energyStorage.writeToNBT(tag); } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); energyStorage.readFromNBT(nbt); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { readFromNBT(pkt.func_148857_g()); } @Override public void updateEntity() { if (energyStorage.getEnergyStored() == energyStorage.getMaxEnergyStored() && worldObj.getTileEntity(xCoord, yCoord + 1, zCoord) instanceof INode) { ((INode) worldObj.getTileEntity(xCoord, yCoord + 1, zCoord)).setNodeType(NodeType.HUNGRY); } } } My custom BlockContainer Class package arcane_engineering.blocks; import java.util.List; import cpw.mods.fml.common.registry.GameRegistry; import arcane_engineering.ArcaneEngineering; 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.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; public abstract class AEBlockContainer extends BlockContainer{ public String itemName; public AEBlockContainer(Material material, String name) { super(material); this.itemName = name; this.setLightLevel(1.0F); this.setBlockName("ArcaneEngineering."+name); GameRegistry.registerBlock(this, name); this.setCreativeTab(ArcaneEngineering.tabArcaneEngineering); } @Override public int damageDropped(int meta) { return meta; } @Override public boolean isOpaqueCube() { return false; } @Override public boolean renderAsNormalBlock() { return false; } @Override public int getRenderType() { return -1; } @Override public abstract TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_); } Model Class package arcane_engineering.client.models; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; /** * HungryHungryHuggable - HuggableCreep * Created using Tabula 4.1.0 */ public class ModelDestabilizer extends ModelBase { public ModelRenderer Base; public ModelRenderer ArmRest; public ModelRenderer Crystal; public ModelRenderer ArmA; public ModelRenderer ArmB; public ModelRenderer ArmC; public ModelRenderer ArmD; public ModelRenderer Arm2; public ModelRenderer Arm2_1; public ModelRenderer Arm2_2; public ModelRenderer Arm2_3; public ModelDestabilizer() { this.textureWidth = 64; this.textureHeight = 64; this.ArmA = new ModelRenderer(this, 0, 0); this.ArmA.setRotationPoint(0.0F, -5.0F, 4.0F); this.ArmA.addBox(-0.5F, 0.0F, -0.5F, 1, 8, 1, 0.0F); this.setRotateAngle(ArmA, 1.0471975511965976F, 0.0F, 0.0F); this.Arm2 = new ModelRenderer(this, 0, 0); this.Arm2.setRotationPoint(0.0F, 8.5F, 0.5F); this.Arm2.addBox(-0.5F, 0.0F, -0.5F, 1, 8, 1, 0.0F); this.setRotateAngle(Arm2, -1.5707963267948966F, 0.0F, 0.0F); this.Base = new ModelRenderer(this, 0, 42); this.Base.setRotationPoint(0.0F, -2.0F, 0.0F); this.Base.addBox(-8.0F, -6.0F, -8.0F, 16, 6, 16, 0.0F); this.ArmB = new ModelRenderer(this, 0, 0); this.ArmB.setRotationPoint(0.0F, -5.0F, -5.0F); this.ArmB.addBox(-0.5F, 0.0F, -1.0F, 1, 8, 1, 0.0F); this.setRotateAngle(ArmB, 1.0471975511965976F, 3.141592653589793F, 0.0F); this.ArmRest = new ModelRenderer(this, 12, 28); this.ArmRest.setRotationPoint(0.0F, 6.0F, 0.0F); this.ArmRest.addBox(-5.0F, -6.0F, -5.0F, 10, 3, 10, 0.0F); this.Arm2_3 = new ModelRenderer(this, 0, 0); this.Arm2_3.setRotationPoint(0.0F, 8.5F, 0.5F); this.Arm2_3.addBox(-0.5F, 0.0F, -0.5F, 1, 8, 1, 0.0F); this.setRotateAngle(Arm2_3, -1.5707963267948966F, 0.0F, 0.0F); this.Arm2_2 = new ModelRenderer(this, 0, 0); this.Arm2_2.setRotationPoint(0.0F, 8.5F, 0.5F); this.Arm2_2.addBox(-0.5F, 0.0F, -0.5F, 1, 8, 1, 0.0F); this.setRotateAngle(Arm2_2, -1.5707963267948966F, 0.0F, 0.0F); this.ArmD = new ModelRenderer(this, 0, 0); this.ArmD.setRotationPoint(-4.0F, -5.0F, 0.0F); this.ArmD.addBox(-0.5F, 0.0F, -0.5F, 1, 8, 1, 0.0F); this.setRotateAngle(ArmD, 1.0471975511965976F, -1.5707963267948966F, 0.0F); this.Crystal = new ModelRenderer(this, 40, 0); this.Crystal.setRotationPoint(0.0F, 3.0F, 0.0F); this.Crystal.addBox(-3.0F, -6.0F, -3.0F, 6, 7, 6, 0.0F); this.ArmC = new ModelRenderer(this, 0, 0); this.ArmC.setRotationPoint(4.0F, -5.0F, 0.0F); this.ArmC.addBox(-0.5F, 0.0F, -0.5F, 1, 8, 1, 0.0F); this.setRotateAngle(ArmC, 1.0471975511965976F, 1.5707963267948966F, 0.0F); this.Arm2_1 = new ModelRenderer(this, 0, 0); this.Arm2_1.setRotationPoint(0.0F, 8.5F, 0.0F); this.Arm2_1.addBox(-0.5F, 0.0F, -0.5F, 1, 8, 1, 0.0F); this.setRotateAngle(Arm2_1, -1.5758577816256802F, 0.0F, 0.0F); this.ArmRest.addChild(this.ArmA); this.ArmA.addChild(this.Arm2); this.ArmRest.addChild(this.ArmB); this.Base.addChild(this.ArmRest); this.ArmD.addChild(this.Arm2_3); this.ArmC.addChild(this.Arm2_2); this.ArmRest.addChild(this.ArmD); this.ArmRest.addChild(this.Crystal); this.ArmRest.addChild(this.ArmC); this.ArmB.addChild(this.Arm2_1); } public void render() { super.render(null, 0F, 0F, 0F, 0F, 0F, 0.0625F); this.Base.render(0.0625F); } /** * This is a helper function from Tabula to set the rotation of model parts */ public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } } ClientProxy package arcane_engineering.client; import cpw.mods.fml.client.registry.ClientRegistry; import arcane_engineering.CommonProxy; import arcane_engineering.blocks.tiles.TileEntityDestabilizer; import arcane_engineering.client.render.RenderDestabilizer; public class ClientProxy extends CommonProxy { public void registerRenders() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDestabilizer.class, new RenderDestabilizer()); } } Main Mod Class package arcane_engineering; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLLoadCompleteEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.creativetab.CreativeTabs; import arcane_engineering.AEContent; import arcane_engineering.blocks.tiles.TileEntityDestabilizer; import arcane_engineering.client.ClientProxy; @Mod(modid = "arcane_engineering", name = "Arcane Engineering", version = "0.1", dependencies = "required-after:Forge;required-after:ImmersiveEngineering;after:Thaumcraft") public class ArcaneEngineering { public static CreativeTabs tabArcaneEngineering = new AECreativeTab(CreativeTabs.getNextID(), "arcaneengineering"); @Mod.Instance public static ArcaneEngineering instance; @SidedProxy(serverSide = "arcane_engineering.CommonProxy", clientSide = "arcane_engineering.client.ClientProxy") public static CommonProxy proxy; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { AEContent.preInitItems(); AEContent.preInitBlocks(); proxy.registerRenders(); } @Mod.EventHandler public void Init(FMLInitializationEvent event) { GameRegistry.registerTileEntity(TileEntityDestabilizer.class, "destabliizer"); } @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { AEResearch.setupResearchPages(); AEResearch.registerResearch(); } }
August 14, 201510 yr Hi I don't know what's causing that symptom, it's quite odd. Vanilla does cull TESR based on where the player is looking, if you haven't overridden that, it might be culling your renderer as soon as you move your head. /** Return an appropriate bounding box enclosing the TESR * This method is used to control whether the TESR should be rendered or not, depending on where the player is looking. * The default is the AABB for the parent block, which might be too small if the TESR renders outside the borders of the * parent block. * If you get the boundary too small, the TESR may disappear when you aren't looking directly at it. * @return an appropriately size AABB for the TileEntity */ @SideOnly(Side.CLIENT) @Override public AxisAlignedBB getRenderBoundingBox() { // if your render should always be performed regardless of where the player is looking, use infinite AxisAlignedBB infiniteExample = INFINITE_EXTENT_AABB; // our gem will stay above the block, up to 1 block higher, so our bounding box is from [x,y,z] to [x+1, y+2, z+1] AxisAlignedBB aabb = new AxisAlignedBB(getPos(), getPos().add(1, 2, 1)); return aabb; } In any case, you can find the caller of your TESR by setting a breakpoint in renderTileEntityAt and then using your debugger to step out of the method into the caller. -TGG
August 15, 201510 yr Author Well I tried that, but it didn't help. Thanks anyways though, as I expect that will be useful elsewhere for me.
August 15, 201510 yr Author After Some debugging, I've realized that for some reason, the tileentity's position constantly fluctuates between 0,0,0 and it's parent block's position, and the rendering method only gets called when the position is 0,0,0, making the tileentity render only at 0,0,0. I'm not sure what is causing this fluctation, but my tileentity code is in a previous post, and I'd appreciate some help
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.