Started by
eagle_skull14
on
Topic category: Help with Minecraft modding (Java Edition)
I keep trying to edit the source code for minecraft, but it says "This is (decompiled/provided) source code and is read-only and intended for internal reference and educational use only." How do I get past this, and edit and save the code?
You cannot, as a modder, directly edit the source code of the game, for several reasons; but the basic idea is that the game will only accept mods as external code, not as things that change the base game, as this would cause problems if you ever wanted to remove the mods, if you wanted to do multiplayer, etc. There are still lots of workarounds to edit vanilla components of the game using external methods, but editing the sourcecode itself is, to the best of my knowledge, not possible with Forge or Fabric. It's not just an MCreator thing.
That's the most to the point answer I have seen, thanks. But lets say I want to edit the code for minecarts to make them faster, which, by what you are saying, I can't do directly, how do I do so using the code blocks or text code? If I can't change the code itself, what should I do to edit the values in some way? Am I able to change variables declared in minecraft's source code?
When you want to edit a vanilla entity like that, there's a couple of workarounds. You could replace the minecart with your own version of the minecart, and have something that triggers on spawn to replace them, or replaces the item in the recipe, inventory, loot tables, etc. For a minecart though, it wouldn't be practical to remake it from scratch just because the rail system is so complicated. Instead, you can use the 'override motion vector' function to change the speed of things. There are also sneakier methods, such as opening your own custom GUI when a player interacts with a vanilla block, and closing the original. If you get into custom code a bit more, it's also possible to make extensions of vanilla items and entities that retain special properties. (Such as making custom arrows that can be used with a vanilla bow.)
For your case, you should be able to just multiply the velocities of the minecart by a small amount to increase its acceleration, and then set your desired maximum speed and limit it beneath that. Essentially, use the 'on entity update tick' global trigger, check that the target entity is a minecart, (unless you want literally everything to accelerate uncontrollably), use an if bracket to check if the sum of the minecart's x/y/z velocities is below your desired amount, and if it is, multiply the speed of the minecart by a very small amount +1. (Something like 1.01, 1.02, etc.) This will add a very small percent to the velocity, and it needs to be small, since it's going to increase every twentieth of a second. (If you wanted to be mathier, you could make this a function of the current speed so that it doesn't increase too rapidly.) You might not need to do the y velocity, depending on how inclined rails work, but it's worth checking. (Otherwise it may have weird effects on falling minecarts, but you could also add another check for if the entity is on ground.)
Hope that's helpful! I haven't personally run into much trouble overriding vanilla stuff, but I also haven't had many occasions to do so.
I know I'm a bit late but is there a way to directly modify items like crossbows to make them shoot faster?
Mixins
https://github.com/SpongePowered/Mixin/wiki/Mixins-on-Minecraft-Forge
Is there any for neoforge?
The forge version also works for neoforge