Posted February 22, 201510 yr Hey guys, got a question. So yesterday I spent all day trying to get my first Techne block to render correctly and set up the code so the block would drop correctly, so those things work. But, in the future I plan to add way more Techne models and I don't want to use multiple classes repeating the same ode over and over again, I want a way to use clean inheritance: You can see in my Block package that I have a BaseJohnnyBlock that extends block, and then all my other blocks in that package simply extend the BaseBlock, that means I need to put a lot less code in my subsequent block classes since all of the hard work for making a block is done in the Base class, such as registering the Block icon, setting a creative tab and getting unlocalized name. However, in my Model package, I don't have a "Base" I can work from, and this also applies to my Renderer packages and classes. In my current system, I'd need to set everything up again, every time I create a new Techne model I wondered if it was possible to make a "Base" TileEntity class and a "Base" renderer class so most of that code would not need to be rewritten I'm pretty sure I'd need to rewrite everything for the actual model.java code produced by Techne, though. Here's my renderer classes: public class ItemRenderJohnnyBlockRubble implements IItemRenderer { TileEntitySpecialRenderer render; private TileEntity entity; public ItemRenderJohnnyBlockRubble(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 == ItemRenderType.ENTITY) GL11.glTranslatef(-0.5F, 0.0F, -0.5F); this.render.renderTileEntityAt(this.entity,0.0D,0.0D,0.0D,0.0F); } } public class RendererJohnnyBlockRubble extends TileEntitySpecialRenderer { private static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID + ":" + "textures/models/johnnyFaceBlockRubble.png" ); private ModelJohnnyRubble model; public RendererJohnnyBlockRubble() { this.model = new ModelJohnnyRubble(); } 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); this.bindTexture(texture); GL11.glPushMatrix(); this.model.renderModel(0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } } and here's my model class public class ModelJohnnyRubble extends ModelBase { //fields ModelRenderer BigChunkOne; ModelRenderer BigChunkOneSideChunkB; ModelRenderer BigChunkTopChunkOne; ModelRenderer BigChunkTwo; ModelRenderer BigChunkOneSideChunkR; ModelRenderer BigChunkTopChunkTwo; public ModelJohnnyRubble() { textureWidth = 64; textureHeight = 64; BigChunkOne = new ModelRenderer(this, 11, 17); BigChunkOne.addBox(0F, 21F, -1F, 5, 3, 5); BigChunkOne.setRotationPoint(0F, 0F, 0F); BigChunkOne.setTextureSize(64, 64); BigChunkOne.mirror = true; setRotation(BigChunkOne, 0F, 0.2602503F, 0F); BigChunkOneSideChunkB = new ModelRenderer(this, 0, 19); BigChunkOneSideChunkB.addBox(0F, 0F, 0F, 4, 2, 1); BigChunkOneSideChunkB.setRotationPoint(1F, 22F, 4F); BigChunkOneSideChunkB.setTextureSize(64, 64); BigChunkOneSideChunkB.mirror = true; setRotation(BigChunkOneSideChunkB, 0F, 0.260246F, 0F); BigChunkTopChunkOne = new ModelRenderer(this, 14, 11); BigChunkTopChunkOne.addBox(0F, 0F, 0F, 3, 2, 3); BigChunkTopChunkOne.setRotationPoint(1F, 19F, 0F); BigChunkTopChunkOne.setTextureSize(64, 64); BigChunkTopChunkOne.mirror = true; setRotation(BigChunkTopChunkOne, 0F, 0.260246F, 0F); BigChunkTwo = new ModelRenderer(this, 44, 47); BigChunkTwo.addBox(0F, 0F, 0F, 2, 4, 2); BigChunkTwo.setRotationPoint(-6F, 20F, -5F); BigChunkTwo.setTextureSize(64, 64); BigChunkTwo.mirror = true; setRotation(BigChunkTwo, 0F, 0.3665191F, 0F); BigChunkOneSideChunkR = new ModelRenderer(this, 17, 26); BigChunkOneSideChunkR.addBox(0F, 0F, 0F, 1, 2, 2); BigChunkOneSideChunkR.setRotationPoint(-1F, 22F, 0F); BigChunkOneSideChunkR.setTextureSize(64, 64); BigChunkOneSideChunkR.mirror = true; setRotation(BigChunkOneSideChunkR, 0F, 0.260246F, 0F); BigChunkTopChunkTwo = new ModelRenderer(this, 17, ; BigChunkTopChunkTwo.addBox(0F, -1F, 0F, 2, 1, 1); BigChunkTopChunkTwo.setRotationPoint(2F, 19F, 0F); BigChunkTopChunkTwo.setTextureSize(64, 64); BigChunkTopChunkTwo.mirror = true; setRotation(BigChunkTopChunkTwo, 0F, 0.260246F, 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); BigChunkOne.render(f5); BigChunkOneSideChunkB.render(f5); BigChunkTopChunkOne.render(f5); BigChunkTwo.render(f5); BigChunkOneSideChunkR.render(f5); BigChunkTopChunkTwo.render(f5); } public void renderModel(float f) { //the one we made BigChunkOne.render(f); BigChunkOneSideChunkB.render(f); BigChunkTopChunkOne.render(f); BigChunkTwo.render(f); BigChunkOneSideChunkR.render(f); BigChunkTopChunkTwo.render(f); } 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); } } Here's my clientproxy public class ClientProxy extends CommonProxy { public void registerRenderThings() { //rubble TileEntitySpecialRenderer render = new RendererJohnnyBlockRubble(); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJohnnyBlockRubble.class, render); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.johnnyFaceBlockRubble), new ItemRenderJohnnyBlockRubble(render, new TileEntityJohnnyBlockRubble())); } public void registerTileEntitySpecialRenderer() { } } Think Java is tough? try BrainFuck!
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.