Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/21/18 in all areas

  1. @Spaceboy Ross You're at a very important point in your programming/modding learning and my main advice is "slow down and understand". You're jumping around across a number of advanced modding topics while missing some fundamental skills related to Java programming as well as setting up your mod. Cutting and pasting and guessing at changing values is not a good way to develop your ability and will lead to weirder and weirder bugs in your code. Now you certainly SHOULD use vanilla code as a reference, even copying portions of it, but you also MUST understand what the code is doing. So if you have a parameter name that is something like p_191986_1_ in the vanilla code you should rename it according to what it actually does. Your code will become much more readable, and your ability to modify it properly will improve. If you don't understand Java well enough to know that you can rename the parameters then you really need to practice getting stronger in Java as well. For parameters passed into a method, the name of the method and the TYPE and order of the parameters must match the call, but the name can be anything you want (and should be meaningful). In order to figure out what the parameters really mean (so you can name them correctly) you should look at the Call Hierarchy (right-click on method name in Eclipse and it will give you that option) to see where other code that uses the method is. You can look at that and it is usually pretty obvious then what the fields represent. Then, regarding debugging you have not followed my suggestion regarding adding lots of console print statements through your code. You should be able to identify what is wrong with almost any code within 10 minutes if you print out the right info to trace the execution. In your case you keep saying "it doesn't work" but that isn't helpful. You need to figure out if your method isn't being called at all versus whether it is being called and executing differently than you expect. I don't personally use debug mode much (I find console statements work for most cases) but if you're going to do that then you need to learn how to do that properly -- setting breakpoints, ensuring the thread settings are correct (so other threads don't time out), and learn the various ways to step through (or into) the code. There are lots of tutorials for that. The reason why we're all jumping in on this thread is because you're showing a lot of potential and obviously have a passion for modding, but you're missing some important lessons you need to learn in order to really progress. So, simply (a) figure out what the code is supposed to do (b) trace the execution.
    2 points
  2. Those methods are specifically made for ContainerWorkbench & break when used in any other class. Someone (shadow facts I think? The code was made for 1.7 or something and still works perfectly) made a method that works on any container and I copied it. Have a look at https://github.com/Cadiboo/WIPTechAlpha/blob/73e647149fd26bebf7d56d6bfbac4818e33dcf78/src/main/java/cadiboo/wiptech/util/ModUtil.java#L237-L270 and the method below it if you need it and have a look at any of the classes in https://github.com/Cadiboo/WIPTechAlpha/tree/73e647149fd26bebf7d56d6bfbac4818e33dcf78/src/main/java/cadiboo/wiptech/inventory
    1 point
  3. Double click the line-number on the line you want to break on, a blue dot should appear. Run the program _in debug mode_ and when the program reaches that line it will pause and Eclipse will ask you if you want to open the debug perspective. Click yes (you can switch back to the default java perspective in the top right later) and you will be able to see the call stack and the values of all your fields and more.
    1 point
  4. i know but where exactly and how would i put it
    1 point
  5. I have experimented for a few hours now, read through countless pages of what came up on google searches and still cannot figure out how to solve this very basic issue: I need to be able to get an object of the world with all its dimensions and chunks. There is the class net.minecraft.world.World that seems to hold access to all that I need but how do I get a usable instance to it? It doesn't seem to have a static access so I really need to know where I can get it from and if it can even do what I need - which is primarily to give me a full list of all players online and secondarily access to all chunks currently loaded in the game. Thanks in advance for any help you can give me. EDIT: I have found a partial solution, but it won't allow me to do everything I need to do. I use an iterator in player-related events: Iterator it = event.player.worldObj.playerEntities.iterator(); However, I didn't see any way of doing this in events not related to players where I do, however, want to check on players. Grabbing the player list from an event with players and then using it elsewhere is possible but seems like a dirty solution.
    1 point
  6. Thanks for the help, I will be using the following now: ArrayList<EntityPlayerMP> allp = new ArrayList<EntityPlayerMP>(); ListIterator itl; for(int i = 0; i<MinecraftServer.getServer().worldServers.length; i++) { itl = MinecraftServer.getServer().worldServers[i].playerEntities.listIterator(); while(itl.hasNext()) allp.add((EntityPlayerMP)itl.next()); }
    1 point
  7. Could try something like: World world = Minecraft.getMinecraft().theWorld; Then do your iterator thing on top of that.
    1 point
×
×
  • Create New...

Important Information

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