Everything posted by lexwebb
-
1.6.4 - Line rendering - not seeing lines!
ThaT helped! I set the translation to the par 2 4 6 and it is now in the right place relative to the world. Only issue now, is that it will start at the right place. But the line will continue on forever. Do I need to do anything more with the tessalator?
-
1.6.4 - Line rendering - not seeing lines!
Bump!
-
1.6.4 - Line rendering - not seeing lines!
Thanks for the link to the minecraft code, i was looking for that! I now have a line! Although it appears to render relative to the player now.. here is my amended code. List<Position> laserToList = ent.laserToList; if (laserToList != null && laserToList.size() > 1) { // System.out.println("LOL"); for (int i = 0; i < laserToList.size() - 1; i++) { // System.out.println(laserToList.get(i).toString()); // System.out.println(laserToList.get(i + 1).toString()); double doubleX = ent.xCoord; double doubleY = ent.yCoord; double doubleZ = ent.zCoord; GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glTranslated(0, 0, 0); GL11.glColor3ub((byte)255,(byte)0,(byte)0); GL11.glLineWidth(10.0F); float mx1 = ent.xCoord - (float) laserToList.get(i + 1).x; float my1 = ent.yCoord - (float) laserToList.get(i + 1).y; float mz1 = ent.zCoord - (float) laserToList.get(i + 1).z; float mx2 = ent.xCoord - (float) laserToList.get(i + 1).x; float my2 = ent.yCoord - (float) laserToList.get(i + 1).y; float mz2 = ent.xCoord - (float) laserToList.get(i + 1).z; Tessellator tessellator = Tessellator.instance; tessellator.startDrawing(3); tessellator.addVertex(mx1, my1, mz1); tessellator.addVertex(mx2,my2, mz2); tessellator.draw(); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_BLEND); GL11.glPopMatrix(); } } else { // System.out.println(laserToList.size()); } I am now changing the coordinates for the laser origin and end points so that they are relative to the TE as you suggested: TE position - laser origin position
-
1.6.4 - Line rendering - not seeing lines!
So, I'm trying to render a series of lines to represent lasers. I am sending a packet from server to client that will add a series of coords into a list on my tile-entity. I am then picking this list up from my Tile-Entity renderer and trying to display lines from point to point; please see the code below. List<Position> laserToList = ent.laserToList; if (laserToList != null && laserToList.size() > 1) { // System.out.println("LOL"); for (int i = 0; i < laserToList.size() - 1; i++) { System.out.println(laserToList.get(i).toString()); System.out.println(laserToList.get(i + 1).toString()); double doubleX = Minecraft.getMinecraft().thePlayer.posX - 0.5; double doubleY = Minecraft.getMinecraft().thePlayer.posY + 0.1; double doubleZ = Minecraft.getMinecraft().thePlayer.posZ - 0.5; GL11.glPushMatrix(); GL11.glTranslated(-doubleX, -doubleY, -doubleZ); GL11.glColor3ub((byte)255,(byte)0,(byte)0); float mx1 = (float) laserToList.get(i + 1).x; float my1 = (float) laserToList.get(i + 1).y; float mz1 = (float) laserToList.get(i + 1).z; float mx2 = (float) laserToList.get(i + 1).x; float my2 = (float) laserToList.get(i + 1).y; float mz2 = (float) laserToList.get(i + 1).z; GL11.glBegin(GL11.GL_LINES); GL11.glVertex3f(mx1, my1, mz1); GL11.glVertex3f(mx2, my2, mz2); GL11.glEnd(); GL11.glPopMatrix(); } } else { // System.out.println(laserToList.size()); } This code is definitely getting hit, as you can see in my client console output: 2014-01-16 19:15:41 [iNFO] [sTDOUT] {150.0, 64.0, 273.0} 2014-01-16 19:15:41 [iNFO] [sTDOUT] {150.0, 64.0, 270.0} The issue is, i am not seeing my lines at all! What am i doing wrong!
-
Entity not Rendering!
Well now I feel dumb! Thanks for your help in clearing this one up
-
Entity not Rendering!
So you know where the problem lies with the entity? I was originally going to use a tileentity for this, but then i also want it to go through transparent surfaces, e.g glass.. so an entity seemed like a better solution. If i cant get it to work ill go back to a tileentity and just make it only go through air.
-
Entity not Rendering!
I know for sure that this is called, as I can insert a println in there and it will output to the console
-
Entity not Rendering!
Thanks for the reply, I seem to be doing similar things, but im not trying to spawn a mob so its slightly different. My code can be found here if you want a more detailed look: https://github.com/lexwebb/opticraft/
-
Entity not Rendering!
Updated the part which actually initiates the Entity: for(int i = this.yCoord; i <= linkedDetector.y - 1; i++){ if (!worldObj.isRemote){ EntityBeam entity = new EntityBeam(worldObj, "UD"); entity.setPosition(xCoord, yCoord + i, zCoord); worldObj.spawnEntityInWorld(entity); //worldObj.playSoundEffect((double)xCoord + 0.5D, (double)yCoord + 0.5D, (double)zCoord + 0.5D, "random.fizz", 0.1F, worldObj.rand.nextFloat() * 0.1F + 0.9F); } } It appears from my debug line the renderer is never getting called. But it is getting initiated... No one got any idea?
-
Getting items from a chest at a specific side and inserting into a specific side
Have a look at TileEntityFurnace ISidedInventory code, its quite useful
- Entity not Rendering!
-
Entity not Rendering!
I'm trying to render a custom entity, pretty simple really. but my rendering code never seems to get called, what am I doing wrong? Entity package opticraft.entitys; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; public class EntityBeam extends Entity { public String orientation; public EntityBeam(World par1World, String orientation) { super(par1World); this.orientation = orientation; } @Override protected void entityInit() { } @Override protected void readEntityFromNBT(NBTTagCompound nbttagcompound) { // TODO Auto-generated method stub } @Override protected void writeEntityToNBT(NBTTagCompound nbttagcompound) { // TODO Auto-generated method stub } } Render package opticraft.render; import opticraft.entitys.EntityBeam; import opticraft.lib.ModInfo; import opticraft.lib.Names; import opticraft.models.BeamModel; import org.lwjgl.opengl.GL11; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.client.renderer.entity.Render; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class BeamRenderer extends Render{ private final BeamModel model; private String orientation = "LR"; public BeamRenderer() { this.model = new BeamModel(); System.out.println("RENDER CONSTRUCTED"); } private void adjustRotatePivotViaMeta(World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); GL11.glPushMatrix(); GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F); GL11.glPopMatrix(); } //Set the lighting stuff, so it changes it's brightness properly. private void adjustLightFixture(World world, int i, int j, int k, Block block) { Tessellator tess = Tessellator.instance; float brightness = block.getBlockBrightness(world, i, j, k); int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0); int modulousModifier = skyLight % 65536; int divModifier = skyLight / 65536; tess.setColorOpaque_F(brightness, brightness, brightness); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) modulousModifier, divModifier); } @Override public void doRender(Entity entity, double x, double y, double z, float f, float f1) { System.out.println("RENDER CALLED"); //The PushMatrix tells the renderer to "start" doing something. GL11.glPushMatrix(); //This is setting the initial location. GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); //This is the texture of your block. It's pathed to be the same place as your other blocks here. //Outdated bindTextureByName("/mods/roads/textures/blocks/TrafficLightPoleRed.png"); //Use in 1.6.2 this ResourceLocation textures = (new ResourceLocation(ModInfo.ID.toLowerCase() + ":textures/blocks/beamTile.png")); //the ':' is very important //binding the textures Minecraft.getMinecraft().renderEngine.bindTexture(textures); //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again! GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); //A reference to your Model file. Again, very important. this.model.render((Entity)entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //Tell it to stop rendering for both the PushMatrix's GL11.glPopMatrix(); GL11.glPopMatrix(); model.LR.isHidden = true; model.FB.isHidden = true; model.TB.isHidden = true; EntityBeam ent = (EntityBeam) entity; orientation = ent.orientation; if(orientation == "LR") model.LR.isHidden = false; else if(orientation == "FB") model.FB.isHidden = false; else if(orientation == "UD") model.TB.isHidden = false; else{ model.LR.isHidden = false; model.FB.isHidden = false; model.TB.isHidden = false; } } @Override protected ResourceLocation getEntityTexture(Entity entity) { return new ResourceLocation(ModInfo.ID.toLowerCase() + ":textures/blocks/beamTile.png"); } } Client Proxy package opticraft.proxies; import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.MinecraftForgeClient; import opticraft.Opticraft; import opticraft.entitys.EntityBeam; import opticraft.entitys.TileEntityItemLaser; import opticraft.entitys.TileEntityLaserDetector; import opticraft.entitys.TileEntitySolarCollector; import opticraft.items.ItemLaserWrench; import opticraft.lib.Ids; import opticraft.render.BeamRenderer; import opticraft.render.ItemLaserRenderer; import opticraft.render.LaserDetectorRenderer; import opticraft.render.LaserWrenchRenderer; import opticraft.render.SolarCollectorRenderer; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.EntityRegistry; public class ClientProxy extends CommonProxy{ @Override public void initRenderers() { } @Override public void initSounds() { } public void registerRenderThings() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityItemLaser.class, new ItemLaserRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySolarCollector.class, new SolarCollectorRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserDetector.class, new LaserDetectorRenderer()); RenderingRegistry.registerEntityRenderingHandler(EntityBeam.class, new BeamRenderer()); MinecraftForgeClient.registerItemRenderer(Ids.laserWrench + 256, (IItemRenderer)new LaserWrenchRenderer()); } } Main class package opticraft; import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.MinecraftForgeClient; import opticraft.blocks.Blocks; import opticraft.client.gui.GuiHandler; import opticraft.entitys.EntityBeam; import opticraft.entitys.TileEntityItemLaser; import opticraft.entitys.TileEntityLaserDetector; import opticraft.entitys.TileEntitySolarCollector; import opticraft.items.Items; import opticraft.items.ItemLaserWrench; import opticraft.lib.Ids; import opticraft.lib.ModInfo; import opticraft.proxies.CommonProxy; import opticraft.render.LaserWrenchRenderer; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION) @NetworkMod (channels = {ModInfo.CHANNEL}, clientSideRequired = true, serverSideRequired = true) public class Opticraft { private GuiHandler guiHandler = new GuiHandler(); @Instance public static Opticraft instance = new Opticraft(); @SidedProxy( clientSide = ModInfo.PROXY_LOCATION + ".ClientProxy", serverSide = ModInfo.PROXY_LOCATION + ".CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.initRenderers(); proxy.initSounds(); Items.init(); Items.addNames(); Blocks.init(); Blocks.addNames(); } @EventHandler public void init(FMLInitializationEvent event) { NetworkRegistry.instance().registerGuiHandler(this, guiHandler); EntityRegistry.registerModEntity(EntityBeam.class, "EntityBeam", EntityRegistry.findGlobalUniqueEntityId(), this, 128, 1, true); proxy.registerRenderThings(); GameRegistry.registerTileEntity(TileEntityItemLaser.class, "tileEntityItemLaser"); GameRegistry.registerTileEntity(TileEntitySolarCollector.class, "tileEntitySolarCollector"); GameRegistry.registerTileEntity(TileEntityLaserDetector.class, "tileEntityLaserDetector"); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } }
-
[Solved] Custom IItemRenderer not showing model
Thanks TTG! it was shouldUseRenderHelper(INVENTORY_BLOCK) returns true that i needed. Here is a screenshot of everything working nicely! thanks both of you for you help
-
[Solved] Custom IItemRenderer not showing model
Wahey! It displays everywhere but the inventory!, where I just get an invisible item. My code for that part is below, see any issues? } else if(type == ItemRenderType.INVENTORY){ RenderBlocks blockRenderer = (RenderBlocks)data[0]; //Entity entity = (Entity)data[1]; // entity holding the item GL11.glPushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(ModInfo.ID.toLowerCase() + ":textures/items/LaserWrench.png")); float scale = 0.7F; GL11.glScalef(scale, scale, scale); GL11.glRotatef(180, 1, 0, 0); // Forward-Backwards Up-Down model.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); }
-
[Solved] Custom IItemRenderer not showing model
Thanks for all the help guys, I realised that the way I was doing the ID's was ignoring Minecraft adding 255 to the ID, I just added 255 into the register item render code and it solved it. My rendering was all messed up, so thanks for help fixing that red!
-
[Solved] Custom IItemRenderer not showing model
Yeah its alled along with those other renderers, which do register. The Both the item and that use the Ids.LaserRench constant
-
[Solved] Custom IItemRenderer not showing model
Having added some debug code, it appears that renderItem in the renderer is never getting called. Which is weird, as my code is pretty darn similar in every other aspect.
-
[Solved] Custom IItemRenderer not showing model
That's the code i adapted for this. Does the vanilla item need a texture? Also i cannot see it in 3rd person
-
[Solved] Custom IItemRenderer not showing model
The texture shouldn't matter as its just place holder code, this is meant to be a custom modelled 3D item
-
[Solved] Custom IItemRenderer not showing model
I am trying to make a custom rendered tool that will show its model in first and third person. However at the moment it is only showing a blank texture. My ClientProxy is as follows: package opticraft.proxies; import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.MinecraftForgeClient; import opticraft.entitys.TileEntityBeam; import opticraft.entitys.TileEntityItemLaser; import opticraft.entitys.TileEntityLaserDetector; import opticraft.entitys.TileEntitySolarCollector; import opticraft.items.LaserWrench; import opticraft.items.LaserWrenchRenderer; import opticraft.lib.Ids; import opticraft.render.BeamRenderer; import opticraft.render.ItemLaserRenderer; import opticraft.render.LaserDetectorRenderer; import opticraft.render.SolarCollectorRenderer; import cpw.mods.fml.client.registry.ClientRegistry; public class ClientProxy extends CommonProxy{ @Override public void initRenderers() { } @Override public void initSounds() { } public void registerRenderThings() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityItemLaser.class, new ItemLaserRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySolarCollector.class, new SolarCollectorRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBeam.class, new BeamRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityLaserDetector.class, new LaserDetectorRenderer()); MinecraftForgeClient.registerItemRenderer(Ids.laserRench, (IItemRenderer)new LaserWrenchRenderer()); } } LaserWrench Item: package opticraft.items; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import opticraft.lib.Ids; import opticraft.lib.ModInfo; import opticraft.lib.Names; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class LaserWrench extends Item{ public LaserWrench(int par1) { super(par1); setMaxStackSize(1); this.setCreativeTab(CreativeTabs.tabTools); this.setUnlocalizedName(Names.laserRench_unlocalizedName); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IconRegister icon) { itemIcon = icon.registerIcon(ModInfo.ID.toLowerCase() + ":" + "Error"); } @Override public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase target) { return false; } @Override public int getSpriteNumber() { return 0; } } LaserWrench Renderer: package opticraft.items; import opticraft.lib.ModInfo; import opticraft.models.ItemLaserModel; import opticraft.models.LaserWrenchModel; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.IItemRenderer; public class LaserWrenchRenderer implements IItemRenderer { protected LaserWrenchModel model; public LaserWrenchRenderer() { model = new LaserWrenchModel(); } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return false; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { if (type == ItemRenderType.EQUIPPED) { RenderBlocks blockRenderer = (RenderBlocks)data[0]; EntityLiving entity = (EntityLiving)data[1]; // entity holding the item GL11.glPushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(ModInfo.ID.toLowerCase() + ":textures/items/LaserWrench.png")); float scale = 1.4F; GL11.glScalef(scale, scale, scale); GL11.glRotatef(90, -1, 0, 0); GL11.glRotatef(85, 0, 0, 1); GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(135, 1, 0, 0); GL11.glTranslatef(-0.1F, -0.5F, 0.5F); // Left-Right // Forward-Backwards Up-Down model.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } } }
-
[Solved] TileEntity Inventory Can't add or remove items
Well now i just feel stupid! Thanks!
-
[Solved] TileEntity Inventory Can't add or remove items
Thanks! I have fixed the not being able to click items by adding missing code to getServerGuiElement to return my Container (Updated on GitHub). However, now when I try and access the inventory the windows instantly closes. Any ideas?
-
[Solved] TileEntity Inventory Can't add or remove items
I have made a custom TileEntity that has a single slot inventory. However, when I try to click an item in the created inventory, it just drops the item. It seems like a client/server desync, but I'm not sure. Also, when i shift click i get this error spammed to my console: 2013-11-21 20:30:25 [iNFO] [sTDOUT] at net.minecraft.inventory.Container.retrySlotClick(Container.java:520) 2013-11-21 20:30:25 [iNFO] [sTDOUT] at net.minecraft.inventory.Container.slotClick(Container.java:291) It repeats so much that i cannot view the actual error, which is very useful... My code can be found here: https://github.com/lexwebb/opticraft TileEntity: https://github.com/lexwebb/opticraft/blob/master/entitys/TileEntityItemLaser.java Block: https://github.com/lexwebb/opticraft/blob/master/blocks/ItemLaserBlock.java Container: https://github.com/lexwebb/opticraft/blob/master/blocks/containers/ItemLaserContainer.java GuiHandler: https://github.com/lexwebb/opticraft/blob/master/client/gui/GuiHandler.java If there's anything I missed please let me know! Thanks in advance!
-
Call readFromNBT on TileEntity create
Thanks, having come from Bukkit modding im used ot doing it that way
-
Call readFromNBT on TileEntity create
No matter what i try i cannot seem to get my TileEntity to read its NBT data on create. Saving works fine though. The 'Code' button does not work for me so here's a paste of my code: http://puu.sh/5hjt0.txt
IPS spam blocked by CleanTalk.