Jump to content

[1.7.10] Custom Modeled/Rendered block wont render in inventory PLZ HELP!


Recommended Posts

Posted

Hello, i am creating a customly rendered block and it will not render in the Inventory, please help!

I did try System.out.println("rendering"); in my Render class, nothing shew up.

TileEntityCondenser is not included, only thing with it is extends TileEntity.

 

 

HERE are the classes:

 

[spoiler=ModBlocks.java]

package com.jonnyetiz.mtrade.block;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

import com.jonnyetiz.mtrade.reference.Names;

import cpw.mods.fml.common.registry.GameRegistry;

public class ModBlocks 
{

public static Block blockCondenser;

public static void loadBlocks()
{

	blockCondenser = new BlockCondenser(Material.wood).setBlockName(Names.Blocks.CONDENSER).setBlockTextureName("magictrade:Condenser.png");
	GameRegistry.registerBlock(blockCondenser, Names.Blocks.CONDENSER);

}
}

 

 

 

[spoiler=BlockCondenser.java]

package com.jonnyetiz.mtrade.block;

import com.jonnyetiz.mtrade.creativetab.CreativeTab;
import com.jonnyetiz.mtrade.tileentity.TileEntityCondenser;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockCondenser extends BlockContainer{

public BlockCondenser(Material material) {
	super(material);
	//Modifiers
	this.setCreativeTab(CreativeTab.MT_TAB);
	this.setHardness(2.0F);
	this.setResistance(5.0F);
	this.setLightLevel(0.5F);
}

public int getRenderType(){
	return -100;
}

public boolean isOpaqueCube(){
	return false;
}

public boolean renderAsNormalBlock(){
	return false;
}

@Override
public TileEntity createNewTileEntity(World var1, int var2){
	return new TileEntityCondenser();
}



}

 

 

[spoiler=RenderCondenser.java]

package com.jonnyetiz.mtrade.renderer;

import org.lwjgl.opengl.GL11;

import com.jonnyetiz.mtrade.models.ModelCondenser;
import com.jonnyetiz.mtrade.reference.Reference;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

public class RenderCondenser extends TileEntitySpecialRenderer{

private static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID + ":" + "magictrade:ModelCondenser.png");

private ModelCondenser model;

public RenderCondenser(){
	this.model = new ModelCondenser();
}

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
	GL11.glPushMatrix();
		GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
			GL11.glRotatef(180, 0F, 0F, 1F);
			this.bindTexture(texture);
			GL11.glPopMatrix();
			GL11.glPushMatrix();
				this.model.renderModel(0.0625F);


				System.out.println("rendering"); 


	GL11.glPopMatrix();

}

}

 

 

[spoiler=ClientProxy.java]

package com.jonnyetiz.mtrade.proxy;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;

import com.jonnyetiz.mtrade.MTradeMain;
import com.jonnyetiz.mtrade.client.handler.DrawBlockHighlightEventHandler;
import com.jonnyetiz.mtrade.client.handler.ItemTooltipEventHandler;
import com.jonnyetiz.mtrade.client.handler.KeyInputEventHandler;
import com.jonnyetiz.mtrade.client.renderer.item.ItemRendererAlchemicalChest;
import com.jonnyetiz.mtrade.client.renderer.tileentity.TileEntityRendererAlchemicalChest;
import com.jonnyetiz.mtrade.client.settings.Keybindings;
import com.jonnyetiz.mtrade.client.util.ClientSoundHelper;
import com.jonnyetiz.mtrade.init.ModBlocks;
import com.jonnyetiz.mtrade.reference.Names.Blocks;
import com.jonnyetiz.mtrade.reference.RenderIds;
import com.jonnyetiz.mtrade.renderer.RenderCondenser;
import com.jonnyetiz.mtrade.tileentity.TileEntityAlchemicalChest;
import com.jonnyetiz.mtrade.tileentity.TileEntityBlockCondenser;
import com.jonnyetiz.mtrade.tileentity.TileEntityCondenser;

import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;

public class ClientProxy extends CommonProxy
{
    @Override
    public void registerEventHandlers()
    {
        super.registerEventHandlers();
        FMLCommonHandler.instance().bus().register(new KeyInputEventHandler());
        MinecraftForge.EVENT_BUS.register(new ItemTooltipEventHandler());
        MinecraftForge.EVENT_BUS.register(new DrawBlockHighlightEventHandler());
    }

    @Override
    public void registerKeybindings()
    {
        ClientRegistry.registerKeyBinding(Keybindings.charge);
        ClientRegistry.registerKeyBinding(Keybindings.extra);
        ClientRegistry.registerKeyBinding(Keybindings.release);
        ClientRegistry.registerKeyBinding(Keybindings.toggle);
    }

    @Override
    public void playSound(String soundName, float xCoord, float yCoord, float zCoord, float volume, float pitch)
    {
        ClientSoundHelper.playSound(soundName, xCoord, yCoord, zCoord, volume, pitch);
    }

    @Override
    public void initRenderingAndTextures()
    {
        RenderIds.calcinator = RenderingRegistry.getNextAvailableRenderId();
        RenderIds.aludel = RenderingRegistry.getNextAvailableRenderId();
        RenderIds.alchemicalChest = RenderingRegistry.getNextAvailableRenderId();
        RenderIds.glassBell = RenderingRegistry.getNextAvailableRenderId();
        RenderIds.researchStation = RenderingRegistry.getNextAvailableRenderId();
        RenderIds.augmentationTable = RenderingRegistry.getNextAvailableRenderId();
        RenderIds.condenser = RenderingRegistry.getNextAvailableRenderId();

        MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.alchemicalChest), new ItemRendererAlchemicalChest());

        ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAlchemicalChest.class, new TileEntityRendererAlchemicalChest());
    }
    @Override
public void registerRenders() {
	//Condenser
	TileEntitySpecialRenderer render0 = new RenderCondenser();
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCondenser.class, render0);
}

@Override
public void registerTileEntitySpecialRenderer() {

}
}

 

 

Posted

It won't render in the inventory by default (see the hopper or saplings or levers or redstone from vanilla to see what I mean) however if you want it to you've got to make another class:

package com.jonnyetiz.mtrade.block;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.IItemRenderer;

public class BlockCondenserItemRenderer implements IItemRenderer {
TileEntitySpecialRenderer render;

private TileEntity entity;

public BlockCondenserItemRenderer(TileEntitySpecialRenderer render, TileEntity entity) {
	this.entity = entity;
	this.render = render;
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	return true;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
		ItemRendererHelper helper) {
	return true;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	if(type == IItemRenderer.ItemRenderType.ENTITY)
		GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
	this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F);
}

}

Then add this to your client proxy just under where you render the block:

MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.blockCondenser), new RenderCondenser(render0, new TileEntityCondenser()));

Finally, add this to the bottom of your BlockCondenser file:

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
	this.blockIcon = iconRegister.registerIcon("modid:textures/model/texturename.png");
}

Hope that helps,

-Toastrackenigma

Posted

It won't render in the inventory by default (see the hopper or saplings or levers or redstone from vanilla to see what I mean) however if you want it to you've got to make another class:

package com.jonnyetiz.mtrade.block;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.IItemRenderer;

public class BlockCondenserItemRenderer implements IItemRenderer {
TileEntitySpecialRenderer render;

private TileEntity entity;

public BlockCondenserItemRenderer(TileEntitySpecialRenderer render, TileEntity entity) {
	this.entity = entity;
	this.render = render;
}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	return true;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
		ItemRendererHelper helper) {
	return true;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	if(type == IItemRenderer.ItemRenderType.ENTITY)
		GL11.glTranslatef(-0.5F, 0.0F, -0.5F);
	this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F);
}

}

Then add this to your client proxy just under where you render the block:

MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.blockCondenser), new RenderCondenser(render0, new TileEntityCondenser()));

Finally, add this to the bottom of your BlockCondenser file:

@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
	this.blockIcon = iconRegister.registerIcon("modid:textures/model/texturename.png");
}

Hope that helps,

-Toastrackenigma

 

done but now i get the following 2 errors.

 

The constructor RenderCondenser(TileEntitySpecialRenderer, TileEntityCondenser) is undefined | In Client Proxy on Line 74

 

&

 

The method registerItemRenderer(Item, IItemRenderer) in the type MinecraftForgeClient is not applicable for the arguments (Item, RenderCondenser) | In Client Proxy on Line 74

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.