Jump to content

Recommended Posts

Posted (edited)

I've made a block which has a TE that extends TileEntityChest. I want the block to render with an ordinary static model (not a TESR) - I've got a blockstates file and model and I know they're correct because that model is used when it's an inventory item. But when I place the block in the world, it renders as a vanilla chest instead of my block model. I've overriden getRenderType to return MODEL, but that's apparently being ignored. The block class does not extend the vanilla chest block, only the TE extends the vanilla TileEntityChest. How can I force it to render as a block model instead of the vanilla TESR?

 

For reference, my block class:

Spoiler

package com.jayavery.jjmod.blocks;

import java.util.Random;
import com.jayavery.jjmod.main.GuiHandler.GuiList;
import com.jayavery.jjmod.main.Jjmod;
import com.jayavery.jjmod.tileentities.TEBasket;
import com.jayavery.jjmod.utilities.BlockMaterial;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

public class BlockBasket extends BlockComplexAbstract {

    public BlockBasket() {
        
        super("basket", BlockMaterial.WOOD_HANDHARVESTABLE, 1, null);
        this.setCreativeTab(CreativeTabs.DECORATIONS);
    }
    
    @Override
    public Item getItemDropped(IBlockState state, Random rand, int fortune) {
        
        return Item.getItemFromBlock(this);
    }
    
    @Override
    public boolean activate(EntityPlayer player, World world,int x, int y, int z) {
        
        if (!world.isRemote) {
            
            player.openGui(Jjmod.instance, GuiList.BASKET.ordinal(),
                    world, x, y, z);
        }
        
        return true;
    }
    
    @Override
    public TileEntity createNewTileEntity(World world, int meta) {
        
        return new TEBasket();
    }
    
    @Override
    public EnumBlockRenderType getRenderType(IBlockState state) {

        return EnumBlockRenderType.MODEL;
    }

    @Override
    public BlockRenderLayer getBlockLayer() {

        return BlockRenderLayer.CUTOUT_MIPPED;
    }
    
    @Override
    public AxisAlignedBB getBoundingBox(IBlockState state,
            IBlockAccess source, BlockPos pos) {
        
        return CENTRE_EIGHT;
    }
    
    @Override
    public int getMetaFromState(IBlockState state) {
        
        return 0;
    }
    
    @Override
    public IBlockState getStateFromMeta(int meta) {
        
        return this.getDefaultState();
    }
    
    @Override
    public IBlockState getActualState(IBlockState state,
            IBlockAccess world, BlockPos pos) {
        
        return state;
    }
    
    @Override
    public BlockStateContainer createBlockState() {
        
        return new BlockStateContainer(this, new IProperty[0]);
    }
    
    @Override
    public void neighborChanged(IBlockState state, World world,
            BlockPos pos, Block block, BlockPos unused) {}
}

 

My TileEntity:

Spoiler

package com.jayavery.jjmod.tileentities;

import com.jayavery.jjmod.blocks.BlockBox;
import com.jayavery.jjmod.container.ContainerBasket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.math.AxisAlignedBB;

public class TEBasket extends TileEntityChest {

    @Override
    public int getSizeInventory() {
        
        return 9;
    }
    
    @Override
    public Container createContainer(InventoryPlayer playerInv,
            EntityPlayer player) {
        
        return new ContainerBasket(player, this.world, this);
    }
    
    @Override
    public void checkForAdjacentChests() {}
    
    @Override
    public void update() {
        
        int i = this.pos.getX();
        int j = this.pos.getY();
        int k = this.pos.getZ();
        
        if (!this.world.isRemote) {

            for (EntityPlayer entityplayer : this.world
                    .getEntitiesWithinAABB(EntityPlayer.class,
                    new AxisAlignedBB(i - 5.0F,
                    j - 5.0F, k - 5.0F,
                    i + 1 + 5.0F,
                    j + 1 + 5.0F,
                    k + 1 + 5.0F))) {
               
                if (entityplayer.openContainer instanceof ContainerBasket) {
                   
                    IInventory iinventory = ((ContainerBasket) entityplayer
                            .openContainer).basketInv;

                    if (iinventory == this) {
                       
                        ++this.numPlayersUsing;
                    }
                }
            }
        }
    }
    
    @Override
    public void closeInventory(EntityPlayer player) {
        
        if (!player.isSpectator() && this.getBlockType() instanceof BlockBox) {
            
            this.numPlayersUsing--;
            this.world.addBlockEvent(this.pos, this.getBlockType(),
                    1, this.numPlayersUsing);
            this.world.notifyNeighborsOfStateChange(this.pos,
                    this.getBlockType(), false);
        }
    }
}

 

Edited by Jay Avery
Posted

When forge renders a TESR the TESR registered is registered by the TileEntity it is rendering in this case i think that when minecraft renders your TileEntity because it extends TileEntityChest it uses the TESR registered with TileEntityChest

So long story short what diesieben07 said

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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