Jump to content

when multiblock is complete, render model?


KeeganDeathman

Recommended Posts

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]

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 3 weeks later...

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.