Jump to content

Recommended Posts

Posted

Hey, I have this setup to register a bunch of simular blocks;

 

    	
    	String[] vanillaBlocks = {"Brick", "Stone", "Stone_Brick", //all vanilla blocks};
    	
    	for(int i = 0; i < vanillaBlocks.length; i++){    		
    		allLarge = new LargeColumnProperties(Material.rock).setBlockName("ModelColumn" + vanillaBlocks[i]).setHardness(20.0F).setResistance(1.0F);
    		GameRegistry.registerBlock(allLarge, "ModelColumn" + vanillaBlocks[i]);
    		GameRegistry.registerTileEntity(TileEntityBlock.class, "ModelColumn" + vanillaBlocks[i]);
    	}
    	

 

In game I can only ever see my model in hand for the last registered block, the other blocks just the the texture colour filling the blocks inventory slot.

 

I wouldn't have though I need to change this, but here is my hand renderer.

 

public class HandEntityRenderer implements IItemRenderer {

TileEntitySpecialRenderer render;
private TileEntity entity;


public HandEntityRenderer(TileEntitySpecialRenderer render, TileEntity entity) {
	this.entity = entity;
	this.render = render;
}	

@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) {
	if(type == IItemRenderer.ItemRenderType.ENTITY)

		GL11.glTranslatef(-0.5F, 0.0F, -0.5F);

	this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F);
}

}

 

In my client proxy I have

 

	//All Large Columns
	TileEntitySpecialRenderer allLarge = new TileEntityRendererLargeColumn(KimptonCore.allLarge.getUnlocalizedName().substring(5), 1);
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlock.class, allLarge);
	MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(KimptonCore.allLarge), new HandEntityRenderer(allLarge, new TileEntityBlock()));

 

Where it says, new TileEntityBlock() - I made this class empty, its pretty much a placeholder, can it only handle one block at a time? :L

 

- All the best.

Posted

1. Why do you use IItemRenderer instead of TileEntitySpecialRenderer?

2. To have TileEntity block must extend BlockContainer and have function

@Override
    public TileEntity createNewTileEntity(World world, int i) {
        return new TileEntityBlock();
    }

3. Also you should register your TileEntityBlock

GameRegistry.registerTileEntity(TileEntityBlock.class, "tileEntityBlock");

4. What do you want to do?  :-\

Posted

I actually don't know - I was taught how todo this by a friend ''this is how all modders do this'' he says. So if you were me, you'd rewrite your client proxy? Ha?

Posted

http://gyazo.com/4dbbf53279b0a9213f1d9c382c6d76df

 

Here you can see the problem visually. Both of these blocks are registered here:

 

    	String[] vanillaBlocks = new String[]{
    			"Stone", "Brick" //all blocks I want
    	};
    	
    	for(int i = 0; i < vanillaBlocks.length; i++){    		
    		allLarge = new LargeColumnProperties(Material.rock).setBlockName("ModelColumn" + vanillaBlocks[i]).setHardness(20.0F).setResistance(1.0F);
    		GameRegistry.registerBlock(allLarge, "ModelColumn" + vanillaBlocks[i]);
    		GameRegistry.registerTileEntity(TileEntityBlock.class, "ModelColumn" + vanillaBlocks[i]);
    	}

 

in my client proxy to register the icon I have:

 

@Override
public void renderInfomation(){		
	/* Tile Entity Renderer Columns :
	 * INDEX
	 * 1 = ModelLargeColumn
	 * 2 = ModelMediumColumn
	 * 3 = ModelSmallColumn
	*/			

	//All Large Columns
	TileEntitySpecialRenderer allLarge = new TileEntityRendererLargeColumn(KimptonCore.allLarge.getUnlocalizedName().substring(5), 1);
	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlock.class, allLarge);
	MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(KimptonCore.allLarge), new HandEntityRenderer(allLarge, new TileEntityBlock()));		
        }

 

and in my HandEntityRenderer I have:

 

public class HandEntityRenderer implements IItemRenderer {

TileEntitySpecialRenderer render;
private TileEntity entity;


public HandEntityRenderer(TileEntitySpecialRenderer render, TileEntity entity) {
	this.entity = entity;
	this.render = render;
}

@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) {
	if(type == IItemRenderer.ItemRenderType.ENTITY)

		GL11.glTranslatef(-0.5F, 0.0F, -0.5F);

	this.render.renderTileEntityAt(this.entity, 0.0D, 0.0D, 0.0D, 0.0F);
}

}

 

 

THIS CODE DOESNT DO ANYTHING FOR MY PROBLEM BUT YOU MENTIONED IT

 

Here is my special renderer:

 

public class TileEntityRendererLargeColumn extends TileEntitySpecialRenderer{

private ModelLargeColumn model;
private ResourceLocation texture;

public TileEntityRendererLargeColumn(String name, int x){

	switch (x){
	case 1:
		model = new ModelLargeColumn();
		break;
	case 2:
		model = new ModelLargeColumn();
		break;
	}

	this.texture = new ResourceLocation(KimptonCore.modid + ":" + "/textures/blocks/" + name + ".png");
}

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f){

	//Open GL open with PUSH and close with POP
	GL11.glPushMatrix();		
		GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
		GL11.glRotatef(180, 0F, 0F, 1F);			
		this.bindTexture(texture);			
		GL11.glPushMatrix();
			this.model.renderModel(0.0625F);
		GL11.glPopMatrix();			
	GL11.glPopMatrix();		
}
}

 

and I have registered my Tile Entity in my loop at the top :)

Posted

Dude, you can't register a tile entity class more than once. Having it in this loop is pointless.

Registering more than one block when you have a tileentity is also horribly redundant.

Either register one block with its tileentity, or register your bunch of blocks with no tileentity.

 

You also failed to understand that "KimptonCore.allLarge" can only contain one block instance, not all of the blocks you made.

Posted

So you're saying If I want this automation - I'd lose all nice rendering inhand? aha? hmm... :/ That's upsetting :o - the alternative seems like alot of writing haha!

Posted

If you don't need special functionality, and you don't need to store more than 4 bits of data for the block, you may as well look into implementing

[url=http://www.minecraftforge.net/wiki/ISimpleBlockRenderingHandler]ISimpleBlockRenderingHandler[/url]

, and registering the implemented class with the

RenderingRegistry

.

 

This way, you can have several blocks using the same BlockRenderingHandler without resorting to a

TileEntitySpecialRenderer

, and avoiding code duplication.

 

If I recall correctly, registered

ISimpleBlockRenderingHandler

s are also cached, improving performance over a TileEntitySpecialRenderer. I might be wrong, there, though.

 

Either way, it sounds like an

ISimpleBlockRenderingHandler

will suffice in your use case.

 

Enjoy :)

Posted

Hey using ISimpleBlockRenderingHandler - I have to remodel my model? I've made my model in techne... and it spits the code out in a format that isn't tessellator - or can tessellators import techne models?

Posted

I don't know what Techne spits out, but it should be simple to convert it to use tessellators.

 

Failing that, you can call

Tessellator.instance.draw()

in the beginning of your method, and

Tessellator.instance.startDrawingQuads()

in the end. Using the tessellator would be preferred though, I think.

 

Keep in mind the texture atlas containing the icon you set for the block is bound.

 

 

If it's a static block with a single simple texture, though, I don't see why you wouldn't want to just use the tessellator in an ISimpleBlockRenderingHandler.

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.