Jump to content

Flayr

Members
  • Posts

    22
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    Nothing in particular.

Flayr's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Okay I don't think I was very clear. Here is my renderer file. package flayr.lensoftruth.tileentities; import i.will.skip.the.imports public class InvisibleBlockRenderer extends TileEntitySpecialRenderer{ @SideOnly(Side.CLIENT) public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { ItemStack heldItem = Minecraft.getMinecraft().thePlayer.getHeldItem(); ItemStack lens = new ItemStack(LensOfTruth.truthLens); if (heldItem != null && ItemStack.areItemStacksEqual(heldItem, lens)) { ResourceLocation rl = new ResourceLocation("lensoftruth:textures/blocks/invisibleBlock.png"); Minecraft.getMinecraft().renderEngine.bindTexture(rl); Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix(); GL11.glTranslated(x, y, z); GL11.glNormal3f(0.0F, 10.0F, 0.0F); // Rendering Code GL11.glPopMatrix(); } } } I have already made a version that used tessalator to individually render all six sides when truthLens is held, however the result looks strange(textures glitch a bit on movement) and it also does not seem like the overall best option. Is there a way to access the regular block rendering code instead?
  2. How do you render a normal looking block within a custom renderer? The renderer changes depending on different factors but sometimes it should look like a regular block, how do I do this without just drawing 6 separate squares with tessalator (it doesn't look right when you do that).
  3. oops! This time I'll type it into my code and make sure it compiles!.... if (Minecraft.getMinecraft().thePlayer.getHeldItem().getItem().itemID == myLightStaffID) { // staff is held so render it } -TGG Okay so if I spawn in lightInv it is invisible and in I make lightInv with the staff it is visible, but whenever I change equip or unequipped the staff respectively it crashes. package flayr.magiclights.tileentities; import java.util.List; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import flayr.magiclights.MagicLights; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraft.world.World; public class LightInvRenderer extends TileEntitySpecialRenderer{ @SideOnly(Side.CLIENT) public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { if (Minecraft.getMinecraft().thePlayer.getHeldItem().getItem().itemID == MagicLights.lightStaff.itemID) { ResourceLocation rl = new ResourceLocation("magiclights:textures/blocks/lightInv.png"); Minecraft.getMinecraft().renderEngine.bindTexture(rl); Tessellator tessellator = Tessellator.instance; GL11.glPushMatrix(); GL11.glTranslated(x+0.5, y+0.5, z+0.5); GL11.glNormal3f(0.0F, 10.0F, 0.0F); GL11.glRotatef(-this.tileEntityRenderer.playerYaw, 0.0F, 1.0F, 0.0F); GL11.glRotatef(this.tileEntityRenderer.playerPitch, 1.0F, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-0.5, 0.5, 0, 1, 0); tessellator.addVertexWithUV(0.5, 0.5, 0, 1, 1); tessellator.addVertexWithUV(-0.5, -0.5, 0, 0, 0); tessellator.addVertexWithUV(0.5, -0.5, 0, 0, 1); tessellator.addVertexWithUV(0.5, -0.5, 0, 1, 0); tessellator.addVertexWithUV(-0.5, -0.5, 0, 0, 0); tessellator.addVertexWithUV(0.5, 0.5, 0, 1, 1); tessellator.addVertexWithUV(-0.5, 0.5, 0, 0, 1); tessellator.draw(); GL11.glPopMatrix(); } } }
  4. That doesnt work, thePlayer does not exist in Minecraft, the problem I have is how to refer to the correct player from within the renderer code. Do you know how to do that?
  5. Thanks for the response, at this point I was already planning on making it check weather the player is holding the staff in the EntityRenderer but I could not find a way to implement the code I used in the block class (it needs the world object as an input to check for players holding the staff). Do you have any ideas for the actual code that I could put in LightRenderer.java that checks if the player is holding the staff?
  6. Sorry, have not been on the forums lately so this response is a bit late. First, here is the GitHub for my sourcecode: https://github.com/TheJawrey/Magic-Lights/ Basically, what the mod does so far is add a single item, Staff of Light(lightStaff in the code) that on right click creates the block Light. The block light can be walked through, seen through and is also not editable without holding the Staff of Light, the object Light also creates a tile entity TileEntityLight that renderers a 2D object witch rotates to face the player. What I need to do is make it so that when you are holding the staff the rendered objects are visible and when the staff is not held they are invisible, basically acting like air that makes light.
  7. AxisAlignedBB aabb = AxisAlignedBB.getAABBPool().getAABB(x-4, y-4, z-4, x+4, y+4, z+4); List w = par1World.getEntitiesWithinAABB(EntityPlayer.class, aabb); if(w.size() > 0) { //at least one player in range EntityPlayer player; for(int i = 0; i < w.size() { player = (EntityPlayer) w.get(i); ItemStack stack = player.getHeldItem(); ItemStack stack2 = new ItemStack(MagicLights.lightStaff); if(ItemStack.areItemStacksEqual(stack, stack2)){ So I wrote code that did change the TileEntity but it was kind of glitchy, I could go back to that but it seems like it would be better to put the code in the Renderer. How would I implement it in the renderer? The only problem is that there is no world object parameter in the renderer method, how would I change this code to work with entities instead of blocks?
  8. You haven't actually used a TileEntity have you? When you (the modder) creates one, you don't have block coordinates. You only have the world: @Override public TileEntity createNewTileEntity(World world) { return new MyTileEntity(); } Vanilla code handles the rest. That is the problem I have, how would i best do the same thing I did with the MovingObjectPosition collisionRayTrace method in a CreateNewTileEntity method because it only has the parameter world.
  9. EDIT: This was solved earlier but then I ran into a problem that stems from this one. So the block that needed to be unelectable when a certain item was held also needs to change what type of tile entity is spawned when this item is held. The problem is that that method does not have x, y and z as parameters so I cannot use the same code. How would I do this? Also, if it would be easier to put the detecting in the renderer to change the texture that would work too. The current code for the original method: @Override public MovingObjectPosition collisionRayTrace(World par1World, int x, int y, int z, Vec3 par5Vec3, Vec3 par6Vec3) { AxisAlignedBB aabb = AxisAlignedBB.getAABBPool().getAABB(x-4, y-4, z-4, x+4, y+4, z+4); List w = par1World.getEntitiesWithinAABB(EntityPlayer.class, aabb); if(w.size() > 0) { //at least one player in range EntityPlayer player; for(int i = 0; i < w.size() { player = (EntityPlayer) w.get(i); ItemStack stack = player.getHeldItem(); ItemStack stack2 = new ItemStack(MagicLights.lightStaff); if(ItemStack.areItemStacksEqual(stack, stack2)){ return super.collisionRayTrace(par1World, x, y, z, par5Vec3, par6Vec3); }else{return null;} } return null; }else{return null;} }
  10. I don't want to store any data I just need to get the coordinates of the block for use in methods, here is an example that would require the x coordinate of the block: public TileEntity createNewTileEntity(World par1world){ if(x>0){ return new TileEntityExample(); }else{ return new TileEntityExample2(); }
  11. I cannot believe that I have to post this, but I can't seem to find the answer by looking through the source. How do I get the coordinates of a block inside it's class as variables that I can use outside of a method that has x y and z as parameters.
  12. It works now, thank you very much for the help!
  13. Well, it is error free now but when I run minecraft i cannot select the block regardless of weather I am holding the staff or not. Here is my current code. @Override public MovingObjectPosition collisionRayTrace(World par1World, int x, int y, int z, Vec3 par5Vec3, Vec3 par6Vec3) { AxisAlignedBB aabb = AxisAlignedBB.getAABBPool().getAABB(x-4, y-4, z-4, x+4, y+4, z+4); List w = par1World.getEntitiesWithinAABB(EntityPlayer.class, aabb); if(w.size() > 0) { //at least one player in range EntityPlayer player; for(int i = 0; i < w.size() { player = (EntityPlayer) w.get(i); if(player.getHeldItem() == new ItemStack(MagicLights.lightStaff)){ return super.collisionRayTrace(par1World, x, y, z, par5Vec3, par6Vec3); }else{return null;} } return null; }else{return null;} }
  14. Here is the method that i am working on: @Override public MovingObjectPosition collisionRayTrace(World par1World, int x, int y, int z, Vec3 par5Vec3, Vec3 par6Vec3) { AxisAlignedBB aabb = AxisAlignedBB.getAABBPool().getAABB(x-4, y-4, z-4, x+4, y+4, z+4); List w = par1World.getEntitiesWithinAABB(EntityPlayer.class, aabb); if(w.size() > 0) { //at least one player in range EntityPlayer player; for(int i = 0; i < w.size(); i++) { [b] player = w.get(i);[/b] } if(player.getHeldItem() == new ItemStack(MagicLights.lightStaff)){ return null; }else{return super.collisionRayTrace(par1World, x, y, z, par5Vec3, par6Vec3);} }else{return super.collisionRayTrace(par1World, x, y, z, par5Vec3, par6Vec3);} } First, is this correct, second I am getting an error on the line "player = w.get(i);"
  15. I was actually having trouble with both things, although checking the players held item was a bigger one. The return statement works perfectly find, but I cannot seem to get it to read the closest player's held item. Could you explain in a bit more what the implementation of this code would be?
×
×
  • Create New...

Important Information

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