Jump to content

ninjapancakes87

Members
  • Posts

    81
  • Joined

  • Last visited

Everything posted by ninjapancakes87

  1. For your item, I dont know whats wrong with it. You have the same code as me. Also, you posted theblock class not the render class
  2. Do you have the render code? Theres probably an error in there. That or you are trying to calculate lighting.
  3. Pretty smart actually For two blocks if u need help, pm me, the block I use with a custom model is two blocks long, so its far more complex because its not like a chest. If it is like a chest, good luck Just wondering, you should try 3D in-hand models. They look really cool and are fairly simple
  4. Could I inquire what mod ur making? Thats an interesting model and I cant think what you would use that for
  5. So did you make a custom model for your block, or what do you mean by custom rendered?
  6. Alright so turns out thats not what I did. I dont know why, but for some reason my metadata values are 2, 3, 4, and 5. Also my render code draws from a getMetadata method I made. For some reason, all this stuff works and it didnt with the obvious solution. My getMetadata method is just two lines, and it returns the metadata of that instance of a tile entity in the given world.
  7. Oh yes, about the metadata. I forgot to mention that i believe you need to add that as a nbt tag in your tile entity. It will force save the metadata. Im pretty sure thats how I have it, I can double check when I get home.
  8. That's what I already have. I get the ItemStack in the slot, and then do .getItem(). It still returns null when an item is in it. Is there anything else?
  9. Ive never used a # before in code. How do I use it?
  10. This took me forever to figure out. What ou have to do is in your onBlockPlacedBy method int par7 = MathHelper.floor_double((double)(par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; . This will get the rotation of the player who placed your block. Then, based on that number (it will return 0, 1, 2, or 3) set the metadata of the block. Next, go into the render code. Do int rotation = TileEntityWhatever.getMetadata(). Then set your rotation to a scale of 90. Lastly, do GL11.glRotatef(scale, 0.0F, 1.0F, 0.0F); This render part is really confusing, so i've posted my render code. @Override public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { TileEntityCannon cannonTE = (TileEntityCannon)tileentity; this.bindTexture(texture); GL11.glPushMatrix(); GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); GL11.glScalef(1.0F, -1F, -1F); int rotation = cannonTE.getMetadata( ); if(rotation == 3){ scale = -90; } if(rotation == 2){ scale = 90; } if(rotation == 5){ scale = 180; } if(rotation == 4){ scale = 0; } GL11.glRotatef(scale, 0.0F, 1.0F, 0.0F); GL11.glRotatef(90, 0, 1.0F, 0); this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } Im only feeding you code because this was very difficult and time consuming to figure out
  11. How do you retrieve what item is in the given slot of a custom gui? Im trying to get whats in slot 0 and 1 of my custom cannon block, and the this.te.getStackInSlot(0).getItem() always returns null. I made sure I did private ItemStack[] cannonItemStacks = new ItemStack[2];[/code} in my Tile Entity. Is there a different method that should be used?
  12. Looks like you forgot to do GameRegistry.registerTileEntity Back on topic, I have a tile entity myself that doesn't save it's byte "rotation." after debugging, I came to the same conclusion, it doesn't save on world reload. Using a getter and setter doesn't change anything. I think your solution may lie in the block metadata. Have you tried writing your number to your block's metadata? I know that metadata saves correctly, so could you just set your block metadata as your random number?
  13. *Don't know why I didn't think of that* For some reason it's not reading right. It reads the rotation as 0, when originally it was 2. This weekend I will try having it draw from the metadata. Did I correctly set the NBT tag in my tile entity?
  14. I did. I set the metadata of the block and i set a byte rotation, which i write to NBT in the tile entity. I diid some debug code, and the block stays rotated, but the model doesnt. Also, it reads fine from NBT, but for some reason it doesnt re-render the model when i reload the world.
  15. I have a block I am making, and it has a custom model. The model is two blocks long, so when you place it, it rotates according to the direction you are facing. The problem is, when I reload the world, it resets the rotation of the model, but not the rotation of the block itself. Does anybody know how to fix this? TileEntityCannon: TileEntityCannonRenderer: Thanks in advance, ninjapancakes87.
  16. just use a switch statement. set the default to whatever you want, I believe you wanted it to be blockIcon
  17. Your problem isn't with your texture. It's with a sound. According to your error log, there is a problem with it playing the step sound for the block. Line 2303 in Render Global, the line causing the problem, is this: this.mc.sndManager.playSound(block.stepSound.getBreakSound(), (float)par3 + 0.5F, (float)par4 + 0.5F, (float)par5 + 0.5F, (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); Since it's throwing a null, that means there is no getBreakSound() is returning null, when it should return the Step Sound Try calling this.setStepSound("sound name here"); in your constructor
  18. I tried using the newest build of forge, it doesnt fix it still. I don't see why it doesnt work though.
  19. TileEntityRenderer: package ninjapancakes87.civilwar.block.cannon; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import ninjapancakes87.civilwar.Extras; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class TileEntityCannonRenderer extends TileEntitySpecialRenderer { private static final ResourceLocation texture = new ResourceLocation(Extras.sb + "cannon.png"); /** The cannon model */ private Cannon model; /** Instance of renderManager, super one is not visible*/ protected RenderManager renderManager; public TileEntityCannonRenderer() { this.model = new Cannon(); } /** * Used for rendering the tile entity * @param tileentity is the tile entity you are using * @param d0 used for translation on the X axis * @param d1 used for translation on the Y axis * @param d2 used for translation on the Z axis * @param f is not used for anything (at least in mine). */ @Override public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { TileEntityCannon cannonTE = (TileEntityCannon)tileentity; GL11.glPushMatrix(); GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); GL11.glScalef(1.0F, -1F, -1F); short scale = getScale(cannonTE.getRotation()); GL11.glRotatef(scale, 0.0F, 1.0F, 0.0F); GL11.glRotatef(90, 0, 1.0F, 0); this.func_110628_a(texture); this.model.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } public short getScale(byte rotation){ short scale = 0; if(rotation == 2){ scale = 0; } if(rotation == 3){ scale = 180; } if(rotation == 4){ scale = -90; } if(rotation == 5){ scale = 90; } return scale; } public void rotate(short scale){ GL11.glPushMatrix(); GL11.glRotatef(scale, 0, 1, 0); GL11.glRotatef(90, 0, 1.0F, 0); GL11.glPopMatrix(); } } CannonRender: package ninjapancakes87.civilwar.block.cannon; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; import ninjapancakes87.civilwar.Extras; import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.FMLClientHandler; //@SideOnly(Side.CLIENT) public class CannonRender implements IItemRenderer { private static final ResourceLocation texture = new ResourceLocation(Extras.sb + "cannon.png"); protected RenderManager renderManager; private Cannon model; public CannonRender() { model = new Cannon(); } @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) { switch (type) { case ENTITY: { renderCannon(-0.5F, 0.0F, 0.5F, 0.25F, 0F, 0F, 0F, 0F, 0); return; } case EQUIPPED: { renderCannon(1.0F, 5.1F, 3.0F, 0.25F, 180F, 0F, 0F, 0F, 0); return; } case EQUIPPED_FIRST_PERSON: { renderCannon(0.0F, 6.0F, 0.0F, 0.25F, -90F, -110F, 0F, 90F, 1); return; } case INVENTORY: { renderCannon(-1.0F, 2.2F, -0.1F, 0.23F, 180F, 0F, 0F, 0F, 0); return; } default: return; } } private void renderCannon(float x, float y, float z, float scale, float rotate, float r1, float r2, float r3, float a) { GL11.glPushMatrix(); GL11.glDisable(GL11.GL_LIGHTING); // Scale, Translate, Rotate GL11.glScalef(scale, scale, scale); GL11.glTranslatef(x, y, z); GL11.glRotatef(rotate, r1, r2, r3); if( a == 1){ GL11.glRotatef(rotate, r1, r2, r3); } // Bind texture //this.renderManager.renderEngine.func_110577_a(texture); FMLClientHandler.instance().getClient().renderEngine.func_110577_a(texture); // Render model.render((Entity)null,0.0F, 0.0F, 0.0F, 0.0F, 0.0F, scale); GL11.glEnable(GL11.GL_LIGHTING); GL11.glPopMatrix(); } }
  20. Yes I have a TileEntityRenderer and a BlockRenderer. In my TileEntityRenderer is my code for rendering the block, and in the BlockRenderer is for rendering the block as 3D in my inventory, in my hand, on the ground, etc. Does the model being 3D affect that?
×
×
  • Create New...

Important Information

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