Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[UNSOLVED][1.10.2]Need help with TESR and tileentity item


Leomelonseeds
 Share

Recommended Posts

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);
            }
        }
    }

 

 

Edited by Leomelonseeds

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

For the 1st question, you need to set the bounding box.

For the 2nd question, does your ItemBlock render as a big missing texture cube? How does it render? Does your grill NOT render in the inventory (is it transparent/invisible?)?

YouTube:

https://www.youtube.com/channel/UCaK5oRw4yd7PurBWww9tVhA

Kuribo64 (where I am most active):

http://kuribo64.net/board/profile.php?id=1423

 

Thanks for your answer!

 

Current projects:

 

3D Geometry Dash: 13%

Terracraft (MC Mod): 8%

New Super Kaizo Bros DS: 100% (no download for now :'( )

New Super Kaizo Bros. Wii: 12%

Super Mario Galaxy 1.5: 96%

New Super Mario Bros Galaxy: 85%

Kerbal Space Program Advance: 47%

MC CREATE: 20%

Mystery Projects: 10%, 40%, 13%, and 94%

Link to comment
Share on other sites

What? Sorry, I don't have a lot of experience with TESR. I am asking what the problem described in 2) is.

YouTube:

https://www.youtube.com/channel/UCaK5oRw4yd7PurBWww9tVhA

Kuribo64 (where I am most active):

http://kuribo64.net/board/profile.php?id=1423

 

Thanks for your answer!

 

Current projects:

 

3D Geometry Dash: 13%

Terracraft (MC Mod): 8%

New Super Kaizo Bros DS: 100% (no download for now :'( )

New Super Kaizo Bros. Wii: 12%

Super Mario Galaxy 1.5: 96%

New Super Mario Bros Galaxy: 85%

Kerbal Space Program Advance: 47%

MC CREATE: 20%

Mystery Projects: 10%, 40%, 13%, and 94%

Link to comment
Share on other sites

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

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

Currently my Grill is like 25% smaller then the collision box.
You can adjust the size using glScale.

 

How do you make the grill render in the inventory, and how does vanilla minecraft do it?
Vanilla's TESRs that render in the inventory are hardcoded in
TileEntityItemStackRenderer

. You can add your own using

ForgeHooksClient.registerTESRItemStack

.

 

Why does it keep asking me for blockstates.json for grill and why doesn't vanilla minecraft need one.
It asks you for a blockstate json because you did not specify anything different, and the default is to try and load a model.

If you do not need one, implement

IStateMapper

and always return an empty Map. Then register your state mapper using

ModelLoader.setCustomStateMapper

in preInit.

Vanilla does not need one, because things are, again, hardcoded, see

BlockModelShapes::registerAllBlock

s resp.

BlockStateMapper::registerBuiltInBlocks

.

 

When I right-click the grill, it is supposed to open like a chest but it doesn't.
You always create a new (empty)
TileEntityChest

when rendering. Why? You need to use the

TileEntity

you get passed in. Why are you using

TileEntitySpecialRenderer

as a raw type?

Link to comment
Share on other sites

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.

 

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

What is a raw type
https://docs.oracle.com/javase/tutorial/java/generics/rawTypes.html

 

and what do you mean by:

YOu need to use the TileEntity you get passed in.

renderTileEntityAt

has a parameter of type

TileEntity

(or rather the type of the generic parameter

T

of

TileEntitySpecialRenderer

). This is the TileEntity to be rendered. You completely disregard it, create a new (empty) instance and render that. Of course that freshly created TileEntity will never have an open lid.

Link to comment
Share on other sites

And in setCustomStateMapper, what do I put for IStateMapper mapper?

 

An IStateMapper implementation.

Here's one of mine.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

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?

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

Oh wait, I just noticed that my custom tnt already has setCustomStateMapper :P

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

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

But how do I make it ignore blockstates.json
If you do not need one, implement
IStateMapper

and always return an empty Map.

 

And, again:

renderTileEntityAt

has a parameter of type

TileEntity

(or rather the type of the generic parameter

T

of

TileEntitySpecialRenderer

). This is the TileEntity to be rendered. You completely disregard it, create a new (empty) instance and render that. Of course that freshly created TileEntity will never have an open lid.

Link to comment
Share on other sites

If you tell it to use the default state mapper and not your own implementation, of course it's going to keep looking.

 

ModelLoader.setCustomStateMapper(Modblocks.megatnt, (new StateMap.Builder()).ignore(new IProperty[] {BlockMegaTNT.EXPLODE}).build());

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yes, but is the code posted above correct, if not can you tell me which parts to correct?

No, it is not correct.

And, again, this is what you need to correct:

 

If you do not need one, implement
IStateMapper

and always return an empty Map.

 

renderTileEntityAt

has a parameter of type

TileEntity

(or rather the type of the generic parameter

T

of

TileEntitySpecialRenderer

). This is the TileEntity to be rendered. You completely disregard it, create a new (empty) instance and render that. Of course that freshly created TileEntity will never have an open lid.

Link to comment
Share on other sites

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.

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

Whoops.

 

Still.

 

You had this:

ModelLoader.setCustomStateMapper(Modblocks.grill, null);

 

Which was still not creating an instance of your custom IStateMapper.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Also, how do I get it to always return an empty map? Doesn't my current method already return an empty map?
Which method? You have not posted any kind of custom
IStateMapper

implementation.

 

And, I don't see any generic types in my TESR posted above.
Yes, because you using the raw type.
Why are you using
TileEntitySpecialRenderer

as a raw type?

Link to comment
Share on other sites

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);
            }
        }
    }

 

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

Why did you implement IStateMapper on your Block? Where do you register it?

 

And you still have not fixed this:

renderTileEntityAt

has a parameter of type

TileEntity

(or rather the type of the generic parameter

T

of

TileEntitySpecialRenderer

). This is the TileEntity to be rendered. You completely disregard it, create a new (empty) instance and render that. Of course that freshly created TileEntity will never have an open lid.

 

This is the last time I am telling you this, if you continue to just ignore my advice, you can solve your problem on your own.

Link to comment
Share on other sites

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()?

Apparently I'm addicted to these forums and can't help but read all the posts. So if I somehow help you, please click the "Like This" button, it helps.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.