Posted October 10, 201411 yr Hello, I'm very new to modding, and new to Java as well (I have tons of experience with other programming languages however) and I have run into a problem when trying to animate my custom rendered model. The block is rendered perfectly, and I got it to animate when it received a redstone signal. However, all blocks in the world would animate, not just the one I was giving a redstone signal to. WAIT! Before you say "Great.... another idiot who doesn't understand static variables," I know that static allows the variable to be shared across all of the blocks in the world, so I removed the static part of my variables. Now, the animation doesn't run. I have tried: public static ModelRenderer PedestalOne; -> Animation works, but runs on all blocks in the world. public ModelRenderer PedestalOne; -> Animation doesn't run. ModelRenderer PedestalOne; -> Animation doesn't run. I have tried various ways to render the model from outside of the Model class, but I am unable to figure this out. Classes: BlueGeneralSiren.java package mcrafter.SirenMod.sirens; //Imports import java.lang.ref.Reference; import java.util.Iterator; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mcrafter.SirenMod.common.SirenMod; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityNote; import net.minecraft.util.Icon; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlueGeneralSiren extends BlockContainer{ //MUST BE "BlockContainer" NOT "Block" //Model will not render on "Block"!!!! //~~~~~~~~~~~~~~~~~~~~~~~~~~~ //_____________________ //VARIABLE DECLARATIONS //_____________________ public String textureName; //Refers to the model class private GeneralSirenModel GeneralSirenModel = new GeneralSirenModel(); //Vars that handle animation angles and # of times the animation has occurred private double angle; private int times; //~~~~~~~~~~~~~~~~~~~~~~~~~~~ //Main Block Handling public BlueGeneralSiren(int id, String textureName) { super(id, Material.piston); this.textureName = textureName; //Sets creative tab this.setCreativeTab(SirenMod.SirenModCreativeTab); setUnlocalizedName(textureName); //Adjusts bounding box this.setBlockBounds(0.16F, 0F, 0.16F, 0.84F, 0.57F, 0.84F); } @Override public TileEntity createNewTileEntity(World world){ return new BlueSirenTileEntity(); } //Rendering details public int getRenderType(){ return -1;} public boolean isOpaqueCube(){ return false;} public boolean renderAsNormalBlock(){ return false;} //Called when block is added into the world public void onBlockAdded(World par1World, int par2, int par3, int par4){ super.onBlockAdded(par1World, par2, par3, par4); this.setDefaultDirection(par1World, par2, par3, par4); //Checks if the block is receiving a redstone signal when it is placed down if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)){ //Gets called if the block is receiving a redstone signal Minecraft.getMinecraft().sndManager.playSound("simplemod:sirens.sirenone", par2, par3, par4, 3.0f, 1.0f); } } //Called when a block beside this block is updated @SideOnly(Side.CLIENT) public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5){ //Checks if the block is receiving a redstone signal when it is placed down if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)){ //Gets called if the block is receiving a redstone signal Minecraft.getMinecraft().sndManager.playSound("simplemod:sirens.sirenone", par2, par3, par4, 3.0f, 1.0f); //****************************************************************** //I Know this is insanely stupid to use this to make the animation, //but I am very new to Java and modding in general so this is the //only way I could think to do the animation //****************************************************************** while (times < 21){ angle = angle + 0.1; GeneralSirenModel.RotorLeft.rotateAngleX = (float) angle; GeneralSirenModel.Panel1.rotateAngleX = (float) angle; GeneralSirenModel.Panel2.rotateAngleX = (float) angle; GeneralSirenModel.Panel3.rotateAngleX = (float) angle; GeneralSirenModel.Panel4.rotateAngleX = (float) angle; GeneralSirenModel.RotorRight.rotateAngleX = (float) angle; GeneralSirenModel.Panel5.rotateAngleX = (float) angle; GeneralSirenModel.Panel6.rotateAngleX = (float) angle; GeneralSirenModel.Panel7.rotateAngleX = (float) angle; GeneralSirenModel.Panel8.rotateAngleX = (float) angle; times = times + 1; try { Thread.sleep(75); } catch (InterruptedException e) { e.printStackTrace(); } } if (times >= 20){ while (times < 51){ angle = angle + 0.2; GeneralSirenModel.RotorLeft.rotateAngleX = (float) angle; GeneralSirenModel.Panel1.rotateAngleX = (float) angle; GeneralSirenModel.Panel2.rotateAngleX = (float) angle; GeneralSirenModel.Panel3.rotateAngleX = (float) angle; GeneralSirenModel.Panel4.rotateAngleX = (float) angle; GeneralSirenModel.RotorRight.rotateAngleX = (float) angle; GeneralSirenModel.Panel5.rotateAngleX = (float) angle; GeneralSirenModel.Panel6.rotateAngleX = (float) angle; GeneralSirenModel.Panel7.rotateAngleX = (float) angle; GeneralSirenModel.Panel8.rotateAngleX = (float) angle; times = times + 1; try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } if (times >=50){ while (times < 76){ angle = angle + 0.5; GeneralSirenModel.RotorLeft.rotateAngleX = (float) angle; GeneralSirenModel.Panel1.rotateAngleX = (float) angle; GeneralSirenModel.Panel2.rotateAngleX = (float) angle; GeneralSirenModel.Panel3.rotateAngleX = (float) angle; GeneralSirenModel.Panel4.rotateAngleX = (float) angle; GeneralSirenModel.RotorRight.rotateAngleX = (float) angle; GeneralSirenModel.Panel5.rotateAngleX = (float) angle; GeneralSirenModel.Panel6.rotateAngleX = (float) angle; GeneralSirenModel.Panel7.rotateAngleX = (float) angle; GeneralSirenModel.Panel8.rotateAngleX = (float) angle; times = times + 1; try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } if (times >=75){ while (times < 101){ angle = angle + 0.9; GeneralSirenModel.RotorLeft.rotateAngleX = (float) angle; GeneralSirenModel.Panel1.rotateAngleX = (float) angle; GeneralSirenModel.Panel2.rotateAngleX = (float) angle; GeneralSirenModel.Panel3.rotateAngleX = (float) angle; GeneralSirenModel.Panel4.rotateAngleX = (float) angle; GeneralSirenModel.RotorRight.rotateAngleX = (float) angle; GeneralSirenModel.Panel5.rotateAngleX = (float) angle; GeneralSirenModel.Panel6.rotateAngleX = (float) angle; GeneralSirenModel.Panel7.rotateAngleX = (float) angle; GeneralSirenModel.Panel8.rotateAngleX = (float) angle; times = times + 1; try { Thread.sleep(60); } catch (InterruptedException e) { e.printStackTrace(); } } } if (times >=100){ while (times < 111){ angle = angle + 0.5; GeneralSirenModel.RotorLeft.rotateAngleX = (float) angle; GeneralSirenModel.Panel1.rotateAngleX = (float) angle; GeneralSirenModel.Panel2.rotateAngleX = (float) angle; GeneralSirenModel.Panel3.rotateAngleX = (float) angle; GeneralSirenModel.Panel4.rotateAngleX = (float) angle; GeneralSirenModel.RotorRight.rotateAngleX = (float) angle; GeneralSirenModel.Panel5.rotateAngleX = (float) angle; GeneralSirenModel.Panel6.rotateAngleX = (float) angle; GeneralSirenModel.Panel7.rotateAngleX = (float) angle; GeneralSirenModel.Panel8.rotateAngleX = (float) angle; times = times + 1; try { Thread.sleep(60); } catch (InterruptedException e) { e.printStackTrace(); } } } if (times >=110){ while (times < 138){ angle = angle + 0.3; GeneralSirenModel.RotorLeft.rotateAngleX = (float) angle; GeneralSirenModel.Panel1.rotateAngleX = (float) angle; GeneralSirenModel.Panel2.rotateAngleX = (float) angle; GeneralSirenModel.Panel3.rotateAngleX = (float) angle; GeneralSirenModel.Panel4.rotateAngleX = (float) angle; GeneralSirenModel.RotorRight.rotateAngleX = (float) angle; GeneralSirenModel.Panel5.rotateAngleX = (float) angle; GeneralSirenModel.Panel6.rotateAngleX = (float) angle; GeneralSirenModel.Panel7.rotateAngleX = (float) angle; GeneralSirenModel.Panel8.rotateAngleX = (float) angle; times = times + 1; try { Thread.sleep(80); } catch (InterruptedException e) { e.printStackTrace(); } } //Sets all values to default, and sets var(times) to "0" so that upon //the next redstone update, the model will animate again times = 0; GeneralSirenModel.RotorLeft.rotateAngleX = 0; GeneralSirenModel.Panel1.rotateAngleX = 0; GeneralSirenModel.Panel2.rotateAngleX = 0; GeneralSirenModel.Panel3.rotateAngleX = 0; GeneralSirenModel.Panel4.rotateAngleX = 0; GeneralSirenModel.RotorRight.rotateAngleX = 0; GeneralSirenModel.Panel5.rotateAngleX = 0; GeneralSirenModel.Panel6.rotateAngleX = 0; GeneralSirenModel.Panel7.rotateAngleX = 0; GeneralSirenModel.Panel8.rotateAngleX = 0; } } } } } //Sets direction of block based on how it is placed down in the world private void setDefaultDirection(World par1World, int par2, int par3, int par4){ if (!par1World.isRemote){ int l = par1World.getBlockId(par2, par3, par4 - 1); int i1 = par1World.getBlockId(par2, par3, par4 + 1); int j1 = par1World.getBlockId(par2 - 1, par3, par4); int k1 = par1World.getBlockId(par2 + 1, par3, par4); byte b0 = 3; if (Block.opaqueCubeLookup[l] && !Block.opaqueCubeLookup[i1]){ b0 = 3; } if (Block.opaqueCubeLookup[i1] && !Block.opaqueCubeLookup[l]){ b0 = 2; } if (Block.opaqueCubeLookup[j1] && !Block.opaqueCubeLookup[k1]){ b0 = 5; } if (Block.opaqueCubeLookup[k1] && !Block.opaqueCubeLookup[j1]){ b0 = 4; } par1World.setBlockMetadataWithNotify(par2, par3, par4, b0, 2); } } public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack){ int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; if (l == 0){ par1World.setBlockMetadataWithNotify(par2, par3, par4, 2, 2); } if (l == 1){ par1World.setBlockMetadataWithNotify(par2, par3, par4, 5, 2); } if (l == 2){ par1World.setBlockMetadataWithNotify(par2, par3, par4, 3, 2); } if (l == 3){ par1World.setBlockMetadataWithNotify(par2, par3, par4, 4, 2); } } //Retrieves meta based on rotation private static int getMetadataBasedOnRotation(int rotation) { if (rotation >= 315 || rotation < 45) { return 1; } else if (rotation >= 45 && rotation < 135) { return 2; } else if (rotation >= 135 && rotation < 225) { return 0; } else { return 3; } } //Registry public void registerIcons(IconRegister iconRegister) { blockIcon = iconRegister.registerIcon("SimpleMod:BlueGeneralSiren"); } } BlueSirenTileEntity.java package mcrafter.SirenMod.sirens; //Imports import net.minecraft.client.Minecraft; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class BlueSirenTileEntity extends TileEntity { } BlueGeneralSirenRenderer.java package mcrafter.SirenMod.sirens; //Imports 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; public class BlueGeneralSirenRenderer extends TileEntitySpecialRenderer { //Block Model private final GeneralSirenModel model; public BlueGeneralSirenRenderer() { this.model = new GeneralSirenModel(); } public void renderTileEntityAt(TileEntity 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); GL11.glRotatef(180, 0F, 0F, 1F); int meta = tileentity.getWorldObj().getBlockMetadata(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord); if (meta==5) meta = 1; else if (meta==2) meta=0; if (meta==4) meta = 3; else if (meta==3) meta=2; GL11.glRotatef(90 * meta, 0F, 1F, 0F); ResourceLocation textures = (new ResourceLocation("simplemod:textures/blocks/SirenModelBlue.png")); this.bindTexture(textures); //GL11.glPushMatrix(); this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //GL11.glPopMatrix(); GL11.glPopMatrix(); } //Lighting stuff 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); } } GeneralSirenModel.java package mcrafter.SirenMod.sirens; //Imports import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class GeneralSirenModel extends ModelBase{ public ModelRenderer PedestalOne; public ModelRenderer PedestalTwo; public ModelRenderer PedestalThree; public ModelRenderer Stator; public ModelRenderer RotorLeft; public ModelRenderer RotorRight; //Left Side Rotor panels public ModelRenderer Panel1; public ModelRenderer Panel2; public ModelRenderer Panel3; public ModelRenderer Panel4; //Right side Rotor panels public ModelRenderer Panel5; public ModelRenderer Panel6; public ModelRenderer Panel7; public ModelRenderer Panel8; public GeneralSirenModel(){ //Texture size textureWidth = 128; textureHeight = 32; //Base components PedestalOne = new ModelRenderer(this, 31, 11); PedestalOne.addBox(0F, 0F, 0F, 11, 2, 11); PedestalOne.setRotationPoint(-5.5F, 22F, -5.5F); PedestalOne.setTextureSize(128, 32); PedestalOne.mirror = true; setRotation(PedestalOne, 0F, 0F, 0F); PedestalTwo = new ModelRenderer(this, 30, 0); PedestalTwo.addBox(0F, 0F, 0F, 8, 2, ; PedestalTwo.setRotationPoint(-4F, 21F, -4F); PedestalTwo.setTextureSize(128, 32); PedestalTwo.mirror = true; setRotation(PedestalTwo, 0F, 0F, 0F); PedestalThree = new ModelRenderer(this, 0, 21); PedestalThree.addBox(0F, 0F, 0F, 2, 4, 2); PedestalThree.setRotationPoint(-1F, 17F, -1F); PedestalThree.setTextureSize(128, 32); PedestalThree.mirror = true; setRotation(PedestalThree, 0F, 0F, 0F); Stator = new ModelRenderer(this, 9, 7); Stator.addBox(0F, 0F, 0F, 7, 3, 3); Stator.setRotationPoint(-3.5F, 16F, -1.5F); Stator.setTextureSize(128, 32); Stator.mirror = true; setRotation(Stator, 0F, 0F, 0F); //Left side rotor RotorLeft = new ModelRenderer(this, 13, 0); RotorLeft.addBox(0F, -1.5F, -1.5F, 3, 3, 3); RotorLeft.setRotationPoint(-5F, 17.5F, 0F); RotorLeft.setTextureSize(128, 32); RotorLeft.mirror = true; setRotation(RotorLeft, 0F, 0F, 0F); //Right side rotor RotorRight = new ModelRenderer(this, 13, 0); RotorRight.addBox(-3F, -1.5F, -1.5F, 3, 3, 3); RotorRight.setRotationPoint(5F, 17.5F, 0F); RotorRight.setTextureSize(128, 32); RotorRight.mirror = true; setRotation(RotorRight, 0F, 0F, 0F); //Left side rotor components Panel1 = new ModelRenderer(this, 0, 0); Panel1.addBox(0F, -2.5F, -1.5F, 3, 1, 3); Panel1.setRotationPoint(-5F, 17.5F, 0F); Panel1.setTextureSize(128, 32); Panel1.mirror = true; setRotation(Panel1, 0F, 0F, 0F); Panel2 = new ModelRenderer(this, 0, 15); Panel2.addBox(0F, 1.5F, -1.5F, 3, 1, 3); Panel2.setRotationPoint(-5F, 17.5F, 0F); Panel2.setTextureSize(128, 32); Panel2.mirror = true; setRotation(Panel2, 0F, 0F, 0F); Panel3 = new ModelRenderer(this, 0, 5); Panel3.addBox(0F, -1.5F, 1.5F, 3, 3, 1); Panel3.setRotationPoint(-5F, 17.5F, 0F); Panel3.setTextureSize(128, 32); Panel3.mirror = true; setRotation(Panel3, 0F, 0F, 0F); Panel4 = new ModelRenderer(this, 0, 10); Panel4.addBox(0F, -1.5F, -2.5F, 3, 3, 1); Panel4.setRotationPoint(-5F, 17.5F, 0F); Panel4.setTextureSize(128, 32); Panel4.mirror = true; setRotation(Panel4, 0F, 0F, 0F); //Right side rotor components Panel5 = new ModelRenderer(this, 0, 0); Panel5.addBox(-3F, -2.5F, -1.5F, 3, 1, 3); Panel5.setRotationPoint(5F, 17.5F, 0F); Panel5.setTextureSize(128, 32); Panel5.mirror = true; setRotation(Panel5, 0F, 0F, 0F); Panel6 = new ModelRenderer(this, 0, 15); Panel6.addBox(-3F, 1.5F, -1.5F, 3, 1, 3); Panel6.setRotationPoint(5F, 17.5F, 0F); Panel6.setTextureSize(128, 32); Panel6.mirror = true; setRotation(Panel6, 0F, 0F, 0F); Panel7 = new ModelRenderer(this, 0, 5); Panel7.addBox(-3F, -1.5F, 1.5F, 3, 3, 1); Panel7.setRotationPoint(5F, 17.5F, 0F); Panel7.setTextureSize(128, 32); Panel7.mirror = true; setRotation(Panel7, 0F, 0F, 0F); Panel8 = new ModelRenderer(this, 0, 10); Panel8.addBox(-3F, -1.5F, -2.5F, 3, 3, 1); Panel8.setRotationPoint(5F, 17.5F, 0F); Panel8.setTextureSize(128, 32); Panel8.mirror = true; setRotation(Panel8, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5){ super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5, entity); PedestalOne.render(f5); PedestalTwo.render(f5); PedestalThree.render(f5); Stator.render(f5); RotorLeft.render(f5); RotorRight.render(f5); Panel1.render(f5); Panel2.render(f5); Panel3.render(f5); Panel4.render(f5); Panel5.render(f5); Panel6.render(f5); Panel7.render(f5); Panel8.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); } } Any help would be appreciated. There is probably a really easy fix for this but I am just overlooking it. -mcrafter
October 10, 201411 yr Hi Although you're not using static variables any more, it won't help because Blocks are "singletons" anyway. A Block instance stores information about the capabilities of a block, not about the state of the block. Minecraft uses metadata for that. http://greyminecraftcoder.blogspot.com.au/2013/07/blocks.html Since you've figured out how to receive redstone signal, I'd suggest the easiest way is probably to store the redstone signal status in the block metadata. When you render the block, retrieve the metadata and change your render based on that. BlockTrapDoor does this, for example. Cheers TGG
October 10, 201411 yr Author Thank you so much! I have been trying so hard to figure this out on my own. It never occurred to me to use metadata. I was actually trying to make the model render from the block class. Haha. Edit: I'm still confused about how to do this. I need to rotate a part of my model rapidly in succession to create the illusion of motion. How can I make it so that when there is a redstone signal the part will spin, without using public static in my model class file?
October 10, 201411 yr Hello. Since you got a tileEntity, you can store in it the values for the rotation of your model. Use updateEntity to change a variable called rotation (or the name you choose, usually public float). Since every tileEntity is unique, in the renderer you can import the tileEntity for xCoord, yCoord and zCoord (TileEntity tile = world.getTileEntity() and cast it to the entity you are talking about) and then take that particular rotation (tile.rotation), then aplly it to the figure you want to rotate (render.figureX(tile.rotation)). for example: TileEntity public void updateEntity() { if (!worldObj.isRemote) { } else { BatRotation += 0.05F; } } renderer 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( "AncientCraft:textures/blocks/BatteryReceptacle.png")); Minecraft.getMinecraft().renderEngine.bindTexture(textures); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); TileEntityBatReceptacle tileBat = (TileEntityBatReceptacle) te; stack = tileBat.getStackInSlot(0); if (stack != null) { if (stack.getItem() == AncientCraft.ItemCorruptBattery) { this.model.batteryRotation = true; } } else { this.model.batteryRotation = false; } //THIS IS THE PLACE I CHANGE ROTATION //getBatRotation is a function of the tileEntity i made because BatRotation is private. this.model.Battery.rotateAngleY = tileBat.getBatRotation(); int meta = te.getBlockMetadata(); this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, meta); GL11.glPopMatrix(); GL11.glPopMatrix(); }
October 11, 201411 yr Author Hello. Since you got a tileEntity, you can store in it the values for the rotation of your model. Use updateEntity to change a variable called rotation (or the name you choose, usually public float). Since every tileEntity is unique, in the renderer you can import the tileEntity for xCoord, yCoord and zCoord (TileEntity tile = world.getTileEntity() and cast it to the entity you are talking about) and then take that particular rotation (tile.rotation), then aplly it to the figure you want to rotate (render.figureX(tile.rotation)). for example: TileEntity public void updateEntity() { if (!worldObj.isRemote) { } else { BatRotation += 0.05F; } } renderer 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( "AncientCraft:textures/blocks/BatteryReceptacle.png")); Minecraft.getMinecraft().renderEngine.bindTexture(textures); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); TileEntityBatReceptacle tileBat = (TileEntityBatReceptacle) te; stack = tileBat.getStackInSlot(0); if (stack != null) { if (stack.getItem() == AncientCraft.ItemCorruptBattery) { this.model.batteryRotation = true; } } else { this.model.batteryRotation = false; } //THIS IS THE PLACE I CHANGE ROTATION //getBatRotation is a function of the tileEntity i made because BatRotation is private. this.model.Battery.rotateAngleY = tileBat.getBatRotation(); int meta = te.getBlockMetadata(); this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F, meta); GL11.glPopMatrix(); GL11.glPopMatrix(); } Would you mind posting the code that is in your TileEntity class please?
October 30, 201410 yr Author The ONLY thing I need to know is how to make it so I only affect the one block instead of all of the blocks in the world. I cannot put TileEntity tile = world.getTileEntity() because there is no reference to "world." in my renderer class.
October 30, 201410 yr The ONLY thing I need to know is how to make it so I only affect the one block instead of all of the blocks in the world. I cannot put TileEntity tile = world.getTileEntity() because there is no reference to "world." in my renderer class. You already have a reference to tileEntity, you don't need the world, but you do need to store the rotation in the tileEntity like Jordor suggested. Such as: public class BlueSirenTileEntity extends TileEntity { public float rotation = 0; } then in the Block, instead of changing the model, change the rotation of the TileEntity: if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)){ if (world.isRemote) ((BlueSirenTileEntity)world.getTileEntity(par2, par3, par4)).rotation += 0.05F; } then just use ((BlueSirenTileEntity)tileentity).rotation in your renderTileEntityAt method to determine how to render the model.
October 31, 201410 yr Author Thank you so much! That little line of code is the only thing I needed to prevent myself from smashing my face into my keyboard! BUT all of the blocks rotate, not just the one I power. What am I doing wrong? EDIT: Oops! I had old code in my updateEntity() method. It's working perfectly. Thanks!
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.