Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Minecraft Forge
  • General Discussion
  • Create mod that exposes subset of Forge through an IPC/RPC API?
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
LuciferK9

Create mod that exposes subset of Forge through an IPC/RPC API?

By LuciferK9, September 10, 2019 in General Discussion

  • Reply to this topic
  • Start new topic

Recommended Posts

LuciferK9    0

LuciferK9

LuciferK9    0

  • Tree Puncher
  • LuciferK9
  • Members
  • 0
  • 3 posts
Posted September 10, 2019 (edited)

I just started playing minecraft after a few years of not playing anymore, so I don't know much about Forge. Sorry for my ignorance in advance.

 

I was thinking about a mod that exposes an API to allow players to create a "mod" in any programming language (I'm going to refer to these "mods" as "xmods" to differentiate them from forge mods). Not the full Forge's API, just a subset of it, like events, or anything that can be exposed.

 

Basically, the mod would receive messages from xmods and do whatever they say and send messages to them telling them whatever it is happening in the minecraft world.

 

I haven't thought about the specific details of the implementation, but for the messages we could use something like protobuf or flatbuffers, this way we could specificate the schema for the API and use it in different languages easily. The communication could be over TCP, or maybe the mod could spawn the xmods in child processes and communicate over stdin/stdout.

 

The schema could look something like:

message CommonEntityProps {
	Vector3 coordinates;
	int32 life;
	...
}

message ServerEvent {
	optional PlayerPlacedBlockEvent player_placed_block = 1;
	...
}

message Entity {
	...
}

message Player {
	required CommonEntityProps common;
	...
}

message Block {
	required Vector3 coordinates;
	required BlockType type;
	...
}

message PlayerPlacedBlockEvent {
	required Player player;
	required Block block;
	...
}

 

This is not supposed to be a replacement to mods. Just a way to easily create custom content without having to download and learn forge and without the trouble that java brings (for people that don't like it).

 

Maybe someone has an idea and needs to quickly make a prototype and they decide to use python or javascript, just to test it and have fun in single player or lan with friends.

 

This would also allow to create, automatize and invent new stuff very quickly. Imagine a player trying to build a giant pyramid where every 3 blocks there is a diamond block or something, this could be easily created in a script with less than 10 lines of code, and when you get to the top, you get burn because there's a god punishing you.

 

Yesterday I was trying to create a basic game mode where you have to throw a player out of a platform, kill the player automatically if they're below an Y coordinate, and give them full armor and custom items after they respawn, I had problems making it with just command blocks. I would've liked to use some if statements but could not afford setting up forge, read the documentation, and probably download intellij because from what I remember, it's a pain in the *** to code java in something like vim or any other editor that is not an IDE.

 

Some code in Rust on how I would like this to look like:

use forge_xmod::{
    Client, Event,
    player::{ Player, Inventory },
    minecraft::{ Enchantment, Item },
};

fn main() {
    let client = Client::connect("127.0.0.1:9999");

    loop {
        while let Some(event) = client.poll_event() {
            match event {
                Event::PlayerPlacedBlock(player, block) => {
                    println!("The player {} placed a block ({}) on: {}", player, block, block.coordinates);
                },
                Event::PlayerMoved(player) => {
                    if player.coordinates.y < 50 {
                        // this would send a TCP? packet, telling the mod to kill said player. Serialized with protobuf?
                        player.kill();
                    }
                },
            }
        }
        for player in client.players() {
            if !player.inventory.contains(Item::DiamondSword) {
                let mut item = Item::DiamondSword;
                item.enchant(Enchantment::Sharpness, 4);
                player.inventory.insert(item); // send packet
            }
        }
    }
}

I could just then compile it, run it and it would already work. Other person could do the same in JavaScript, C++, etc.

 

I want to read your opinions and see if anyone is interested in working on something like this. As I said, I don't know much about Forge, so I would like some help since I plan to make this anyways, at least to fit my needs. I would help to find where the main Forge APIs are located to see if I can generate the schema programatically.

Edited September 10, 2019 by LuciferK9
Minor edit
  • Quote

Share this post


Link to post
Share on other sites

ShinyAfro    0

ShinyAfro

ShinyAfro    0

  • Tree Puncher
  • ShinyAfro
  • Members
  • 0
  • 10 posts
Posted September 10, 2019 (edited)

Java is pretty easy with intelliJ really. Also lex has said in the past he's not including other languages in forge. Forge is for java. If you need another language lib / cross compatability, you best make your own in java. 

 

At that point honestly just write it in java. Or Kotlin / Scala etc which have their libs you can include and run on JVM bytecode. Better then having to bog things down with cross language stuff.  Writing using intelliJ is easy. You can write without, i used to write C# in notepad++ to be frank and it never bothered me much, just got to check them compile errors and your code is trash and slow because you have no IDE assists.

Java is honestly one of the easier OO languages. Less to worry about then say C++ etc. or any of the big languages, Rust is trying to replace C++ along with Golang and Dlang so it in theory would be quite more low level the java but honestly out of the 4, i'd probably be more inclined to learn D / Go if i had to. Either way point is i don't really like rust and have never really learned it so i could be off the mark on how easy it is to learn but when it's trying to replace C++ you would assume it would be more low level. 

Edited September 10, 2019 by ShinyAfro
  • Quote

Share this post


Link to post
Share on other sites

LuciferK9    0

LuciferK9

LuciferK9    0

  • Tree Puncher
  • LuciferK9
  • Members
  • 0
  • 3 posts
Posted September 10, 2019
5 hours ago, ShinyAfro said:

Java is pretty easy with intelliJ really. Also lex has said in the past he's not including other languages in forge. Forge is for java. If you need another language lib / cross compatability, you best make your own in java.

I know Java is easy with intelliJ, the post was not about java being difficult, was about just wanting to code in a better language. I wasn't asking to include compatibility in Forge with another language, I was talking about creating a mod that exposes the API through RPC/IPC. It's not a feature request, that's why it's here in general discussion.

 

5 hours ago, ShinyAfro said:

At that point honestly just write it in java. Or Kotlin / Scala etc which have their libs you can include and run on JVM bytecode. Better then having to bog things down with cross language stuff.  Writing using intelliJ is easy. You can write without, i used to write C# in notepad++ to be frank and it never bothered me much, just got to check them compile errors and your code is trash and slow because you have no IDE assists.

I don't think a language should depend on an IDE. The only language (that I know) that lacks command line tools is java. Even C# with .NET Core already has better tooling that allows people to write code efficiently without using a full IDE.

 

5 hours ago, ShinyAfro said:

Java is honestly one of the easier OO languages. Less to worry about then say C++ etc. or any of the big languages, Rust is trying to replace C++ along with Golang and Dlang so it in theory would be quite more low level the java but honestly out of the 4, i'd probably be more inclined to learn D / Go if i had to. Either way point is i don't really like rust and have never really learned it so i could be off the mark on how easy it is to learn but when it's trying to replace C++ you would assume it would be more low level. 

D, GoLang, Rust and modern C++ are just as easy as java. But using these languages you have a set of features that you can opt-in if you want to write lower-level code or make some hand-crafted optimizations.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7589

diesieben07

diesieben07    7589

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7589
  • 54989 posts
Posted September 10, 2019
51 minutes ago, LuciferK9 said:

The only language (that I know) that lacks command line tools is java.

There are plenty of build tools (Gradle or Maven to name two of the most common). They make it "easy" (well, as easy as it gets) to write Java with a normal text editor + the command line.

 

As for your request: Sure, it's perfectly possible. If you want to use proto buffers you might want to look into GRPC.

Personally though, I don't see this being useful as it will always be inherently limited in what you can do. Forge mods can do pretty much everything in the game. Something is a private field? You can reflect into it and change it anyways.

  • Quote

Share this post


Link to post
Share on other sites

DavidM    179

DavidM

DavidM    179

  • World Shaper
  • DavidM
  • Members
  • 179
  • 1821 posts
Posted September 11, 2019

Personally, this is probably not necessary.

This would means that the developer need to write a hook in all the said languages to expose the Forge API. This of course includes the circumvention of non dynamically loadable languages like C++. Unless you meant to parse the said languages into a intermediate form (which probably require more effort, as a compiler is needed), which is then loaded by the "xmod", but this would make the user unable to access Minecraft and Forge with reflection and ASM.

 

18 hours ago, LuciferK9 said:

The only language (that I know) that lacks command line tools is java.

You can compile and run Java code from the command line. However, writing Java (and most other static languages) without an IDE would be a pain and is not recommended.

  • Quote

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Share this post


Link to post
Share on other sites

ShinyAfro    0

ShinyAfro

ShinyAfro    0

  • Tree Puncher
  • ShinyAfro
  • Members
  • 0
  • 10 posts
Posted September 14, 2019
On 9/11/2019 at 2:48 AM, LuciferK9 said:

I know Java is easy with intelliJ, the post was not about java being difficult, was about just wanting to code in a better language. I wasn't asking to include compatibility in Forge with another language, I was talking about creating a mod that exposes the API through RPC/IPC. It's not a feature request, that's why it's here in general discussion.

 

I don't think a language should depend on an IDE. The only language (that I know) that lacks command line tools is java. Even C# with .NET Core already has better tooling that allows people to write code efficiently without using a full IDE.

 

D, GoLang, Rust and modern C++ are just as easy as java. But using these languages you have a set of features that you can opt-in if you want to write lower-level code or make some hand-crafted optimizations.

Well a little while ago there was a bunch of hackers on the 1.7.10 mods and i noticed a few mods used RPC from netty to execute java bytecode. You might want to look into that if you want to make a mod for any language you want to make some sort of library.

 

And hell yes i have written C# in a text editor and you can do the same with java, I just don't see the why when said tools greatly accelerate my workflow. Eclipse is another good editor.

 

  • Quote

Share this post


Link to post
Share on other sites

LuciferK9    0

LuciferK9

LuciferK9    0

  • Tree Puncher
  • LuciferK9
  • Members
  • 0
  • 3 posts
Posted September 15, 2019

Hey, guys! Sorry for not replying before. I've been busy.

 

I decided to do the same but for plugins instead. I wanted to do this because I like to create quick games for me and my sister, and it makes more sense to do it on a server.

 

Thank you for your replies!

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      [1.15.2] Render as 2D icon in GUI, 3D model in hand

      By diesieben07 · Posted 23 minutes ago

      The loader is an inner class: https://github.com/MinecraftForge/MinecraftForge/blob/1.16.x/src/main/java/net/minecraftforge/client/model/SeparatePerspectiveModel.java#L164   You need to register the loader (see where Forge does it). Then the loader will be called to load the JSON model into memory.
    • Woodside
      [1.15.2] Render as 2D icon in GUI, 3D model in hand

      By Woodside · Posted 36 minutes ago

      Loader, is that another class I extend off of? Is that SeparaterPerspectiveModel? I really have no context for how these pieces of information fit together. Can you explain with some more detail?
    • ChampionAsh5357
      [1.16.4] Looking to add trades to villagers/wandering traders

      By ChampionAsh5357 · Posted 1 hour ago

      Villagers can be added via VillagerTradesEvent while wandering traders via WandererTradesEvent.
    • ChampionAsh5357
      [1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES

      By ChampionAsh5357 · Posted 1 hour ago

      Yes, as you can see it has the obfuscated name which translate to its unique srg name and then finally the mapped name. You will need the srg name as your parameter. The static keyword makes the field/method available at class level meaning you do not need an instance to grab the associated value. So, a null value can be passed in instead.
    • ChampionAsh5357
      [1.16] Transparent Picture Render in GUI

      By ChampionAsh5357 · Posted 1 hour ago

      Setting the alpha state does not enable transparency. You need to set up the blend function in such a way such that the rgba inputs are being blended correctly. This is why I mentioned TRANSLUCENT_TRANSPARENCY.
  • Topics

    • Woodside
      10
      [1.15.2] Render as 2D icon in GUI, 3D model in hand

      By Woodside
      Started 19 hours ago

    • basicsid
      1
      [1.16.4] Looking to add trades to villagers/wandering traders

      By basicsid
      Started 6 hours ago

    • Klarks
      9
      [1.16.4] How i can put my strucnures in to FlatGenerationSettings.STRUCTURES

      By Klarks
      Started 20 hours ago

    • monkeysHK
      3
      [1.16] Transparent Picture Render in GUI

      By monkeysHK
      Started Yesterday at 12:19 AM

    • kiou.23
      12
      Is it normal for configuration to take this long?

      By kiou.23
      Started Thursday at 09:57 PM

  • Who's Online (See full list)

    • diesieben07
    • ChampionAsh5357
    • CookieLukas
    • RedCo0rp
    • Lellian
    • Danebi
    • loordgek
    • Somonestolemyusername
    • Woodside
  • All Activity
  • Home
  • Minecraft Forge
  • General Discussion
  • Create mod that exposes subset of Forge through an IPC/RPC API?
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community