Jump to content

espda

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by espda

  1. Not sure what was wrong, but I totally rewrote the code and it's working now. Probably a stupid mistake that I didn't make the second time. Thanks for the help.
  2. Thanks a lot for the quick response. I fixed the error you pointed out, but it doesn't seem to have corrected the issue. Still, thanks for pointing it out. You probably just prevented me from having another problem down the line.
  3. Hi fellow Minecrafters! As you can probably tell by my post count, I'm pretty new to modding Minecraft. I have a reasonable knowledge of Java and OOP in general, though nowhere near professional level. I've had good success with creating items, standard blocks, recopies and creating custom blocks. I'm now trying to create a block with a custom model, but I'm running into some trouble. My block appears in creative, can be placed and has a collision box, but stubbornly refuses to render. I simply get a empty box where the model should be. I assume it is a problem with either my model or my custom renderer. I've replaced my model with a simple cube, to see if it was the model file, but it still won't work. I've poured over the tutorial I've been following several times, but as far as I can tell, I'm doing it right. I know I'm probably making a stupid mistake somewhere, but I just can't seem to find it. If someone out there wouldn't mind giving me a hand, could you take a look at my code and let me know what I'm doing wrong? I'd really appreciate it. package emptyskies.testblock; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class TestBlockBlock extends BlockContainer { //Treat it like a normal block here. The Block Bounds are a good idea - the first three are X Y and Z of the botton-left corner, //And the second three are the top-right corner. public TestBlockBlock(Block TrafficLight, Material iron) { super(Material.iron); this.setCreativeTab(CreativeTabs.tabMisc); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); this.setBlockName("TestBlock"); this.setHardness(10.0F); //Time to break. Stone = 1.5F, Obsidian = 50.0F this.setResistance(10.F); //Explosion resistance. Stone = 10.0F, Obsidian = 2000.0F this.setHarvestLevel("Pickaxe", 0); //Effective tool and needed level. Wood = 0, Stone = 1, Iron = 2, Diamond = 3 this.setTickRandomly(false); //Does it get random updates? true / false this.setStepSound(soundTypeGravel); //Sets how it sounds when you step on it } //You don't want the normal render type, or it wont render properly. @Override public int getRenderType() { return -1; } //It's not an opaque cube, so you need this. @Override public boolean isOpaqueCube() { return false; } //It's not a normal block, so you need this too. public boolean renderAsNormalBlock() { return false; } @Override public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { // TODO Auto-generated method stub return null; } } Block Entity: -Seems silly to put this in, but what the hey package emptyskies.testblock; import net.minecraft.tileentity.TileEntity; public class TestBlockEntity extends TileEntity { } Model: package emptyskies.testblock; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class TestBlockModel extends ModelBase { //fields ModelRenderer Shape1; public TestBlockModel() { textureWidth = 64; textureHeight = 64; Shape1 = new ModelRenderer(this, 0, 0); Shape1.addBox(0F, 0F, 0F, 10, 10, 10); Shape1.setRotationPoint(0F, 0F, 0F); Shape1.setTextureSize(64, 64); Shape1.mirror = true; setRotation(Shape1, 0F, 0F, 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); Shape1.render(f5); } 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); } } Renderer: package emptyskies.testblock; import org.lwjgl.opengl.GL11; 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.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class TestBlockRenderer extends TileEntitySpecialRenderer { private final TestBlockModel model; public TestBlockRenderer() { this.model = new TestBlockModel(); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); ResourceLocation textures = (new ResourceLocation("emptyskies:textures/blocks/testBlock.png")); Minecraft.getMinecraft().renderEngine.bindTexture(textures); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); this.model.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F); GL11.glPopMatrix(); GL11.glPopMatrix(); } } Thanks for any help you can provide. I apologize in advance if I'm doing something really stupid.
×
×
  • Create New...

Important Information

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