Jump to content

Nephroid

Members
  • Posts

    91
  • Joined

  • Last visited

Everything posted by Nephroid

  1. Even after reading this and this, I still don't quite get how Forge uses these files, and I couldn't find that much other documentation on the new system. I.e. what is happening when I declare blockstates? How does Forge know what new variant names to look for? What is the actual class that interacts with and parses .json files? And so on. For the people who do know, can you share a link to some resources that you think are helpful?
  2. I remember seeing code for scroll bars in the gui that relates to the multiplayer/server selection window.
  3. You want to put initializing code in the constructor of the creative tab, so it's clearer when that code gets called. For example, it's better to have this line of code inside the constructor instead of getTabIconItem() : this.setNoScrollbar(); The static list initializer should also be in the constructor, and you should call that constructor AFTER you registered all your items. You must set the creative tab of the items after you call the constructor (can be inside the constructor) so that the creative tab of the items aren't null. Your constructor should look something like this then: public NCTab(int i, String s) { super(i, s); this.setNoScrollbar(); List<Item> ncTab_order = Arrays.asList(new Item[]{ item1.setCreativeTab(this), item2.setCreativeTab(this), ... }); } As a sidenote, I'm failing to see the use for sorting the items in the creative tab like this. Items and blocks get added in the order you register them in, so you can just register them in the order you want instead of doing complex things like sorting and using comparators.
  4. I ran into a similar problem with worldgen a few days ago. Using setBlock with flag 2 might help. The default flag is 3, which schedules a block update I believe.
  5. Looking at the stack trace (error messages), try setting breakpoints at these locations (the numbers are most likely line numbers): net.minecraftforge.fml.common.FMLCommonHandler.callFuture(FMLCommonHandler.java:677) net.minecraft.inventory.InventoryBasic.<init>(InventoryBasic.java:33) ~[inventoryBasic.class:?] Then look at what values are null. In the segment you posted above, blockType is null , which may or may not cause problems. There might be other null variables that you should check too. If you see any bit of code of the form variable.something and variable is null, that's will cause a null pointer.
  6. The code that you posted is extremely broad. Believe it or not, it takes time to analyze code to identify what's going wrong, and the more code you post, the longer it takes. If it takes too long, people might give up. Therefore, narrowing your code down will help others help you. A good way to narrow down your search is to use breakpoints and debug mode. In Eclipse, to set a breakpoint, right click on the left edge of the text area, and select "toggle breakpoint": You can set breakpoints in the forge library code too, not just the code that you have written. When you start running in debug mode, when the code reaches a breakpoint, it will pause BEFORE executing that line. When the program is paused, you can check the values of every variable at that point in the program by mousing over them: To narrow down your code, set a bunch of breakpoints in your code. When you reach one without any errors, you know that all the code before that breakpoint works. As soon as you get an error, you know that the error must be caused by something in between the last breakpoint and the current breakpoint. Using this technique, you can more precisely identify the portion of code that is causing the problem. You might even figure out the problem yourself in the process.
  7. I have a tutorial examples showing you how to modify the overlay: https://github.com/Nephroid1/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/overlay_simple https://github.com/Nephroid1/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/overlay_advanced The second one renders an HP bar, so it shows you how to access player information while rendering the overlay. The same concepts apply if you want to render other things, like the inventory status of a player. In general, you only want to handle the RenderGameOverlay.Post and RenderGameOverlay.Pre events, not the RenderGameOverlayEvent itself. For rendering a bit of text, it's only necessary to render it once per screen update. The code you have right now would render your text at least four times (twice in the pre event and twice in the post event; once for the jump bar, once for the exp bar), which is extra, unnecessary work. Also, when asking for help, it's a good idea to actually say what you're having problems with. That way, people can actually help you with your problem.
  8. In general, a good way to debug OpenGL is to comment out everything that you think causes the problem, and see if the problem still exists. (If it does, then keep commenting until the problem goes away.) Then uncomment each line one by one until the problem reappears again. This will identify the specific piece of code that causes your problem, which will help you and others identify the problem too. If you use Eclipse, you can actually run your mod in debug mode, and the changes will take effect without restarting the mod. A good OpenGL trick is to use the push and pop functions to save and reset the "states" of OpenGL. If you call glPushAttrib(GL_ALL_ATTRIB_BITS) before your other OpenGL calls, it "saves" the current rendering "state" of OpenGL (i.e. color, lighting, etc). After your rendering calls, call glPopAttrib() to revert to the last pushed state, effectively resetting everything that you've done. In this case, after you figure out the segment of code causing the problem, surround it with a push and pop. That usually solves problems with weird rendering issues.
  9. If you open up that class (net.minecraftforge.client.event.GuiScreenEvent), you can see all of its fields; event.gui and event.buttonList look promising. If you use Eclipse, ctrl+click to open that class.
  10. I figured it out. The main class should be net.minecraft.launchwrapper.Launch instead of Start.
  11. I'm not sure if this would help, but when I was playing with dimensions, this chunk provider creates an empty world: public class ChunkProviderEmpty extends ChunkProviderFlat { public ChunkProviderEmpty(World w, long l) { super(w, l, false, "2;0x1;0;"); } @Override public void populate(IChunkProvider par1IChunkProvider, int i, int j) { } } It uses the superflat chunk provider, but I tell it to generate no layers. More information on the string format can be found here: http://minecraft.gamepedia.com/Superflat#Preset_code_format Then I can create the chunks individually using world.setBlock() .
  12. I'm trying to test an API function, so I don't think setting up a mod is that straightforward. I used this link to set up my project, so I'm not sure where the mods go. (I'm pretty sure this project doesn't have a functioning Minecraft either; I get something about missing lwjgl when I try to run net.minecraft.client.main.Main, so I assume Minecraft isn't installed.) Do I have to run gradlew genPatches, then gradlew setupDecompWorkspace, then create a mod every time I want to test something?
  13. Try Material.plants instead. Or you can make your own material. The key part is the isSolid method. private static Material myMaterial = new Material(MapColor.grassColor) { @Override public boolean isSolid() { return false; } @Override public boolean blocksLight() { return true; } @Override public boolean blocksMovement() { return false; } };
  14. Edit: To be more precise, I'm writing an API for Forge, and I want to test it. I have already followed the instructions here: https://github.com/MinecraftForge/MinecraftForge/wiki/If-you-want-to-contribute-to-Forge
  15. How does this new piece of code relate to the original code? Anyways, like I said before, if you move the print statement inside the if block, it should only be printed once. if(!world.isRemote) { ... print("Hello World"); } Also remove the SideOnly annotation, that physically removes code from the client/server (think of it as commenting code out on one side).
  16. Do you ever reset xCoords ? If you don't make it zero somewhere, it's going to increase without bound. It's better practice to use your indexing variable (i.e. use num instead of x ) for these types of things too.
  17. I'm pretty sure it's because your print statement is both client and server side. If you put it inside the if block, it should only be executed once.
  18. Ah, I can't believe I didn't realize this earlier. You have to use setBlockState with flag 2, otherwise it will want to do tons of block updates or something. (I remember seeing a list of what the flags were, but I can't seem to find it anymore...) I.e. @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { world.setBlockState(new BlockPos(chunkX*16 + i, 127, chunkZ*16 + j), Blocks.glass.getDefaultState(), 2); } } } This creates a glass ceiling:
  19. I'd like to add that if you truly want to learn programming, it's best if you stay away from modding altogether. Sure, modding is fun and all, and it's exciting to see something that you do work; however, compared to programming exercises, it teaches you next to nothing. For example, if you implement an algorithm like Djikstra's, or even a simple sorting algorithm in Java, you'll learn much more about the object hierarchy and problem solving in general than getting a Block to render. Learning a language isn't about knowing just how to code; it's more about knowing what your code does. Learning Java doesn't just include knowing how to write Java code, it also includes understanding the code that you write too, and modding Minecraft will definitely not teach you what is actually happening. For debugging purposes, the latter becomes much more important, and the distinction between knowing how to write code and understanding what code does becomes quite clear.
  20. After commenting out the print in the decorate event, here's the console output: [15:04:17] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods [15:04:17] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:nephroid_cloudcraft [15:04:17] [Client thread/INFO]: SoundSystem shutting down... [15:04:17] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com [15:04:17] [sound Library Loader/INFO]: Starting up SoundSystem... [15:04:18] [Thread-9/INFO]: Initializing LWJGL OpenAL [15:04:18] [Thread-9/INFO]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org) [15:04:18] [Thread-9/INFO]: OpenAL initialized. [15:04:18] [sound Library Loader/INFO]: Sound engine started [15:04:19] [Client thread/INFO]: Created: 512x512 textures-atlas [15:04:26] [Client thread/INFO]: Deleting level New World [15:04:26] [Client thread/INFO]: Attempt 1... [15:04:30] [server thread/INFO]: Starting integrated minecraft server version 1.8 [15:04:30] [server thread/INFO]: Generating keypair [15:04:30] [server thread/INFO]: Converting map! [15:04:30] [server thread/INFO]: Scanning folders... [15:04:30] [server thread/INFO]: Total conversion count is 0 [15:04:30] [server thread/INFO] [FML]: Injecting existing block and item data into this server instance [15:04:30] [server thread/INFO] [FML]: Applying holder lookups [15:04:30] [server thread/INFO] [FML]: Holder lookups applied [15:04:30] [server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@63198870) [15:04:30] [server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@63198870) [15:04:30] [server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@63198870) [15:04:30] [server thread/INFO]: Preparing start region for level 0 [15:04:31] [server thread/INFO]: Preparing spawn area: 7% [15:04:32] [server thread/INFO]: Preparing spawn area: 15% [15:04:33] [server thread/INFO]: Preparing spawn area: 28% [15:04:34] [server thread/INFO]: Preparing spawn area: 41% [15:04:35] [server thread/INFO]: Preparing spawn area: 54% [15:04:36] [server thread/INFO]: Preparing spawn area: 66% [15:04:37] [server thread/INFO]: Preparing spawn area: 77% [15:04:38] [server thread/INFO]: Preparing spawn area: 90% [15:04:39] [server thread/INFO]: Changing view distance to 12, from 10 [15:04:40] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 1 [15:04:40] [Netty Server IO #1/INFO] [FML]: Client protocol version 1 [15:04:40] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 4 mods : mcp@9.05,FML@8.0.12.1252,Forge@11.14.0.1252,nephroid_cloudcraft@1.0 [15:04:40] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established [15:04:40] [server thread/INFO] [FML]: [server thread] Server side modded connection established [15:04:40] [server thread/INFO]: Player954[local:E:913afe8b] logged in with entity id 320 at (-58.5, 72.0, 246.5) [15:04:40] [server thread/INFO]: Player954 joined the game [15:04:43] [server thread/INFO]: Saving and pausing game... [15:04:43] [server thread/INFO]: Saving chunks for level 'New World'/Overworld [15:04:46] [server thread/INFO]: Saving chunks for level 'New World'/Nether [15:04:46] [server thread/INFO]: Saving chunks for level 'New World'/The End [15:04:46] [server thread/WARN]: Can't keep up! Did the system time change, or is the server overloaded? Running 6587ms behind, skipping 131 tick(s) (The prints in the pre and post events don't happen.)
  21. The furthest progress I made is on the bottom post of this thread: http://www.minecraftforge.net/forum/index.php/topic,26378.0.html But that slows down the game way too much to be useful. I've also tried using the DecorateBiome.Post event, but I'd rather not have world generation be dependent on the position of flowers/trees. I couldn't actually figure out when the Post event actually gets fired either. I could only get the Decorate event to fire. @SubscribeEvent(receiveCanceled = true) public void onEvent(DecorateBiomeEvent.Pre event) { BlockPos pos = event.pos; World world = event.world; System.out.format("[DEBUG] (Pre) %s\n", pos); } @SubscribeEvent(receiveCanceled = true) public void onEvent(DecorateBiomeEvent.Decorate event) { BlockPos pos = event.pos; World world = event.world; System.out.format("[DEBUG] (Decorate) %s\n", pos); } @SubscribeEvent(receiveCanceled = true) public void onEvent(DecorateBiomeEvent.Post event) { BlockPos pos = event.pos; World world = event.world; System.out.format("[DEBUG] (Post) %s\n", pos); } The code above produces the following console output:
  22. Yes, that's the basic idea. I forgot to account for the location of the origin though. To deal with it, instead of just rotating, translate it to the upper left, perform the rotation, then translate it back. I.e. glPushMatrix(); glTranslatef(x, y, 0); glRotate(ang, xR, yR, zR); glTranslatef(-x, -y, 0); //rendering glPopMatrix(); Unfortunately, you will probably need to guess and check values of x and y. It shouldn't be too bad if you run your mod in debug mode though.
  23. After trying all sorts of things (IWorldGenerator, various events, etc.) that didn't work or caused massive slowdowns, I'm wondering if anybody has gotten world generation to work in 1.8, or otherwise knows anything about world generation. If so, can you share an example of your code or some documentation that you used that helped? If I wanted to make a ceiling of glass at y level 200 in the overworld, what would I do? It seems like this should be really simple, but apparently I can't figure it out, and the "tutorials" that I've found are either out dated, incomplete, or wrong.
  24. For a list of events visit here. The RenderWorldEvent.Pre and RenderWorldEvent.Post events look promising.
  25. Isolate the code where you render your texture. Push the matrix before, perform the rotation, then pop the matrix after. Your code would look something like this: GL11.glPushMatrix(); GL11.glRotatef(angle, x, y, z); //Render anything you want to render here GL11.glPopMatrix(); // This resets all the transforms you did after GL11.glPushMatrix Just in case you don't know the arguments for rotate, angle is self explanatory, but x, y, and z specify the vector that is perpendicular to the plane of rotation. For 2D images, you would set x = 0, y = 0, z = 1. (For more information about the OpenGL functions, I have examples of their usage here.)
×
×
  • Create New...

Important Information

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