Jump to content

Modding with C#


Brendanp01

Recommended Posts

So I was looking into modding with C#, and I came across this. Nothing helpful. Just a guy claiming "Minecraft IS Java" and "There is no way around this", which simply isn't true. I'm wondering if there are any good ways to do this. If not, are there any smaller projects trying to do this that I could contribute to? Just to be clear, I'm not looking for mods to contribute to, I'm looking for projects allowing mods to be created in C#.

 

Edit

Another thing I want to make clear: I'm not looking for somebody to tell me that MC is written in Java, or how MC works. I know all about it. Which is why I know that this kind of thing is possible if someone is willing to put in the work. I'm not looking for a lecture about everything I already know.

Edited by Brendanp01
Link to comment
Share on other sites

37 minutes ago, diesieben07 said:

There are no such projects that I am aware of.

You would have to somehow use JNI and write java wrappers that then call out to the C# code - and even then I'm not sure if it is even possible to use JNI with C#. If not, you'd have to have yet another layer written in C++ to handle the JNI part.

 

And yes, the response was right, Minecraft is written in Java so any mods need to be, firstly, written in Java. If that Java code then does random crazy stuff and calls out to other language runtimes, sure, you can in theory do that. However the entrypoint of the mod still needs to be written in Java (or more specifically in something that compiles to JVM class files) so that Minecraft and the Forge mod loader knows what to do wiht it.

Like I said, I'm not looking for someone to tell me how MC works. Pretty much everything you said is true, but also a bit obvious to anyone who isn't a beginner. The reason I did that edit was because I knew that someone would end up telling me what I already know. However, I will look into what you said in the first paragraph.

Link to comment
Share on other sites

Well, unfortunately, because of <thing you already know>, it isn't possible because <thing you already know.> As such what you want to do would require <doing things you don't want to do>.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

49 minutes ago, Draco18s said:

Well, unfortunately, because of <thing you already know>, it isn't possible because <thing you already know.> As such what you want to do would require <doing things you don't want to do>.

Not possible? We already can compile Java to .NET assemblies using IKVM. Don't tell me it's not possible to compile C# to Java bytecode. Don't tell me there's no way to create a bridge between .NET and Java. This exact thing I'm looking for has been done before, you can see it here. However, it's no longer kept up. I'm asking for answers, not people telling me something isn't possible when it's been done before. Apparently, the last sentence of your "signature" is true, "No help will be given".

 

Edit

There is a reason I asked for projects to contribute to. If your skull is too thick to figure that out, I honestly feel bad. Since you obviously couldn't figure it out, let me explain: I asked for projects to contribute to so that I could contribute to a project. Seems obvious, but I guess not. I simply don't care enough about this to start a project like this from scratch.

Edited by Brendanp01
Link to comment
Share on other sites

2 minutes ago, diesieben07 said:

That is not what IKVM is. IKVM is a JVM written in Java, i.e. it runs java class files on .NET by being a JVM itself.

 

Of course its possible. Just requires a lot of work. Of course its possible write Minecraft mods in Brainfuck if you wanted to, you just need to put the work in to write the adapters.

 

 

Yes, you are correct, sorry.

Edited by Brendanp01
Link to comment
Share on other sites

11 minutes ago, Brendanp01 said:

Not possible? We already can compile Java to .NET assemblies using IKVM. Don't tell me it's not possible to compile C# to Java bytecode. Don't tell me there's no way to create a bridge between .NET and Java. This exact thing I'm looking for has been done before, you can see it here. However, it's no longer kept up. I'm asking for answers, not people telling me something isn't possible when it's been done before. Apparently, the last sentence of your "signature" is true, "No help will be given".

 

Edit

There is a reason I asked for projects to contribute to. If your skull is too thick to figure that out, I honestly feel bad. Since you obviously couldn't figure it out, let me explain: I asked for projects to contribute to so that I could contribute to a project. Seems obvious, but I guess not. I simply don't care enough about this to start a project like this from scratch.

I feel bad for you not being able to understand that THERE ARE NO PROJECTS TO CONTRIBUTE TO!! And that you will have to start from scratch to do this. Just use java. Way easier. 

Link to comment
Share on other sites

5 minutes ago, mandar1jn said:

I feel bad for you not being able to understand that THERE ARE NO PROJECTS TO CONTRIBUTE TO!! And that you will have to start from scratch to do this. Just use java. Way easier. 

This. I mean, unless you are trying to use C# for fun or education, just use Java. All the wrappers and who knows what else will just cause more problems and make things run slower if they work at all.

Edited by Nuke3d
Link to comment
Share on other sites

2 minutes ago, mandar1jn said:

I feel bad for you not being able to understand that THERE ARE NO PROJECTS TO CONTRIBUTE TO!! And that you will have to start from scratch to do this. Just use java. Way easier. 

One person on this entire page said anything about projects I could contribute to. And he didn't say there are none, he said he isn't aware of any. I thought at this point it was clear, I want answers. If you're just going to say something like "not possible" without looking into it at all, don't say anything.

Link to comment
Share on other sites

2 minutes ago, Nuke3d said:

This. I mean, unless you are trying to use C# for fun or education, just use Java. All the wrappers and who knows what else will just cause more problems and make things run slower if they work at all.

Yes, I'm aware. I'm not trying to do anything crazy. Just want to try out modding. Of the programming languages that I know how to use, Java is probably my least favorite. I know C# is similar to Java. However, I prefer the .NET platform, and I like the fact that I can use F# along with C#.

Link to comment
Share on other sites

3 minutes ago, Brendanp01 said:

Yes, I'm aware. I'm not trying to do anything crazy. Just want to try out modding. Of the programming languages that I know how to use, Java is probably my least favorite. I know C# is similar to Java. However, I prefer the .NET platform, and I like the fact that I can use F# along with C#.

I would recommend you start out modding in Java, and then once you feel you have decent command of that, if you still want to try doing it in C# go for it. You'll likely have the tools to make it happen on your own at that point too, and could start assembling your own group around the project. Good luck whatever you choose!

  • Like 1
Link to comment
Share on other sites

1 minute ago, Nuke3d said:

I would recommend you start out modding in Java, and then once you feel you have decent command of that, if you still want to try doing it in C# go for it. You'll likely have the tools to make it happen on your own at that point too, and could start assembling your own group around the project. Good luck whatever you choose!

Thank you! You're the most helpful anyone has been here.

Link to comment
Share on other sites

54 minutes ago, Brendanp01 said:

There is a reason I asked for projects to contribute to. If your skull is too thick to figure that out, I honestly feel bad. Since you obviously couldn't figure it out, let me explain: I asked for projects to contribute to so that I could contribute to a project. Seems obvious, but I guess not. I simply don't care enough about this to start a project like this from scratch.

The reason no projects exist is because there's no pre-written API. Because there is no pre-written API, it is not possible for you to contribute to an existing project. As such you would have to write the API yourself. In Java.

1 hour ago, Draco18s said:

Well, unfortunately, because of <thing you already know>, it isn't possible because <thing you already know.> As such what you want to do would require <doing things you don't want to do>.

 

image.png.5d5c0d93b0a395c836a500e520a602a3.png

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

11 minutes ago, Draco18s said:

The reason no projects exist is because there's no pre-written API. Because there is no pre-written API, it is not possible for you to contribute to an existing project. As such you would have to write the API yourself. In Java.

 

image.png.5d5c0d93b0a395c836a500e520a602a3.png

thing I already know = MC is written in Java

I asked if there were people who have already done this. I didn't ask what programming language MC is written, how modding with Forge works, or for you to tell me that there are none. If you don't know of any, don't say anything. If you do, great! Let me know. Icame here for help and so far you haven't said anything helpful.

Edited by Brendanp01
typo
Link to comment
Share on other sites

13 minutes ago, Brendanp01 said:

If you have a useful answer that will help me do what I want to do, then good.

You've gotten that answer. "You cannot."

13 minutes ago, Brendanp01 said:

If not, I don't want to hear it. However, if you say something stupid I'm not just going to ignore it.

Something something flies and honey.

  • Confused 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

2 minutes ago, Draco18s said:

You've gotten that answer. "You cannot."

Something something flies and honey.

Well, that's not true. I already gave you a link of an old project that did it. "You cannot", does not help me do what I want to do. It's not useful, since it isn't true.

Link to comment
Share on other sites

Let me clarify:

You cannot.

In general, yes it can be done, but you aren't interested in building those APIs and as those APIs don't already exist, the thing you want to do cannot be done.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

6 hours ago, Brendanp01 said:

Okay, I'm done arguing with idiotic people. I'll say it one more time, if you know what you're talking about, unlike some people (Draco18s), then tell me.

Look, when I decided to get into modding C# was the only language I knew. I saw forge and minecraft, were programmed in Java, but I didn't want to learn Java because I loved C#. I looked everywhere for ways to do it and couldn't find none. it's a non-sensical task: you'd need to write wrappers for all the classes that minecraft and forge provides, and then you would need to keep updating it everytime a new mapping or forge/minecraft version came out. it's a lot of work, for very little benefit, the modding communnity isn't big enough for this to be a reasonable project.

you could look into how to write c# that compiles to jar's, sure.. but you still would need access to classes that exist in Java code.

What I can tell you is that it is not worth it. We, programmers, can't fall in love for a language and try do to everything with it, it's a very common programming sin. You need to recognize the best language for the job, and accept it. And if you just ahte the language so much you can't even think of writing in it, then maybe not doing the project is just a better option

 

The best I could recommend you, if you really don't want to write Java, is to take a look at Kotlin or Scala, they are better versions of Java basically.

Or do what I did, learned Java, it isn't even that bad. but having to do C programming really lowered my bars

 

and also, maybe think a little bit before saying a Forum Moderator that has been contributing to the modding community for 8+ years, doesn't know what he's talking about. you're the newbie here, tyring to do something that is, honestly, idiotic

Edited by kiou.23
  • Thanks 1
Link to comment
Share on other sites

5 hours ago, Brendanp01 said:

Okay, I'm done arguing with idiotic people. I'll say it one more time, if you know what you're talking about, unlike some people (Draco18s), then tell me.

*sigh* <people who know what they're talking about> have already spoken up and told you what you needed to know. You didn't like what they had to say and now you're just being rude. You had some very insightful responses from people. Bottom line, it really isn't done because it really isn't feasible or worth the time. Minecraft is written in Java. I get that that may not be your favorite language, but if you want to do MC in C#, there are no known projects that will let you do this, so you'll have to do it yourself. You do not have the Java chops to do it yet and since there are no projects that will allow you to do it, your only choice is to learn to mod MC in Java until you are experienced enough to handle both the Java and C#(and possibly C++) stuff yourself. You do not sound experienced enough in any of those languages to pull it off. I've been around programmers my entire life (I'm almost 50) and experienced programmers...well, you can just tell when they are talking about what they're good at. Maybe I'm wrong(wouldn't be the first time) but my advice to you is to listen to the "elders" of the forum.

 

It sounds like you do not want to do this anyway, so, *shrug* I guess that's that.

 

And please don't take any of this as insult. It's not. It's just truth. Sometimes truth cuts deep. Life is like that.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Minecraft is written in Java.

Mods need to be written in a language that compiles to the JVM.

Any arguments over this is just stupid.

If you wanna write a mod in C# go find a game that is written in C#.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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