Posted August 8, 201312 yr Im trying to make it so that when you finish my multiblock, it renders a model, ive set up the multiblock correctly, but setting the boolean that allows the model to render isnt working. heres my code: multiblock function @Override public void onBlockAdded(World World, int x, int y, int z) { TileEntityHolomap teh = new TileEntityHolomap(); System.out.println("isMultiBlock called"); if(!teh.shouldRender) System.out.println("holomap tileentity is set to not render, checking multiblock"); if(World.getBlockId(x+1, y, z+1) == Lyoko.blockHolomap.blockID && World.getBlockId(x+1, y, z) == Lyoko.blockHolomap.blockID && World.getBlockId(x+1, y, z-1) == Lyoko.blockHolomap.blockID && World.getBlockId(x, y, z+1) == Lyoko.blockHolomap.blockID && World.getBlockId(x, y, z) == Lyoko.blockHolomapProjector.blockID && World.getBlockId(x, y, z-1) == Lyoko.blockHolomap.blockID && World.getBlockId(x+1, y, z+1) == Lyoko.blockHolomap.blockID && World.getBlockId(x-1, y, z+1) == Lyoko.blockHolomap.blockID && World.getBlockId(x-1, y, z) == Lyoko.blockHolomap.blockID && World.getBlockId(x-1, y, z-1) == Lyoko.blockHolomap.blockID) { System.out.println("Holomap Projector Complte"); ((TileEntityHolomap)teh).shouldRender = true; } } tile entity: package codelyoko.Client; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.INetworkManager; import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet132TileEntityData; import net.minecraft.tileentity.TileEntity; public class TileEntityHolomap extends TileEntity{ public boolean shouldRender = false; @Override public Packet getDescriptionPacket() { NBTTagCompound tag = new NBTTagCompound(); this.writeToNBT(tag); return new Packet132TileEntityData(xCoord, yCoord, zCoord, 0, tag); } @Override public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) { NBTTagCompound tag = pkt.customParam1; this.readFromNBT(tag); } @Override public void readFromNBT(NBTTagCompound tagCompound) { super.readFromNBT(tagCompound); this.shouldRender = tagCompound.getBoolean("shouldRender"); } @Override public void writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); tagCompound.setBoolean("shouldRender", this.shouldRender); } } Tile Entity render: package codelyoko.Client; 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.util.ResourceLocation; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; import codelyoko.common.Lyoko; import codelyoko.models.ModelHolomapProjector; import codelyoko.models.ModelSuperComputerInterface; import codelyoko.models.ModelTowerConsole; import codelyoko.models.ModelTowerFloor; public class TileEntityRenderHolomap extends TileEntitySpecialRenderer{ //This method is called when minecraft renders a tile entity public static Minecraft mc = Minecraft.getMinecraft(); public static String modelfile = ""; public void renderTileEntityAt(TileEntity tileEntity, double d, double d1, double d2, float f) { GL11.glPushMatrix(); //This will move our renderer so that it will be on proper place in the world GL11.glTranslatef((float)d, (float)d1, (float)d2); /*Note that true tile entity coordinates (tileEntity.xCoord, etc) do not match to render coordinates (d, etc) that are calculated as [true coordinates] - [player coordinates (camera coordinates)]*/ renderBlockYour(tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, Lyoko.blockHolomapProjector); GL11.glPopMatrix(); } //And this method actually renders your tile entity public void renderBlockYour(World world, int i, int j, int k, Block block) { TileEntityHolomap teh = (TileEntityHolomap) world.getBlockTileEntity(i, j, k); if(teh.shouldRender) { if(this.modelfile.equals("")) { System.out.println("Loading Holomap Model: Default"); ModelHolomapProjector model = new ModelHolomapProjector(); Tessellator tessellator = Tessellator.instance; //This will make your block brightness dependent from surroundings lighting. float f = block.getBlockBrightness(world, i, j, k); int l = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int l1 = l % 65536; int l2 = l / 65536; tessellator.setColorOpaque_F(f, f, f); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)l1, (float)l2); GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0, 0.0F); //This line actually rotates the renderer. GL11.glRotatef(0F, 0F, 1F, 0F); GL11.glTranslatef(0.5F, -0.5F, 0.5F); mc.renderEngine.func_110577_a(new ResourceLocation("codelyoko:textures/blocks/HolomapProjector.png")); model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } } } } ive had the block create the tile entity, registered it, bound the renderer to the tile entity, any one know whats happening? cause i dont [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
August 8, 201312 yr can you make println to see where its failing ? how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
August 8, 201312 yr Author well i can tell that the multiblock is working cause the 'holomap projector complete' line is printed. im not sure where i would put the println [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
August 8, 201312 yr Hmm i'd set a breakpoint at the place where you set the value to true and see what happens and what the server and client is doing? Also using breakpoints you could make the program pause whenever the variable is changed, so you can see if it's switched back and forth between true and false If you guys dont get it.. then well ya.. try harder...
August 8, 201312 yr Author thanks ill try that [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
August 28, 201312 yr Well, my guess is it's something to do with packets. None of my tileentity variables are being retained. I'm adding packet handling code now. I'll report back with how I go.
August 28, 201312 yr At the start of my onBlockPlacedBy I had if (!world.isRemote){ onBlockPlacedBy When I removed that it worked. But, I'll probably sort out the packet handling stuff, anyway.
August 28, 201312 yr Author whoah thanks. Like alot, now i can do multiBlocks! [shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]
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.