Skip to content

Commit

Permalink
Merge pull request #153 from LandOfRails/feature/issue-151-rail-switc…
Browse files Browse the repository at this point in the history
…h-always-points-left-from-either-perspective

Feature/issue 151 rail switch always points left from either perspective
  • Loading branch information
Danielxs01 authored Feb 15, 2024
2 parents e09c4c2 + 6ebf438 commit de6fd3d
Show file tree
Hide file tree
Showing 60 changed files with 11,150 additions and 2,108 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### Release 1.3.2

* Fixed [#151] : Rail switch always points left from either perspective
* Added [#151] : Added three more versions of the switch stand


* Added : SH2 with light as top and full version
* Improved : LF1 model (fixed lights)

### Release 1.3.1

* Fixed [#143] : Manipulator didn't work on multiplayer (NullPointerException on client)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.1
1.3.2
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ public static GenericContentPack fromJson(InputStream jsonInputStream) {
return gson.fromJson(json, GenericContentPack.class);
}

public String toShortString(){
return String.format("[Addonversion: %s; Name: %s; Packversion: %s; Author: %s]", addonversion, name, packversion, author);
}

}
33 changes: 28 additions & 5 deletions src/main/java/net/landofrails/landofsignals/LOSBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ public static void register() {
registerSignContentPack("block_sign_part_gsar_ne1", "GSAR Trapeztafel NE1", true, models("models/block/landofsignals/signs/gsar/ne1/signalne1.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f})}, blockSignPartMetalRod.getKey(), blockSignPartMetalRod.getValue()));

// Signs: SH2
registerSignContentPack("block_sign_part_gsar_sh2_full_wo_light", "GSAR Schutzsignal SH2 (Full, w/o Light)", false, Collections.singletonMap("models/block/landofsignals/signs/gsar/sh2/signalsh2.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0.5f, 0.5f, 0.5f}, new String[]{"Sign01_SI01", "MetalRodLong_MR02"})}));
registerSignContentPack("block_sign_part_gsar_sh2_top_wo_light", "GSAR Schutzsignal SH2 (Top, w/o Light)", false, Collections.singletonMap("models/block/landofsignals/signs/gsar/sh2/signalsh2.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new String[]{"Sign01_SI01", "MetalRod_MR01"})}));
registerSignContentPack("block_sign_part_gsar_sh2_full_wo_light", "GSAR Schutzsignal SH2 (Full, w/o light)", false, Collections.singletonMap("models/block/landofsignals/signs/gsar/sh2/signalsh2.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0.5f, 0.5f, 0.5f}, new String[]{"Sign01_SI01", "MetalRodLong_MR02"})}));
registerSignContentPack("block_sign_part_gsar_sh2_top_wo_light", "GSAR Schutzsignal SH2 (Top, w/o light)", false, Collections.singletonMap("models/block/landofsignals/signs/gsar/sh2/signalsh2.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new String[]{"Sign01_SI01", "MetalRod_MR01"})}));
registerSignContentPack("block_sign_part_gsar_sh2_full_w_light", "GSAR Schutzsignal SH2 (Full, with light)", false, Collections.singletonMap("models/block/landofsignals/signs/gsar/sh2/signalsh2.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0.5f, 0.5f, 0.5f}, new String[]{"Sign01_SI01", "MetalRodLong_MR02", "RedLightOn_RLOn", "RedLightOff_RLOff"})}));
registerSignContentPack("block_sign_part_gsar_sh2_top_w_light", "GSAR Schutzsignal SH2 (Top, with light)", false, Collections.singletonMap("models/block/landofsignals/signs/gsar/sh2/signalsh2.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new String[]{"Sign01_SI01", "MetalRod_MR01", "RedLightOn_RLOn", "RedLightOff_RLOff"})}));

// Signs: Hecto Signs
registerSignContentPack("block_sign_part_gsar_hecto_sign", "GSAR Hectosignal", true, models("models/block/landofsignals/signs/gsar/hectosign/hectosign.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f})}, blockSignPartMetalRod.getKey(), blockSignPartMetalRod.getValue()));
Expand Down Expand Up @@ -420,9 +422,30 @@ public static void register() {

registerLeverContentPack(
"switchstand_jake",
"Switch stand by Jake Steampson",
models("models/block/landofsignals/switchstand_jake/switch_on.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})}),
models("models/block/landofsignals/switchstand_jake/switch_off.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})})
"Switch stand by Jake Steampson (right side, left turn)",
models("models/block/landofsignals/switchstand_jake/right_side_left_turn/right_side_left_turn_on.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})}),
models("models/block/landofsignals/switchstand_jake/right_side_left_turn/right_side_left_turn_off.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})})
);

registerLeverContentPack(
"switchstand_jake_right_side_left_turn",
"Switch stand by Jake Steampson (right side, right turn)",
models("models/block/landofsignals/switchstand_jake/right_side_right_turn/right_side_right_turn_on.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})}),
models("models/block/landofsignals/switchstand_jake/right_side_right_turn/right_side_right_turn_off.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})})
);

registerLeverContentPack(
"switchstand_jake_left_side_left_turn",
"Switch stand by Jake Steampson (left side, left turn)",
models("models/block/landofsignals/switchstand_jake/left_side_left_turn/left_side_left_turn_on.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})}),
models("models/block/landofsignals/switchstand_jake/left_side_left_turn/left_side_left_turn_off.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})})
);

registerLeverContentPack(
"switchstand_jake_left_side_right_turn",
"Switch stand by Jake Steampson (left side, right turn)",
models("models/block/landofsignals/switchstand_jake/left_side_right_turn/left_side_right_turn_on.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})}),
models("models/block/landofsignals/switchstand_jake/left_side_right_turn/left_side_right_turn_off.obj", new ContentPackModel[]{new ContentPackModel(new float[]{0.5f, 0f, 0.5f}, new float[]{0.5f, 0f, 0.5f}, new float[]{1f, 1f, 1f}, new float[]{1f, 1f, 1f}, new float[]{0f, 180f, 0f})})
);

}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/landofrails/landofsignals/LandOfSignals.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import cam72cam.mod.render.ItemRender;
import cam72cam.mod.resource.Identifier;
import cam72cam.mod.text.Command;
import net.landofrails.landofsignals.commands.ConfigCommand;
import net.landofrails.landofsignals.commands.LandOfSignalsCommand;
import net.landofrails.landofsignals.configs.LandOfSignalsConfig;
import net.landofrails.landofsignals.contentpacks.ContentPackHandler;
import net.landofrails.landofsignals.gui.overlay.ManipualtorOverlay;
Expand All @@ -29,7 +29,7 @@ public class LandOfSignals extends ModCore.Mod {
public static final String MODID = "landofsignals";
// Current version
@SuppressWarnings("unused")
public static final String VERSION = "1.3.1";
public static final String VERSION = "1.3.2";

@Override
public String modID() {
Expand Down Expand Up @@ -64,10 +64,12 @@ public void commonEvent(final ModEvent event) {
Packet.register(SignalUpdatePacket::new, PacketDirection.ServerToClient);
Packet.register(SignTextPacket::new, PacketDirection.ClientToServer);
Packet.register(SignTextPacket::new, PacketDirection.ServerToClient);
Packet.register(ConfigGuiPacket::new, PacketDirection.ServerToClient);
Packet.register(CommandClientPacket::new, PacketDirection.ServerToClient);
Packet.register(GuiSignalPrioritizationToClientPacket::new, PacketDirection.ServerToClient);
Packet.register(GuiSignalPrioritizationToServerPacket::new, PacketDirection.ClientToServer);
Packet.register(GuiItemManipulatorToClient::new, PacketDirection.ServerToClient);

Command.register(new LandOfSignalsCommand());
} else if (event == ModEvent.INITIALIZE) {
// LandOfSignals Config
ConfigFile.sync(LandOfSignalsConfig.class);
Expand Down Expand Up @@ -117,8 +119,6 @@ public void clientEvent(final ModEvent event) {
BlockRender.register(LOSBlocks.BLOCK_TICKET_MACHINE_DB, TileMissingRender::render, TileTicketMachineDB.class);
BlockRender.register(LOSBlocks.BLOCK_TICKET_MACHINE_SBB, TileMissingRender::render, TileTicketMachineSBB.class);

Command.register(new ConfigCommand());

break;
case SETUP:
GlobalRender.registerOverlay((state, partialticks) -> new ManipualtorOverlay().draw());
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package net.landofrails.landofsignals.commands;

import cam72cam.mod.entity.Player;
import cam72cam.mod.text.Command;
import cam72cam.mod.text.PlayerMessage;
import net.landofrails.api.contentpacks.GenericContentPack;
import net.landofrails.landofsignals.LandOfSignals;
import net.landofrails.landofsignals.configs.LandOfSignalsConfig;
import net.landofrails.landofsignals.contentpacks.ContentPackHandler;
import net.landofrails.landofsignals.packet.CommandClientPacket;

import java.io.File;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;

public class LandOfSignalsCommand extends Command {
@Override
public String getPrefix() {
return "landofsignals";
}

@Override
public String getUsage() {
return "Usage: /landofsignals help";
}

/**
*
* landofsignals command (will only be executed server-side)
*
* @param sender
* @param player
* @param args
* @return
*/
@Override
public boolean execute(final Consumer<PlayerMessage> sender, final Optional<Player> player, final String[] args) {

String arg0 = args.length > 0 ? args[0].toUpperCase() : "";

// HELP
// DEBUG
// LOS-CONFIG
// CONFIGFOLDER

switch (arg0){
case "HELP":
case "?":
return help(sender);
case "DEBUGINFO":
case "DEBUG":
return debug(sender, player);
case "LOS-CONFIG":
case "CONFIG":
return losConfig(sender, player);
case "CONFIGFOLDER":
case "FOLDER":
return configFolder(sender, player);
default:
return false;
}
}


private boolean help(final Consumer<PlayerMessage> sender){
Consumer<String> send = msg -> sender.accept(PlayerMessage.direct(msg));
String text = " ->- Help for /landofsignals (page 1/1) -<-" +
"\n/landofsignals help : Shows the available commands" +
"\n/landofsignals debug : Shows debug information for client and/or server" +
"\n/landofsignals los-config : Opens config GUI (needs a restart to take effect)" +
"\n/landofsignals configfolder : Opens/Returns the config folder (where contentpacks can be placed in)" +
"\n/landofsignals contentpacks [load <contentpack] : >> NOT AVAILABLE YET << Loads contentpacks while ingame (only client-side)" +
"\n ->- Help for /landofsignals (page 1/1) -<-";
for(String line : text.split("\\n"))
send.accept(line);
return true;
}

private boolean debug(final Consumer<PlayerMessage> sender, final Optional<Player> player) {

Consumer<String> send = msg -> sender.accept(PlayerMessage.direct(msg));

// Server
send.accept("Server report:");
send.accept("Version: " + LandOfSignals.VERSION);
send.accept("Settings: ");
for(Map.Entry<String, Object> conf : LandOfSignalsConfig.values().entrySet())
send.accept(" - " + conf.getKey() + ": " + conf.getValue().toString());
send.accept("Detected contentpacks: ");
for(Map.Entry<GenericContentPack, Map.Entry<Boolean, String>> gcp : ContentPackHandler.getContentpackHeaders().entrySet()) {
send.accept(" - " + gcp.getKey().toShortString());
send.accept(" * UTF8: " + gcp.getValue().getKey() + "; Status: " + gcp.getValue().getValue());
}

// Client
player.ifPresent(value -> new CommandClientPacket(CommandClientPacket.Command.DEBUG).sendToPlayer(value));

return false;
}

private boolean losConfig(final Consumer<PlayerMessage> sender, final Optional<Player> optionalPlayer) {
if(optionalPlayer.isPresent()){
new CommandClientPacket(CommandClientPacket.Command.CONFIG).sendToPlayer(optionalPlayer.get());
} else {
sender.accept(PlayerMessage.direct("This command is only available for players!"));
}
return true;
}

private boolean configFolder(final Consumer<PlayerMessage> sender, final Optional<Player> optionalPlayer) {

if(optionalPlayer.isPresent()){
new CommandClientPacket(CommandClientPacket.Command.FOLDER).sendToPlayer(optionalPlayer.get());
return true;
}

final File assetFolder = new File("./config/landofsignals");
final String assetUrl = "file://" + assetFolder.getAbsolutePath();

boolean success = true;
if (!assetFolder.exists()) {
success = assetFolder.mkdirs();
}

if(!success){
sender.accept(PlayerMessage.direct("Couldn't create folder! Target:"));
sender.accept(PlayerMessage.url(assetUrl));
return true;
}

sender.accept(PlayerMessage.direct("Can't open the folder, but you can find it here:"));
sender.accept(PlayerMessage.url(assetUrl));

return true;
}





}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import cam72cam.mod.config.ConfigFile;

import java.util.HashMap;
import java.util.Map;

@ConfigFile.Comment("Configuration File for LandOfSignals")
@ConfigFile.Name("general")
@ConfigFile.File("landofsignals.cfg")
Expand All @@ -20,4 +23,11 @@ public static class Experimental {

}

public static Map<String, Object> values(){
Map<String, Object> values = new HashMap<>();
values.put("preloadModels", preloadModels);
values.put("experimental.rescaleItems", Experimental.rescaleItems);
return values;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class ContentPackHandler {

private static final String BASE_IDENTIFIER = "/base/";

private static final Map<GenericContentPack, Map.Entry<Boolean, String>> contentpackHeaders = new HashMap<>();

private ContentPackHandler() {

}
Expand Down Expand Up @@ -108,6 +110,7 @@ private static void load(ZipFile zip, ZipEntry landofsignalsJson, boolean isUTF8
zip.getInputStream(zip.getEntry(landofsignalsJson.getName())));

if (!genericContentPack.isValid()) {
contentpackHeaders.put(genericContentPack, new AbstractMap.SimpleEntry<>(isUTF8, "FAILED"));
LandOfSignals.error("Failed loading ZIP named %s!\nNot all required fields have been set.", zip.getName());
return;
}
Expand All @@ -122,14 +125,15 @@ private static void load(ZipFile zip, ZipEntry landofsignalsJson, boolean isUTF8

if ("1".equals(addonversion)) {
ContentPackHandlerV1.load(zip, landofsignalsJson.getName(), isUTF8);

contentpackHeaders.put(genericContentPack, new AbstractMap.SimpleEntry<>(isUTF8, "HEAD OK - v1"));
} else if ("2".equals(addonversion)) {
ContentPackHandlerV2.load(zip, landofsignalsJson.getName(), isUTF8);

contentpackHeaders.put(genericContentPack, new AbstractMap.SimpleEntry<>(isUTF8, "HEAD OK - v2"));
} else {
LandOfSignals.error("Failed loading Contentpack named %s!\nUnsupported addonversion: %s." +
" Either your version of LandOfSignals is not up-to-date" +
" or the author used an invalid addonversion.", genericContentPack.getName(), addonversion);
contentpackHeaders.put(genericContentPack, new AbstractMap.SimpleEntry<>(isUTF8, "UNSUPPORTED ADDONVERSION - " + addonversion));
}


Expand Down Expand Up @@ -469,6 +473,10 @@ private static float[] retranslateItem(OBJModel model, float[] newScale, float[]
return newTranslation;
}

public static Map<GenericContentPack, Map.Entry<Boolean, String>> getContentpackHeaders(){
return Collections.unmodifiableMap(contentpackHeaders);
}

// For method references
private static <T> Predicate<T> not(Predicate<T> t) {
return t.negate();
Expand Down
Loading

0 comments on commit de6fd3d

Please sign in to comment.