Jump to content

Recommended Posts

Posted

Hello, I know I can search on YT or Google, but I didnt found any (about TileEntities and their usage).

Can anyone tell me some basic informations about: What TE doing, what things you can do with them, etc...

Or if you know a hyperlink to a good tutorial, you can write the link there  ;)

 

Reason: I am currently doing on a Energy Site in my mod. I need TE to do some hard stuff.

Like:

If there is a block on the any of the 6 sides, check if the block can store energy. If yes send energy to him if the main block have extra energy. If no, it is full of energy. If have the main block space, consume the energy from the block and etc.

 

 

Thanks very much!

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

Yes hydroflame, but the tutorial dont tell me what things I can do with tile entities. But I give you good karma :D

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

ah ok

 

generic description: tile entities are used to store any extra information that wont fit in the metadata (aka a number between 0-15)

 

vanilla blocks that use tile entities(TE): sign, store the text to be displayed, chest, store  if if or not the chest is opened by someone, beacon, store how many buff are available and if its active.

 

random idea i have at 6am just woke up: statue that holds buff that player can get and recover them periodically, 2 way teleporter, slot machine, bank

 

for more exemple look at almost any mod on github.

 

-hydroflame, FRev-

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

-hydroflame, author of the forge revolution-

Posted

Ok, so. I created a this things in My Tile Entity and My Block Class. How I can "run" this things. It dont do anything.

BLOCK CLASS:

 

package mar21.omega.machine;

 

import java.util.Random;

 

import mar21.omega.ModCore;

import mar21.omega.machine.tileEntity.TileEntityPowerConduit;

import mar21.omega.mar21.Mar21Block;

import net.minecraft.block.material.Material;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

 

public class MachinePowerConduit extends Mar21Block

{

    private final Random powerRand = new Random();

    public static int powerTick;

 

 

    public MachinePowerConduit(int id, Material par2Material, CreativeTabs par3CreativeTabs)

    {

    super(id, par2Material, par3CreativeTabs);

    this.setHardness(2.0F);

    }

 

    public int idDropped(int par1, Random par2Random, int par3)

    {

        return ModCore.power_conduit.blockID;

    }

   

    public TileEntity createTileEntity(World world, int metadata)

    {

    return new TileEntityPowerConduit();

    }

   

    public void onBlockAdded(World par1World, int par2, int par3, int par4)

    {

        super.onBlockAdded(par1World, par2, par3, par4);

        par1World.scheduleBlockUpdate(par2, par3, par4, ModCore.power_conduit.blockID, 5);

    }

   

@Override

public void updateTick(World world, int x,int y, int z, Random rand)

{

    super.updateTick(world, x, y, z, rand);

    world.scheduleBlockUpdate(x, y, z, ModCore.power_conduit.blockID, 5);

}

}

 

 

TILEENTITYCLASS:

 

package mar21.omega.machine.tileEntity;

 

import java.util.Random;

 

import mar21.omega.ModCore;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

 

public class TileEntityPowerConduit extends TileEntity

{

public int EnergyStored;

public int maxEnergyStored;

public int sendEnergyPacket;

public boolean canSendEnergy;

public boolean canReceiveEnergy;

public World par1World;

public int i,j,k;

public boolean side1,side2,side3,side4,side5,side6;

 

@Override

public void writeToNBT(NBTTagCompound par1)

{

super.writeToNBT(par1);

par1.setInteger("EnergyStored", EnergyStored);

}

@Override

public void readFromNBT(NBTTagCompound par1)

{

super.readFromNBT(par1);

this.EnergyStored = par1.getInteger("EnergyStored");

}

public boolean checkBlockOnSide(int i, int j, int k)

{

par1World = this.worldObj;

if(ModCore.power_conduit.blockID == par1World.getBlockId(i, j, k))

{return true;}else{return false;}

}

public void checkSides()

{

par1World = this.worldObj;

i = this.xCoord;

j = this.yCoord;

k = this.zCoord;

side1 = checkBlockOnSide(i+1,j,k);

side2 = checkBlockOnSide(i-1,j,k);

side3 = checkBlockOnSide(i,j+1,k);

side4 = checkBlockOnSide(i,j-1,k);

side5 = checkBlockOnSide(i,j,k+1);

side6 = checkBlockOnSide(i,j,k-1);

}

 

public void updateEntity()

{

par1World = this.worldObj;

i = this.xCoord;

j = this.yCoord;

k = this.zCoord;

checkSides();

if(side1 == true){System.out.println("SIDE1");};

if(side2 == true){System.out.println("SIDE2");};

if(side3 == true){System.out.println("SIDE3");};

if(side4 == true){System.out.println("SIDE4");};

if(side5 == true){System.out.println("SIDE5");};

if(side6 == true){System.out.println("SIDE6");};

}

}

 

Yes, I can be mad :D

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

Hi again,

 

 

basicly you want your block to implement the "onNeighborBlockChange" method.

it is called everytime a neighbor block is updated.

Inside the implementations do

world.getBlockTileEntity

cast it into your "TileEntityPowerConduit" and call the updateEntity method you made

 

Cheers,

-hydroflame, FRev-

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

-hydroflame, author of the forge revolution-

Posted

Ou, I think a know what you mean... I think  :)

But how I can do this ? I dont know what you mean the world.getBlockTileEntity

 

 

And I have another question to you, I dont want to create new topic because I think it is not a big problem.

I created a custom block model for my machine. Everything is working fine, but the block is rotated only in one direction even If I try to place him to another direction.

Explanation: If I place the block, he isnt rotated as it need to be, If you know what I am want to say to you...

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

heuf .... here we go

 

 

 

 

//you class my block wtv thigny should be like this

public class someBlock extends Block{

//some code here like constructors n shit

public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID) {

TileEntity tileEntity = world.getBlockTileEntity(x, y, z);//this will return the tile entity at this location

  if(tileEntity != null){//safety check

  if(tileEntity instanceof TileEntityYourBlock){//safety check

    TileEntityYourBlock tileEntityYourBlock = (TileEntityYourBlock) tileEntity;//cast into the right kind

    tileEntityYourBlock.updateEntity();//call the update function on the tile entity

  }

  }

 

}

//some more code about wtv

}

 

 

 

as for the other thing about orientation, search the forge wiki for "metadata"

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

-hydroflame, author of the forge revolution-

Posted

Before that rotation worked perfectly. Now with the model doesnt.

Hmm, the code doesnt work...

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

you might have to call something like

 

GL11.glRotate(angle, 0, 1, 0); before rendering the model to rotate it before

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

-hydroflame, author of the forge revolution-

Posted

SO :D

I created a rotation thingy.

Code in TileEntityPoweredMelterRender:

 

        @Override

        public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {

        //The PushMatrix tells the renderer to "start" doing something.

                GL11.glPushMatrix();

        //This is setting the initial location.

                GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);

        //This is the texture of your block. It's pathed to be the same place as your other blocks here.

                bindTextureByName(Mar21Extender.getRenderedTexture("powered_melter"));

        //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!                     

                GL11.glPushMatrix();

                GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

        //This rotation part is making the model rotated as well!

                if(MachinePoweredMelter.getSide == 0){GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);}

                if(MachinePoweredMelter.getSide == 1){GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);}

                if(MachinePoweredMelter.getSide == 2){GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F);}

                if(MachinePoweredMelter.getSide == 3){GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);}

        //A reference to your Model file. Again, very important.

                this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

        //Tell it to stop rendering for both the PushMatrix's

                GL11.glPopMatrix();

                GL11.glPopMatrix();

        }

 

And changed code in Block class:

 

public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving, ItemStack par6ItemStack)

    {

        int l = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

 

        if (l == 0)

        {

            par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2);

            this.getSide = l;

        }

 

        if (l == 1)

        {

            par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2);

            this.getSide = l;

        }

 

        if (l == 2)

        {

            par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2);

            this.getSide = l;

        }

 

        if (l == 3)

        {

            par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2);

            this.getSide = l;

        }

 

        if (par6ItemStack.hasDisplayName())

        {

            ((TileEntityPoweredMelter)par1World.getBlockTileEntity(par2, par3, par4)).func_94129_a(par6ItemStack.getDisplayName());

        }

    }

 

But there is ONE IMPORTANT PROBLEM :D

If I place the machine, it will rotate as I want... But every machine in world is rotated the same, If I place differently rotated machine, all machines gets the rotation of last placed machine!

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

as a opengl expert

//The PushMatrix tells the renderer to "start" doing something.

this is hilarious and also giving me cancer but dont worry I'm super anal about CG code

 

i know that its because of "MachinePoweredMelter.getSide" can you show me how this variable is set, it should be different for every block and it behing the same is the cause for the same orientation everywhere

 

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

-hydroflame, author of the forge revolution-

Posted

as a opengl noob :)

getSide is public static int

If you want anything else... I dont know :D

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

yeah ok it makes a lot of sens.

 

getSide shouldnt be static, as static means its the same for everyone.

 

what you want is a way to access a world variable and call

world.getBlockMetadata(x, y, z);

thsi will return what "getSide" is, but the specific value for every different block, if you want more help,

 

 

 

put in spoiler every class you think could help, i dont have access to a minecraft build at the moment so i cant search by myself

 

 

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

-hydroflame, author of the forge revolution-

Posted

Yes ...

There is something with rotate in name :D :

 

        private void adjustRotatePivotViaMeta(World world, int x, int y, int z) {

                int meta = world.getBlockMetadata(x, y, z);

                GL11.glPushMatrix();

                GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);

                GL11.glPopMatrix();

        }

 

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

yes, except if you have to render your block before you pull the matrix (ill spare you the details)

 

but technicly

 

pushMatrix
rotate
draw
popMatrix

 

bellow will not work

 

pushMatrix
rotate
popMatrix
draw

 

 

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

-hydroflame, author of the forge revolution-

Posted

Heh, I set! I am totaly render idiot :D

So, I have this in my rendering class:

 

package mar21.omega.machine.tileEntity.render;

 

import mar21.omega.machine.MachinePoweredMelter;

import mar21.omega.mar21.Mar21Extender;

import net.minecraft.block.Block;

import net.minecraft.client.renderer.OpenGlHelper;

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

 

import org.lwjgl.opengl.GL11;

 

public class TileEntityPoweredMelterRender extends TileEntitySpecialRenderer {

       

        //The model of your block

        private final powered_melter model;

        private int getSide = MachinePoweredMelter.getSide;

       

        public TileEntityPoweredMelterRender() {

                this.model = new powered_melter();

        }

       

        private void adjustRotatePivotViaMeta(World world, int x, int y, int z) {

                int meta = world.getBlockMetadata(x, y, z);

                GL11.glPushMatrix();

                GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);

                GL11.glPopMatrix();

        }

       

        @Override

        public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {

        //The PushMatrix tells the renderer to "start" doing something.

                GL11.glPushMatrix();

        //This is setting the initial location.

                GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);

        //This is the texture of your block. It's pathed to be the same place as your other blocks here.

                bindTextureByName(Mar21Extender.getRenderedTexture("powered_melter"));

        //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!                     

                GL11.glPushMatrix();

                GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

        //This rotation part is making the model rotated as well!

                if(getSide == 0){GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);}

                if(getSide == 1){GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);}

                if(getSide == 2){GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F);}

                if(getSide == 3){GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);}

        //A reference to your Model file. Again, very important.

                this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

        //Tell it to stop rendering for both the PushMatrix's

                GL11.glPopMatrix();

                GL11.glPopMatrix();

        }

 

        //Set the lighting stuff, so it changes it's brightness properly.     

        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);

        }

}

 

What I need to write there :D ??

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

 

 

package mar21.omega.machine.tileEntity.render;

 

import mar21.omega.machine.MachinePoweredMelter;

import mar21.omega.mar21.Mar21Extender;

import net.minecraft.block.Block;

import net.minecraft.client.renderer.OpenGlHelper;

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

 

import org.lwjgl.opengl.GL11;

 

public class TileEntityPoweredMelterRender extends TileEntitySpecialRenderer {

     

        //The model of your block

        private final powered_melter model;

     

        public TileEntityPoweredMelterRender() {

                this.model = new powered_melter();

        }

     

        //you dont need this function

        private void adjustRotatePivotViaMeta(World world, int x, int y, int z) {

                int meta = world.getBlockMetadata(x, y, z);

                GL11.glPushMatrix();

                GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);

                GL11.glPopMatrix();

        }

     

        @Override

        public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {

        //The PushMatrix tells the renderer to "start" doing something.

                GL11.glPushMatrix();

        //This is setting the initial location.

                GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);

        //This is the texture of your block. It's pathed to be the same place as your other blocks here.

                bindTextureByName(Mar21Extender.getRenderedTexture("powered_melter"));

        //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!                     

                GL11.glPushMatrix();

                GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

        //This rotation part is making the model rotated as well!

 

//i think you can do this

side = te.blockMetadata;

//and adjust the rotation after

 

                if(side == 0){GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);}

                if(side == 1){GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);}

                if(side == 2){GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F);}

                if(side == 3){GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F);}

        //A reference to your Model file. Again, very important.

                this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

        //Tell it to stop rendering for both the PushMatrix's

                GL11.glPopMatrix();

                GL11.glPopMatrix();

        }

 

        //Set the lighting stuff, so it changes it's brightness properly.     

        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);

        }

}

 

 

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

-hydroflame, author of the forge revolution-

Posted

Yes :D But this wont work, it says error nad this: change modifier of blockMetadata to static...

 

//EDIT

Small fixes and the code is working, but bit weird :D

It is not rotating properly, like before :!

 

//EDIT

Ok, So, I improved the rotating code and the rotating is working fine now.  :)

                int meta = te.getBlockMetadata();
                int rotation = 0;
                if(meta == 2){rotation = 180;}//SOUTH
                if(meta == 3){rotation = 0;}//NORTH
                if(meta == 4){rotation = -90;}//EAST
                if(meta == 5){rotation = 90;}//WEST
                GL11.glRotatef(rotation, 0, 1, 0);

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

:)

Ok, is there any way to show the model in the inventory? not the classic 16p image for the block?

Explanation:

It is showing the 16p image of block, not the custom rendered model ...

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted
change modifier of blockMetadata to static

yeah sorry i didnt actually compiled the code, i tought you would understand what i meant

 

to render in inventory you have to make a class that implements IItemRenderer and render when the ItemRenderType is of INVENTORY_BLOCK

 

look at the javadoc and the actual class its pretty straightfoward

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

-hydroflame, author of the forge revolution-

Posted

To show your model in your inventory, you need a item renderer.

 

Thats this class:

 

package YOUR_PACKAGE;

public class YOUR_ITEM_RENDERER implements IItemRenderer
{
    private YOUR_MODEL model;
    
    public YOUR_ITEM_RENDERER()
    {
        model = new YOUR_MODEL();
    }
    @Override
    public boolean handleRenderType(ItemStack itemstack, 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)
    {
        TileEntityRenderer.instance.renderTileEntityAt(new YOUR_TILEENTITY), 0.0D, 0.0D, 0.0D, 0.0F);
    }
}

 

 

And put this in your ClientProxy class:

 

MinecraftForgeClient.registerItemRenderer(YOUR_BLOCK_ID, new YOUR_ITEM_RENDERER());

 

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Hey Man!

Heh, thanks for the item renderer, but :  :) I DONT HAVE PROXIES ! :)

So, this is only joke, I know how to do this without any proxies :)

Thanks, one more time !

 

//EDIT

So, there is one/two more questions:

 

1) In the randomDisplayTick() I have the particle generator like in normal furnace, it is possible to generate the particles in the block? because I want to have in this setup smoke and flame particles when machine is on:

XXXXX
XXYXX
XXXXX
XXXXX
FFFFFF

The Y character is point where I want to particles come from and

the F character is the front side of the block.

 

2)Is possible to set the texturemap for the custom render, to render 2 different texturemaps?

One map if the block is active and Second if the block is inactive

 

Thank for the IItemRenderer ! :)

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

To show your model in your inventory, you need a item renderer.

 

Thats this class:

 

package YOUR_PACKAGE;

public class YOUR_ITEM_RENDERER implements IItemRenderer
{
    private YOUR_MODEL model;
    
    public YOUR_ITEM_RENDERER()
    {
        model = new YOUR_MODEL();
    }
    @Override
    public boolean handleRenderType(ItemStack itemstack, 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)
    {
        TileEntityRenderer.instance.renderTileEntityAt(new YOUR_TILEENTITY), 0.0D, 0.0D, 0.0D, 0.0F);
    }
}

 

 

And put this in your ClientProxy class:

 

MinecraftForgeClient.registerItemRenderer(YOUR_BLOCK_ID, new YOUR_ITEM_RENDERER());

 

 

Really ?  :) This code is making game crash... Errorlog:

 

[iNFO] [sTDERR] java.lang.NullPointerException

[iNFO] [sTDERR] at net.minecraft.tileentity.TileEntity.getBlockType(TileEntity.java:222)

[iNFO] [sTDERR] at net.minecraft.tileentity.TileEntity.func_85027_a(TileEntity.java:281)

[iNFO] [sTDERR] at net.minecraft.client.renderer.tileentity.TileEntityRenderer.renderTileEntityAt(TileEntityRenderer.java:178)

[iNFO] [sTDERR] at mar21.omega.machine.tileEntity.render.TileEntityPoweredMelterInvRender.renderItem(TileEntityPoweredMelterInvRender.java:29)

[iNFO] [sTDERR] at net.minecraftforge.client.ForgeHooksClient.renderInventoryItem(ForgeHooksClient.java:167)

[iNFO] [sTDERR] at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:439)

[iNFO] [sTDERR] at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:858)

[iNFO] [sTDERR] at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:217)

[iNFO] [sTDERR] at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:158)

[iNFO] [sTDERR] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1000)

[iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:872)

[iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:761)

[iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source)

 

 

TileEntityPoweredMelterInvRender:

 

package mar21.omega.machine.tileEntity.render;

 

import mar21.omega.machine.tileEntity.TileEntityPoweredMelter;

import net.minecraft.client.renderer.tileentity.TileEntityRenderer;

import net.minecraft.item.ItemStack;

import net.minecraftforge.client.IItemRenderer;

 

public class TileEntityPoweredMelterInvRender implements IItemRenderer

{

    private powered_melter_model model;

   

    public TileEntityPoweredMelterInvRender()

    {

        model = new powered_melter_model();

    }

    @Override

    public boolean handleRenderType(ItemStack itemstack, 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)

    {

        TileEntityRenderer.instance.renderTileEntityAt(new TileEntityPoweredMelter(), 0.0D, 0.0D, 0.0D, 0.0F);

    }

}

 

 

My registering line in base mod class:

 

MinecraftForgeClient.registerItemRenderer(powered_melter_idle.blockID, new TileEntityPoweredMelterInvRender());

 

 

I dont know why, eclipse doesnt show any errors..

Check out my m2cAPI: http://pastebin.com/SJmjgdgK [WIP! If something doesnt work or you have a better resolution, write me a PM]

If you want to use my API please give me a Karma/Thank you

Sorry for some bad words ´cause I am not a walkin´ library!

Posted

MinecraftForgeClient.registerItemRenderer(powered_melter_idle.blockID, new TileEntityPoweredMelterInvRender());

thsi should be in a client proxy, not in a base mod class

 

 

2 eclipse isnt some kind of magical god, it will only show compilation errors, not runtime errors

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

-hydroflame, author of the forge revolution-

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.