I need a mod to disable the automatic creation of water source blocks when 2 other waterblocks are nearby. Just like Lava, You can actually drain a lake using only a Bucket. I need it to be Forge and MC 1.7.10 compatible.
It was made before for modloader at this topic, but it is outdated and is not compatible with Forge.
I'll try it. I don't have much experience with Forge besides a couple of tutorials (luckily 1.7.10), and I can't guarantee success, but I'll give it a shot.
I can probably ASM something... I'll have a look and get back to you later (I need to learn ASM, won't take long, Java is pretty intuitive).
EDIT: So I've finished learning how to transform bytecode, will go eat dinner, then figure out what I need to change for water (actually, I already know exactly what I need to change, but w/e).
EDIT2 : Posted link in a the next comment down to make sure you got a notification.
Rollback Post to RevisionRollBack
I believe in the Invisible Pink Unicorn, bless her Invisible Pinkness.
It turns out that water and lava are combined in the code, not really fluids like oil from Buildcraft or Sludge from MFR. Modifying this without a base edit and maintaining compatibility so that your world doesn't dry up as soon as you load the world without the mod might not be possible in 1.7, but I'll keep working on it. This would be much easier as a base edit, but then it wouldn't be compatible with anything else.
EDIT: Looks like you found what you needed! (Forgot to refresh the page).
I started on mod develop and i don't understand the Minecraft code yet (little time to study the code). And I'm interested to know how you did that. (I am a Java student).
I started on mod develop and i don't understand the Minecraft code yet (little time to study the code). And I'm interested to know how you did that. (I am a Java student).
It turns out that water and lava are combined in the code, not really fluids like oil from Buildcraft or Sludge from MFR. Modifying this without a base edit and maintaining compatibility so that your world doesn't dry up as soon as you load the world without the mod might not be possible in 1.7, but I'll keep working on it. This would be much easier as a base edit, but then it wouldn't be compatible with anything else.
It needs ASM transformation.
The thing about Java is that it is not compiled directly, but instead, converted into something called byte code, which the JVM compiles just before the code needs to be run (bytecode is about 99% of the way to machine code). Anyway, the thing is; while the bytecode is loaded into the JVM, we can modify it.
Einsteinsci, you are correct, Water and Lava both use the same classes ; BlockLiquid, BlockStaticLiquid, and BlockDynamicLiquid. We are interested in the BlockDynamicLiquid, and luckily, we only need to change one instruction: during the update tick, the part where the water block counts its neighbors and changes into another water block. In my forge, this is at line 72 (ln 40 within the UpdateTick method).
if (this.field_149815_a >= 2 && this.blockMaterial == Material.water)
Using a bytecode plugin (I used Bytecode outline), you need to open this up and have a look. In this case, the bytecode looks like this;
GETFIELD net/minecraft/block/BlockDynamicLiquid.field_149815_a : I
ICONST_2 <<<----------- ICONST_2 = 2; the necessary number of neighbors. I changed this to ICONST_5 (5), since a block can only have 4 adjacent neighbors.
With this kind of miniscule change, compatibility should be extremely high.
From here, you just need to transform the bytecode as the classes load. There are probably some tutorials on this, though I dislike tutorials and recommend the "figure out as much as you can by yourself" approach [which is why it took 6 hours, whereas copy pasting a tutorial would take 20 minutes or less].
Basically, have your main class implement cpw.mods.fml.relauncher.IFMLLoadingPlugin, which defers to the declared transformer class as an instance of net.minecraft.launchwrapper.IClassTransformer [specifically, it calls the "transform" method, sending the class name and bytecode as parameters]) and hacked my way through the rest using the native ASM library documentation (org.objectweb.asm).
When you are done, the line of code will actually be;
if (this.field_149815_a >= 5 && this.blockMaterial == Material.water)
Which isn't possible, and hence the water won't duplicate.
That said, I've been coding for a long time, and I've been using this learning approach for a long time (I've only been using Java for 2 weeks lol). If you don't have a strong understanding of how programming languages work at an instructional level, or rather, how bytecode/assembly works (noting that bytecode and assembly are extremely similar), then you might have some trouble.
Brilliant! While I'm relatively new to Java, I have quite a bit of experience in C#, .NET, and CLR (basically anything in Visual Studio except F#, which is stupid). I once or twice delved into the disassembly of some C++ code to see what is going on in a simple 'if' structure. Java seems to compile much differently than C++ and .NET do, and lets you modify the main code afterward as it's being compiled. Reflection in Java seems kind of daunting though, so I'll stick to the regular object-oriented approach for now.
I need a mod to disable the automatic creation of water source blocks when 2 other waterblocks are nearby. Just like Lava, You can actually drain a lake using only a Bucket. I need it to be Forge and MC 1.7.10 compatible.
It was made before for modloader at this topic, but it is outdated and is not compatible with Forge.
http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/requests-ideas-for-mods/1307049-mod-request-finite-water-water-that-is-taken-away
I don't want to use Finite Liquids, cause it changes the mechanics a lot.
If you need more information, feel free to PM.
Can anyone take this request?
EDIT: So I've finished learning how to transform bytecode, will go eat dinner, then figure out what I need to change for water (actually, I already know exactly what I need to change, but w/e).
EDIT2 : Posted link in a the next comment down to make sure you got a notification.
I believe in the Invisible Pink Unicorn, bless her Invisible Pinkness.
Just drop it in your mods folder and let me know if it works/
https://www.dropbox.com/s/kbem2f9r0lg0bks/WaterDuplicationPatch.jar
Screenshots... though it's kind of hard to see what's going on lol.
Also here, I placed one water block at each end of a 3x1 trench
I believe in the Invisible Pink Unicorn, bless her Invisible Pinkness.
EDIT: Looks like you found what you needed! (Forgot to refresh the page).
4HeadTiger, how did you go about doing this? I would love to know.
I started on mod develop and i don't understand the Minecraft code yet (little time to study the code). And I'm interested to know how you did that. (I am a Java student).
Thank you too einsteinsci.
No problem, I had to learn ASM anyway
It needs ASM transformation.
The thing about Java is that it is not compiled directly, but instead, converted into something called byte code, which the JVM compiles just before the code needs to be run (bytecode is about 99% of the way to machine code). Anyway, the thing is; while the bytecode is loaded into the JVM, we can modify it.
Einsteinsci, you are correct, Water and Lava both use the same classes ; BlockLiquid, BlockStaticLiquid, and BlockDynamicLiquid. We are interested in the BlockDynamicLiquid, and luckily, we only need to change one instruction: during the update tick, the part where the water block counts its neighbors and changes into another water block. In my forge, this is at line 72 (ln 40 within the UpdateTick method).
Using a bytecode plugin (I used Bytecode outline), you need to open this up and have a look. In this case, the bytecode looks like this;
We want this bit;
With this kind of miniscule change, compatibility should be extremely high.
From here, you just need to transform the bytecode as the classes load. There are probably some tutorials on this, though I dislike tutorials and recommend the "figure out as much as you can by yourself" approach [which is why it took 6 hours, whereas copy pasting a tutorial would take 20 minutes or less].
Basically, have your main class implement cpw.mods.fml.relauncher.IFMLLoadingPlugin, which defers to the declared transformer class as an instance of net.minecraft.launchwrapper.IClassTransformer [specifically, it calls the "transform" method, sending the class name and bytecode as parameters]) and hacked my way through the rest using the native ASM library documentation (org.objectweb.asm).
When you are done, the line of code will actually be;
Which isn't possible, and hence the water won't duplicate.
That said, I've been coding for a long time, and I've been using this learning approach for a long time (I've only been using Java for 2 weeks lol). If you don't have a strong understanding of how programming languages work at an instructional level, or rather, how bytecode/assembly works (noting that bytecode and assembly are extremely similar), then you might have some trouble.
EDIT: google is the best: The first google search result for Forge Core Modding
I believe in the Invisible Pink Unicorn, bless her Invisible Pinkness.
Thanks, have a Diamond