Skip to content

Commit

Permalink
use VERSION file to set version
Browse files Browse the repository at this point in the history
  • Loading branch information
noskill committed Jul 17, 2023
1 parent 1f869fe commit 5ea0fee
Show file tree
Hide file tree
Showing 16 changed files with 165 additions and 158 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.1.5
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

version = "0.1.4"
version = rootProject.file('VERSION').text.trim()
archivesBaseName = project.archives_base_name + '-fabric_' + project.fabric_version
group = project.maven_group

Expand Down
72 changes: 36 additions & 36 deletions src/main/java/io/singularitynet/Client/ClientStateMachine.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public ClientStateMachine(ClientState initialState, IMalmoModClient malmoModClie
ClientTickEvents.END_CLIENT_TICK.register(client -> this.onClientTick(client));
ClientEntityEvents.ENTITY_LOAD.register(this::onEntityLoad);
ClientEntityEvents.ENTITY_UNLOAD.register(this::onEntityUnoad);
SidesMessageHandler.server2client.registerForMessage(this, MalmoMessageType.SERVER_TEXT);
SidesMessageHandler.server2client.registerForMessage(this, VereyaMessageType.SERVER_TEXT);
setupClientCallbacks();
}

Expand Down Expand Up @@ -252,14 +252,14 @@ public IScreenHelper getScreenHelper()
}

@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data)
public void onMessage(VereyaMessageType messageType, Map<String, String> data)
{
LOGGER.info("got message type " + messageType.toString());
if (messageType == MalmoMessageType.SERVER_TEXT)
if (messageType == VereyaMessageType.SERVER_TEXT)
{
LOGGER.info("got server text message" + data.toString());
}
if (messageType == MalmoMessageType.SERVER_STOPPED) {
if (messageType == VereyaMessageType.SERVER_STOPPED) {
this.onServerStopped();
}
}
Expand All @@ -269,7 +269,7 @@ public void onServerStopped(){
}

@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data, ServerPlayerEntity player) {
public void onMessage(VereyaMessageType messageType, Map<String, String> data, ServerPlayerEntity player) {
LOGGER.info("got message type " + messageType.toString());
}

Expand Down Expand Up @@ -814,7 +814,7 @@ public abstract class ErrorAwareEpisode extends StateEpisode implements IVereyaM
public ErrorAwareEpisode(ClientStateMachine machine)
{
super(machine);
// MalmoMod.MalmoMessageHandler.registerForMessage(this, MalmoMessageType.SERVER_ABORT);
// MalmoMod.MalmoMessageHandler.registerForMessage(this, VereyaMessageType.SERVER_ABORT);
}

protected boolean pingAgent(boolean abortIfFailed)
Expand All @@ -841,14 +841,14 @@ protected boolean pingAgent(boolean abortIfFailed)
}

@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data, ServerPlayerEntity player) {
public void onMessage(VereyaMessageType messageType, Map<String, String> data, ServerPlayerEntity player) {
throw new RuntimeException("Got server message in client");
}

@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data)
public void onMessage(VereyaMessageType messageType, Map<String, String> data)
{
if (messageType == MalmoMessageType.SERVER_ABORT)
if (messageType == VereyaMessageType.SERVER_ABORT)
{
synchronized (this)
{
Expand Down Expand Up @@ -878,7 +878,7 @@ public void onMessage(MalmoMessageType messageType, Map<String, String> data)
public void cleanup()
{
super.cleanup();
// MalmoMod.MalmoMessageHandler.deregisterForMessage(this, MalmoMessageType.SERVER_ABORT);
// MalmoMod.MalmoMessageHandler.deregisterForMessage(this, VereyaMessageType.SERVER_ABORT);
}

protected boolean inAbortState()
Expand Down Expand Up @@ -1193,7 +1193,7 @@ public void run() {
}
// send mission init to server
ClientPlayNetworking.send(NetworkConstants.CLIENT2SERVER,
(new VereyaMessage(MalmoMessageType.CLIENT_MISSION_INIT, 0, map)).toBytes());
(new VereyaMessage(VereyaMessageType.CLIENT_MISSION_INIT, 0, map)).toBytes());
episodeHasCompleted(ClientState.WAITING_FOR_SERVER_READY);
}
} else { // not needNewWorld and no world: error
Expand All @@ -1220,7 +1220,7 @@ public class WaitingForServerEpisode extends ErrorAwareEpisode implements IVerey
protected WaitingForServerEpisode(ClientStateMachine machine)
{
super(machine);
SidesMessageHandler.server2client.registerForMessage(this, MalmoMessageType.SERVER_ALLPLAYERSJOINED);
SidesMessageHandler.server2client.registerForMessage(this, VereyaMessageType.SERVER_ALLPLAYERSJOINED);
}

private boolean isChunkReady()
Expand Down Expand Up @@ -1307,7 +1307,7 @@ public void onClientTick(MinecraftClient client)
currentMissionBehaviour().appendExtraServerInformation(map);
LOGGER.info("***Telling server we are ready - " + agentName);
ClientPlayNetworking.send(NetworkConstants.CLIENT2SERVER,
(new VereyaMessage(MalmoMessageType.CLIENT_AGENTREADY, 0, map)).toBytes());
(new VereyaMessage(VereyaMessageType.CLIENT_AGENTREADY, 0, map)).toBytes());
}

// We also ping our agent, just to check it is still available:
Expand Down Expand Up @@ -1418,12 +1418,12 @@ protected void handleLan()
}

@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data)
public void onMessage(VereyaMessageType messageType, Map<String, String> data)
{
LOGGER.debug("ClientStateMachine:onMessage: " + messageType);
super.onMessage(messageType, data);

if (messageType != MalmoMessageType.SERVER_ALLPLAYERSJOINED)
if (messageType != VereyaMessageType.SERVER_ALLPLAYERSJOINED)
return;
MinecraftClient client = MinecraftClient.getInstance();
if (ClientStateMachine.this.serverHandlers != null)
Expand Down Expand Up @@ -1491,7 +1491,7 @@ public void onMessage(MalmoMessageType messageType, Map<String, String> data)
}

@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data, ServerPlayerEntity player) {
public void onMessage(VereyaMessageType messageType, Map<String, String> data, ServerPlayerEntity player) {
throw new RuntimeException("Unexpected message to server");
}

Expand Down Expand Up @@ -1538,7 +1538,7 @@ private void proceed()
public void cleanup()
{
super.cleanup();
SidesMessageHandler.server2client.deregisterForMessage(this, MalmoMessageType.SERVER_ALLPLAYERSJOINED);
SidesMessageHandler.server2client.deregisterForMessage(this, VereyaMessageType.SERVER_ALLPLAYERSJOINED);
}
}

Expand All @@ -1555,8 +1555,8 @@ public class MissionRunningEpisode extends ErrorAwareEpisode implements VideoPro
protected MissionRunningEpisode(ClientStateMachine machine)
{
super(machine);
SidesMessageHandler.server2client.registerForMessage(this, MalmoMessageType.SERVER_STOPAGENTS);
SidesMessageHandler.server2client.registerForMessage(this, MalmoMessageType.SERVER_GO);
SidesMessageHandler.server2client.registerForMessage(this, VereyaMessageType.SERVER_STOPAGENTS);
SidesMessageHandler.server2client.registerForMessage(this, VereyaMessageType.SERVER_GO);
}

boolean serverHasFiredStartingPistol = false;
Expand Down Expand Up @@ -1602,7 +1602,7 @@ protected void onMissionStarted()
// Tell the server we have started:
HashMap<String, String> map = new HashMap<String, String>();
map.put("username", MinecraftClient.getInstance().player.getName().getString());
VereyaMessage msg = new VereyaMessage(MalmoMessageType.CLIENT_AGENTRUNNING, 0, map);
VereyaMessage msg = new VereyaMessage(VereyaMessageType.CLIENT_AGENTRUNNING, 0, map);
ClientPlayNetworking.send(NetworkConstants.CLIENT2SERVER, msg.toBytes());

// Set up our mission handlers:
Expand Down Expand Up @@ -1781,7 +1781,7 @@ public void onClientTick(MinecraftClient event)
map.put("username", MinecraftClient.getInstance().player.getName().getString());
map.put("quitcode", this.quitCode);
LOGGER.info("informing server that player has quited");
ClientPlayNetworking.send(NetworkConstants.CLIENT2SERVER, (new VereyaMessage(MalmoMessageType.CLIENT_AGENTFINISHEDMISSION, 0, map)).toBytes());
ClientPlayNetworking.send(NetworkConstants.CLIENT2SERVER, (new VereyaMessage(VereyaMessageType.CLIENT_AGENTFINISHEDMISSION, 0, map)).toBytes());
ClientStateMachine.this.cancelReservation();
onMissionEnded(ClientState.IDLING, null);
}
Expand Down Expand Up @@ -1950,11 +1950,11 @@ private boolean handleCommand(String command)
}

@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data)
public void onMessage(VereyaMessageType messageType, Map<String, String> data)
{
super.onMessage(messageType, data);
// This message will be sent to us once the server has decided the mission is over.
if (messageType == MalmoMessageType.SERVER_STOPAGENTS)
if (messageType == VereyaMessageType.SERVER_STOPAGENTS)
{
this.quitCode = data.containsKey("QuitCode") ? data.get("QuitCode") : "";
/*
Expand All @@ -1974,7 +1974,7 @@ public void onMessage(MalmoMessageType messageType, Map<String, String> data)
*/

onMissionEnded(ClientState.MISSION_ENDED, null);
} else if (messageType == MalmoMessageType.SERVER_GO) {
} else if (messageType == VereyaMessageType.SERVER_GO) {
this.serverHasFiredStartingPistol = true; // GO GO GO!
} else {
throw new RuntimeException("unexpected message received " + messageType.name());
Expand All @@ -1985,8 +1985,8 @@ public void onMessage(MalmoMessageType messageType, Map<String, String> data)
public void cleanup()
{
super.cleanup();
SidesMessageHandler.server2client.deregisterForMessage(this, MalmoMessageType.SERVER_STOPAGENTS);
SidesMessageHandler.server2client.deregisterForMessage(this, MalmoMessageType.SERVER_GO);
SidesMessageHandler.server2client.deregisterForMessage(this, VereyaMessageType.SERVER_STOPAGENTS);
SidesMessageHandler.server2client.deregisterForMessage(this, VereyaMessageType.SERVER_GO);
}
}

Expand Down Expand Up @@ -2091,7 +2091,7 @@ protected void execute()
if (player != null) // Might not be a player yet.
map.put("username", player.getName().getString());
map.put("error", ClientStateMachine.this.getErrorDetails());
PacketByteBuf buf = new VereyaMessage(MalmoMessageType.CLIENT_BAILED, 0, map).toBytes();
PacketByteBuf buf = new VereyaMessage(VereyaMessageType.CLIENT_BAILED, 0, map).toBytes();
LOGGER.debug("informing server of a failure with: " + map.toString());
ClientPlayNetworking.send(NetworkConstants.CLIENT2SERVER, buf);
}
Expand Down Expand Up @@ -2188,7 +2188,7 @@ public class WaitingForServerMissionEndEpisode extends ErrorAwareEpisode
protected WaitingForServerMissionEndEpisode(ClientStateMachine machine)
{
super(machine);
SidesMessageHandler.server2client.registerForMessage(this, MalmoMessageType.SERVER_MISSIONOVER);
SidesMessageHandler.server2client.registerForMessage(this, VereyaMessageType.SERVER_MISSIONOVER);
}

@Override
Expand All @@ -2204,22 +2204,22 @@ protected void execute() throws Exception
HashMap<String, String> map = new HashMap<String, String>();
map.put("agentname", agentName);
ClientPlayNetworking.send(NetworkConstants.CLIENT2SERVER,
new VereyaMessage(MalmoMessageType.CLIENT_AGENTSTOPPED, 0, map).toBytes());
new VereyaMessage(VereyaMessageType.CLIENT_AGENTSTOPPED, 0, map).toBytes());
}

@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data)
public void onMessage(VereyaMessageType messageType, Map<String, String> data)
{
super.onMessage(messageType, data);
if (messageType == MalmoMessageType.SERVER_MISSIONOVER)
if (messageType == VereyaMessageType.SERVER_MISSIONOVER)
episodeHasCompleted(ClientState.DORMANT);
}

@Override
public void cleanup()
{
super.cleanup();
SidesMessageHandler.server2client.deregisterForMessage(this, MalmoMessageType.SERVER_MISSIONOVER);
SidesMessageHandler.server2client.deregisterForMessage(this, VereyaMessageType.SERVER_MISSIONOVER);
}

@Override
Expand All @@ -2240,7 +2240,7 @@ public class MissionIdlingEpisode extends ErrorAwareEpisode
protected MissionIdlingEpisode(ClientStateMachine machine)
{
super(machine);
SidesMessageHandler.server2client.registerForMessage(this, MalmoMessageType.SERVER_STOPAGENTS);
SidesMessageHandler.server2client.registerForMessage(this, VereyaMessageType.SERVER_STOPAGENTS);
}

@Override
Expand All @@ -2250,19 +2250,19 @@ protected void execute()
}

@Override
public void onMessage(MalmoMessageType messageType, Map<String, String> data)
public void onMessage(VereyaMessageType messageType, Map<String, String> data)
{
super.onMessage(messageType, data);
// This message will be sent to us once the server has decided the mission is over.
if (messageType == MalmoMessageType.SERVER_STOPAGENTS)
if (messageType == VereyaMessageType.SERVER_STOPAGENTS)
episodeHasCompleted(ClientState.MISSION_ENDED);
}

@Override
public void cleanup()
{
super.cleanup();
SidesMessageHandler.server2client.deregisterForMessage(this, MalmoMessageType.SERVER_STOPAGENTS);
SidesMessageHandler.server2client.deregisterForMessage(this, VereyaMessageType.SERVER_STOPAGENTS);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/singularitynet/IVereyaMessageListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

public interface IVereyaMessageListener
{
void onMessage(MalmoMessageType messageType, Map<String, String> data);
void onMessage(MalmoMessageType messageType, Map<String, String> data, ServerPlayerEntity player);
void onMessage(VereyaMessageType messageType, Map<String, String> data);
void onMessage(VereyaMessageType messageType, Map<String, String> data, ServerPlayerEntity player);
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class CommandForWheeledRobotNavigationImplementation extends CommandBase
/** Small MovementInput class that calls our own movement handling code.
* This object is used by Minecraft to decide how to move the player.
*/
@Environment(value= EnvType.SERVER)
@Environment(value= EnvType.CLIENT)
public class AIMovementInput extends KeyboardInput {

public AIMovementInput(GameOptions settings) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,42 @@

import io.singularitynet.VereyaMessage;
import io.singularitynet.NetworkConstants;
import io.singularitynet.VereyaMessageType;
import io.singularitynet.projectmalmo.MissionInit;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;

import java.util.Map;

public class CommandForWheeledRobotNavigationMobImplementation extends CommandBase {


public static class MotionMessage extends VereyaMessage {

public MotionMessage(String parameters, String uuid, String value){
super(VereyaMessageType.CLIENT_MOVE, parameters);
this.getData().put("uuid", uuid);
this.getData().put("value", value);
}

public MotionMessage(Map<String, String> data) {
super(VereyaMessageType.CLIENT_MOVE, data.get("message"));
this.getData().put("uuid", data.get("uuid"));
this.getData().put("value", data.get("value"));
}

public String getUuid(){
return this.getData().get("uuid");
}

public String getValue(){
return this.getData().get("value");
}

public String getVerb(){
return this.getData().get("message");
}
}

@Override
public boolean isOverriding() {
return false;
Expand Down Expand Up @@ -41,7 +73,7 @@ protected boolean onExecute(String verb, String parameter, MissionInit missionIn
parameter = params[1];


VereyaMessage vereyaMessage = new CommandForWheeledRobotNavigationMobImplementationServer.MotionMessage(verb, entity_uuid, parameter);
VereyaMessage vereyaMessage = new MotionMessage(verb, entity_uuid, parameter);

ClientPlayNetworking.send(NetworkConstants.CLIENT2SERVER, vereyaMessage.toBytes());
return true;
Expand Down
Loading

0 comments on commit 5ea0fee

Please sign in to comment.