Jump to content

TheNuclearDuck

Members
  • Posts

    39
  • Joined

  • Last visited

Everything posted by TheNuclearDuck

  1. In this particular case, the server-side of the mod isn't always needed. The mod will run without the server-side, just with some of its features disabled (I have the server-side send a packet to notify the client that it's there and turn those features on). I don't want to spam @SideOnlys everywhere so I'll stick to only invoking those classes that refer to client-only stuff from the client.
  2. I'm working on updating a very heavily client-sided mod. The only part of the mod that needs to run on the server side is a couple of event handlers, which only send IMessage packets back to the client for the main part of the mod to handle. Since a server-only JAR of this mod would be tiny, be very easy to debug and update and not cause problems with @SideOnly, would it be a good idea to cut the server stuff completely from the client mod and create a new, server-only mod for the event handlers? Is there a better way to handle this situation? Edit: Does using @SideOnly(Side.CLIENT) on classes and fields which are guaranteed to be accessed only on the client side make any difference to performance? I don't know too much about Java class loading so I'm not sure if those classes would ever be loaded regardless, or even read from the JAR file.
  3. FIXED! The solution wasn't exactly what you said, but your findings did cause me to look into a few things. First, I rendered the whole texture so I could see better, then I looked into RenderItem#renderEffect(). I found that some of my calculations were weirdly flipped (*8 instead of /8, for example). I think this was actually part of a previous attempt to fix the problem, someone suggested using the reciprocal. Either way, that caused the animation to work properly again (did have to mess around with the bound texture, though...) Thank you RANKSHANK!
  4. GitHub. This is for 1.7.10, but none of the code has changed apart from things like replacing .addVertexWithUV from Tessellator to WorldRenderer.
  5. Not directly a solution, but the error on the additional quads sounds like an undersized UV area. I've messed around previously with the Glint for a shield esque overlay and when its UV coords aren't displaced enough you get gaps akin to what you've described because it 'zooms' in on the textures. Why would the UVs have changed at all between me rendering these two quads (the only thing inbetween is a regular quad, drawTexturedModalRect). I wouldn't thought it was some OpenGL state that's now changed in 1.8... Hmm. I wish I could say I had any ideas.
  6. I've been able to draw the enchantment effect over a quad in 1.7.10, using the following method: /** Bits which are modified while rendering item glints, so must be pushed/popped. * @see #drawTexturedGlintRect(int, int, int, int, int, int) */ public static final int GL_GLINT_BITS = GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_TRANSFORM_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT; /** Render an 'item glint' over the specified quad with the currently bound texture for clipping. * @param x X coordinate of the top-left * @param y Y coordinate of the top-left * @param u Texture X coordinate, in pixels * @param v Texture Y coordinate, in pixels * @param width The width of the quad to draw, in pixels * @param height The height of the quad to draw, in pixels * @see ItemRenderer#renderItem(net.minecraft.entity.EntityLivingBase, ItemStack, int, net.minecraftforge.client.IItemRenderer.ItemRenderType) */ public void drawTexturedGlintRect(int x, int y, int u, int v, int width, int height) { mc.mcProfiler.startSection("glint"); // Push bits we modify to restore later on glPushAttrib(GL_GLINT_BITS); glDepthFunc(GL_EQUAL); glDisable(GL_LIGHTING); glEnable(GL_BLEND); // Mapped OpenGL constants from [768, 1, 1, 0] OpenGlHelper.glBlendFunc(GL_SRC_COLOR, GL_ONE, GL_ONE, GL_ZERO); glColor4f(0.38F, 0.19F, 0.608F, 1.0F); // #61309B, light purple tint mc.getTextureManager().bindTexture(RES_ITEM_GLINT); glMatrixMode(GL_TEXTURE); long time = Minecraft.getSystemTime(); // Rect #1 glPushMatrix(); glScalef(0.125F, 0.125F, 0.125F); glTranslatef((float) (time % 3000L) / 3000.0F * 8.0F, 0.0F, 0.0F); glRotatef(-50.0F, 0.0F, 0.0F, 1.0F); this.drawTexturedModalRect(x, y, u, v, width, height); glPopMatrix(); // Rect #2 glPushMatrix(); glScalef(0.125F, 0.125F, 0.125F); glTranslatef((float) (time % 4873L) / 4873.0F * -8.0F, 0.0F, 0.0F); glRotatef(10.0F, 0.0F, 0.0F, 1.0F); this.drawTexturedModalRect(x, y, u, v, width, height); glPopMatrix(); glPopAttrib(); mc.mcProfiler.endSection(); } This works perfectly, if I run it after drawTexturedModalRect. It was ripped and slightly modified from vanilla's method for rendering over items, but since item rendering has changed a lot between 1.7.10 and 1.8 it no longer works. The new method of rendering items seems to be so complicated that I can't find any new method of doing this. In 1.8, this code sort of works correctly, for the first quad I draw it over. Any further quads cause the texture to remain blank for most of the time, then very quickly the entire enchantment texture moves across the quad and disappears again for a second or two. Any ideas on how this same effect can be achieved in 1.8?
  7. Thank you all. I got it working, using a custom EntityItem class and Item#createEntity(). I can now render exactly how I want!
  8. As I have found from a couple of older threads and other sites, item rendering in 1.8 does not apply any transformation to items on the ground or in item frames. Therefore, the only way to make your model smaller is to scale it down in its default state. I want to scale down an item when it is thrown. However, I would like it to remain the same size in the player's inventory and everywhere else, and I want to use an inbuilt model (i.e. generated from the texture of the item). I just want the same model smaller when it's dropped. What do I do?
  9. I'm back. After a release of the mod, and me being sure everything was working perfectly again, I found out I was wrong. Here we are again, same issue, absolutely no reason I can think of why. Seems like putting any code at all into a RenderGameOverlayEvent causes the problem. Ugh...
  10. Writing a new post here, because I think I actually do have a solution. I updated Minecraft Forge... Turns out I must've been using one of the early development versions rather than any of the newer ones which work properly. Why I hadn't tried that earlier, I can't fathom.
  11. SOLUTION! "You could try copying drawRect into your own class, and slowly whittling down further until you get to the statement which causes the issue. Apart from that I'm stuck, sorry!" Before I saw this post, this is what I started doing. I copied over drawRect into my own RenderUtil class and, as you said, whittled it down. Somehow, that came up with a solution. Now, what I find most baffling is what was causing the problem. It was with this line: GlStateManager.enableBlend(); Even though all I could find in this method was a lot of abstraction from GL11.glEnable(GL11.GL_BLEND), removing that line and replacing it with glEnable directly somehow fixed the problem. (I also removed the disabling blending part, because I imagine other parts of the GUI need blending enabled, e.g. chat). Weird how MC's own rendering manager can cause such a glitch, when it has such a simple task to do. I couldn't even find another line of active code that would have changed anything, just lots and lots of wrapper. Anyway, it's a solution, I don't know why it's a solution, but it is. Thank you for your help, TheGreyGhost. EDIT: Not really a solution... Sigh. I was so happy having fixed this thing, I thought everything was great, then I typed something into the chat. The back of the chat box (which is translucent) now has the same issue. I have nothing but my own version of drawRect in my render method now, with all the methods from GlStateManager replaced with raw GL (I don't trust that thing anymore...). I've tried just leaving GL_BLEND replaced, to no avail. When the time is evening, I look towards the sunset and the chat box becomes orange tinted, and I look away and it goes blue again. This pretty much confirms the skybox is definitely interfering with rendering somehow. But I'm not doing a single thing to let that happen. Oh, and it's still affecting the hotbar, after I've typed a message into chat.
  12. No luck. I was already using glPushAttrib and glPushMatrix. I tried removing them, and interestingly, removing glPushAttrib and glPopAttrib (GL_ALL_ATTRIB_BITS) actually fixed the problem... Partially. When I did that, the problem appeared whenever I was looking at the skybox and not the terrain, then went away again afterwards. However, since I do change some GL states during my rendering, I can't keep it like this (and it only makes more errors, anyway...). So, I started removing parts to see if the error would fix. In the end, I managed to narrow the entire problem down to Minecraft's vanilla function, Gui.drawRect. I managed to narrow down my entire rendering code to the following, and the same problem persisted: @SubscribeEvent(priority = EventPriority.LOWEST) // We want this to render last out of everything public void onRenderTick(RenderGameOverlayEvent.Post e) { if(mc == null) mc = Minecraft.getMinecraft(); if(fr == null) fr = mc.fontRendererObj; if(ri == null) ri = mc.getRenderItem(); if(e.type == RenderGameOverlayEvent.ElementType.ALL) { if(mc != null && mc.ingameGUI != null && fr != null && mc.thePlayer != null) { glPushAttrib(GL_ALL_ATTRIB_BITS); { glPushMatrix(); { GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); mc.ingameGUI.drawRect(5, 5, 105, 105, 0xaaffffff); } glPopMatrix(); } glPopAttrib(); } } } Removing that one call to drawRect solves the problem, but then of course I'm not rendering anything. Drawing strings, interestingly, does not cause the problem. Looking into the code from drawRect, the only rendering code is the following: float f3 = (float)(color >> 24 & 255) / 255.0F; float f = (float)(color >> 16 & 255) / 255.0F; float f1 = (float)(color >> 8 & 255) / 255.0F; float f2 = (float)(color & 255) / 255.0F; Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); GlStateManager.enableBlend(); GlStateManager.disableTexture2D(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); GlStateManager.color(f, f1, f2, f3); worldrenderer.startDrawingQuads(); worldrenderer.addVertex((double)left, (double)bottom, 0.0D); worldrenderer.addVertex((double)right, (double)bottom, 0.0D); worldrenderer.addVertex((double)right, (double)top, 0.0D); worldrenderer.addVertex((double)left, (double)top, 0.0D); tessellator.draw(); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); Nothing here appears out of the ordinary, right? It enables, then disables blending, same with texture2D but reversed. Fiddling with blending or texture2D does absolutely nothing in my rendering code, regardless of whether I use MC's "GLStateManager" or just pure GL11 functions. Only thing I can think of now is the "tryBlendFuncSeparate" function, which I doubt would cause an issue... I'm completely stuck for ideas. EDIT: drawTexturedModalRect also doesn't cause the problem (the last bound texture before my method was the font texture, if it's useful).
  13. Hello, I hook into RenderGameOverlayEvent, and check for ElementType.ALL to ensure everything only renders once. The event is lowest priority, so it should render last. Within the event I render several things to the GUI, including text, items, textured quads, and some transparent textured quads. The transparency seems to break the rendering engine somehow, because whenever I render anything with a transparent colour, the following happens to the hotbar and every other transparent part of the HUD: Everything gets weirdly bright, and I can't work out what's causing it. It seems to correspond with the day/night cycle, since at night this stops happening. Do I have to disable the day/night lighting system somewhere? I've tried various combinations of the following set of lines: GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Along with trying to bind textures, enabling and disabling GL_LIGHTING or GL_TEXTURE_2D. All the usual fixes don't seem to work here. Does anyone know what's going on? What's interesting is that depending on the ElementType, sometimes this doesn't happen. However, every type I've tried so far has screwed up another part of the vanilla HUD somehow. None of my rendering methods contain any code outside of vanilla functions (drawTexturedModalRect, drawString, bindTexture...) and the OpenGL functions above - I have also used glPushMatrix and glPopMatrix when necessary. Thank you for reading.
  14. Seems the issue is gone, turns out the issue was that I hadn't set a glBlendFunc, so I just used the usual GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA and the issue appears to have disappeared. Thanks for your help, though!
  15. I'm attempting to create a custom rendered block, which will use a model from Techne. I've got everything rendering fine, except at random intervals I enccounter a weird lighting bug. I've tried using tessellator light values, disabling lighting, and nothing works. The rendered block switches between the two images seen below - the first (darker) one is the correct one. Here's the rendering code I have at the moment: @Override public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { TileEntityCrystal te = ((TileEntityCrystal) tileentity); float[] components = colors[tileentity.getBlockMetadata()]; glPushMatrix(); { glEnable(GL_BLEND); glColor4f(components[0], components[1], components[2], 0.8F); double offsetX = (double) te.getOffsetX() / 512.0; double offsetZ = (double) te.getOffsetZ() / 512.0; glTranslated(d0 + 0.5 + offsetX, d1 + 1.5D, d2 + 0.5 + offsetZ); glRotatef(te.getRotation() / 255F * 360F, 0, 1, 0); glRotatef(180, 0F, 0F, 1F); this.bindTexture(texture); model.render(null, 0, 0, 0, 0, 0, 0.0625F, te.getDensity()); // 1/16 glDisable(GL_BLEND); } glPopMatrix(); } Any ideas? PS: the black variation of the block doesn't show up at all instead of becoming brighter. I assume this is linked to the same glitch...
  16. Well, here's the loop I'm using to draw all the blocks: RenderItem renderItem = new RenderItem(); String[] i = blocks.split(";"); for(int x = 0; x < i.length; x++) { if(i[x].contains("m")) { String[] z = i[x].split("m"); renderItem.renderItemAndEffectIntoGUI(this.fontRenderer, this.mc.renderEngine, new ItemStack(Integer.parseInt(z[0]), 1, Integer.parseInt(z[1])), this.width / 2 -75 + ((x % * 19), this.height / 4 + 185 - 16 + ((x / * 20)); } else { renderItem.renderItemIntoGUI(this.fontRenderer, this.mc.renderEngine, new ItemStack(Integer.parseInt(i[x]), 1, 0), this.width / 2 -75 + ((x % * 19), this.height / 4 + 185 - 16 + ((x / * 20)); } } Does this help at all?
  17. Anyone? Surely somebody must be experiencesd with how OpenGL messes this up. I've tried backtracking and looking through the actual renderItem method, but to no avail...
  18. I'm working on my WallJump mod, and I've noticed that when you attempt to render a block onto a GUI using the following: renderItemIntoGUI(FontRenderer par1FontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5) that this sometimes messes up OpenGL colours and when you proceed to do the same again, the colour of the block is incorrect. For example, when you render an item then a block, the block will be slightly too dark, colours of things like grass will not show, etc. Does anyone know why this happens, or how to fix it? Here's an example of what I mean: Any help is much appreciated.
  19. Okay, can you tell me how I'd go about creating such a renderer?
  20. I've been looking around for a while on Google, and I can't seem to find anything about this subject. Basically, I want to draw a block so that it has an overlay drawn on top of the original texture, with a tint. I know it can be done, because there are examples in vanilla such as the sides of grass blocks, and also in other mods such as the shards in Mystcraft. Looking through some of the code, I found a couple of methods in BlockGrass.java which let you change the tint of the whole block, but this is not what I want. what I want is to overlay it with another texture, with a tint. How can this be done in Minecraft Forge? Please help!
  21. Are you exprienced with advanced Mincraft Forge programming? Do you want to be part of an amazing mod? Do you have Skype IM Service? Are you over the age of 12? If you answered "Sure thing, NukeDuck!" to all of these questions, you're in luck! I'm NukeDuck, texture artist and community manager of the team behind Arcticraft, and we're looking for someone who can help us rewrite the mod for Minecraft 1.4.x! You'll be credited over on the official page, and will get full credit for all of the work you do. We specifically need people who know a lot about dimensions, since it's a dimension mod, and other minecraft modding experience with Forge. If you'd like to sign up, please use this form: Name: Age: Previous Modding Experience: Why should I be let into the team: Thank you for reading, and remember to sign up below!
  22. Is there any way to use Minecraft Forge to generate a new block to a mod in the world? For example, in my case, I need to, when a new world is generated, randomly place my new block on top of the grass in the world, but only in certain biomes, e.g. plains and jungles, much like pumpkins generate in their little groups. Is there any way I can do this?
  23. Update: I now think I know why this is happening, for some reason whatever block metadata the block in your inventory has, the block always seems to place without any metadata at all. Any ideas?
×
×
  • Create New...

Important Information

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