Skip to content

Commit

Permalink
initial support for multiple agents on server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
noskill committed Oct 29, 2024
1 parent 449a129 commit 508f248
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 6 deletions.
1 change: 1 addition & 0 deletions server/config.xml
1 change: 1 addition & 0 deletions server/launch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -Dlog4j.configurationFile=`pwd`/config.xml -Xmx2G -jar fabric-server-mc.1.21-loader.0.16.5-launcher.1.0.1.jar
63 changes: 63 additions & 0 deletions server/server.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#Minecraft server properties
#Tue Oct 29 19:57:45 MSK 2024
accepts-transfers=false
allow-flight=false
allow-nether=true
broadcast-console-to-ops=true
broadcast-rcon-to-ops=true
bug-report-link=
difficulty=easy
enable-command-block=false
enable-jmx-monitoring=false
enable-query=false
enable-rcon=false
enable-status=true
enforce-secure-profile=false
enforce-whitelist=false
entity-broadcast-range-percentage=100
force-gamemode=false
function-permission-level=2
gamemode=survival
generate-structures=true
generator-settings={"biome"\:"minecraft\:desert","layers"\:[{"block"\:"minecraft\:bedrock","height"\:1},{"block"\:"minecraft\:stone","height"\:3},{"block"\:"minecraft\:sandstone","height"\:116}],"structures"\:{"village"\:{}}}
hardcore=false
hide-online-players=false
initial-disabled-packs=
initial-enabled-packs=vanilla
level-name=world
level-seed=
level-type=minecraft\:normal
log-ips=true
max-chained-neighbor-updates=1000000
max-players=20
max-tick-time=60000
max-world-size=29999984
motd=A Minecraft Server
network-compression-threshold=256
online-mode=false
op-permission-level=4
player-idle-timeout=0
prevent-proxy-connections=false
pvp=true
query.port=25565
rate-limit=0
rcon.password=
rcon.port=25575
region-file-compression=deflate
require-resource-pack=false
resource-pack=
resource-pack-id=
resource-pack-prompt=
resource-pack-sha1=
server-ip=
server-port=25565
simulation-distance=10
spawn-animals=true
spawn-monsters=true
spawn-npcs=true
spawn-protection=16
sync-chunk-writes=true
text-filtering-config=
use-native-transport=true
view-distance=10
white-list=false
Original file line number Diff line number Diff line change
Expand Up @@ -1388,8 +1388,9 @@ public void onClientTick(MinecraftClient client)

if (agents.size() > 1 && currentMissionInit().getClientRole() != 0)
{
/*
throw new RuntimeException("Not implemented");
/*
// We are waiting to join an out-of-process server. Need to pay attention to what happens -
// if we can't join, for any reason, we should abort the mission.
GuiScreen screen = Minecraft.getMinecraft().currentScreen;
Expand Down Expand Up @@ -1423,7 +1424,7 @@ protected void execute() throws Exception
//if (agents == null || agents.size() <= currentMissionInit().getClientRole())
// throw new Exception("No agent section for us!"); // TODO
this.agentName = agents.get(currentMissionInit().getClientRole()).getName();

/*
if (agents.size() > 1 && currentMissionInit().getClientRole() != 0)
{
// Multi-agent mission, we should be joining a server.
Expand All @@ -1445,7 +1446,7 @@ protected void execute() throws Exception
}
this.waitingForPlayer = false;
LOGGER.info("player exists and names match");
}
}*/
}

protected void handleLan()
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/io/singularitynet/Client/VereyaModClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ public void onKey(long window, int key, int scancode, int action, int modifiers)

@Override
public void onInitializeClient() {
LOGGER.info("initialising vereya mod client");
this.stateMachine = new ClientStateMachine(ClientState.WAITING_FOR_MOD_READY, (IMalmoModClient) this);
// subscribe to setScreen event
ScreenEvents.SET_SCREEN.register(this);
PayloadTypeRegistry.playS2C().register(MessagePayload.ID, MessagePayload.CODEC);
// register the instance for messages from Server to the Client
// this is registered in VereyaModServer even on client
// PayloadTypeRegistry.playS2C().register(MessagePayload.ID, MessagePayload.CODEC);
ClientPlayNetworking.registerGlobalReceiver(MessagePayload.ID,
(payload, context) -> { SidesMessageHandler.server2client.onMessage(payload, context) ; });
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/io/singularitynet/Server/VereyaModServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,17 @@ public boolean hasServer(){

@Override
public void onInitialize() {
Logger LOGGER = LogManager.getLogger();
LOGGER.info("initialising vereya mod server");
instance = this;
PayloadTypeRegistry.playC2S().register(MessagePayload.ID, MessagePayload.CODEC);
PayloadTypeRegistry.playS2C().register(MessagePayload.ID, MessagePayload.CODEC);
// register the instance for messages from Client to the Server
ServerPlayNetworking.registerGlobalReceiver(MessagePayload.ID, (payload, context) -> {
SidesMessageHandler.client2server.onMessage(payload, context);
});
ServerLifecycleEvents.SERVER_STARTED.register((MinecraftServer server) -> {
Logger LOGGER = LogManager.getLogger();

LOGGER.info("Server started");
if (stateMachine == null ) {
this.stateMachine = new ServerStateMachine(ServerState.WAITING_FOR_MOD_READY, null, server);
Expand Down

0 comments on commit 508f248

Please sign in to comment.