Jump to content

Toxicshadow

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by Toxicshadow

  1. Did you have the @SubscribeEvent and all? It should look like: @SubscribeEvent public void onLivingUpdateEvent(LivingUpdateEvent event) { // Code } You'll also need to register the event; have you done that? You should have somewhere (either postInit or a manager called in postInit): MinecraftForge.EVENT_BUS.register(new LivingUpdateClassName()); Lastly make sure you're actually running the register event code, in your postInit method. For organization you might want to make a class that has one method that runs all the register event code, and you call this one method in postInit, instead of a bunch of methods. Up to you though.
  2. What exactly is the context for these? By inventory texture do you mean like, the texture for an item..? Are you replacing the vanilla player model in the second part of this quote? I'm just not sure what you're trying to achieve... As for drawing an entity on the screen as with the inventory, this code is from the GuiInventory class in vanilla minecraft: /** * Draws the entity to the screen. Args: xPos, yPos, scale, mouseX, mouseY, entityLiving */ public static void drawEntityOnScreen(int p_147046_0_, int p_147046_1_, int p_147046_2_, float p_147046_3_, float p_147046_4_, EntityLivingBase p_147046_5_) { GlStateManager.enableColorMaterial(); GlStateManager.pushMatrix(); GlStateManager.translate((float)p_147046_0_, (float)p_147046_1_, 50.0F); GlStateManager.scale((float)(-p_147046_2_), (float)p_147046_2_, (float)p_147046_2_); GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F); float f2 = p_147046_5_.renderYawOffset; float f3 = p_147046_5_.rotationYaw; float f4 = p_147046_5_.rotationPitch; float f5 = p_147046_5_.prevRotationYawHead; float f6 = p_147046_5_.rotationYawHead; GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(-((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); p_147046_5_.renderYawOffset = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 20.0F; p_147046_5_.rotationYaw = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 40.0F; p_147046_5_.rotationPitch = -((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F; p_147046_5_.rotationYawHead = p_147046_5_.rotationYaw; p_147046_5_.prevRotationYawHead = p_147046_5_.rotationYaw; GlStateManager.translate(0.0F, 0.0F, 0.0F); RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager(); rendermanager.setPlayerViewY(180.0F); rendermanager.setRenderShadow(false); rendermanager.renderEntityWithPosYaw(p_147046_5_, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); rendermanager.setRenderShadow(true); p_147046_5_.renderYawOffset = f2; p_147046_5_.rotationYaw = f3; p_147046_5_.rotationPitch = f4; p_147046_5_.prevRotationYawHead = f5; p_147046_5_.rotationYawHead = f6; GlStateManager.popMatrix(); RenderHelper.disableStandardItemLighting(); GlStateManager.disableRescaleNormal(); GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); GlStateManager.disableTexture2D(); GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); } No clue where the model is set, however, as I'm not familiar with the 1.8 rendering system. The fact that Entity.java and EntityLivingBase.java don't have anything to do with models leads me to believe it's handled in some minecraft.client.* file, but you'd have to do some exploration to figure that out.
  3. It just needs to get ran somehow. This can be achieved by hooking into events. Inside the 'onLivingUpdate' event, you can add your code specifically. For my project I actually took code from one of the vanilla mobs and began tweaking it to what I need. If you want to go this route, you could create your own 'renderParticle' method, pass in an EntityLiving or something else with coordinates, and an EnumParticleTypes. For a full list of those, find the EnumParticleTypes file. Not sure how fireworks work yet, so I can't help you with those particles. By doing this, you can skip rewriting a bunch of particle code, but if you only need one thing to have particles, you're better off just copying and modifying code from vanilla mobs.
  4. Ah thank you. I forgot I put the old code code there I see what was going on. I was just passing in a new inventory every time. Thank you!
  5. Alright, so I fixed my issues from earlier. I'm so close to being done with this inventory work. But, after going through CoolAlias' tutorial on inventory, updates and all, my new custom slots don't save. You can place an item in whichever slot, but when you close and reopen the GUI, the item is deleted forever. So sad :'( hehe. So I did some searching, saw some previous posts on this issue but never found any solutions for my issue. Inventory Class: ExtendPlayer: Should be all the code you'd need; I don't think it's a container issue, but idk. Once more, any help is appreciated.
  6. Okay that makes sense, I can do packets, but are you saying I need the open the gui on the server side? If thats what you mean, I can figure it out from here. Either way, thank you!
  7. Did you delete your project by accident? Also did you maybe change where eclipse is looking for your project?
  8. jfc. Sorry. EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; if (ClientProxy.classKey.isPressed()) { FMLNetworkHandler.openGui(player, Rot.instance, 1, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ); } This is where I call the gui. I'm not sure actually... I'll switch that.
  9. oh. public class GuiHandler implements IGuiHandler { @Override public Object getClientGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getTileEntity(new BlockPos(x, y, z)); switch (guiId) { case 0 : if (entity instanceof TileEntityBaseBuilder) { return new GuiBaseNode((TileEntityBaseBuilder) entity, player); } else { return null; } case 1 : { return new GuiPseudoPlayer(player); } default : return null; } } // 0 is base builder // 1 is class Menu @Override public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) { TileEntity entity = world.getTileEntity(new BlockPos(x, y, z)); switch (guiId) { case 0 : if (entity instanceof TileEntityBaseBuilder) { return null; } else { return null; } default : return null; } } } There's code for another GUI, ignore that. You might be looking specifically for the line: return new GuiPseudoPlayer(player); Idk though
  10. Wow haha I'm surprised it looks okay. But the constructor for the class is public GuiPseudoPlayer(EntityPlayer player) { super(new ContainerPseudoPlayer(Minecraft.getMinecraft().thePlayer.inventory, player)); this.player = player; this.xSize = 176; this.ySize = 166; } Is it just because I'm passing in the client player inventory?
  11. Okay so I've been trying to do some inventory work; I ended up just working backwards from vanilla code trying my best, and I actually got items to appear! However they appear because I'm literally just copying the vanilla inventory and rendering it again in a new GUI. The reasoning for this is to add in my own additional slots to go with the vanilla slots. So right now I can get the inventory to render, based on you placing blocks in the vanilla menu, and then opening the new menu. However when you click them it super fast picks the item up and places it right back down. There are plenty of other bugs too, but right now I need the inventory to be interactable first. I don't mean to just dump code and ask "whats wrong" but I honestly no absolutely nothing about inventories/containers except the relationship between the two. I've tried looking at tutorials but the only ones I found were outdated and not the best quality. package ca.grm.rot.gui; import ca.grm.rot.inventory.RotTrinketInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ContainerPseudoPlayer extends Container{ private IInventory pseudoPlayerInventory; @Override public boolean canInteractWith(EntityPlayer playerIn) { return true; } public ContainerPseudoPlayer(final InventoryPlayer realPlayerInventory, EntityPlayer player) { int i; int j; // Inventory for (i = 0; i < 3; ++i) { for (j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(realPlayerInventory, j + (i + 1) * 9, 8 + j * 18, 84 + i * 18)); } } // Hotbar for (i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(realPlayerInventory, i, 8 + i * 18, 142)); } // Trinkets for (i = 0; i < 4; i++) { this.addSlotToContainer(new Slot(new RotTrinketInventory(), i, 26, 8 + i * 18)); } // Armor, literally copy-pasted from container-player for (i = 0; i < 4; ++i) { final int k = i; this.addSlotToContainer(new Slot(realPlayerInventory, realPlayerInventory.getSizeInventory() - 1 - i, 8, 8 + i * 18) { public int getSlotStackLimit() { return 1; } public boolean isItemValid(ItemStack stack) { if (stack == null) return false; return stack.getItem().isValidArmor(stack, k, player); } @SideOnly(Side.CLIENT) public String getSlotTexture() { return ItemArmor.EMPTY_SLOT_NAMES[k]; } }); } } } Any help is appreciated, because right now this code is garbage. I'm just super lost.
  12. Thank you! I had a feeling I'd need to do something like this.
  13. Hi everyone, quick request: I've got a file which we'll call 'ExtendMob' and each EntityLiving gets turned into an ExtendMob object aside from the player. This all works fine, and so I'm trying to change the scaling of the mob's model. I know this can be achieved by all the new model stuff added by 1.8, but that's not what I need. So after looking over the different vanilla files, trying to figure out how the GiantZombie scales, I found the variables 'width' and 'height'; after changing such in a quick experiment I learned that that only has an effect on the bounding box, not the actual model. And then I saw the GiantZombie class uses the 'setSize' method, but to me demise it was protected. Then I embarked on using reflection to invoke the method, and after finally getting it to work, I simply learned that it does the exact same thing as just changing width and height. Is there any way of changing the mob's model scaling in the code, not the asset files? Would I maybe need to do some GL11 wizardry?
  14. Oh my gosh. I feel like an idiot, but thank you! I can get it to work from here, now that it actually rotates
  15. Okay so I've done some changes and I've gotten it to a point where it will render a quad above an entity's head. However it still will not rotate. The code I'm using now is: public void drawUglyQuad(Entity entity, RendererLivingEntity renderer) { double x = (Minecraft.getMinecraft().thePlayer.getPosition().getX() - entity.getPosition().getX()) * -1; double y = (Minecraft.getMinecraft().thePlayer.getPosition().getY() - entity.getPosition().getY()) * -1; double z = (Minecraft.getMinecraft().thePlayer.getPosition().getZ() - entity.getPosition().getZ()) * -1; GL11.glPushMatrix(); Tessellator t = Tessellator.getInstance(); WorldRenderer tw = t.getWorldRenderer(); tw.startDrawingQuads(); GL11.glEnable(GL11.GL_BLEND); GlStateManager.translate(x,y,z); GlStateManager.rotate(-renderer.func_177068_d().playerViewY % 360, 1.0F, 1.0F, 1.0F); GlStateManager.rotate(renderer.func_177068_d().playerViewX, 1.0F, 1.0F, 1.0F); tw.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tw.addVertexWithUV(x,y+2,z, 0, 0); tw.addVertexWithUV(x,y+3,z, 0, 0); tw.addVertexWithUV(x+1,y+3,z, 0, 0); tw.addVertexWithUV(x+1,y+2,z, 0, 0); GL11.glPopMatrix(); t.draw(); } @SubscribeEvent public void handlerRenderLiving(RenderLivingEvent.Pre event) { drawUglyQuad(event.entity, event.renderer); } Any help on getting the rotation to work? I suspect the GlStateManager.translate and .rotate are doing nothing...
  16. Alright it's broken into two methods, which are: public void drawUglyQuad(Entity entity, RendererLivingEntity renderer) { Tessellator t = Tessellator.getInstance(); WorldRenderer tw = t.getWorldRenderer(); tw.startDrawingQuads(); GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); tw.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); GL11.glRotatef(-renderer.func_177068_d().playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(renderer.func_177068_d().playerViewX, 1.0F, 0.0F, 0.0F); tw.addVertexWithUV(0,2,0, 0, 0); tw.addVertexWithUV(0,3,0, 0, 0); tw.addVertexWithUV(1,3,0, 0, 0); tw.addVertexWithUV(1,2,0, 0, 0); GL11.glPopMatrix(); t.draw(); } @SubscribeEvent public void handlerRenderLiving(RenderLivingEvent.Pre event) { drawUglyQuad(event.entity, event.renderer); }
  17. It somewhat helped, atleast for understand the UV section, so thank you for that However the plane I've created still does not rotate...
  18. Okay previously I made a topic asking about using the Tessellator and I was told to just use the GlStateManager and I've really been trying. What I'm trying to do is render a square that rotates with the camera based on the player view. I've been trying to use code from Render.class but it's been a struggle still. Here's what I've got so far: public void drawNameWithHealth(Entity entity, RendererLivingEntity renderer) { Tessellator t = Tessellator.getInstance(); WorldRenderer tw = t.getWorldRenderer(); tw.startDrawingQuads(); GL11.glPushMatrix(); GL11.glEnable(GL11.GL_BLEND); tw.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); GL11.glRotatef(-renderer.func_177068_d().playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(renderer.func_177068_d().playerViewX, 1.0F, 0.0F, 0.0F); tw.addVertex(0,2,0); tw.addVertex(0,3,0); tw.addVertex(1,3,0); tw.addVertex(1,2,0); GL11.glPopMatrix(); t.draw(); } @SubscribeEvent public void handlerRenderLiving(RenderLivingEvent.Pre event) { drawNameWithHealth(event.entity, event.renderer); } And when I run it, the player gets an ugly semi-transparent square to the upper left of it's model. This is okay, however even though I'm calling GlStateManager.rotate, it does not rotate. Also if you're wondering, the function func_177068_d() does, is it simply returns a RenderManager because the variable renderManager is protected and thus I cannot call renderer.renderManager, but this is essentially what I'm doing. The reason i'm calling the renderer.func_177068_d() code is because in the Render.class, they use GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); to achieve the effect I desire. What am I doing wrong and how can I fix it? Thank you! Edit: Changed GlStateManager to GL11 so it all uses GL11 instead of some of each.
  19. In my attempt to use the GlStateManager I gave the player a permanent superman-pose disability. While I won't ask for a tutorial on using GlStateManager, how do you access the statemanager for a Tessellator and a WorldRenderer object? The vanilla code on this doesn't make much sense to me...
  20. Apologies. Totally spaced it, but it's indeed 1.8.
  21. Not to be rude because I might not understand your question but have you tried: import domain.package1.package2.Filename; In seriousness I think this is what you want: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fconcepts-13.htm if that doesn't help try [lmgtfy=where to place external resources in eclipse]this.[/lmgtfy]
  22. Hey everyone, Lately I've been working with the Tessellator, and it's almost nice. It seems that most people who use it, use it for blocks or for GUIs, however I'm not using it for either. Instead I'm trying to render a box above entity heads. So far this is going okay, except it obviously doesn't rotate because I haven't set the vertices to update with the client. The actual code for the vertices is just: // tw is just a worldrenderer from a tessellator object. tw.addVertex(0,2,0); tw.addVertex(0,3,0); tw.addVertex(1,3,0); tw.addVertex(1,2,0); Like I said this works fine, but I am lost as to how to get this to rotate with the client. So I did some searching in the vanilla code and it looks like they handle it slightly differently. Their code for rotation is: GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); Because I'm using Tessellator and not a GlStateManager, I'm not sure how to go about this. Any help would be appreciated!
  23. Okay thanks. I saw the Predicate but the lack of naming tripped me up. The actual part I got confused on was: public WorldGenMinable(IBlockState p_i45630_1_, int p_i45630_2_) { this(p_i45630_1_, p_i45630_2_, BlockHelper.forBlock(Blocks.stone)); } I thought this was the only definition of something to replace. But I now see that I missed public WorldGenMinable(IBlockState p_i45631_1_, int p_i45631_2_, Predicate p_i45631_3_) { this.oreBlock = p_i45631_1_; this.numberOfBlocks = p_i45631_2_; this.field_175919_c = p_i45631_3_; } Thank you guys!
×
×
  • Create New...

Important Information

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