Jump to content

TheGreyGhost

Members
  • Posts

    3280
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by TheGreyGhost

  1. Hi Have you accidentally modified the vanilla source, by any chance? Try a reinstall of the vanilla + forge source? -TGG
  2. ... except that you have to register it on FMLCommonHandler.instance().bus() instead of MinecraftForge.EVENT_BUS ? -TGG
  3. Hi Yeah you got it :-) I think you're both right about stylistic preferences, I don't know of any reason it has to be done one way or the other. Personally, I prefer to keep client and server code completely separate, and I try to move as much functionality out of the "mega classes" as I can, by pushing it into smaller classes which I can understand and test more easily. My EventHandlers etc generally only contain one or two lines of code, because they immediately pass the call to another class. But that's just my preference and for uncomplicated mods I reckon it doesn't make any difference. -TGG
  4. Thanks, I like your tutorials. I don't understand your statement (in the linked tutorial) that the sided proxy "has NOTHING TO DO with the difference between client-side and server-side. That is something totally different." Can you explain the difference? It seems related to me -- for example subscribing a GUI event handler on the server proxy seems to give me trouble, similar to any other gui method running on the server elsewhere in the code. For example, what would be the difference between: a) putting my registerRenderers() in ClientProxy b) using no proxy and instead use @SideOnly in main class and have two preInit methods (preInitServer and preInitClient) where only the preInitClient registers renderers? c) using no proxy and instead use one preInit method in which you test FMLcommonHandler.instance().getEffectiveSide() and register renders if on client? Hi What I meant by "the sided proxy has NOTHING TO DO with the difference between client-side and server-side" is that the sided proxy is used to tell the difference between your mod being installed on a client, or your mod being installed on the dedicated server. It won't tell your code whether it's being called on the "client side", or on the "server side"; you need to use isRemote() for that. For example - On the client side, you can access Minecraft but not MinecraftServer. If you do, it might appear to work for a while but it will eventually crash, because although the MinecraftServer class might exist, it is either unused or is in use by a different thread. On the Server side, you can access MinecraftServer but not Minecraft. If you try, it might crash immediately (if this is a dedicated server), or crash after some time (if this is a normal client). You're right they are kind of related, but only very loosely I think. CombinedClient: both server side objects ok and client side objects ok, can have classes common to both which use isRemote to tell which side they are on DedicatedServer: server side only objects. Any classes which contain references to client-side objects will cause immediate crash, even if those references aren't used Without trying it, I think (a) and (b) would be the same, but © wouldn't. getEffectiveSide is similar to isRemote, i.e. it can't tell your the difference between being installed on the client (which has all vanilla objects) and the dedicatedserver (which is missing half of them). I suspect getEffectiveSide doesn't return anything meaningful in the preInit method. -TGG
  5. Hi This link might be of interest http://greyminecraftcoder.blogspot.com.au/2013/11/how-forge-starts-up-your-code.html In my experience you can subscribe the same class to event handlers on both sides, so long as your class doesn't refer to any of the client-side-only vanilla objects. Usually, all my handler does is immediately call another of my classes (depending on which side). Since all my classes are present on both sides, no crash. -TGG
  6. Hi You might find this link useful http://greyminecraftcoder.blogspot.com.au/2013/08/lighting.html -TGG
  7. Hi Depending on the number of textures you need, I'd suggest the best idea is just taking up more blockIDs. With (say) 8 metadata and 32 block IDs, you could have 256 different textures which is probably enough? You could perhaps get around the creative tab problem by just having a single chameleon block on the tab, which changes its own blockID when it gets placed. -TGG
  8. Hi Ah, yeah, I should have copied that too (from EntityRenderer.updateCameraAndRender) ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); int i = scaledresolution.getScaledWidth(); int j = scaledresolution.getScaledHeight(); int k = Mouse.getX() * i / this.mc.displayWidth; int l = j - Mouse.getY() * j / this.mc.displayHeight - 1; -TGG
  9. Then why do so many people in high places - including the developer of the mod I have seen called "the leader in optimization" - say otherwise? Perhaps the code has changed since they last looked at it. Perhaps they never tested it using the same conditions that you're running it under. Perhaps they're just all wrong. I'd say, believe what your testing shows you and don't worry about it too much :-) Time to move on to the next possible source of performance problems I reckon... BTW do you know about the inbuilt Minecraft profiler? All those this.mc.mcProfiler.startSection("level"); sprinkled through the code? /debug start /debug stop (creates a dump file) You can even add your own sections if you want. Your IDE might also have some powerful profiling capabilities too, I often find the results a surprise and show me performance gains I probably wouldn't have spotted without it. -TGG
  10. Hi Yes there is. Look in GuiContainer.drawScreen for inspiration, in particular this bit for (int j1 = 0; j1 < this.inventorySlots.inventorySlots.size(); ++j1) { Slot slot = (Slot)this.inventorySlots.inventorySlots.get(j1); this.drawSlotInventory(slot); if (this.isMouseOverSlot(slot, par1, par2) && slot.func_111238_b()) { this.theSlot = slot; GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); int k1 = slot.xDisplayPosition; i1 = slot.yDisplayPosition; this.drawGradientRect(k1, i1, k1 + 16, i1 + 16, -2130706433, -2130706433); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); } } par1, par2 are mouseXpos and mouseYpos, which you can get from int k = Mouse.getX() * i / this.mc.displayWidth; int l = j - Mouse.getY() * j / this.mc.displayHeight - 1; (this.mc is Minecraft). inventorySlots has public access. Need to check mc.currentScreen is actually the inventory container, of course. You will need to do it on client because none of this exists on the server. -TGG
  11. Hi coolAlias I think you may need to use reflection to modify the base class; the setting up of the viewpoint in EntityRenderer.setupCameraTransform and .orientCamera doesn't look like you can easily "intercept" it. If you could find a way to add an extra GL11.glTranslatef after the setupCameraTransform and before the start of the rendering, that might do it. Alternatively, you might be able to change the renderViewEntity to your own copy of the player, which you manually synchronise with the real player. You're right that renderViewEntity refers to the player object, but perhaps it doesn't have to: EntityRenderer.renderWorld: if (this.mc.renderViewEntity == null) { this.mc.renderViewEntity = this.mc.thePlayer; } If necessary you might be able to change it immediately before render, then change it back immediately afterwards -TGG
  12. Hi Coding in 1.7.2 is still a pain in the rear. Here is the code from 1.6.4 (with a couple of parameters renamed) /** * Ticks the block if it's been scheduled */ public void updateTick(World par1World, int x, int y, int z, Random par5Random) { super.updateTick(par1World, x, y, z, par5Random); if (par1World.getBlockLightValue(x, y + 1, z) >= 9) { int l = par1World.getBlockMetadata(x, y, z); if (l < 7) { float f = this.getGrowthRate(par1World, x, y, z); if (par5Random.nextInt((int)(25.0F / f) + 1) == 0) { ++l; par1World.setBlockMetadataWithNotify(x, y, z, l, 2); } } } } The weird stuff in this line float f = 0.5F; this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); is probably because the original code had something like float HALF_CROP_BLOCK_WIDTH = 0.5F; this.setBlockBounds(0.5F - HALF_CROP_BLOCK_WIDTH, 0.0F, 0.5F - HALF_CROP_BLOCK_WIDTH, 0.5F + HALF_CROP_BLOCK_WIDTH, 0.25F, 0.5F + HALF_CROP_BLOCK_WIDTH); (You realise that the variable f in the constructor has nothing to do with the f in the updatetick, yeah?) -TGG
  13. Hi In my experience it's usually difficult to predict in advance what the most efficient way of implementing the code will be. There are some good general rules, and it can be very important to choose the appropriate algorithm, but nine times out of ten I find that the differences are completely negligible when you run in the real game. So I think what you're doing is the right approach- write your code to be understandable, modular, and easily maintained, measure its performance, and optimise the bits that need it using your "real situation" performance measurements. -TGG
  14. hi The GL11.glRotatef should work I think. Perhaps your meta is not right? This link http://www.glprogramming.com/red/chapter03.html has some more information about GL11, if you want the technical details, but the short answer is that GL11.glRotatef(angle, 0, 1F, 0F) should rotate your model around the y axis (vertical) by the angle. Easy to test - just change to GL11.glRotatef(45, 0, 1F, 0F) and see if it changes. -TGG
  15. Hi The vanilla render distance is controlled by Minecraft.getMinecraft().gameSettings.renderDistance It affects the fog settings and far plane settings (see EntityRenderer) and the rendered chunks (see RenderGlobal.loadRenderers) Blindness potion has good clues too (EntityRenderer.setupFog) -TGG
  16. Hi Entity.travelToDimension? i.e. you can override this function in your Entity? -TGG
  17. Hi " Using missing texture, unable to load " is a very common error and it means your texture name doesn't match the filename / location. If you search this forum for "tgg using missing texture" you'll find a few answers. -TGG
  18. Hi a couple of suggestions Don't take square root, calculate the SquaredDistance first and compare to that instead. Much faster. If you are searching for Blocks that have a TileEntity, you can find them much faster by first calling WorldServer.getAllTileEntityInBox, and then iterating through the list, discarding any which are further away from you than your search radius. This will let you use a much bigger search radius without causing horrible lag. (Re WorldServer: usually you will be given a World, and you can check if it's a WorldServer using .isRemote - if it returns false, you're on the server.) -TGG
  19. Hi Dude, the first thing I'd suggest is to rename your parameters to something sensible Stuff like (World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) will do your head in if you try to debug it for too long. Using the right indenting should help a lot too. Putting @Override before the methods you're overriding from the base class will help pick up subtle problems where you think you're overriding a base class method but you've misspelled it. I can't see an obvious problem but then I can't actually read the code either so that doesn't mean anything :-) I'd suggest you put a breakpoint into some of these methods especially canBlockStay and canPlaceBlockAt to see if you can figure out why it won't let you place them on top of each other. -TGG
  20. Hi If you just need the glass to be connected in the same way as normal glass is connected, this link might help http://greyminecraftcoder.blogspot.com.au/2013/07/rendering-transparent-blocks.html If you're just starting out modding, might be best to start with something very simple first (like an ordinary block) and work up from there. Lots of tutorials on this forum in the "tutorials" section. -TGG
  21. Hi You can certainly use a TESR to change the texture. Your wavefront is rendered fresh every frame, you just need to reassign the texture before each call to the wavefront renderer. this.bindTexture(myTextureForThisFrame); Check out TileEntityBeaconRenderer for example. Make sure you set up the textures for the different frames once and swap between them each frame, don't create a fresh one every frame or it will be unnecessarily slow.. -TGG
  22. Hi Have a look in EntityLivingBase.rayTrace, that will give you the position of the cursor (the player's line of sight). CommandServerTp will give you the teleport code. -TGG
  23. Hi I suspect it's because you're setting the render colour to white in the game (your sign is in full sunlight, yes?) but the fake block coordinates you use in the GUI is not full sunlight, so you get a grey. this.t.setColorOpaque_F(bright, bright, bright); This link might help with some background info http://greyminecraftcoder.blogspot.com.au/2013/08/lighting.html -TGG
  24. Hi So, you mean that meta is always <= 5? Or that (eg) this.setBlockBounds(0, -1, 0, 1, 6, 1); doesn't set the bounds to what you expect? -TGG
  25. Hi The checkerboard probably means that your itemIconFleshBound texture file was not found. Check the error log for "Using missing texture, unable to load". If you search this forum for that keyword, you'll turn up a number of posts talking about how to fix that. -TGG
×
×
  • Create New...

Important Information

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