-
Posts
157 -
Joined
-
Last visited
Everything posted by Torojima
-
This tip probably should go to the FAQ (if it isn't there already ) To all the Java-Unsavy people out there: @Override *EVERY* method you create and remove the @Override if it creates an error ... And this my friends, is me (former informatics-teacher) giving in to the ignorance of the ppl out there demanding to be able to put together mods, but not willing to learn any basic programming skills whatsoever ... Learning Java/programming/software-architecture etc ... by programming a minecraft mod is like trying to learn how to operate a car by joining the WRC ...
-
since you have not supplied the crash report everything we can do is guessing ... but the obvious solution would be this: public void onBlockAdded(World world, int x, int y, int z) { int randBlock = rand.nextInt(Block.blocksList.length); if(null != Block.blocksList[randBlock]) { world.setBlock(x, y, z, Block.blocksList[randBlock].blockID); } } you very obviously presume every BlockId is available, which also very obviously is not the case. Thus when your random number hits an empty spot, there probably will be a null stored at that place... As a general rule for coding you should remember *never* to access anything you haven't checked before or are very (rather absolutely) certain, is properly filled ...
-
actually, more or less, I do it like this: in the entity class. The interact method is compulsory for every mob entity class (inherited from the vanilla classes), but you probably know that
-
actually, more or less, I do it like this: in the entity class. The interact method is compulsory for every mob entity class (inherited from the vanilla classes), but you probably know that
-
How to place a row of the currently selected block?
Torojima replied to Imbalance's topic in Modder Support
got nerved by the same thing and done this: click one block with the wand and click another and ping you got the in between filled with cobble stone ... I have set a limit of 15x5x15 so I don't kill the system by overloading it in any way. But the first click is not forgotten if the second is outside of the limits, so the hole thing is very user unfriendly... have done it only for me to speed up building (got another wand for digging 3x3x3 holes and another one for dirt and a last one for filling water columns with sand (click next to water and the a sand column will appear falling into the water for fast filling of lakes ...) thought about making the cobble/dirt wand dynamic, but haven't found the time yet now if you make the set block id dynamic instead of cobble you got what you're asking for (and wrap a basic mod structure around it of course ) ps: I can send you the mod if you like, I haven't published it yet since I don't think is very user friendly right now ... btw, done something like this with it: -
How to place a row of the currently selected block?
Torojima replied to Imbalance's topic in Modder Support
got nerved by the same thing and done this: click one block with the wand and click another and ping you got the in between filled with cobble stone ... I have set a limit of 15x5x15 so I don't kill the system by overloading it in any way. But the first click is not forgotten if the second is outside of the limits, so the hole thing is very user unfriendly... have done it only for me to speed up building (got another wand for digging 3x3x3 holes and another one for dirt and a last one for filling water columns with sand (click next to water and the a sand column will appear falling into the water for fast filling of lakes ...) thought about making the cobble/dirt wand dynamic, but haven't found the time yet now if you make the set block id dynamic instead of cobble you got what you're asking for (and wrap a basic mod structure around it of course ) ps: I can send you the mod if you like, I haven't published it yet since I don't think is very user friendly right now ... btw, done something like this with it: -
How can I make multiple, separate mods that with one forge python module?
Torojima replied to jinoh's topic in Modder Support
you asked to share a python module, not the mcp and forge environment ... maybe you should not construct your questions with an online translator ... anyway, very obviously you haven't even considered to try what you would like to do before asking, else you would have noticed you can have one separate java-packet for each mod in the forge/mcp environment. They will be recompiled and reobfuscated at once, but you can decide which packet you want to publish separately, thus have different mods in one forge/mcp environment ... -
How can I make multiple, separate mods that with one forge python module?
Torojima replied to jinoh's topic in Modder Support
you asked to share a python module, not the mcp and forge environment ... maybe you should not construct your questions with an online translator ... anyway, very obviously you haven't even considered to try what you would like to do before asking, else you would have noticed you can have one separate java-packet for each mod in the forge/mcp environment. They will be recompiled and reobfuscated at once, but you can decide which packet you want to publish separately, thus have different mods in one forge/mcp environment ... -
How can I make multiple, separate mods that with one forge python module?
Torojima replied to jinoh's topic in Modder Support
create one package with whatever is used by both (or all mods) and add a using statement wherever the classes/methods are used ... (similar to the third party packages already added ...) -
actually not, bad coding placement or unclear code leads to misunderstand code, leads to misused code, leads to bugs etc ... been there, done that. About halve of my knowledge about software development, software architecture and coding I gathered by doing the wrong thing and getting hurt in the process. But that had been back in the 80's and 90's when there hasn't been much "clean-code-awareness" and monolithic 5000+ line functions have been the conventional way of doing stuff. Today I do write "pretty-code" not only because it is much more of a pleasure to do so, but also because "pretty-code" is much more understandable and therefore I will be able to understand, use and most important alter it without breaking it or creating bugs. The days of "hackers" who sit in their parents attics and proudly produce code only they themselves can understand are long gone. Software-Development today is a team effort and involves as much communicating between project colleagues as it involves writing code. And for the actual code to fit in into these modern system it has to be clean and understandable. Now you could argue this is not a professional area we are programming right here, but even the more us doing mc-modding for fun is reason enough to produce well formed clean code. Let me ask you an analogue question. I do have a sports car I tend to by myself (maintenance, oil, minor repairs (and bigger ones ) ). Wouldn't it be very strange if I would let that car rot and go to waste, just because I am using it in my free time and "just for fun"? No, I tent to it maybe even more than to my day to day car. Same goes for my software. I would not write bad software in my free time, just because I just do it for fun ... but I think I'm drifting off Point is, before being able to be a good software developer one has to be able to write "pretty-code". And if the mod produced should be fun to use not only for a very brief time, it should be easily maintainable, else it will be gone with the next mc version ...
-
with the a &= list_of_b and starting a as true, a will finally be true only if every entry in list_of_b is true and false if any one in list_of_b is false. You notice the &= not just = a &= b will set a to true if a *and* b are true and false if a *or* b are false. The code provided by me will do exactly the same as your code, plus it will do so for any inventory size. And it's a lot better to read. But your mod, your code, your call
-
Minor help needed. [Solved and fixed code given]
Torojima replied to xXRoboJackXx's topic in Modder Support
do a search in the methods.csv file: func_94575_c,setBlock,2,"Sets a block and notifies relevant systems with the block change Args: x, y, z, blockID" and the fields.csv file: field_85192_a,worldServerInstance,2, -
and if you do not need the individual entries in chestfulldetect and chestemptydetect at a later time, I would skip them altogether and only use the isFull and isEmpty bools ...
-
may I propose this: private boolean isFull = false; private boolean isEmpty = true; private boolean chestfulldetect[] = new boolean[9]; private boolean chestemptydetect[] = new boolean[9]; public TileTestChest(int i) { yourstack = new ItemStack[i]; inventorysize = i; } public void updateEntity() { for(int i = 0; i < getSizeInventory(); i++) { if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == Math.min(getInventoryStackLimit(), getStackInSlot(i).getMaxStackSize())) { this.chestfulldetect[i] = true; } else { chestfulldetect[i] = false; } if(getStackInSlot(i) == null) { chestemptydetect[i] = true; } else { chestemptydetect[i] = false; } } this.isFull = true; this.isEmpty = true; for(int i = 0; i < inventorysize; i++) { this.isFull &= this.chestfulldetect[i]; this.isEmpty &= this.chestemptydetect[i]; } }
-
buy this, read it and ***understand it*** !!! http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882 if the "bad coder" would only produce code for himself to read, in, as you put it, "their OWN MOD", I would not give a #2 how rubbish their code might be. But if somebody will ask for help regarding the code, I demand the code to be clean and pretty (and that includes well chosen names and correct indention)
-
for the sake of ppl reading this later while searching for a solution for their problems, you should post your found solution, not only a "solved" statement...
-
behind the gui is the container with the player inventory and your special inventory (chest, backpack, saddlebags, whatever). The container doesn't know if it's been opened by an item or a block (or even a mob). The item/block/mob has to open the container GUI when triggered (right-click, shift-click, whatever). The GUI will load the container, the container will load the inventories and the inventories will load and store the contained items by means of the readFromNBT and writeToNBT methods ...
-
[SOLVED] Is it possible to check the biome when placing a block?
Torojima replied to LutzBlox's topic in Modder Support
according to wiki it's pretty similar http://en.wikipedia.org/wiki/Comparison_of_integrated_development_environments#Java ^^there you can find links to the individual descriptions of the IDE's I still would stick with Eclipse ... -
you'll find *everything* you need in net.minecraft.inventory.ContainerChest ... (this would also be your sample code with place holders you'll have to exchange for your own settings ...)
-
you've got two fields private static boolean isFull = false; private static boolean isEmpty = true; set to static. So either you want to have *all* of your instances of the class set to the same value (which doesn't make to much sense in my opinion and in yours too if I do interpret your comments correctly, or you do not use the static keyword correctly. If you want *every* instance (aka your individual chests) have an individual setting you have to remove the static keywords. With static the field is not a object, but a class field, can only accessed via the class and can only have one value at a given time. If changed, it will change for every object ... Google, searchwords "java static" first hit http://www.javatutorialhub.com/java-static-variable-methods.html there might be better explanations ...
-
you should really (no, really ... REALLY, DO IT!!!) look up what the keyword static is doing ... and you should get your indention right ...
-
I do have a little problem with my mods container. The composition is very similar (if not copied ) to the vanilla chest. It works very well except one little hickup. If an item on the player inventory is shift-clicked, it will be transfered automatically to the container inventory as expected. Vice versa the same. But, if an item in the action bar is shift-clicked it will be dropped to the ground. I have found out that in case of the item slot is located in the players action bar, the third parameter of the slotClick method of the Container class is given as 4, whilst it is 1 if the slot is located in the common area of the player inventory. Now, if I do the following everything in my container class (derived from Container) is working fine again: @Override public ItemStack slotClick(int slotIdx, int par2, int par3, EntityPlayer player) { // hack ... not very nice ... if(par3 == 4) { par3 = 1; } return super.slotClick(slotIdx, par2, par3, player); } But this is not as I would like to keep it. Thus I have two questions: First, do somebody know what the par3 in slotClick is all about? (or the par2 whilst we're at it ) and second, does anybody else have a similar problem and a solution for it? Or does know of a solution even without having the same problem
-
If you would know anything about coding, software architecture and programming languages, you would know how stupid this sentence is ... I am professionally coding within an legacy code base written in c and I'm writing GUI's in c# and I have build and coded software tools using java and I can tell you, if you know c, apart from basic structures like loops and branching, you do know nothing about java... and if you know "just" java, you'll probably get hurt if you get your hands dirty in pointer arithmetic... That is the only way to do it. Learn java (and as many other languages as you can), learn the ideas of oop, get to know about patterns, read about this patterns, use them, learn about the intrinsic attributes of the languages you are using, LEARN TO PRODUCE CLEAN CODE!!!, learn about software architecture and then and only then try to produce a mod that's more than yet another funny additional sword mod ... And if you still don't get it after 20odd posts and still think you'll become an instant coding hero just by copying some lines from a tutorial into your main mod class, the tone you're addressed with will get a bit harsher, live with it ... Btw, tutorials, I use them too, but it helps if you know why what is done is done, so you can vary the code and actually use the knowledge gained by following the tutorial. If you just copy paste the stuff found in the tutorials, not you will be the author of your mod, but the different tutorial authors and you have gained nothing ...
-
Decreasing stack size after usage in BonemealEvent [solved]
Torojima replied to Torojima's topic in Modder Support
that explains that good bug tho, had me simplify my code in the process -
Decreasing stack size after usage in BonemealEvent [solved]
Torojima replied to Torojima's topic in Modder Support
thank you removed everything there was before for decreasing the stack size and added the above mentioned line after the fertilizing has taken place. Now everything works perfectly, even with the green sparkles included now rather unimportant for this problem, but still interesting: why is the entityPlayer field of the event not pointing towards the player in question?