Jump to content

Recommended Posts

Posted

I am making a mod and am finding I can't get my custom block model to render correctly.  I have all the correct classes, but instead of showing my custom model (made in techne) it just shows the texture I have for it as each side of a block.

BlockCannon:

package ninjapancakes87.civilwar.common.block.cannon;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.DataWatcher;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import ninjapancakes87.civilwar.common.CivilWar;
import ninjapancakes87.civilwar.common.Registry;
import ninjapancakes87.civilwar.common.item.EntityCannonBall;

public class BlockCannon extends BlockContainer {
public BlockCannon(int id) {
	super(id, Material.iron);
	this.setCreativeTab(CivilWar.tabCivilWar);
}
public TileEntityCannon te;
public ChunkCoordinates coord;
public DataWatcher dataWatcher;
public World worldObj;
public boolean isLoaded = false;

protected static int x;
protected static int y;
protected static int z;
@Override
public void onBlockAdded(World par1World, int par2, int par3, int par4)
    {
        if (!par1World.isRemote)
        {
            par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
        }
    }
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    {
	int item = par5EntityPlayer.getCurrentEquippedItem().itemID;
        if(item == Registry.cannonball.itemID){
        	if(par1World.isRemote){
        		setLoaded(par5EntityPlayer);
        		par5EntityPlayer.inventory.consumeInventoryItem(Registry.cannonball.itemID);
        		return true;
        	}
        }
        else if(getIsLoaded().equals("true") && item == Item.gunpowder.itemID){
        	fire(getCoord(1), getCoord(2), getCoord(3));
        	setUnLoaded();
        	return true;
        }
        else{
        	return false;
        }
        return false;
    }

public TileEntity createNewTileEntity(World var1)
{
  return new TileEntityCannon();
}

@Override
    public int getRenderType()
    {
        return Registry.renderId;
    }
@Override
public boolean renderAsNormalBlock() {
	return false;
}

@Override
public boolean isOpaqueCube() {
	return false;
}
public void setLoaded(EntityPlayer player){
	this.isLoaded = true;;
	player.addChatMessage(getIsLoaded());
}
public void setUnLoaded(){
	this.isLoaded = false;
}
public String getIsLoaded(){
	//return this.isLoaded;
	if(this.isLoaded = true){
		return "true";
	}
	if(this.isLoaded = false){
		return "false";
	}
	return "";
}
public double getCoord(int par1){
	switch(par1){
	case 1: return coord.posX;
	case 2: return coord.posY;
	case 3: return coord.posZ;
	default: return 1;
	}

}
public void fire(double x, double y, double z){
	EntityCannonBall entity = new EntityCannonBall(worldObj);
        entity.setLocationAndAngles(x,y,z, 0.0F, 0.0F);
	worldObj.spawnEntityInWorld(entity);
        worldObj.spawnParticle("smoke", getCoord(1), getCoord(2), getCoord(3), 1,1,1);
        setUnLoaded();
}

}

TileEntityCannon:

package ninjapancakes87.civilwar.common.block.cannon;

import net.minecraft.entity.DataWatcher;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraftforge.common.ForgeDirection;
import ninjapancakes87.civilwar.common.item.EntityCannonBall;

public class TileEntityCannon extends TileEntity{
public ForgeDirection rotation = null;
protected DataWatcher dataWatcher;
public NBTTagCompound nbt = new NBTTagCompound();
public BlockCannon cannon;

@Override
public void writeToNBT(NBTTagCompound tag) {
	super.writeToNBT(tag);
	//tag.setBoolean("loaded", isLoaded);
	tag.setByte("Direction", (byte)rotation.ordinal());
}

@Override
public void readFromNBT(NBTTagCompound tag) {
	super.readFromNBT(tag);
	rotation = ForgeDirection.VALID_DIRECTIONS[tag.getByte("direction")];
	 //isLoaded = tag.getBoolean("loaded");
}
public void getDescriptionForClient(NBTTagCompound nbt) {	
	nbt.setByte("direction", (byte) rotation.ordinal());
}

public void onUpdatePacket(NBTTagCompound nbt) {
	if(nbt.hasKey("direction"))
		rotation = ForgeDirection.VALID_DIRECTIONS[nbt.getByte("direction")];
}

public void onDescriptionPacket(NBTTagCompound nbt) {
	rotation = ForgeDirection.VALID_DIRECTIONS[nbt.getByte("direction")];
}
@Override
public void updateEntity() {
}
static{
	addMapping(TileEntityCannon.class, "Cannon");
}
}

TileEntityCannonRenderer:

package ninjapancakes87.civilwar.common.block.cannon;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import ninjapancakes87.civilwar.common.Registry;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import java.util.Random;
public class TileEntityCannonRenderer extends TileEntitySpecialRenderer
{
private ModelCannon model;

public TileEntityCannonRenderer()
{
	model = new ModelCannon();
}

public void renderAModelAt(TileEntityCannon tile, double d, double d1, double d2, float f)
{

	bindTextureByName("/mods/Civil War/textures/blocks/cannon.png");

/*GL11.glPushMatrix();
GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.5F, (float)d2 + 0.5F); //size
GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);// change the first 0 in like 90 to make it rotate 90 degrees.
GL11.glScalef(1.0F, -1F, -1F); // to make your Block have a normal positioning. comment out to see what happens
GL11.glPopMatrix();*/
}
public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
{
	renderAModelAt((TileEntityCannon) tileentity, d, d1, d2, f);
}
}

RenderCannon:

package ninjapancakes87.civilwar.common.block.cannon;

import org.lwjgl.opengl.GL11;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import ninjapancakes87.civilwar.common.Registry;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

public class RenderCannon implements ISimpleBlockRenderingHandler{

@Override
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
TileEntityRenderer.instance.renderTileEntityAt(new TileEntityCannon(), 0.0D, 0.0D, 0.0D, 0.0F);
}

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	TileEntity tempTile = world.getBlockTileEntity(x, y, z);
	if(tempTile!=null)
	{
		renderTileEntityAt(tempTile,(double)x,(double)y,(double)z,1.0F);
		return true;
	}
	return false;
}

@Override
public boolean shouldRender3DInInventory() {
	return true;
}

public int getRenderId() {
	return 0;
}
public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
{
	renderAModelAt((TileEntityCannon)tileentity, d, d1, d2, f);
}
public void renderAModelAt(TileEntityCannon tileentity1, double d, double d1, double d2, float f)
{
	GL11.glPushMatrix();   
	{
	Minecraft.getMinecraft().renderEngine.bindTexture("/mods/Civil War/textures/blocks/cannon.png");
	GL11.glTranslatef((float) d + 1.F, (float) d1 + 1.5F, (float) d2 + 1.5F);
	GL11.glPushMatrix();
	GL11.glPopMatrix();
	}
	GL11.glPopMatrix();
}

}

ModelCannon:

package ninjapancakes87.civilwar.common.block.cannon;

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

public class ModelCannon extends ModelBase
{
    ModelRenderer Bwheel2;
    ModelRenderer Shape1;
    ModelRenderer Shape2;
    ModelRenderer Shape3;
    ModelRenderer Shape31;
    ModelRenderer Shape4;
    ModelRenderer Shape5;
    ModelRenderer Shape6;
    ModelRenderer Shape7;
    ModelRenderer Shape8;
    ModelRenderer Shape9;
    ModelRenderer Shape10;
    ModelRenderer Shape11;
    ModelRenderer Bwheel1;
    ModelRenderer Shape12;
    ModelRenderer Shape13;
    ModelRenderer Shape14;
    ModelRenderer Shape15;
    ModelRenderer Shape16;
    ModelRenderer Shape17;
    ModelRenderer Shape18;
    ModelRenderer Shape19;
    ModelRenderer Shape20;
    ModelRenderer Shape21;
    ModelRenderer Shape22;
    ModelRenderer Shape23;
    ModelRenderer Shape24;
    ModelRenderer Shape25;
    ModelRenderer Shape26;
    ModelRenderer Shape27;
    ModelRenderer Shape28;
    ModelRenderer Shape29;
    ModelRenderer Shape30;
    ModelRenderer Shape301;
    ModelRenderer Shape291;
    ModelRenderer Shape292;
    ModelRenderer Shape271;
    ModelRenderer Shape311;
    ModelRenderer Shape32;
    ModelRenderer Shape322;
    ModelRenderer Shape33;
    ModelRenderer Shape331;
    ModelRenderer Shape34;
  
  public ModelCannon()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      Bwheel2 = new ModelRenderer(this, 4, 0);
      Bwheel2.addBox(0F, 0F, 0F, 4, 1, 1);
      Bwheel2.setRotationPoint(-1F, 23F, -6F);
      Bwheel2.setTextureSize(64, 64);
      Bwheel2.mirror = true;
      setRotation(Bwheel2, 0F, 0F, 0F);
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape1.setRotationPoint(3F, 22F, -6F);
      Shape1.setTextureSize(64, 64);
      Shape1.mirror = true;
      setRotation(Shape1, 0F, 0F, 0F);
      Shape2 = new ModelRenderer(this, 0, 0);
      Shape2.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape2.setRotationPoint(-2F, 22F, -6F);
      Shape2.setTextureSize(64, 64);
      Shape2.mirror = true;
      setRotation(Shape2, 0F, 0F, 0F);
      Shape3 = new ModelRenderer(this, 8, 2);
      Shape3.addBox(0F, 0F, 0F, 1, 4, 1);
      Shape3.setRotationPoint(-3F, 18F, -6F);
      Shape3.setTextureSize(64, 64);
      Shape3.mirror = true;
      setRotation(Shape3, 0F, 0F, 0F);
      Shape31 = new ModelRenderer(this, 8, 2);
      Shape31.addBox(0F, 0F, 0F, 1, 4, 1);
      Shape31.setRotationPoint(4F, 18F, -6F);
      Shape31.setTextureSize(64, 64);
      Shape31.mirror = true;
      setRotation(Shape3, 0F, 0F, 0F);
      Shape4 = new ModelRenderer(this, 0, 0);
      Shape4.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape4.setRotationPoint(-2F, 17F, -6F);
      Shape4.setTextureSize(64, 64);
      Shape4.mirror = true;
      setRotation(Shape4, 0F, 0F, 0F);
      Shape5 = new ModelRenderer(this, 0, 0);
      Shape5.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape5.setRotationPoint(3F, 17F, -6F);
      Shape5.setTextureSize(64, 64);
      Shape5.mirror = true;
      setRotation(Shape5, 0F, 0F, 0F);
      Shape6 = new ModelRenderer(this, 4, 12);
      Shape6.addBox(0F, 0F, 0F, 4, 1, 1);
      Shape6.setRotationPoint(-1F, 16F, -6F);
      Shape6.setTextureSize(64, 64);
      Shape6.mirror = true;
      setRotation(Shape6, 0F, 0F, 0F);
      Shape7 = new ModelRenderer(this, 0, 2);
      Shape7.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape7.setRotationPoint(2F, 18F, -6F);
      Shape7.setTextureSize(64, 64);
      Shape7.mirror = true;
      setRotation(Shape7, 0F, 0F, 0F);
      Shape8 = new ModelRenderer(this, 0, 2);
      Shape8.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape8.setRotationPoint(-1F, 18F, -6F);
      Shape8.setTextureSize(64, 64);
      Shape8.mirror = true;
      setRotation(Shape8, 0F, 0F, 0F);
      Shape9 = new ModelRenderer(this, 0, 17);
      Shape9.addBox(0F, 0F, 0F, 2, 2, 1);
      Shape9.setRotationPoint(0F, 19F, -6F);
      Shape9.setTextureSize(64, 64);
      Shape9.mirror = true;
      setRotation(Shape9, 0F, 0F, 0F);
      Shape10 = new ModelRenderer(this, 0, 2);
      Shape10.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape10.setRotationPoint(2F, 21F, -6F);
      Shape10.setTextureSize(64, 64);
      Shape10.mirror = true;
      setRotation(Shape10, 0F, 0F, 0F);
      Shape11 = new ModelRenderer(this, 0, 2);
      Shape11.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape11.setRotationPoint(-1F, 21F, -6F);
      Shape11.setTextureSize(64, 64);
      Shape11.mirror = true;
      setRotation(Shape11, 0F, 0F, 0F);
      Bwheel1 = new ModelRenderer(this, 4, 0);
      Bwheel1.addBox(0F, 0F, 0F, 4, 1, 1);
      Bwheel1.setRotationPoint(-1F, 23F, 5F);
      Bwheel1.setTextureSize(64, 64);
      Bwheel1.mirror = true;
      setRotation(Bwheel1, 0F, 0F, 0F);
      Shape12 = new ModelRenderer(this, 0, 0);
      Shape12.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape12.setRotationPoint(3F, 22F, 5F);
      Shape12.setTextureSize(64, 64);
      Shape12.mirror = true;
      setRotation(Shape12, 0F, 0F, 0F);
      Shape13 = new ModelRenderer(this, 0, 0);
      Shape13.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape13.setRotationPoint(-2F, 22F, 5F);
      Shape13.setTextureSize(64, 64);
      Shape13.mirror = true;
      setRotation(Shape13, 0F, 0F, 0F);
      Shape14 = new ModelRenderer(this, 8, 2);
      Shape14.addBox(0F, 0F, 0F, 1, 4, 1);
      Shape14.setRotationPoint(4F, 18F, 5F);
      Shape14.setTextureSize(64, 64);
      Shape14.mirror = true;
      setRotation(Shape14, 0F, 0F, 0F);
      Shape15 = new ModelRenderer(this, 8, 2);
      Shape15.addBox(0F, 0F, 0F, 1, 4, 1);
      Shape15.setRotationPoint(-3F, 18F, 5F);
      Shape15.setTextureSize(64, 64);
      Shape15.mirror = true;
      setRotation(Shape15, 0F, 0F, 0F);
      Shape16 = new ModelRenderer(this, 0, 0);
      Shape16.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape16.setRotationPoint(3F, 17F, 5F);
      Shape16.setTextureSize(64, 64);
      Shape16.mirror = true;
      setRotation(Shape16, 0F, 0F, 0F);
      Shape17 = new ModelRenderer(this, 0, 0);
      Shape17.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape17.setRotationPoint(-2F, 17F, 5F);
      Shape17.setTextureSize(64, 64);
      Shape17.mirror = true;
      setRotation(Shape17, 0F, 0F, 0F);
      Shape18 = new ModelRenderer(this, 4, 12);
      Shape18.addBox(0F, 0F, 0F, 4, 1, 1);
      Shape18.setRotationPoint(-1F, 16F, 5F);
      Shape18.setTextureSize(64, 64);
      Shape18.mirror = true;
      setRotation(Shape18, 0F, 0F, 0F);
      Shape19 = new ModelRenderer(this, 0, 2);
      Shape19.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape19.setRotationPoint(-1F, 18F, 5F);
      Shape19.setTextureSize(64, 64);
      Shape19.mirror = true;
      setRotation(Shape19, 0F, 0F, 0F);
      Shape20 = new ModelRenderer(this, 0, 2);
      Shape20.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape20.setRotationPoint(2F, 18F, 5F);
      Shape20.setTextureSize(64, 64);
      Shape20.mirror = true;
      setRotation(Shape20, 0F, 0F, 0F);
      Shape21 = new ModelRenderer(this, 0, 2);
      Shape21.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape21.setRotationPoint(2F, 21F, 5F);
      Shape21.setTextureSize(64, 64);
      Shape21.mirror = true;
      setRotation(Shape21, 0F, 0F, 0F);
      Shape22 = new ModelRenderer(this, 0, 2);
      Shape22.addBox(0F, 0F, 0F, 1, 1, 1);
      Shape22.setRotationPoint(-1F, 21F, 5F);
      Shape22.setTextureSize(64, 64);
      Shape22.mirror = true;
      setRotation(Shape22, 0F, 0F, 0F);
      Shape23 = new ModelRenderer(this, 0, 17);
      Shape23.addBox(0F, 0F, 0F, 2, 2, 1);
      Shape23.setRotationPoint(0F, 19F, 5F);
      Shape23.setTextureSize(64, 64);
      Shape23.mirror = true;
      setRotation(Shape23, 0F, 0F, 0F);
      Shape24 = new ModelRenderer(this, 0, 20);
      Shape24.addBox(0F, 0F, 0F, 1, 1, 10);
      Shape24.setRotationPoint(0F, 19F, -5F);
      Shape24.setTextureSize(64, 64);
      Shape24.mirror = true;
      setRotation(Shape24, 0F, 0F, 0F);
      Shape25 = new ModelRenderer(this, 0, 20);
      Shape25.addBox(0F, 0F, 0F, 1, 1, 10);
      Shape25.setRotationPoint(1F, 20F, -5F);
      Shape25.setTextureSize(64, 64);
      Shape25.mirror = true;
      setRotation(Shape25, 0F, 0F, 0F);
      Shape26 = new ModelRenderer(this, 0, 31);
      Shape26.addBox(0F, 0F, 0F, 5, 1, 2);
      Shape26.setRotationPoint(2F, 20F, -1F);
      Shape26.setTextureSize(64, 64);
      Shape26.mirror = true;
      setRotation(Shape26, 0F, 0F, 0.7330383F);
      Shape27 = new ModelRenderer(this, 36, 0);
      Shape27.addBox(0F, 0F, 0F, 13, 1, 2);
      Shape27.setRotationPoint(-10F, 18F, -1F);
      Shape27.setTextureSize(64, 64);
      Shape27.mirror = true;
      setRotation(Shape27, 0F, 0F, 0F);
      Shape28 = new ModelRenderer(this, 38, 4);
      Shape28.addBox(0F, 0F, 0F, 13, 1, 1);
      Shape28.setRotationPoint(-10F, 17F, -2F);
      Shape28.setTextureSize(64, 64);
      Shape28.mirror = true;
      setRotation(Shape28, 0F, 0F, 0F);
      Shape29 = new ModelRenderer(this, 38, 4);
      Shape29.addBox(0F, 0F, 0F, 13, 1, 1);
      Shape29.setRotationPoint(-10F, 17F, 1F);
      Shape29.setTextureSize(64, 64);
      Shape29.mirror = true;
      setRotation(Shape29, 0F, 0F, 0F);
      Shape30 = new ModelRenderer(this, 38, 7);
      Shape30.addBox(0F, 0F, 0F, 13, 2, 1);
      Shape30.setRotationPoint(-10F, 15F, 2F);
      Shape30.setTextureSize(64, 64);
      Shape30.mirror = true;
      setRotation(Shape30, 0F, 0F, 0F);
      Shape301 = new ModelRenderer(this, 38, 7);
      Shape301.addBox(0F, 0F, 0F, 13, 2, 1);
      Shape301.setRotationPoint(-10F, 15F, -3F);
      Shape301.setTextureSize(64, 64);
      Shape301.mirror = true;
      setRotation(Shape30, 0F, 0F, 0F);
      Shape291 = new ModelRenderer(this, 38, 4);
      Shape291.addBox(0F, 0F, 0F, 13, 1, 1);
      Shape291.setRotationPoint(-10F, 14F, 1F);
      Shape291.setTextureSize(64, 64);
      Shape291.mirror = true;
      setRotation(Shape29, 0F, 0F, 0F);
      Shape292 = new ModelRenderer(this, 38, 4);
      Shape292.addBox(0F, 0F, 0F, 13, 1, 1);
      Shape292.setRotationPoint(-10F, 14F, -2F);
      Shape292.setTextureSize(64, 64);
      Shape292.mirror = true;
      setRotation(Shape29, 0F, 0F, 0F);
      Shape271 = new ModelRenderer(this, 36, 0);
      Shape271.addBox(0F, 0F, 0F, 13, 1, 2);
      Shape271.setRotationPoint(-10F, 13F, -1F);
      Shape271.setTextureSize(64, 64);
      Shape271.mirror = true;
      setRotation(Shape27, 0F, 0F, 0F);
      Shape311 = new ModelRenderer(this, 58, 12);
      Shape311.addBox(0F, 0F, 0F, 1, 2, 2);
      Shape311.setRotationPoint(2F, 15F, -1F);
      Shape311.setTextureSize(64, 64);
      Shape311.mirror = true;
      setRotation(Shape31, 0F, 0F, 0F);
      Shape32 = new ModelRenderer(this, 58, 17);
      Shape32.addBox(0F, 0F, 0F, 1, 1, 2);
      Shape32.setRotationPoint(2F, 14F, -1F);
      Shape32.setTextureSize(64, 64);
      Shape32.mirror = true;
      setRotation(Shape32, 0F, 0F, 0F);
      Shape322 = new ModelRenderer(this, 58, 17);
      Shape322.addBox(0F, 0F, 0F, 1, 1, 2);
      Shape322.setRotationPoint(2F, 17F, -1F);
      Shape322.setTextureSize(64, 64);
      Shape322.mirror = true;
      setRotation(Shape32, 0F, 0F, 0F);
      Shape33 = new ModelRenderer(this, 60, 21);
      Shape33.addBox(0F, 0F, 0F, 1, 2, 1);
      Shape33.setRotationPoint(2F, 15F, -2F);
      Shape33.setTextureSize(64, 64);
      Shape33.mirror = true;
      setRotation(Shape33, 0F, 0F, 0F);
      Shape331 = new ModelRenderer(this, 60, 21);
      Shape331.addBox(0F, 0F, 0F, 1, 2, 1);
      Shape331.setRotationPoint(2F, 15F, 1F);
      Shape331.setTextureSize(64, 64);
      Shape331.mirror = true;
      setRotation(Shape33, 0F, 0F, 0F);
      Shape34 = new ModelRenderer(this, 56, 25);
      Shape34.addBox(0F, 0F, 0F, 3, 1, 1);
      Shape34.setRotationPoint(2F, 15F, 0F);
      Shape34.setTextureSize(64, 64);
      Shape34.mirror = true;
      setRotation(Shape34, 0F, 0F, -0.5061455F);
  }
  
  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);
    Bwheel2.render(f5);
    Shape1.render(f5);
    Shape2.render(f5);
    Shape3.render(f5);
    Shape3.render(f5);
    Shape4.render(f5);
    Shape5.render(f5);
    Shape6.render(f5);
    Shape7.render(f5);
    Shape8.render(f5);
    Shape9.render(f5);
    Shape10.render(f5);
    Shape11.render(f5);
    Bwheel1.render(f5);
    Shape12.render(f5);
    Shape13.render(f5);
    Shape14.render(f5);
    Shape15.render(f5);
    Shape16.render(f5);
    Shape17.render(f5);
    Shape18.render(f5);
    Shape19.render(f5);
    Shape20.render(f5);
    Shape21.render(f5);
    Shape22.render(f5);
    Shape23.render(f5);
    Shape24.render(f5);
    Shape25.render(f5);
    Shape26.render(f5);
    Shape27.render(f5);
    Shape28.render(f5);
    Shape29.render(f5);
    Shape30.render(f5);
    Shape30.render(f5);
    Shape29.render(f5);
    Shape29.render(f5);
    Shape27.render(f5);
    Shape31.render(f5);
    Shape32.render(f5);
    Shape32.render(f5);
    Shape33.render(f5);
    Shape33.render(f5);
    Shape34.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);
  }

}

here is the code I used to register the renderer in my main mod class:

GameRegistry.registerTileEntity(TileEntityCannon.class, "ninjapancakes87.civilwar.common.block.cannon");

RenderingRegistry.instance().registerBlockHandler(new RenderCannon());

Posted

I don't use a tile entity renderer

Here is an example of a model block

BlockExample

package YourPackageHere;

import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockExample extends BlockContainer {


public BlockExample(int id, Material par2Material)
{
	super(id, par2Material);
	this.setCreativeTab(CreativeTabs.tabBlock);
	this.setHardness(3.0F);
	this.setResistance(3.0F);
	this.setLightValue(30F);
	this.setBlockUnbreakable();
}

public boolean isOpaqueCube()
{

	return false;
}


public boolean renderAsNormalBlock()
    {
            return false;
    }



    public int getRenderType()
    {
            return -1;
    }


@Override
public TileEntity createNewTileEntity(World world) {
	return new TileEntityExample();
}



}


ModelExample

package YourPackageHere;

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

public class ModelExample extends ModelBase
{
  //fields
    ModelRenderer Leg1;
    ModelRenderer Leg2;
    ModelRenderer Leg3;
    ModelRenderer Leg4;
    ModelRenderer Shape1;
  
  public ModelExample()
  {
    textureWidth = 128;
    textureHeight = 32;
    
      Leg1 = new ModelRenderer(this, 0, 0);
      Leg1.addBox(0F, 0F, 0F, 1, 20, 1);
      Leg1.setRotationPoint(-8F, 4F, -8F);
      Leg1.setTextureSize(128, 32);
      Leg1.mirror = true;
      setRotation(Leg1, 0F, 0F, 0F);
      Leg2 = new ModelRenderer(this, 0, 0);
      Leg2.addBox(0F, 0F, 0F, 1, 20, 1);
      Leg2.setRotationPoint(-8F, 4F, 7F);
      Leg2.setTextureSize(128, 32);
      Leg2.mirror = true;
      setRotation(Leg2, 0F, 0F, 0F);
      Leg3 = new ModelRenderer(this, 0, 0);
      Leg3.addBox(0F, 0F, 0F, 1, 20, 1);
      Leg3.setRotationPoint(7F, 4F, -8F);
      Leg3.setTextureSize(128, 32);
      Leg3.mirror = true;
      setRotation(Leg3, 0F, 0F, 0F);
      Leg4 = new ModelRenderer(this, 0, 0);
      Leg4.addBox(0F, 0F, 0F, 1, 20, 1);
      Leg4.setRotationPoint(7F, 4F, 7F);
      Leg4.setTextureSize(128, 32);
      Leg4.mirror = true;
      setRotation(Leg4, 0F, 0F, 0F);
      Shape1 = new ModelRenderer(this, 0, 0);
      Shape1.addBox(0F, 0F, 0F, 16, 1, 16);
      Shape1.setRotationPoint(-8F, 3F, -8F);
      Shape1.setTextureSize(128, 32);
      Shape1.mirror = true;
      setRotation(Shape1, 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);
    Leg1.render(f5);
    Leg2.render(f5);
    Leg3.render(f5);
    Leg4.render(f5);
    Shape1.render(f5);
  }
  public void renderAll(float f5){
  Leg1.render(f5);
    Leg2.render(f5);
    Leg3.render(f5);
    Leg4.render(f5);
    Shape1.render(f5);

  }
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
  {
    
  }
  

}

RenderExample

package YourPackageHere;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

import org.lwjgl.opengl.GL11;
public class RenderExample extends TileEntitySpecialRenderer
{
        public RenderExample()
        {
                aModel = new ModelExample();
        }

        public void renderAModelAt(TileEntityExample tileentity1, double d, double d1, double d2, float f)
        {  
                GL11.glPushMatrix();
                GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.52F, (float)d2 + 0.5F);
                GL11.glRotatef(180F, 0F, 0F, 1F);
                bindTextureByName("/mods/lantern.png");
                GL11.glPushMatrix();
                aModel.renderAll(0.0625F);
                GL11.glPopMatrix();     
                GL11.glPopMatrix();                                     
        }
        public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2,
                        float f)
        {
                renderAModelAt((TileEntityExample)tileentity, d, d1, d2, f);
        }
        private ModelExample aModel;
}



TileEntityExample

package YourPackageHere;
import net.minecraft.tileentity.TileEntity;
public class TileEntityExample extends TileEntity
{

}

In your main

ClientRegistry.bindTileEntitySpecialRenderer(TileEntityExample.class, new RenderExample());

Posted

I don't use a tile entity renderer

 

---

 

RenderExample

package YourPackageHere;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

import org.lwjgl.opengl.GL11;
public class RenderExample extends TileEntitySpecialRenderer
{
        public RenderExample()
        {
                aModel = new ModelExample();
        }

        public void renderAModelAt(TileEntityExample tileentity1, double d, double d1, double d2, float f)
        {  
                GL11.glPushMatrix();
                GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.52F, (float)d2 + 0.5F);
                GL11.glRotatef(180F, 0F, 0F, 1F);
                bindTextureByName("/mods/lantern.png");
                GL11.glPushMatrix();
                aModel.renderAll(0.0625F);
                GL11.glPopMatrix();     
                GL11.glPopMatrix();                                     
        }
        public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2,
                        float f)
        {
                renderAModelAt((TileEntityExample)tileentity, d, d1, d2, f);
        }
        private ModelExample aModel;
}



 

You do have a renderer...

Looks like you took it from my (wrong) tutorial. I'll be updating it later tonight but this render code works better (both of you can use it :P)

 

package co.uk.silvania.roads.tileentities.renderers;

import org.lwjgl.opengl.GL11;


import co.uk.silvania.roads.Roads;
import co.uk.silvania.roads.client.models.TrafficLightModel;

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;


public class TileEntityTrafficLightRenderer extends TileEntitySpecialRenderer {

private final TrafficLightModel model;
private final boolean powered;

public TileEntityTrafficLightRenderer(boolean power) {
	this.model = new TrafficLightModel();
	this.powered = power;
}

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
	int i = te.getBlockMetadata();
	int meta = 180;

	if (i == 3) {
		meta = 0;
	}

	if (i == 5) {
		meta = 90;
	}

	if (i == 2) {
		meta = 180;
	}

	if (i == 4) {
		meta = 270;
	}

	bindTextureByName("/mods/Roads/textures/blocks/TrafficLightPoleGreen.png");
	GL11.glPushMatrix();
	GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
	GL11.glRotatef(meta, 0.0F, 1.0F, 0.0F);
	//GL11.glRotatef(((TileEntityBarrierEntity)tile).getRotationPivot()), 0.0F, 1.0F, 0.0F);
	GL11.glScalef(1.0F, -1F, -1F);
	this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
	GL11.glPopMatrix();
}

private void adjustLightFixture(World world, int i, int j, int k, Block block) {
	Tessellator tess = Tessellator.instance;
	float brightness = block.getBlockBrightness(world, i, j, k);
	int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
	int modulousModifier = skyLight % 65536;
	int divModifier = skyLight / 65536;
	tess.setColorOpaque_F(brightness, brightness, brightness);
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,  (float) modulousModifier,  divModifier);
}
}

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

I would just like to remind people to use tile entity special renderer only if you are usign a tile entity if you are simply making a weird shaped block please use only ISimpleBlockRenderingHandler as you will not force player to create a billion tile entity if the block is common. But in the case of a cannon you will probably want to see a animation of some sort when the cannon is firing (unless its only a decoration)

 

remember that tile entities take memory for every instance of the tile entity while blocks and models are only created once.

 

if there is no animation/factor that is different from one block to the other. use ISimpleBlockRenderer and NO tile entity/tile entitySpecialRenderer

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

Thanks guys I tried both of your methods (pun intended :P) but neither of them changed anything.  I have in my main mod file now

ClientRegistry.registerTileEntity(TileEntityCannon.class, "ninjapancakes87.civilwar.common.block.cannon", new TileEntityCannonRenderer());

And all I have is the TileEntityCannonRenderer file.

package ninjapancakes87.civilwar.common.block.cannon;

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Calendar;
import net.minecraft.block.Block;
import net.minecraft.block.BlockChest;
import net.minecraft.client.model.ModelChest;
import net.minecraft.client.model.ModelLargeChest;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.world.IBlockAccess;
import ninjapancakes87.civilwar.common.CivilWar;

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

@SideOnly(Side.CLIENT)
public class TileEntityCannonRenderer extends TileEntitySpecialRenderer {
    /** The normal small chest model. */
    private ModelCannon model;
    
    private TileEntityCannon cannonTE = new TileEntityCannon();

    public TileEntityCannonRenderer()
    {
    	this.model = new ModelCannon();
    }
public void renderAModelAt(TileEntityCannon tileentity1, double d, double d1, double d2, float f)
    {  
            GL11.glPushMatrix();
            GL11.glTranslatef((float)d + 0.5F, (float)d1 + 1.52F, (float)d2 + 0.5F);
            GL11.glRotatef(180F, 0F, 0F, 1F);
            bindTextureByName("/mods/Civil War/textures/blocks/cannon.png");
            GL11.glPushMatrix();
            this.model.render((Entity)null, 0.0F, 0.0F, 0.0F,0.0F,0.0F,0.0F);
            GL11.glPopMatrix();     
            GL11.glPopMatrix();                                     
    }
@Override
    public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
    {
            renderAModelAt((TileEntityCannon)tileentity, d, d1, d2, f);
    }

}

I got rid of my two render files and just have this

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

×
×
  • Create New...

Important Information

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