Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Whenever I try to place my TileEntity, the model doesn't render and there is an empty bounding box where the block should be. Here is my code:

 

Block Class:

Spoiler

public class BlockTurret extends BlockTileEntity<TileEntityTurret> {

    public BlockTurret(String name) {
        super(Material.IRON, MapColor.TNT, name);
        setHardness(1.5f);
        setSoundType(SoundType.METAL);
    }

    @Override
    public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
        return false;
    }

    @Override
    public boolean isBlockNormalCube(IBlockState state) {
        return false;
    }

    @Override
    public EnumBlockRenderType getRenderType(IBlockState state) {
        return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
    }

    @Override
    public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face) {
        return false;
    }

    @Override
    public Class<TileEntityTurret> getTileEntityClass() {
        return TileEntityTurret.class;
    }

    @Nullable
    @Override
    public TileEntityTurret createTileEntity(World world, IBlockState state) {
        return new TileEntityTurret();
    }

    @Override
    @Deprecated
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

    @Override
    @Deprecated
    public boolean isFullCube(IBlockState state) {
        return false;
    }
}

 

TileEntity Base Class:

Spoiler

public abstract class BlockTileEntity<TE extends TileEntity> extends BlockBase {

    public BlockTileEntity(Material material, MapColor mapColor, String name) {
        super(material, mapColor, name);
    }

    public abstract Class<TE> getTileEntityClass();

    public TE getTileEntity(IBlockAccess world, BlockPos pos) {
        return (TE) world.getTileEntity(pos);
    }

    @Override
    public boolean hasTileEntity(IBlockState state) {
        return true;
    }

    @Nullable
    @Override
    public abstract TE createTileEntity(World world, IBlockState state);
}

 

 

TESR Class:

Spoiler

@SideOnly(Side.CLIENT)
public class TESRTurret extends TileEntitySpecialRenderer<TileEntityTurret> {

    private final ModelTurret model = new ModelTurret();
    private static ResourceLocation TEXTURE = new ResourceLocation(Sentries.modId,"textures/blocks/turret/rf_turret.png");

    @Override
    public void render(TileEntityTurret te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
        GlStateManager.pushMatrix();
        GlStateManager.translate(x,y,z);
        bindTexture(TEXTURE);
        model.renderAll();
        GlStateManager.popMatrix();
        super.render(te, x, y, z, partialTicks, destroyStage, alpha);

    }
}

 

Model Class:

Spoiler

@SideOnly(Side.CLIENT)
public class ModelTurret extends ModelBase {
    public ModelRenderer base;
    public ModelRenderer swivel;
    public ModelRenderer westArm;
    public ModelRenderer eastArm;
    public ModelRenderer gun;

    public ModelTurret() {
        this.textureWidth = 64;
        this.textureHeight = 32;

        this.base = new ModelRenderer(this, 0, 10);
        this.base.setRotationPoint(-6.0F, 22.0F, -6.0F);
        this.base.addBox(0.0F, 0.0F, 0.0F, 12, 2, 12);
        this.swivel = new ModelRenderer(this, 2, 0);
        this.swivel.setRotationPoint(-4.0F, 21.0F, -4.0F);
        this.swivel.addBox(0.0F, 0.0F, 0.0F, 8, 2, 8);
        this.westArm = new ModelRenderer(this, 26, 0);
        this.westArm.setRotationPoint(-2.0F, 17.0F, -2.0F);
        this.westArm.addBox(0.0F, 0.0F, 0.0F, 1, 4, 4);
        this.eastArm = new ModelRenderer(this, 0, 0);
        this.eastArm.setRotationPoint(1.0F, 17.0F, -2.0F);
        this.eastArm.addBox(0.0F, 0.0F, 0.0F, 1, 4, 4);
        this.gun = new ModelRenderer(this, 0, 13);
        this.gun.setRotationPoint(-1.0F, 12.0F, -1.0F);
        this.gun.addBox(0.0F, 0.0F, 0.0F, 2, 7, 2);
    }
    private float scale = 1;

    public void renderAll() {
        this.base.render(scale);
        this.swivel.render(scale);
        this.westArm.render(scale);
        this.eastArm.render(scale);
        this.gun.render(scale);
    }
}

 

Server-side registration:

Spoiler

public static BlockTurret RFTurret;
    private void initBlocks(){ //Called from preInit
        RFTurret = registerBlocks(new BlockRFTurret());
    }
    
    private static <T extends Block> T registerBlocks(T block, ItemBlock itemBlock) {
        GameRegistry.findRegistry(Block.class).register(block);
        GameRegistry.findRegistry(Item.class).register(itemBlock);

        if (block instanceof BlockBase) {
            ((BlockBase) block).registerItemModel(itemBlock);
        }
        if (block instanceof BlockTileEntity) {
            GameRegistry.registerTileEntity(((BlockTileEntity<?>) block).getTileEntityClass(), block.getRegistryName().toString());
        }

        return block;
    }

    private static <T extends Block> T registerBlocks(T block) {
        ItemBlock itemBlock = new ItemBlock(block);
        itemBlock.setRegistryName(block.getRegistryName());
        return registerBlocks(block, itemBlock);
        
    }

 

Client-side registration:

Spoiler

public void registerRenderers() { //Called from preInit
        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTurret.class, new TESRTurret());
    }

 

What's going on? (I guess not going on, more specifically.)

 

---SOLUTION---

 

 

Edited by OttselKid
god help us...

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.