The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
Ok so i've looked all around and i cant seem to figure out how to get a block to point different directions based on which way your facing when you place the block down.
I've also having trouble getting the block icon (how it renders in your inventory) to show up properly.
//Treat it like a normal block here. The Block Bounds are a good idea - the first three are X Y and Z of the botton-left corner,
//And the second three are the top-right corner.
public Telescope() {
super(Material.rock);
this.setBlockName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerBlock(this, name);
//setBlockTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setHardness(2.0f);
this.setBlockBounds(0.4F, 0.0F, 0.4F, 0.6F, 1.5F, 0.6F);
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileEntityTelescope();
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
{
int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 1.5D) & 3;
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
So after further trial and error i still have yet to figure out how to get the block to face depending on which way you place it down but i did try and make it so it rotates when you right click it but with little success as it will flicker in the turned position and then always return to its original position as well as cause all the other blocks of the same type to turn as well.
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3)
{
Facing++;
if(Facing == 4){
Facing = 0;
}
int wait = 0;
while (wait < 5000) { //to try and delay the time in between right clicks
wait = wait + 1;
}
return true;
}
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
int facing = Telescope.Facing;
int k = 0;
if (facing == 0) {
k = 0;
}
if (facing == 1) {
k = 90;
}
if (facing == 1) {
k = 180;
}
if (facing == 3) {
k = 270;
}
GL11.glPushMatrix();
GL11.glRotatef(180F, k, 0F, 1F);
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
So how would i check for a player activation like onBlockActivated within the render class?
could i just copy paste the whole onBlockActivated method from my block class and put it in the renderer? or is there another method i would have to use?
Create an integer Calls Rotation or so in your block file.
Set this integer based on your onBlockPlacedBy to 90, 180 or 270.
Then in your render file under the method renderTileEntityAt create a new instance of your TileEntity and rotate your model based on the Rotation integer.
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
Ok so now i have implemented the Meta data on the block and used the rotation method from the link but still no luck. I'm guessing i have some stupid error having to do with the meta data.
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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();
}
public void renderTileEntityAt(TileEntityTelescope tileentity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
int metadata = tileentity.getBlockMetadata();
int rotationAngle = 0;
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
woopse no duh ok so i took the onBlockPlacedBy method from the furnace class and now it works for the north and south directions but when you place it from the east or west it points north
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileEntityTelescope();
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack)
{
int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 0, 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);
}
Ok so no I'm back from school and I might have found your fail. Let's take a look at this line from you render:
GL11.glRotatef(180F, rotationAngle, 0F, 1F);
And now take a look at the method glRotatef and it's parameters ...
public static void glRotatef(float angle, float x, float y, float z)
The first parameter should be you rotation angle, so you basically rotate it always 180 degrees.
The next three floats are the rotation point of your model.
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
well now unfortunately I'm at school so I can't test this but from previous testing I thought that if the first parameter wasn't 180 then the modle would render upsidedown so could i change it to GL11.glRotatef(rotationAngle, 180, 0F, 0F);? Instead and still have have it render right side up
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
IT WORKS so what i found out is that you put the angle you want the model to rotate in the first parameter then you put either a 1 or a 0 for true or false on either the X Y or Z to indicate that you want that rotation angle to apply to that axis
so first set the rotation angle to 180 then told it to use that angle to rotate it along the z axis then i told it to use the rotationAngle and apply it to the y axis
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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();
}
public void renderTileEntityAt(TileEntityTelescope tileentity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
int metadata = tileentity.getBlockMetadata();
int rotationAngle = 0;
if (metadata%4 == 0)//south
{
//System.out.println("Meta data 0 triggered");
rotationAngle = 0;
}
if (metadata%4 == 1)//west
{
//System.out.println("Meta data 1 triggered");
rotationAngle = 90;
}
if (metadata%4 == 2)//north
{
//System.out.println("Meta data 2 triggered");
rotationAngle = 180;
}
if (metadata%4 == 3) //east
{
//System.out.println("Meta data 3 triggered");
rotationAngle = -90;
}
GL11.glPushMatrix();
GL11.glRotatef(180F, 0F, 0F, 1F); // rotates the whole model so its not upside down
GL11.glRotatef(rotationAngle, 0F, 1F, 0F); //rotates the model dependent on which way you place it
If you want to render a 3D Icon in your Inventory you need a ItemRenderer. You have to register this in your proxy as well. I'll post you a link to the files of my mod:
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
i got an error at the model.renderAll in the tileEntityRenderer class so i tried changing it to this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); like it is in the renderTileEntityAt method and it removed the error however nothing changed in game
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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();
}
public void renderTileEntityAt(TileEntityTelescope tileentity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
int metadata = tileentity.getBlockMetadata();
int rotationAngle = 0;
if (metadata%4 == 0)//south
{
//System.out.println("Meta data 0 triggered");
rotationAngle = 0;
}
if (metadata%4 == 1)//west
{
//System.out.println("Meta data 1 triggered");
rotationAngle = 90;
}
if (metadata%4 == 2)//north
{
//System.out.println("Meta data 2 triggered");
rotationAngle = 180;
}
if (metadata%4 == 3) //east
{
//System.out.println("Meta data 3 triggered");
rotationAngle = -90;
}
public static void registerRenderThings() {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTelescope.class, new TileEntityTelescopeRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.telescope), new ItemTelescopeRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStand.class, new TileEntityStandRenderer());
}
}
The Meaning of Life, the Universe, and Everything.
Join Date:
5/26/2013
Posts:
52
Minecraft:
Jared_Brian_
Member Details
No unfortunately that doesn't help because there already isn't a second entity parameter in my model class so i cant remove it like you suggested to do in his case.
Ok so i've looked all around and i cant seem to figure out how to get a block to point different directions based on which way your facing when you place the block down.
I've also having trouble getting the block icon (how it renders in your inventory) to show up properly.
Here's the code
The block class:
package com.planetaryalignmentmod.blocks;
import com.planetaryalignmentmod.lib.IZoom;
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import com.planetaryalignmentmod.tileentities.TileEntityTelescope;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
public class Telescope extends BlockContainer {
private String name = "telescope";
//Treat it like a normal block here. The Block Bounds are a good idea - the first three are X Y and Z of the botton-left corner,
//And the second three are the top-right corner.
public Telescope() {
super(Material.rock);
this.setBlockName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerBlock(this, name);
//setBlockTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setHardness(2.0f);
this.setBlockBounds(0.4F, 0.0F, 0.4F, 0.6F, 1.5F, 0.6F);
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileEntityTelescope();
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon(PlanetaryAlignmentMod.MODID + ":" + "telescope");
}
public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_)
{
int l = MathHelper.floor_double((double)(p_149689_5_.rotationYaw * 4.0F / 360.0F) + 1.5D) & 3;
if (l == 0)
{
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 1, 2);
}
if (l == 1)
{
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 4, 2);
}
if (l == 2)
{
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 3, 2);
}
if (l == 3)
{
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, 2, 2);
}
}
}
The TileEntity Class:
package com.planetaryalignmentmod.tileentities;
import net.minecraft.tileentity.TileEntity;
public class TileEntityTelescope extends TileEntity {
}
The TileEntityRenderer:
package com.planetaryalignmentmod.tileentities;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
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.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.planetaryalignmentmod.blocks.Telescope;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
GL11.glPushMatrix();
GL11.glRotatef(180F, 0F, 0F, 1.0F);
this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
private void adjustLightFixture(World world, int i, int j, int k, Block block) {
Tessellator tess = Tessellator.instance;
float brightness = block.getLightValue(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);
}
}
Any help you can offer will be greatly appreciated
(also i am still pretty new to modding so i'm still a bit nooby so there very well could be some completely obvious mistakes)
So after further trial and error i still have yet to figure out how to get the block to face depending on which way you place it down but i did try and make it so it rotates when you right click it but with little success as it will flicker in the turned position and then always return to its original position as well as cause all the other blocks of the same type to turn as well.
Here's the code
The Block Class:
package com.planetaryalignmentmod.blocks;
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import com.planetaryalignmentmod.tileentities.TileEntityTelescope;
import cpw.mods.fml.common.registry.GameRegistry;
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.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import java.util.List;
public class Telescope extends BlockContainer {
private String name = "telescope";
public static int Facing = 0;
public Telescope() {
super(Material.wood);
this.setBlockName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerBlock(this, name);
//setBlockTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setHardness(2.0f);
this.setBlockBounds(0.4F, 0.0F, 0.4F, 0.6F, 1.5F, 0.6F);
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileEntityTelescope();
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon(PlanetaryAlignmentMod.MODID + ":" + "telescope");
}
@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3)
{
Facing++;
if(Facing == 4){
Facing = 0;
}
int wait = 0;
while (wait < 5000) { //to try and delay the time in between right clicks
wait = wait + 1;
}
return true;
}
}
The TileEntity Class:
package com.planetaryalignmentmod.tileentities;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
public class TileEntityTelescope extends TileEntity {
}
The TileEntityRenderer Class:
package com.planetaryalignmentmod.tileentities;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
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.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.planetaryalignmentmod.blocks.Telescope;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
int facing = Telescope.Facing;
int k = 0;
if (facing == 0) {
k = 0;
}
if (facing == 1) {
k = 90;
}
if (facing == 1) {
k = 180;
}
if (facing == 3) {
k = 270;
}
GL11.glPushMatrix();
GL11.glRotatef(180F, k, 0F, 1F);
//GL11.glRotatef(180F, 0F, 0F, 1F);
this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
private void adjustLightFixture(World world, int i, int j, int k, Block block) {
Tessellator tess = Tessellator.instance;
float brightness = block.getLightValue(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);
}
}
Again i am very new to modding and have little experience so any help you could offer will be greatly appreciated
I believe the problem is your costum Render. He will render your Block always in the same direction.
So you need to check in your render file in which direction your block should face and then rotate your model there.
Could be wrong with this but I think I had the same problem a while ago.
TechMagee66
So how would i check for a player activation like onBlockActivated within the render class?
could i just copy paste the whole onBlockActivated method from my block class and put it in the renderer? or is there another method i would have to use?
Thanks
-Jared_Brian_
Maybe this would help you?
Another way to do this:
Create an integer Calls Rotation or so in your block file.
Set this integer based on your onBlockPlacedBy to 90, 180 or 270.
Then in your render file under the method renderTileEntityAt create a new instance of your TileEntity and rotate your model based on the Rotation integer.
TechMage66
Ok so now i have implemented the Meta data on the block and used the rotation method from the link but still no luck. I'm guessing i have some stupid error having to do with the meta data.
Block class:
package com.planetaryalignmentmod.blocks;
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import com.planetaryalignmentmod.tileentities.TileEntityTelescope;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import java.util.List;
public class Telescope extends BlockContainer {
private String name = "telescope";
public Telescope() {
super(Material.wood);
this.setBlockName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerBlock(this, name);
//setBlockTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setHardness(2.0f);
this.setBlockBounds(0.4F, 0.0F, 0.4F, 0.6F, 1.5F, 0.6F);
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileEntityTelescope();
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public int getMetadata(int meta) {
return meta;
}
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon(PlanetaryAlignmentMod.MODID + ":" + "telescope");
}
}
TileEntityRenderer:
package com.planetaryalignmentmod.tileentities;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
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.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.planetaryalignmentmod.blocks.Telescope;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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();
}
public void renderTileEntityAt(TileEntityTelescope tileentity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
int metadata = tileentity.getBlockMetadata();
int rotationAngle = 0;
if (metadata%4 == 0)
{
rotationAngle = 0;
}
if (metadata%4 == 1)
{
rotationAngle = 180;
}
if (metadata%4 == 2)
{
rotationAngle = 100000;
}
if (metadata%4 == 3)
{
rotationAngle = -180;
}
GL11.glPushMatrix();
GL11.glRotatef(180F, rotationAngle, 0F, 1F);
//GL11.glRotatef(180F, 0F, 0F, 1F);
this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
private void adjustLightFixture(World world, int i, int j, int k, Block block) {
Tessellator tess = Tessellator.instance;
float brightness = block.getLightValue(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);
}
@Override
public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
{
renderTileEntityAt((TileEntityTelescope)tileentity, d, d1, d2, f);
}
}
ItemBlock:
package com.planetaryalignmentmod.lib;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
public class ItemBlockTelescope extends ItemBlock {
public ItemBlockTelescope(Block block) {
super(block);
setHasSubtypes(true);
}
}
Again thank you so much for your help
-Jared_Brian_
I can't see where you set the metadata of your block based on the direction it should face in ...
I have no computer at the moment (on the way to work) so I can't help you to much with the actual code ... sry
TechMagee66
woopse no duh ok so i took the onBlockPlacedBy method from the furnace class and now it works for the north and south directions but when you place it from the east or west it points north
Block class:
package com.planetaryalignmentmod.blocks;
import com.planetaryalignmentmod.lib.ModCreativeTabs;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import com.planetaryalignmentmod.tileentities.TileEntityTelescope;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
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.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import java.util.List;
public class Telescope extends BlockContainer {
private String name = "telescope";
public Telescope() {
super(Material.wood);
this.setBlockName(PlanetaryAlignmentMod.MODID + "_" + name);
this.setCreativeTab(ModCreativeTabs.tabPlanetaryAlignment);
GameRegistry.registerBlock(this, name);
//setBlockTextureName(PlanetaryAlignmentMod.MODID + ":" + name);
this.setHardness(2.0f);
this.setBlockBounds(0.4F, 0.0F, 0.4F, 0.6F, 1.5F, 0.6F);
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileEntityTelescope();
}
@Override
public int getRenderType() {
return -1;
}
@Override
public boolean isOpaqueCube() {
return false;
}
public boolean renderAsNormalBlock() {
return false;
}
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack)
{
int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (l == 0)
{
world.setBlockMetadataWithNotify(x, y, z, 0, 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);
}
}
public int getMetadata(int meta) {
return meta;
}
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon(PlanetaryAlignmentMod.MODID + ":" + "telescope");
}
}
and don't worry about it you've helped a ton already
-Jared_Brian_
I think the rotation angles in your render file are wrong ... If your meta is 2 you rotate it 10000 degrees?
If your meta is 3 you rotate it -180 degrees which I basically the same as 180 degrees ...
Try to change these two to 90 and -90
TechMagee66
i changed the two and unfortunately the same result :/
Can you make a console output in your render file under if metadata == 2 and if metadata == 3 to check if they are triggered.
I'm in school now so can't write you amy more ...
TechMagee66
interestingly enough they all do get triggered and what i found out is meta data 0 should be facing south, 1 west, 2 north, and 3 east
again thank you so much for your help
-Jared_Brian_
Ok so no I'm back from school and I might have found your fail. Let's take a look at this line from you render:
GL11.glRotatef(180F, rotationAngle, 0F, 1F);
And now take a look at the method glRotatef and it's parameters ...
public static void glRotatef(float angle, float x, float y, float z)
The first parameter should be you rotation angle, so you basically rotate it always 180 degrees.
The next three floats are the rotation point of your model.
TechMage66
well now unfortunately I'm at school so I can't test this but from previous testing I thought that if the first parameter wasn't 180 then the modle would render upsidedown so could i change it to GL11.glRotatef(rotationAngle, 180, 0F, 0F);? Instead and still have have it render right side up
Thanks
-Jared_Brian_
IT WORKS so what i found out is that you put the angle you want the model to rotate in the first parameter then you put either a 1 or a 0 for true or false on either the X Y or Z to indicate that you want that rotation angle to apply to that axis
so first set the rotation angle to 180 then told it to use that angle to rotate it along the z axis then i told it to use the rotationAngle and apply it to the y axis
TileEntityRenderer
package com.planetaryalignmentmod.tileentities;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
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.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.planetaryalignmentmod.blocks.Telescope;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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();
}
public void renderTileEntityAt(TileEntityTelescope tileentity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
int metadata = tileentity.getBlockMetadata();
int rotationAngle = 0;
if (metadata%4 == 0)//south
{
//System.out.println("Meta data 0 triggered");
rotationAngle = 0;
}
if (metadata%4 == 1)//west
{
//System.out.println("Meta data 1 triggered");
rotationAngle = 90;
}
if (metadata%4 == 2)//north
{
//System.out.println("Meta data 2 triggered");
rotationAngle = 180;
}
if (metadata%4 == 3) //east
{
//System.out.println("Meta data 3 triggered");
rotationAngle = -90;
}
GL11.glPushMatrix();
GL11.glRotatef(180F, 0F, 0F, 1F); // rotates the whole model so its not upside down
GL11.glRotatef(rotationAngle, 0F, 1F, 0F); //rotates the model dependent on which way you place it
this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
private void adjustLightFixture(World world, int i, int j, int k, Block block) {
Tessellator tess = Tessellator.instance;
float brightness = block.getLightValue(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);
}
@Override
public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
{
renderTileEntityAt((TileEntityTelescope)tileentity, d, d1, d2, f);
}
}
Now i just need to know how to render the icon properly as you can see in the picture i posted it just shows the texture instead of the model
Thanks
-Jared_Brian_
If you want to render a 3D Icon in your Inventory you need a ItemRenderer. You have to register this in your proxy as well. I'll post you a link to the files of my mod:
ItemEssenceNodeRenderer
TileEntityEssenceNodeRenderer
ClientProxy
i got an error at the model.renderAll in the tileEntityRenderer class so i tried changing it to this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); like it is in the renderTileEntityAt method and it removed the error however nothing changed in game
TileEntityTelescopeRenderer
package com.planetaryalignmentmod.render;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
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.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.planetaryalignmentmod.blocks.Telescope;
import com.planetaryalignmentmod.lib.PlanetaryAlignmentMod;
import com.planetaryalignmentmod.model.TelescopeModel;
import com.planetaryalignmentmod.tileentities.TileEntityTelescope;
public class TileEntityTelescopeRenderer extends TileEntitySpecialRenderer {
private final TelescopeModel model;
public TileEntityTelescopeRenderer() {
this.model = new TelescopeModel();
}
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();
}
public void renderTileEntityAt(TileEntityTelescope tileentity, double x, double y, double z, float f)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
ResourceLocation textures = (new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
Minecraft.getMinecraft().renderEngine.bindTexture(textures);
int metadata = tileentity.getBlockMetadata();
int rotationAngle = 0;
if (metadata%4 == 0)//south
{
//System.out.println("Meta data 0 triggered");
rotationAngle = 0;
}
if (metadata%4 == 1)//west
{
//System.out.println("Meta data 1 triggered");
rotationAngle = 90;
}
if (metadata%4 == 2)//north
{
//System.out.println("Meta data 2 triggered");
rotationAngle = 180;
}
if (metadata%4 == 3) //east
{
//System.out.println("Meta data 3 triggered");
rotationAngle = -90;
}
GL11.glPushMatrix();
GL11.glRotatef(180F, 0F, 0F, 1F);
GL11.glRotatef(rotationAngle, 0F, 1F, 0F);
this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
private void adjustLightFixture(World world, int i, int j, int k, Block block) {
Tessellator tess = Tessellator.instance;
float brightness = block.getLightValue(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);
}
@Override
public void renderTileEntityAt(TileEntity tileentity, double d, double d1, double d2, float f)
{
renderTileEntityAt((TileEntityTelescope)tileentity, d, d1, d2, f);
}
public void renderHand(double x, double y, double z)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
GL11.glPushMatrix();
this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //model.renderAll();
GL11.glPopMatrix();
GL11.glPopMatrix();
}
public void renderInventory(double x, double y, double z)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y - 0.2F, (float) z);
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("planetaryAlignmentMod:textures/blocks/telescope.png"));
GL11.glPushMatrix();
GL11.glScaled(1.5D, 1.5D, 1.5D);
this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //model.renderAll();
GL11.glPopMatrix();
GL11.glPopMatrix();
}
}
TelescopeModel
package com.planetaryalignmentmod.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
public class TelescopeModel extends ModelBase
{
//fields
ModelRenderer Leg1;
ModelRenderer Leg2;
ModelRenderer Leg3;
ModelRenderer legBase;
ModelRenderer scopeStandPt1;
ModelRenderer scopeStandPt2;
ModelRenderer scopeStandPt3;
ModelRenderer Scope;
ModelRenderer sight1;
ModelRenderer knob1;
ModelRenderer knob2;
ModelRenderer scopeEnd1;
ModelRenderer sight2;
ModelRenderer ScopeEnd2;
public TelescopeModel()
{
textureWidth = 32;
textureHeight = 32;
Leg1 = new ModelRenderer(this, 24, 0);
Leg1.addBox(0F, 0F, 0F, 2, 20, 2);
Leg1.setRotationPoint(1F, 6F, -2F);
Leg1.setTextureSize(32, 32);
Leg1.mirror = true;
setRotation(Leg1, -0.4F, -1F, 0F);
Leg2 = new ModelRenderer(this, 24, 0);
Leg2.addBox(0F, 0F, 0F, 2, 20, 2);
Leg2.setRotationPoint(-2F, 6F, -1F);
Leg2.setTextureSize(32, 32);
Leg2.mirror = true;
setRotation(Leg2, -0.4F, 1F, 0F);
Leg3 = new ModelRenderer(this, 24, 0);
Leg3.addBox(0F, 0F, 0F, 2, 20, 2);
Leg3.setRotationPoint(-1F, 6F, 0F);
Leg3.setTextureSize(32, 32);
Leg3.mirror = true;
setRotation(Leg3, 0.3F, 0F, 0F);
legBase = new ModelRenderer(this, 0, 4);
legBase.addBox(0F, 0F, 0F, 4, 1, 4);
legBase.setRotationPoint(-2F, 5F, -2F);
legBase.setTextureSize(32, 32);
legBase.mirror = true;
setRotation(legBase, 0F, 0F, 0F);
scopeStandPt1 = new ModelRenderer(this, 0, 9);
scopeStandPt1.addBox(0F, 0F, 0F, 2, 2, 2);
scopeStandPt1.setRotationPoint(-1F, 3F, -1F);
scopeStandPt1.setTextureSize(32, 32);
scopeStandPt1.mirror = true;
setRotation(scopeStandPt1, 0F, 0F, 0F);
scopeStandPt2 = new ModelRenderer(this, 0, 0);
scopeStandPt2.addBox(0F, 0F, 0F, 1, 3, 1);
scopeStandPt2.setRotationPoint(1F, 3.5F, 0.5F);
scopeStandPt2.setTextureSize(32, 32);
scopeStandPt2.mirror = true;
setRotation(scopeStandPt2, -2.617994F, 0F, 0F);
scopeStandPt3 = new ModelRenderer(this, 0, 0);
scopeStandPt3.addBox(0F, 0F, 0F, 1, 3, 1);
scopeStandPt3.setRotationPoint(-2F, 3.5F, 0.5F);
scopeStandPt3.setTextureSize(32, 32);
scopeStandPt3.mirror = true;
setRotation(scopeStandPt3, -2.617994F, 0F, 0F);
Scope = new ModelRenderer(this, 16, 0);
Scope.addBox(0F, 0F, 0F, 2, 10, 2);
Scope.setRotationPoint(-1F, 3.5F, -6F);
Scope.setTextureSize(32, 32);
Scope.mirror = true;
setRotation(Scope, 1.850049F, 0F, 0F);
sight1 = new ModelRenderer(this, 4, 0);
sight1.addBox(0F, 0F, 0F, 1, 2, 1);
sight1.setRotationPoint(-0.5F, 2F, -6F);
sight1.setTextureSize(32, 32);
sight1.mirror = true;
setRotation(sight1, -1.308997F, 0F, 0F);
knob1 = new ModelRenderer(this, 8, 0);
knob1.addBox(0F, 0F, 0F, 1, 1, 1);
knob1.setRotationPoint(-1.5F, 2.25F, -7.5F);
knob1.setTextureSize(32, 32);
knob1.mirror = true;
setRotation(knob1, 0F, 0F, 0F);
knob2 = new ModelRenderer(this, 8, 0);
knob2.addBox(0F, 0F, 0F, 1, 1, 1);
knob2.setRotationPoint(0.5F, 2.3F, -7.5F);
knob2.setTextureSize(32, 32);
knob2.mirror = true;
setRotation(knob2, 0F, 0F, 0F);
scopeEnd1 = new ModelRenderer(this, 0, 13);
scopeEnd1.addBox(0F, 0F, 0F, 4, 4, 5);
scopeEnd1.setRotationPoint(-2F, -3F, 6F);
scopeEnd1.setTextureSize(32, 32);
scopeEnd1.mirror = true;
setRotation(scopeEnd1, 0.2617994F, 0F, 0F);
sight2 = new ModelRenderer(this, 4, 0);
sight2.addBox(0F, 0F, 0F, 1, 3, 1);
sight2.setRotationPoint(-0.5F, 2.8F, -7F);
sight2.setTextureSize(32, 32);
sight2.mirror = true;
setRotation(sight2, -2.356194F, 0F, 0F);
ScopeEnd2 = new ModelRenderer(this, 0, 22);
ScopeEnd2.addBox(0F, 0F, 0F, 3, 3, 5);
ScopeEnd2.setRotationPoint(-1.5F, -1.3F, 2F);
ScopeEnd2.setTextureSize(32, 32);
ScopeEnd2.mirror = true;
setRotation(ScopeEnd2, 0.2617994F, 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); //add entity here
Leg1.render(f5);
Leg2.render(f5);
Leg3.render(f5);
legBase.render(f5);
scopeStandPt1.render(f5);
scopeStandPt2.render(f5);
scopeStandPt3.render(f5);
Scope.render(f5);
sight1.render(f5);
knob1.render(f5);
knob2.render(f5);
scopeEnd1.render(f5);
sight2.render(f5);
ScopeEnd2.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 e)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
}
}
clientProxy
package com.planetaryalignmentmod.proxy;
import net.minecraft.item.Item;
import net.minecraftforge.client.MinecraftForgeClient;
import com.planetaryalignmentmod.blocks.ModBlocks;
import com.planetaryalignmentmod.render.ItemTelescopeRenderer;
import com.planetaryalignmentmod.render.TileEntityStandRenderer;
import com.planetaryalignmentmod.render.TileEntityTelescopeRenderer;
import com.planetaryalignmentmod.tileentities.TileEntityStand;
import com.planetaryalignmentmod.tileentities.TileEntityTelescope;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
public class ClientProxy extends CommonProxy{
public static void registerRenderThings() {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTelescope.class, new TileEntityTelescopeRenderer());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.telescope), new ItemTelescopeRenderer());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityStand.class, new TileEntityStandRenderer());
}
}
ItemTelescopeRenderer
package com.planetaryalignmentmod.render;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;
public class ItemTelescopeRenderer implements IItemRenderer
{
@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
return true;
}
@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
return true;
}
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
switch (type)
{
case INVENTORY:
(new TileEntityTelescopeRenderer()).renderInventory(0.0D, 0.0D, 0.0D);
break;
default:
(new TileEntityTelescopeRenderer()).renderHand(0.0D, 0.0D, 0.0D);
}
}
}
i also voided out the original icon method in my block class so there wouldn't be conflicting icons.
should there be a renderAll method in my model class?
Thanks
-Jared_Brian_
Oh I'm using a blender model so it might be a bit different ...
No I'm in school again but maybe this helps you
TehMage66
No unfortunately that doesn't help because there already isn't a second entity parameter in my model class so i cant remove it like you suggested to do in his case.
Thanks
-Jared_Brian_