Jump to content

[1.7.10] Block Model Render in Inventory [SOLVED]


iLegendx98

Recommended Posts

I have made a block using techne that I would like to have modeled in my inventory/hand as well as the world. For some reason, I cant get it to work. It just displays as an Item with a missing texture.

 

 

XYmHs70.png

 

 

 

Here is all the code that is related to the block. Note: The block is a machine as well so there is a lot of code unrelated to the render. The block is named enditeReactor.

 

BlockEnditeReactor

 

 

package blocks;

import gui.GuiID;

import java.util.Random;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import tileentity.TileEntityEnditeReactor;
import main.RunicScrolls;
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.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class BlockEnditeReactor extends BlockContainer
{
private final boolean isActive;
private static boolean keepInventory;
public TileEntityEnditeReactor enditeReactor;
private Random rand = new Random();
public static boolean isParticle;

public BlockEnditeReactor(boolean isActive) 
{
	super(Material.iron);
	this.isActive = isActive;
}

@Override
public int getRenderType()
{
	int id;
	id = RenderingRegistry.getNextAvailableRenderId();
	return id;
}
public boolean isOpaqueCube() 
{
	return false;
}

public boolean renderAsNormalBlock() 
{
	return false;
}


@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
	this.blockIcon = iconRegister.registerIcon(RunicScrolls.modid + ":"
			+ this.getUnlocalizedName().substring(5));
}


@Override
public TileEntity createNewTileEntity(World world, int i) 
{
	return new TileEntityEnditeReactor();
}

public void onBlockAdded(World world, int x, int y, int z) {
	super.onBlockAdded(world, x, y, z);

	if(world.getBlockMetadata(x, y, z) == 0)
	{
		this.setDefaultDirection(world, x, y, z);
	}
}

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) 
{
	int l = MathHelper.floor_double((double)(entityplayer.rotationYaw * 4.0F / 360.F) + 0.5D) & 3;
	if(l == 0) 
	{
		world.setBlockMetadataWithNotify(x, y, z, 4, 2); 
	}
	if(l == 1) 
	{
		world.setBlockMetadataWithNotify(x, y, z, 1, 2); 
	}

	if(l == 2) 
	{
		world.setBlockMetadataWithNotify(x, y, z, 2, 2);
	}
	if(l == 3) 
	{
		world.setBlockMetadataWithNotify(x, y, z, 3, 2);
	}
	if(itemstack.hasDisplayName()) 
	{
		((TileEntityEnditeReactor)world.getTileEntity(x, y, z)).setGuiDisplayName(itemstack.getDisplayName());
	}
}

private void setDefaultDirection(World world, int x, int y, int z) 
{
	if(!world.isRemote) 
	{
		Block b1 = world.getBlock(x, y, z - 1);
		Block b2 = world.getBlock(x,  y,  z + 1);
		Block b3 = world.getBlock(x - 1, y, z);
		Block b4  = world.getBlock(x + 1, y, z);
		byte b0 = 3;
		if(b1.func_149730_j() && !b2.func_149730_j()) 
		{
			b0 = 3;	
		}
		if(b2.func_149730_j() && !b1.func_149730_j()) 
		{
			b0 = 2;	
		}
		if(b3.func_149730_j() && !b4.func_149730_j()) 
		{
			b0 = 5;	
		}
		if(b4.func_149730_j() && !b3.func_149730_j()) 
		{
			b0 = 4;	
		}
		world.setBlockMetadataWithNotify(x, y, x, b0, 2);
	}
}

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
	if(!world.isRemote)
	{
		if(this.isMultiblockFormedEnergized(world, x, y, z))
		{
			FMLNetworkHandler.openGui(player, RunicScrolls.instance, GuiID.guiIDEnditeReactorEnergized, world, x, y, z);
		}
	}
	return true;
}

public static void updateEnditeReactorBlockState(boolean active, World worldObj, int xCoord, int yCoord, int zCoord) 
{
	int i = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
	TileEntity tileentity = worldObj.getTileEntity(xCoord, yCoord, zCoord);
	keepInventory = true;
	if(active) 
	{
		worldObj.setBlock(xCoord, yCoord, zCoord, RunicScrolls.blockEnditeReactor);
		BlockEnditeReactor.isParticle = true;
	}
	else 
	{
		worldObj.setBlock(xCoord, yCoord, zCoord, RunicScrolls.blockEnditeReactor);
		BlockEnditeReactor.isParticle = false;
	}
	keepInventory = false;
	worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, i, 2);
	if(tileentity != null) 
	{
		tileentity.validate();
		worldObj.setTileEntity(xCoord, yCoord, zCoord, tileentity);
	}
}

public boolean isMultiblockFormedEnergized(World world, int x, int y, int z)
{
	Block chamber = RunicScrolls.blockEnergizedChamber;
	if(world.getBlock(x + 1, y, z) == chamber)
	{
		if(world.getBlock(x - 1, y, z) == chamber)
		{
			if(world.getBlock(x, y, z - 1) != Blocks.air)
			{
				return true;
			}
			if(world.getBlock(x, y, z + 1) != Blocks.air)
			{
				return true;
			}
		}
	}
	else if(world.getBlock(x - 1, y, z) == chamber)
	{
		if(world.getBlock(x + 1, y, z) == chamber)
		{
			if(world.getBlock(x, y, z - 1) != Blocks.air)
			{
				return true;
			}
			if(world.getBlock(x, y, z + 1) != Blocks.air)
			{
				return true;
			}
		}
	}
	else if(world.getBlock(x, y, z + 1) == chamber)
	{
		if(world.getBlock(x, y, z - 1) == chamber)
		{
			if(world.getBlock(x + 1, y, z) != Blocks.air)
			{
				return true;
			}
			if(world.getBlock(x - 1, y, z) != Blocks.air)
			{
				return true;
			}
		}
	}
	else if(world.getBlock(x, y, z - 1) == chamber)
	{
		if(world.getBlock(x, y, z + 1) == chamber)
		{
			if(world.getBlock(x + 1, y, z) != Blocks.air)
			{
				return true;
			}
			if(world.getBlock(x - 1, y, z) != Blocks.air)
			{
				return true;
			}
		}
	}
	return false;
}



public void breakBlock(World world, int x, int y, int z, Block oldblock, int oldMetaData) 
{
	if(!keepInventory) 
	{
		TileEntityEnditeReactor tileentity = (TileEntityEnditeReactor) world.getTileEntity(x, y, z);
		if(tileentity != null) 
		{
			for(int i = 0; i < tileentity.getSizeInventory(); i++) 
			{
				ItemStack itemstack = tileentity.getStackInSlot(i);
				if(itemstack != null) 
				{
					float f = this.rand.nextFloat() * 0.8F + 0.1F;
					float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
					float f2 = this.rand.nextFloat() * 0.8F + 0.1F;
					while(itemstack.stackSize > 0) 
					{
						int j = this.rand.nextInt(21) + 10;
						if(j > itemstack.stackSize) 
						{
							j = itemstack.stackSize;
						}
						itemstack.stackSize -= j;
						EntityItem item = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));
						if(itemstack.hasTagCompound()) 
						{
							item.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
						}
						world.spawnEntityInWorld(item);
					}
				}
			}
			world.func_147453_f(x, y, z, oldblock);
		}
	}
	super.breakBlock(world, x, y, z, oldblock, oldMetaData);
}

}

 

 

 

RenderEnditeReactor

 

 

 

package renderer;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import tileentity.TileEntityEnditeReactor;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.relauncher.SideOnly;
import main.RunicScrolls;
import model.ModelBlockEnditeReactor;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityEnderChestRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;


public class RenderEnditeReactor extends TileEntitySpecialRenderer
{
private static final ResourceLocation texture = new ResourceLocation(RunicScrolls.modid + ":" + "textures/model/BlockEnditeReactor.png");

private ModelBlockEnditeReactor model;

public RenderEnditeReactor() 
{
	this.model = new ModelBlockEnditeReactor();
}

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) 
{
	int i;
        if (tileentity.getWorldObj() == null)
        {
        	i = 0;
        } else 
        {
        	Block block = tileentity.getBlockType();
        	i = tileentity.getBlockMetadata();
        	if (block != null && i == 0)
        	{
        		i = tileentity.getBlockMetadata();
        	}
        }
	GL11.glPushMatrix();
	GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
	Minecraft.getMinecraft().renderEngine.bindTexture(texture);
	GL11.glPushMatrix();
	GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
	int j = 0;
	if (i == 3) 
	{
		j = 270;
	}
	if (i == 2) 
	{
		j = 180;
	}
	if (i == 1) 
	{
		j = 90;
	}
	if (i == 0) 
	{
		j = 360;
	}
	GL11.glRotatef(j, 0.0F, 1.0F, 0F);
	this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
	GL11.glPopMatrix();
	GL11.glPopMatrix();
}


}

 

 

 

RenderItemEnditeReactor

 

 

 

package renderer;

import org.lwjgl.opengl.GL11;

import main.RunicScrolls;
import model.ModelBlockEnditeReactor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;

public class RenderItemEnditeReactor implements IItemRenderer {

protected ModelBase blockModel;
protected ResourceLocation blockTexture;
TileEntitySpecialRenderer render;
private TileEntity entity;

public RenderItemEnditeReactor(TileEntitySpecialRenderer render, TileEntity entity){
	blockModel = new ModelBlockEnditeReactor();
	blockTexture = new ResourceLocation(RunicScrolls.modid + ":" + "textures/model/BlockEnditeReactor.png");
	this.entity = entity;
	this.render = render;

}
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
	case ENTITY:
	case INVENTORY:
		return true;
	default:
		return false;
	}
		}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item,
		ItemRendererHelper helper) {
	switch (type) {
	case ENTITY: {
		return false;
	}
	case EQUIPPED: {
		return false;
	}
	case EQUIPPED_FIRST_PERSON: {
		return false;
	}
	case INVENTORY:// this case statement is required to get an inventory texture
	{
		return helper == ItemRendererHelper.INVENTORY_BLOCK;
	}
	default: {
		return false;
	}
	}
	}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	switch (type) {
	case EQUIPPED:
	case EQUIPPED_FIRST_PERSON:
		GL11.glPushMatrix();
		// rotates the item
		GL11.glRotatef(0, 0, 0, 1);
		GL11.glRotatef(0, 0, 1, 0);
		GL11.glRotatef(00, 1, 0, 0);
		GL11.glTranslatef(0.5f, 0.90f,0.3f);
		GL11.glScalef(-2F, -2F, -2F);
		Minecraft.getMinecraft().renderEngine
				.bindTexture(this.blockTexture);
		// renders the item
		blockModel.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();

	default:
		break;
	// Renders the Campfire on ground as a pickable item
	}
	switch (type) {
	case ENTITY:

		GL11.glPushMatrix();
		// rotates the item and translates the item
		GL11.glRotatef(0, 0, 0, 1);
		GL11.glRotatef(180, 0, 1, 0);
		GL11.glRotatef(180, 1, 0, 0);
		GL11.glTranslatef(0, -2.95f, 0f);
		GL11.glScalef(6F, 6F, 6F);
		Minecraft.getMinecraft().renderEngine
				.bindTexture(this.blockTexture);
		// renders the item
		blockModel.render((Entity) data[1], 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0225f);
		GL11.glPopMatrix();
	default:
		break;
	}
	switch (type) {
	case INVENTORY:

		GL11.glPushMatrix();
		// rotates the item and translates the item
		GL11.glRotatef(0, 0, 0, 1);
		GL11.glRotatef(45, 0, 1, 0);
		GL11.glRotatef(10, 1, 0, 0);
		GL11.glTranslatef(0f, -2.2f, 0f);
		GL11.glScalef(4.2F, 4.2F, 4.2F);
		Minecraft.getMinecraft().renderEngine
				.bindTexture(this.blockTexture);
		// renders the item
		blockModel.render(null, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0225f);
		GL11.glPopMatrix();
	default:
		break;
	}

}
 protected ResourceLocation getEntityTexture(Entity Campfire) {
	return this.blockTexture;
}
}

 

 

 

TileEntityEnditeReactor

 

 

 

package tileentity;

import java.awt.List;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import recipes.RecipesEnditeReactorEnergize;
import cpw.mods.fml.common.registry.GameRegistry;
import blocks.BlockEnditeReactor;
import main.RunicScrolls;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;

public class TileEntityEnditeReactor extends TileEntity implements ISidedInventory 
{
public int direction;

private ItemStack slots[];
private String localizedName;

private static final int[] slots_top = new int[]{0};
private static final int[] slots_bottom = new int[]{2};
private static final int[] slots_side = new int[]{1};

public int reactTime;
public static final int reactSpeed = 40;

public TileEntityEnditeReactor()
{
	slots = new ItemStack[3];
}

public void setGuiDisplayName(String displayName) 
{
	this.localizedName = displayName;
}

public String getInventoryName() 
{
	return this.hasCustomInventoryName() ? this.localizedName : "container.enditeReactor";
}

public boolean hasCustomInventoryName() 
{
	return this.localizedName != null && this.localizedName.length() > 0;
}

@Override
public int getSizeInventory() 
{
	return this.slots.length;
}

@Override
public ItemStack getStackInSlot(int var1) 
{
	return this.slots[var1];
}















@Override
public ItemStack decrStackSize(int var1, int var2) 
{
	if(this.slots[var1] != null)
	{
		ItemStack itemstack;

		if(this.slots[var1].stackSize <= var2 )
		{
			itemstack = this.slots[var1];
			this.slots[var1] = null;
			return itemstack;
		}
		else
		{
			itemstack = this.slots[var1].splitStack(var2);

			if(this.slots[var1].stackSize == 0) 
			{
				this.slots[var1] = null;
			}
			return itemstack;
		}
	}
	else
	{
		return null;
	}
}

@Override
public ItemStack getStackInSlotOnClosing(int i) 
{
	if (slots[i] != null) 
	{
		ItemStack itemstack = slots[i];
		slots[i] = null;
		return itemstack;
	}
	else
	{
		return null;
	}
}

@Override
public void setInventorySlotContents(int i, ItemStack itemstack) 
{
	slots[i] = itemstack;
	if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) 
	{
		itemstack.stackSize = getInventoryStackLimit();
	}
}

@Override
public int getInventoryStackLimit() 
{
	return 64;
}

public boolean isUseableByPlayer(EntityPlayer entityplayer) 
{
	return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double)this.xCoord + 0.5D, 
			(double)this.yCoord + 0.5D, (double)this.zCoord) + 0.5D <=64.0D ;
}

public void openInventory() {}
public void closeInventory() {}

@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) 
{
	return true;
}

@Override
public int[] getAccessibleSlotsFromSide(int var1) 
{
	return var1 == 0 ? slots_bottom : (var1 == 1 ? slots_top : slots_side);
}

@Override
public boolean canInsertItem(int i, ItemStack itemstack, int var3) 
{
	return this.isItemValidForSlot(i, itemstack);
}

@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j) 
{
	return true;
}

public void readFromNBT (NBTTagCompound nbt) 
{
	super.readFromNBT(nbt);
	NBTTagList list = nbt.getTagList("Items", 10);
	slots = new ItemStack[getSizeInventory()];
	for (int i = 0; i < list.tagCount(); i++) 
	{
		NBTTagCompound nbt1 = (NBTTagCompound)list.getCompoundTagAt(i);
		byte b0 = nbt1.getByte("Slot");
		if (b0 >= 0 && b0 < slots.length) 
		{
			slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
		}
	}
	reactTime = nbt.getShort("EnergizeTime");
}

public void writeToNBT(NBTTagCompound nbt) 
{
	super.writeToNBT(nbt);
	nbt.setShort("ReactTime", (short)reactTime);
	NBTTagList list = new NBTTagList();
	for (int i = 0; i < slots.length; i++) 
	{
		if (slots[i] != null) 
		{
			NBTTagCompound nbt1 = new NBTTagCompound();
			nbt1.setByte("Slot", (byte)i);
			slots[i].writeToNBT(nbt1);
			list.appendTag(nbt1);
		}
	}
	nbt.setTag("Items", list);
}

public int getReactProgressScaled(int i)
{
	return (reactTime * i) / this.reactSpeed;
}

private boolean canReact()
{
	if(slots[0] == null || slots[2] == null)
	{
		return false;
	}
	ItemStack itemstack = RecipesEnditeReactorEnergize.getProcessResult(slots[0].getItem(), slots[2].getItem());	
	if(itemstack == null)
	{
		return false;
	}
	if(slots[1] == null)
	{
		return true;
	}
	if(!slots[1].isItemEqual(itemstack))
	{
		return false;
	}
	if(slots[1].stackSize < getInventoryStackLimit() && slots[1].stackSize < slots[1].getMaxStackSize())
	{
		return true;
	}
	else
	{
		return slots[1].stackSize < itemstack.getMaxStackSize();
	}
}

private void reactItem()
{
	if (canReact()) 
	{
		ItemStack itemstack = RecipesEnditeReactorEnergize.getProcessResult(slots[0].getItem(), slots[2].getItem());
		if (slots[1] == null) 
		{
			slots[1] = itemstack.copy();
		}
		else if (slots[1].isItemEqual(itemstack)) 
		{
			slots[1].stackSize += itemstack.stackSize;
		}
		if (slots[0].stackSize <= 0) 
		{
			slots[0] = new ItemStack(slots[0].getItem().setFull3D());
		}else
		{
			slots[0].stackSize--;
		}
		if (slots[0].stackSize <= 0){
			slots[0] = null;
		}
		if (slots[2].stackSize <= 0) 
		{
			slots[2] = new ItemStack(slots[0].getItem().setFull3D());
		}else
		{
			slots[2].stackSize--;
		}
		if (slots[2].stackSize <= 0){
			slots[2] = null;
		}
	}
}

public boolean isReacting() 
{
	return this.reactTime > 0;
}

public void updateEntity()
{
	boolean flag1 = false;
	if(!worldObj.isRemote)
	{
		if(canReact())
		{
			reactTime++;
			if(this.reactTime == this.reactSpeed)
			{
				this.reactTime = 0;
				this.reactItem();
				flag1 = true;
			}
		}
		else
		{
			reactTime = 0;
		}
	}
	if (flag1) {
		this.markDirty();
	}
}
}

 

 

 

ClientProxy

 

 

 

package main;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;
import renderer.RenderEnditeReactor;
import renderer.RenderItemEnditeReactor;
import tileentity.TileEntityEnditeReactor;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxy extends ServerProxy 
{
public void registerRenderThings() 
{
	//EnditeReactor
	TileEntitySpecialRenderer render = new RenderEnditeReactor();
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEnditeReactor.class, render);
	MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RunicScrolls.blockEnditeReactor), new RenderItemEnditeReactor(render, new TileEntityEnditeReactor()));
}

public int addArmor(String armor) 
{
	return RenderingRegistry.addNewArmourRendererPrefix(armor);
}
}

 

 

 

ModelBlockEnditeReactor

 

 

package model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelBlockEnditeReactor extends ModelBase 
{
ModelRenderer Bottom;
ModelRenderer Stand;
ModelRenderer Main;
ModelRenderer Left;
ModelRenderer Right;
ModelRenderer Back;
ModelRenderer Interface;

public ModelBlockEnditeReactor() 
{
	textureWidth = 128;
	textureHeight = 64;

	Bottom = new ModelRenderer(this, 0, 0);
	Bottom.addBox(0F, 0F, 0F, 14, 1, 14);
	Bottom.setRotationPoint(-7F, 23F, -7F);
	Bottom.setTextureSize(128, 64);
	Bottom.mirror = true;
	setRotation(Bottom, 0F, 0F, 0F);
	Stand = new ModelRenderer(this, 0, 16);
	Stand.addBox(0F, 0F, 0F, 8, 2, ;
	Stand.setRotationPoint(-4F, 21F, -4F);
	Stand.setTextureSize(128, 64);
	Stand.mirror = true;
	setRotation(Stand, 0F, 0F, 0F);
	Main = new ModelRenderer(this, 0, 27);
	Main.addBox(0F, 0F, 0F, 10, 10, 10);
	Main.setRotationPoint(-5F, 11F, -5F);
	Main.setTextureSize(128, 64);
	Main.mirror = true;
	setRotation(Main, 0F, 0F, 0F);
	Left = new ModelRenderer(this, 0, 48);
	Left.addBox(0F, 0F, 0F, 3, 4, 4);
	Left.setRotationPoint(-8F, 14F, -2F);
	Left.setTextureSize(128, 64);
	Left.mirror = true;
	setRotation(Left, 0F, 0F, 0F);
	Right = new ModelRenderer(this, 15, 48);
	Right.addBox(0F, 0F, 0F, 3, 4, 4);
	Right.setRotationPoint(5F, 14F, -2F);
	Right.setTextureSize(128, 64);
	Right.mirror = true;
	setRotation(Right, 0F, 0F, 0F);
	Back = new ModelRenderer(this, 30, 48);
	Back.addBox(0F, 0F, 0F, 4, 4, 3);
	Back.setRotationPoint(-2F, 14F, 5F);
	Back.setTextureSize(128, 64);
	Back.mirror = true;
	setRotation(Back, 0F, 0F, 0F);
	Interface = new ModelRenderer(this, 33, 16);
	Interface.addBox(0F, 0F, 0F, 8, 8, 1);
	Interface.setRotationPoint(-4F, 12F, -6F);
	Interface.setTextureSize(128, 64);
	Interface.mirror = true;
	setRotation(Interface, 0F, 0F, 0F);
}

public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) 
{
	super.render(entity, f, f1, f2, f3, f4, f5);
	setRotationAngles(f, f1, f2, f3, f4, f5, entity);
	Bottom.render(f5);
	Stand.render(f5);
	Main.render(f5);
	Left.render(f5);
	Right.render(f5);
	Back.render(f5);
	Interface.render(f5);
}

private void setRotation(ModelRenderer model, float x, float y, float z) 
{
	model.rotateAngleX = x;
	model.rotateAngleY = y;
	model.rotateAngleZ = z;
}


public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) 
{
	super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}

public void renderModel(float f) 
{
	Bottom.render(f);
	Stand.render(f);
	Main.render(f);
	Left.render(f);
	Right.render(f);
	Back.render(f);
	Interface.render(f);
}
}

 

 

 

If any other classes are necessary, I can paste them here.

Thanks

 

 

Link to comment
Share on other sites

Thanks for the response.

 

I looked and the shouldUseRenderHelper method isnt being called at all. In my main class, RunicScrolls.java, I have blockEnditeReactor registered like so:

 blockEnditeReactor = new BlockEnditeReactor(false).setBlockName("blockEnditeReactor").setCreativeTab(scrollTab).setHardness(5.0F).setResistance(6000000.0F); 

 

This is how I have registered my other blocks, excluding the false. This is only because the block has an active state and an unactive state. This is a Boolean in the constructor, so false is necessary. How would I register the IItemRenderer? I dont think im not sure if I have done this and that could be the issue.

Link to comment
Share on other sites

Hi

 

I think the Block is being registered ok, but your IItemRenderer is not, perhaps.

 

you are registering it here in ClientProxy

		MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(RunicScrolls.blockEnditeReactor), new RenderItemEnditeReactor(render, new TileEntityEnditeReactor()));

Off the top of my head that looks right so I suspect that either

1) this proxy method is never called, or

2) this proxy method is called before your blockEnditeReactor = new BlockEnditeReactor is being called.

 

-TGG

Link to comment
Share on other sites

The client proxy is definately being called at some point otherwise the block wouldn't have a model. I just removed the line

 ClientRegistry.bindTileEntitySpecialRenderer(TileEntityEnditeReactor.class, render); 

from the registerRenderThings() method and the block didn't render.

 

I then added some print lines to the registerRenderThings() method in the client proxy and the preInit method in my main. As shown by the console, the proxy is being called first.

[13:34:05] [Client thread/INFO] [FML]: Processing ObjectHolder annotations
[13:34:05] [Client thread/INFO] [FML]: Found 341 ObjectHolder annotations
[13:34:05] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0
ClientProxy
preInit
[13:34:05] [Client thread/INFO] [FML]: Applying holder lookups
[13:34:05] [Client thread/INFO] [FML]: Holder lookups applied

 

I moved the initialization to the init method in my main.

 

IT WORKED!!!

 

Thank you so much! I can finally release version 2.2 of my mod. Thanks! :) :) :) :) :) :) :)

 

nRj2lj1.png

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