Jump to content

TheArni

Members
  • Posts

    5
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

TheArni's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Right now I think the textures are bugged. Have you tried on clicking the "Resource Packs" button? That reloads the textures. I hope I helped and that I explained correctly
  2. OK, solved, I tried casting the doubles to ints, so tileEntity.worldObj.getBlockTileEntity((int) x,(int) y,(int) z); But i though that it didn't work because of the casting, but it actually was because it was null, there was no entity there... at least now it doesn't crash, but now it doesn't render. OK, my job here it's done. PD: Also thanks ChickenBones from the DW20 Irc, you helped me a lot, and I'm sorry to wasted your time D:
  3. Please any idea? I tried to use: tileEntity.worldObj.getBlockTileEntity(int x, int y, int z) but that didn't work because in the models i only have this values on double format and I don't know why x.intValue doesn't work. Help me please!
  4. Mmmm well, all that... I'm working arround, but it actually can update the TileEntity's vars. But it can't access it in the rendering process, so now I must care of the client side. Later I will test the mod with my friends... When I get a stable build...
  5. First of all, hello everyone, I'm TheArni (I'm sure you have noticed it...) and I'm new to the Forge Forums . I'm working on a mod a couple of months ago: GasCraft. So, the problem I'm recently having is that I need to access to a variable of the TileEntity when I render it. But apparently, in the TileEntitySpecialRender class, in the method renderTileEntityAt() it gives me a copy of the class of the TileEntity, but I need the object because every TileEntity is different. BTW, I do this because every block renders different. It's essentially a pipe, and to *optimize* the rendering I only check the state of the pipe on block update, so I need to store it somewhere. Long story short: I need to acces a specific TileEntity in the world because the method doesn't give the Tile in question, otherwise the class/type. Oh, I hope I have explained correctly. Code: PipeRender.class package TheArni.GasCraft.Render; import TheArni.GasCraft.Models.ModelPipe; import TheArni.GasCraft.Pipes.TileEntity.GasPipe_softCopper; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; public class PipeRender extends TileEntitySpecialRenderer { static final float scale = (float) (1.0 / 16.0); private ModelPipe Pipe = new ModelPipe(scale); @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float tick) { Pipe.render((GasPipe_softCopper)tileEntity, x, y, z); int Blockx = tileEntity.xCoord; int Blocky = tileEntity.xCoord; int Blockz = tileEntity.xCoord; System.out.println(((GasPipe_softCopper)tileEntity).connectivity_0); } } GasPipe_softCopper.class package TheArni.GasCraft.Pipes.TileEntity; import TheArni.GasCraft.GasCraft; import TheArni.GasCraft.Network.IGasNetwork; import TheArni.GasCraft.Network.IGasNetworkMachine; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class GasPipe_softCopper extends TileEntity { public IGasNetwork network; public boolean connectivity_0, connectivity_1, connectivity_2, connectivity_3; public GasPipe_softCopper(){ } public void checkConectivity(World world, int BlockX, int BlockY, int BlockZ){ if(world.getBlockId(BlockX+1, BlockY, BlockZ) == GasCraft.GasPipe1.blockID){ this.connectivity_3 = true; } else if(world.getBlockTileEntity(BlockX+1, BlockY, BlockZ) instanceof IGasNetworkMachine){ if(((IGasNetworkMachine)world.getBlockTileEntity(BlockX+1, BlockY, BlockZ)).canConectPipes()==true){ this.connectivity_3 = true; } } else this.connectivity_3 = false; if(world.getBlockId(BlockX, BlockY, BlockZ+1) == GasCraft.GasPipe1.blockID){ this.connectivity_0 = true; } else if (world.getBlockTileEntity(BlockX, BlockY, BlockZ+1) instanceof IGasNetworkMachine){ if(((IGasNetworkMachine)world.getBlockTileEntity(BlockX, BlockY, BlockZ+1)).canConectPipes()==true){ this.connectivity_0 = true; } } else this.connectivity_0 = false; if(world.getBlockId(BlockX-1, BlockY, BlockZ) == GasCraft.GasPipe1.blockID){ this.connectivity_1 = true; } else if(world.getBlockTileEntity(BlockX-1, BlockY, BlockZ) instanceof IGasNetworkMachine){ if(((IGasNetworkMachine)world.getBlockTileEntity(BlockX-1, BlockY, BlockZ)).canConectPipes()==true){ this.connectivity_1 = true; } } else this.connectivity_1 = false; if(world.getBlockId(BlockX, BlockY, BlockZ-1) == GasCraft.GasPipe1.blockID){ this.connectivity_2 = true; } else if(world.getBlockTileEntity(BlockX, BlockY, BlockZ-1) instanceof IGasNetworkMachine){ if(((IGasNetworkMachine)world.getBlockTileEntity(BlockX, BlockY, BlockZ-1)).canConectPipes()==true){ this.connectivity_2 = true; } } else this.connectivity_2 = false; System.out.println("Connectiviy checked, values are:"+connectivity_0+connectivity_1+connectivity_2+connectivity_3); } } ModelPipe.class package TheArni.GasCraft.Models; import org.lwjgl.opengl.GL11; import TheArni.GasCraft.GasCraft; import TheArni.GasCraft.Pipes.TileEntity.GasPipe_softCopper; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.client.ForgeHooksClient; public class ModelPipe extends ModelBase { //fields ModelRenderer Pipe1; ModelRenderer Pipemid; ModelRenderer Pipe2; ModelRenderer Pipe3; ModelRenderer Pipe4; private float scale; public ModelPipe(float scale) { this.scale = scale; textureWidth = 64; textureHeight = 32; Pipemid = new ModelRenderer(this, 20, 0); Pipemid.addBox(0F, 0F, 0F, 4, 3, 4); Pipemid.setRotationPoint(6F, 0F, 6F); Pipemid.setTextureSize(64, 32); Pipemid.mirror = true; Pipe1 = new ModelRenderer(this, 0, 16); Pipe1.addBox(0F, 0F, 0F, 6, 3, 4); Pipe1.setRotationPoint(0F, 0F, 6F); Pipe1.setTextureSize(64, 32); Pipe1.mirror = true; Pipe2 = new ModelRenderer(this, 0, 0); Pipe2.addBox(0F, 0F, 0F, 4, 3, 6); Pipe2.setRotationPoint(6F, 0F, 0F); Pipe2.setTextureSize(64, 32); Pipe2.mirror = true; Pipe3 = new ModelRenderer(this, 0, 9); Pipe3.addBox(0F, 0F, 0F, 6, 3, 4); Pipe3.setRotationPoint(10F, 0F, 6F); Pipe3.setTextureSize(64, 32); Pipe3.mirror = true; Pipe4 = new ModelRenderer(this, 0, 23); Pipe4.addBox(0F, 0F, 0F, 4, 3, 6); Pipe4.setRotationPoint(6F, 0F, 10F); Pipe4.setTextureSize(64, 32); Pipe4.mirror = true; } public void render(float scale) { Pipe1.render(scale); Pipemid.render(scale); Pipe2.render(scale); Pipe3.render(scale); Pipe4.render(scale); } public void render(GasPipe_softCopper tile, double x, double y, double z) { GL11.glPushMatrix(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glTranslated(x, y, z); ForgeHooksClient.bindTexture("/TheArni/GasCraft/Textures/SoftCopperPipe.png", 0); variableRender(tile); Pipemid.render(scale); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } private void variableRender(GasPipe_softCopper tile) { if(tile.connectivity_0) Pipe4.render(scale); if(tile.connectivity_1) Pipe1.render(scale); if(tile.connectivity_2) Pipe2.render(scale); if(tile.connectivity_3) Pipe3.render(scale); //System.out.println(tile.connectivity_0); } } Thanks a lot. If you need something else, tell me! PD: I'm still working on 1.4.7 . I've got a lot of problems to solve before the mod-crushing 1.5.1 update
×
×
  • Create New...

Important Information

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