diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 031e801c2..4d8862577 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -30,7 +30,7 @@ jobs: if: endswith(github.ref_name, 'master') && github.ref_protected && github.ref_type == 'branch' runs-on: ubuntu-latest env: - APPVEYOR_BUILD_VERSION: '3.0.2' + APPVEYOR_BUILD_VERSION: '3.1.0' CURSETOKEN: ${{ secrets.CURSETOKEN }} steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/versioncheck.yml b/.github/workflows/versioncheck.yml new file mode 100644 index 000000000..097de5994 --- /dev/null +++ b/.github/workflows/versioncheck.yml @@ -0,0 +1,21 @@ +name: "Check version!" +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled, push] + +jobs: + # Enforces the update of the gradle file on every pull request + test: + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + steps: + - name: Get Changed Files + id: changed + uses: foodee/pr-includes-file-change@master + with: + paths: github/workflows/gradle.yml + + - name: Echo Match + if: steps.changed.outputs.matched == 'true' + run: echo Matched \ No newline at end of file diff --git a/changelog.md b/changelog.md index 10e9ee128..e4c558d0a 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,27 @@ # Changelog +## [1.12.2 - 3.1.0] + +* feat: added help panel to signalbox +* feat: added shortcuts in help panel +* feat: added manipulator tool for new signal renaming +* feat: reverse resetting pathways +* feat: added tooltip to text input field +* feat: added tooltip hiding option +* feat: remove grid in usage mode from signalbox +* feat: readded configurable block light emission +* feat: configurable colors +* feat: add preview renderer +* feat: added sorting and search option in linking list +* feat: switch handle with opposide basic position +* fix: circle model +* fix: tooltip out of screen +* fix: bug in signal configs (hl, zs2v, semaphore) +* fix: redstone output of switch signals +* fix: content pack problems +* ref: better code performance +* ref: predicate properties + ## [1.12.2 - 3.0.2] * feat/fix: better and working system for relinking inputs after SignalBox Placement diff --git a/contentPackLib b/contentPackLib index 2fa4ab1c8..94dab59ce 160000 --- a/contentPackLib +++ b/contentPackLib @@ -1 +1 @@ -Subproject commit 2fa4ab1c8d0d84d242b3b8a4cd79074fb9a4882d +Subproject commit 94dab59ce58333a898f707c04c689a5abf321df7 diff --git a/guilib b/guilib index 8d58e5fb6..bddb6f9c8 160000 --- a/guilib +++ b/guilib @@ -1 +1 @@ -Subproject commit 8d58e5fb606dde0e827e58a5cdfd2d90b38ccdad +Subproject commit bddb6f9c8624786f15d3da6b4b2d223f2197c822 diff --git a/src/main/java/com/troblecodings/signals/SEProperty.java b/src/main/java/com/troblecodings/signals/SEProperty.java index 51f29c63d..bf33fa920 100644 --- a/src/main/java/com/troblecodings/signals/SEProperty.java +++ b/src/main/java/com/troblecodings/signals/SEProperty.java @@ -103,10 +103,6 @@ public boolean testMap(final Map t) { return this.deps.test(t); } - public static SEProperty cst(final Object iup) { - return (SEProperty) iup; - } - public JsonEnum getParent() { return parent; } diff --git a/src/main/java/com/troblecodings/signals/blocks/GhostBlock.java b/src/main/java/com/troblecodings/signals/blocks/GhostBlock.java index 40bb75ed2..9bcdcf774 100644 --- a/src/main/java/com/troblecodings/signals/blocks/GhostBlock.java +++ b/src/main/java/com/troblecodings/signals/blocks/GhostBlock.java @@ -1,5 +1,7 @@ package com.troblecodings.signals.blocks; +import com.troblecodings.signals.config.ConfigHandler; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -17,6 +19,7 @@ public class GhostBlock extends BasicBlock { public GhostBlock() { super(Material.GLASS); + setLightLevel(ConfigHandler.lightEmission / 15.0F); } @Override diff --git a/src/main/java/com/troblecodings/signals/blocks/Post.java b/src/main/java/com/troblecodings/signals/blocks/Post.java index f7c81bbe2..02e3aafa3 100644 --- a/src/main/java/com/troblecodings/signals/blocks/Post.java +++ b/src/main/java/com/troblecodings/signals/blocks/Post.java @@ -20,4 +20,4 @@ public AxisAlignedBB getBoundingBox(final IBlockState state, final IBlockAccess final BlockPos pos) { return BOUNDING_BOX; } -} +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/blocks/Signal.java b/src/main/java/com/troblecodings/signals/blocks/Signal.java index 9e2b9eb48..f07dc9f2f 100644 --- a/src/main/java/com/troblecodings/signals/blocks/Signal.java +++ b/src/main/java/com/troblecodings/signals/blocks/Signal.java @@ -12,6 +12,7 @@ import com.google.common.collect.ImmutableList; import com.troblecodings.signals.OpenSignalsMain; import com.troblecodings.signals.SEProperty; +import com.troblecodings.signals.config.ConfigHandler; import com.troblecodings.signals.core.JsonEnum; import com.troblecodings.signals.core.PosIdentifier; import com.troblecodings.signals.core.RenderOverlayInfo; @@ -29,9 +30,7 @@ import com.troblecodings.signals.init.OSItems; import com.troblecodings.signals.items.Placementtool; import com.troblecodings.signals.parser.ValuePack; -import com.troblecodings.signals.properties.BooleanProperty; -import com.troblecodings.signals.properties.FloatProperty; -import com.troblecodings.signals.properties.HeightProperty; +import com.troblecodings.signals.properties.PredicatedPropertyBase.PredicateProperty; import com.troblecodings.signals.properties.SoundProperty; import com.troblecodings.signals.tileentitys.SignalTileEntity; @@ -83,7 +82,6 @@ public class Signal extends BasicBlock { private final int id; private List signalProperties; private final Map signalPropertiesToInt = new HashMap<>(); - private SEProperty powerProperty = null; public Signal(final SignalProperties prop) { super(Material.ROCK); @@ -96,6 +94,7 @@ public Signal(final SignalProperties prop) { final SEProperty property = signalProperties.get(i); signalPropertiesToInt.put(property, i); } + setLightLevel(ConfigHandler.lightEmission / 15.0f); } public int getID() { @@ -105,8 +104,8 @@ public int getID() { @Override public AxisAlignedBB getBoundingBox(final IBlockState state, final IBlockAccess source, final BlockPos pos) { - final SignalTileEntity te = (SignalTileEntity) source.getTileEntity(pos); - if (te == null) + final TileEntity te = source.getTileEntity(pos); + if (te == null || !(te instanceof SignalTileEntity)) return FULL_BLOCK_AABB; final World world = te.getWorld(); final SignalStateInfo info = new SignalStateInfo(world, pos, this); @@ -246,11 +245,10 @@ public void breakBlock(final World worldIn, final BlockPos pos, final IBlockStat } } - @SuppressWarnings("unchecked") public int getHeight(final Map map) { - for (final HeightProperty property : this.prop.signalHeights) { - if (property.predicate.test(map)) - return property.height; + for (final PredicateProperty property : this.prop.signalHeights) { + if (property.test(map)) + return property.state; } return this.prop.defaultHeight; } @@ -293,7 +291,6 @@ public void renderOverlay(final RenderOverlayInfo info) { this.renderOverlay(info, this.prop.customNameRenderHeight); } - @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void renderScaleOverlay(final RenderOverlayInfo info, final float renderHeight) { final Map map = ClientSignalStateHandler.getClientStates( @@ -302,9 +299,9 @@ public void renderScaleOverlay(final RenderOverlayInfo info, final float renderH if (customNameState == null || customNameState.equalsIgnoreCase("FALSE")) return; float customRenderHeight = renderHeight; - for (final FloatProperty property : this.prop.customRenderHeights) { + for (final PredicateProperty property : this.prop.customRenderHeights) { if (property.predicate.test(map)) { - customRenderHeight = property.height; + customRenderHeight = property.state; } if (customRenderHeight == -1) return; @@ -316,9 +313,9 @@ public void renderScaleOverlay(final RenderOverlayInfo info, final float renderH return; } boolean doubleSidedText = false; - for (final BooleanProperty boolProp : this.prop.doubleSidedText) { + for (final PredicateProperty boolProp : this.prop.doubleSidedText) { if (boolProp.predicate.test(map)) { - doubleSidedText = boolProp.doubleSided; + doubleSidedText = boolProp.state; } } final SignalAngel face = state.getValue(Signal.ANGEL); @@ -354,7 +351,6 @@ public void renderSingleScaleOverlay(final RenderOverlayInfo info) { GlStateManager.popMatrix(); } - @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void renderOverlay(final RenderOverlayInfo info, final float renderHeight) { float customRenderHeight = renderHeight; @@ -363,9 +359,9 @@ public void renderOverlay(final RenderOverlayInfo info, final float renderHeight final String customNameState = map.get(CUSTOMNAME); if (customNameState == null || customNameState.equalsIgnoreCase("FALSE")) return; - for (final FloatProperty property : this.prop.customRenderHeights) { + for (final PredicateProperty property : this.prop.customRenderHeights) { if (property.predicate.test(map)) { - customRenderHeight = property.height; + customRenderHeight = property.state; } } if (customRenderHeight == -1) @@ -377,9 +373,9 @@ public void renderOverlay(final RenderOverlayInfo info, final float renderHeight return; } boolean doubleSidedText = false; - for (final BooleanProperty boolProp : this.prop.doubleSidedText) { + for (final PredicateProperty boolProp : this.prop.doubleSidedText) { if (boolProp.predicate.test(map)) { - doubleSidedText = boolProp.doubleSided; + doubleSidedText = boolProp.state; } } @@ -439,34 +435,31 @@ public boolean onBlockActivated(final World world, final BlockPos pos, final IBl return false; } final SignalStateInfo stateInfo = new SignalStateInfo(world, pos, this); - if (loadRedstoneOutput(world, stateInfo)) { - world.setBlockState(pos, state, 3); - world.notifyNeighborsOfStateChange(pos, this, false); - world.markAndNotifyBlock(pos, null, state, state, 3); - return true; - } - final boolean customname = canHaveCustomname(SignalStateHandler.getStates(stateInfo)); - if ((canBeLinked() || customname)) { + final Map states = SignalStateHandler.getStates(stateInfo); + final boolean customname = canHaveCustomname(states); + if (player.getHeldItemMainhand().getItem().equals(OSItems.MANIPULATOR) + && (canBeLinked() || customname)) { if (world.isRemote) return true; OpenSignalsMain.handler.invokeGui(Signal.class, player, world, pos, "signal"); return true; } - return false; + if (loadRedstoneOutput(world, stateInfo, states)) { + world.setBlockState(pos, state, 3); + world.notifyNeighborsOfStateChange(pos, this, true); + world.markAndNotifyBlock(pos, null, state, state, 3); + } + return true; } @SuppressWarnings("unchecked") - private boolean loadRedstoneOutput(final World worldIn, final SignalStateInfo info) { + private boolean loadRedstoneOutput(final World worldIn, final SignalStateInfo info, + final Map properties) { if (!this.prop.redstoneOutputs.isEmpty()) { - final Map properties = SignalStateHandler.getStates(info); - this.powerProperty = null; for (final ValuePack pack : this.prop.redstoneOutputs) { - if (pack.predicate.test(properties)) { - this.powerProperty = pack.property; - SignalStateHandler.getState(info, pack.property).ifPresent(power -> { - SignalStateHandler.setState(info, pack.property, - Boolean.toString(!Boolean.valueOf(power))); - }); + if (properties.containsKey(pack.property) && pack.predicate.test(properties)) { + SignalStateHandler.setState(info, pack.property, + Boolean.toString(!Boolean.valueOf(properties.get(pack.property)))); return true; } } @@ -474,9 +467,13 @@ private boolean loadRedstoneOutput(final World worldIn, final SignalStateInfo in return false; } + public boolean hasRedstoneOut() { + return !this.prop.redstoneOutputs.isEmpty() || !this.prop.redstoneOutputPacks.isEmpty(); + } + @Override public boolean canProvidePower(final IBlockState state) { - return !this.prop.redstoneOutputs.isEmpty(); + return hasRedstoneOut(); } @Override @@ -489,25 +486,24 @@ public int getStrongPower(final IBlockState blockState, final IBlockAccess block @Override public int getWeakPower(final IBlockState blockState, final IBlockAccess blockAccess, final BlockPos pos, final EnumFacing side) { - if (this.prop.redstoneOutputs.isEmpty() || this.powerProperty == null - || !(blockAccess instanceof World)) { + if (!hasRedstoneOut() || !(blockAccess instanceof World)) { return 0; } final SignalStateInfo stateInfo = new SignalStateInfo((World) blockAccess, pos, this); - if (SignalStateHandler.getState(stateInfo, powerProperty) - .filter(power -> power.equalsIgnoreCase("false")).isPresent()) { - return 0; - } final Map properties = SignalStateHandler.getStates(stateInfo); - for (final ValuePack pack : this.prop.redstoneOutputs) { - if (pack.predicate.test(properties)) { - return 15; + for (final List valuePacks : ImmutableList.of(this.prop.redstoneOutputPacks, + this.prop.redstoneOutputs)) { + for (final ValuePack pack : valuePacks) { + if (properties.containsKey(pack.property) && pack.predicate.test(properties) + && !properties.get(pack.property) + .equalsIgnoreCase(pack.property.getDefault())) { + return 15; + } } } return 0; } - @SuppressWarnings("unchecked") public void getUpdate(final World world, final BlockPos pos) { if (this.prop.sounds.isEmpty()) return; @@ -519,7 +515,7 @@ public void getUpdate(final World world, final BlockPos pos) { return; if (sound.duration == 1) { - world.playSound(null, pos, sound.sound, SoundCategory.BLOCKS, 1.0F, 1.0F); + world.playSound(null, pos, sound.state, SoundCategory.BLOCKS, 1.0F, 1.0F); } else { if (world.isUpdateScheduled(pos, this)) { return; @@ -531,14 +527,13 @@ public void getUpdate(final World world, final BlockPos pos) { } } - @SuppressWarnings("unchecked") public SoundProperty getSound(final Map map) { for (final SoundProperty property : this.prop.sounds) { if (property.predicate.test(map)) { return property; } } - return new SoundProperty(); + return new SoundProperty(null, t -> true, 0); } @Override @@ -552,7 +547,7 @@ public void updateTick(final World worldIn, final BlockPos pos, final IBlockStat if (sound.duration <= 1) { return; } - worldIn.playSound(null, pos, sound.sound, SoundCategory.BLOCKS, 1.0F, 1.0F); + worldIn.playSound(null, pos, sound.state, SoundCategory.BLOCKS, 1.0F, 1.0F); worldIn.scheduleUpdate(pos, this, sound.duration); } diff --git a/src/main/java/com/troblecodings/signals/config/ConfigHandler.java b/src/main/java/com/troblecodings/signals/config/ConfigHandler.java new file mode 100644 index 000000000..ba53e74cd --- /dev/null +++ b/src/main/java/com/troblecodings/signals/config/ConfigHandler.java @@ -0,0 +1,55 @@ +package com.troblecodings.signals.config; + +import com.troblecodings.guilib.ecs.GuiConfigHandler; +import com.troblecodings.signals.OpenSignalsMain; + +import net.minecraftforge.common.config.Config; +import net.minecraftforge.common.config.Config.Comment; +import net.minecraftforge.common.config.Config.Name; +import net.minecraftforge.common.config.Config.RangeInt; +import net.minecraftforge.common.config.Config.RequiresMcRestart; + +@Config(modid = OpenSignalsMain.MODID) +public final class ConfigHandler { + + private ConfigHandler() { + } + + @RangeInt(min = 0, max = 15) + @Name("Signal light emission") + @RequiresMcRestart + @Comment({ + "Change the light emssion value of a signal.", + " When you change the value, the signal block lights ", + "up and illuminates the environment. Default: 1" + }) + public static int lightEmission = 1; + + @Name("Signalbox background color") + @Comment("Change the background color of the signalbox gui. Default: -7631989") + public static int signalboxBackgroundColor = 0xFF8B8B8B; + + @Name("Signalbox free color") + @Comment("Change the color of normal path elements. Default: -16777216") + public static int signalboxFreeColor = 0xFF000000; + + @Name("Signalbox select color") + @Comment("Change the color of a selected path. Default: -16711936") + public static int signalboxSelectColor = 0xFF00FF00; + + @Name("Signalbox used color") + @Comment("Change the color of a blocked path. Default: -65536") + public static int signalboxUsedColor = 0xFFFF0000; + + @Name("Basic text color") + @Comment("Change the color of a default text. Default: -16777216") + public static int basicTextColor = GuiConfigHandler.basicTextColor; + + @Name("info text color") + @Comment("Change the color of an info text. Default: -16777046") + public static int infoTextColor = GuiConfigHandler.infoTextColor; + + @Name("Error text color") + @Comment("Change the color of an error text. Default: -16776961") + public static int errorTextColor = GuiConfigHandler.errorTextColor; +} diff --git a/src/main/java/com/troblecodings/signals/contentpacks/ChangeConfigParser.java b/src/main/java/com/troblecodings/signals/contentpacks/ChangeConfigParser.java index b88f81598..44d309a77 100644 --- a/src/main/java/com/troblecodings/signals/contentpacks/ChangeConfigParser.java +++ b/src/main/java/com/troblecodings/signals/contentpacks/ChangeConfigParser.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.function.Predicate; +import com.google.common.collect.Maps; import com.google.gson.Gson; import com.troblecodings.signals.OpenSignalsMain; import com.troblecodings.signals.SEProperty; @@ -13,8 +14,7 @@ import com.troblecodings.signals.parser.FunctionParsingInfo; import com.troblecodings.signals.parser.LogicParser; import com.troblecodings.signals.parser.LogicalParserException; -import com.troblecodings.signals.properties.ConfigProperty; -import com.troblecodings.signals.properties.SignalPair; +import com.troblecodings.signals.properties.PredicatedPropertyBase.ConfigProperty; public class ChangeConfigParser { @@ -23,11 +23,10 @@ public class ChangeConfigParser { private Map savedPredicates; private Map> values; - public static final Map> CHANGECONFIGS = new HashMap<>(); + public static final Map, List> CHANGECONFIGS = new HashMap<>(); private static final Gson GSON = new Gson(); - @SuppressWarnings("rawtypes") public static void loadChangeConfigs() { for (final Map.Entry files : OpenSignalsMain.contentPacks @@ -43,7 +42,7 @@ public static void loadChangeConfigs() { + "This config with filename '" + files.getKey() + "' will be skiped!"); continue; } - final SignalPair pair = new SignalPair(start, end); + final Map.Entry pair = Maps.immutableEntry(start, end); if (CHANGECONFIGS.containsKey(pair)) { throw new LogicalParserException("A signalconfig with the signals [" + start.getSignalTypeName() + ", " + end.getSignalTypeName() @@ -60,7 +59,7 @@ public static void loadChangeConfigs() { for (final Map.Entry> entry : parser.values.entrySet()) { String valueToParse = entry.getKey().toLowerCase(); - Predicate predicate = t -> true; + Predicate, Object>> predicate = t -> true; if (valueToParse.contains("map(") && savedPredicates != null && !savedPredicates.isEmpty()) { diff --git a/src/main/java/com/troblecodings/signals/contentpacks/ContentPackException.java b/src/main/java/com/troblecodings/signals/contentpacks/ContentPackException.java index 7b4fc42cc..a3a27fbc2 100644 --- a/src/main/java/com/troblecodings/signals/contentpacks/ContentPackException.java +++ b/src/main/java/com/troblecodings/signals/contentpacks/ContentPackException.java @@ -15,5 +15,4 @@ public ContentPackException(final Throwable err) { public ContentPackException(final String message, final Throwable err) { super(message, err); } - } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/contentpacks/DefaultConfigParser.java b/src/main/java/com/troblecodings/signals/contentpacks/DefaultConfigParser.java index 30dc7e825..0041f5536 100644 --- a/src/main/java/com/troblecodings/signals/contentpacks/DefaultConfigParser.java +++ b/src/main/java/com/troblecodings/signals/contentpacks/DefaultConfigParser.java @@ -13,7 +13,7 @@ import com.troblecodings.signals.parser.FunctionParsingInfo; import com.troblecodings.signals.parser.LogicParser; import com.troblecodings.signals.parser.LogicalParserException; -import com.troblecodings.signals.properties.ConfigProperty; +import com.troblecodings.signals.properties.PredicatedPropertyBase.ConfigProperty; public class DefaultConfigParser { @@ -25,7 +25,6 @@ public class DefaultConfigParser { private static final Gson GSON = new Gson(); - @SuppressWarnings("rawtypes") public static void loadDefaultConfigs() { for (final Map.Entry files : OpenSignalsMain.contentPacks @@ -55,7 +54,7 @@ public static void loadDefaultConfigs() { for (final Map.Entry> entry : parser.values.entrySet()) { String valueToParse = entry.getKey().toLowerCase(); - Predicate predicate = t -> true; + Predicate, Object>> predicate = t -> true; if (valueToParse.contains("map(") && savedPredicates != null && !savedPredicates.isEmpty()) { @@ -124,5 +123,4 @@ public static void loadDefaultConfigs() { DEFAULTCONFIGS.put(signal, properties); } } - -} +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/contentpacks/OneSignalConfigParser.java b/src/main/java/com/troblecodings/signals/contentpacks/OneSignalConfigParser.java index c3dc5d5fe..e6f01e037 100644 --- a/src/main/java/com/troblecodings/signals/contentpacks/OneSignalConfigParser.java +++ b/src/main/java/com/troblecodings/signals/contentpacks/OneSignalConfigParser.java @@ -5,13 +5,14 @@ import java.util.List; import java.util.Map; +import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import com.troblecodings.signals.OpenSignalsMain; import com.troblecodings.signals.SEProperty; import com.troblecodings.signals.blocks.Signal; import com.troblecodings.signals.parser.FunctionParsingInfo; import com.troblecodings.signals.parser.LogicalParserException; -import com.troblecodings.signals.properties.ConfigProperty; +import com.troblecodings.signals.properties.PredicatedPropertyBase.ConfigProperty; public class OneSignalConfigParser { @@ -29,7 +30,7 @@ public static void loadOneSignalConfigs() { loadResetConfigs(); } - public static void loadShuntigConfigs() { + private static void loadShuntigConfigs() { for (final Map.Entry files : OpenSignalsMain.contentPacks .getFiles("signalconfigs/shunting")) { final OneSignalConfigParser parser = GSON.fromJson(files.getValue(), @@ -48,14 +49,14 @@ public static void loadShuntigConfigs() { final List propertes = new ArrayList<>(); for (final String property : parser.values) { final String[] value = property.split("\\."); - propertes - .add(new ConfigProperty((SEProperty) info.getProperty(value[0]), value[1])); + propertes.add(new ConfigProperty(t -> true, + ImmutableMap.of((SEProperty) info.getProperty(value[0]), value[1]))); } SHUNTINGCONFIGS.put(signal, propertes); } } - public static void loadResetConfigs() { + private static void loadResetConfigs() { for (final Map.Entry files : OpenSignalsMain.contentPacks .getFiles("signalconfigs/reset")) { final OneSignalConfigParser parser = GSON.fromJson(files.getValue(), @@ -75,8 +76,8 @@ public static void loadResetConfigs() { final List propertes = new ArrayList<>(); for (final String property : parser.values) { final String[] value = property.split("\\."); - propertes - .add(new ConfigProperty((SEProperty) info.getProperty(value[0]), value[1])); + propertes.add(new ConfigProperty(t -> true, + ImmutableMap.of((SEProperty) info.getProperty(value[0]), value[1]))); } RESETCONFIGS.put(signal, propertes); } @@ -85,8 +86,9 @@ public static void loadResetConfigs() { private static Signal checkSignal(final String signalName, final String filename) { final Signal signal = Signal.SIGNALS.get(signalName.toLowerCase()); if (signal == null) { - throw new ContentPackException("The signal '" + signalName + "' doesn't exists! " - + "Please check " + filename + " where to problem is!"); + throw new ContentPackException( + "The signal '" + signalName + "' doesn't exists! " + "Please check " + filename + + " where to problem is! Valid Signals: " + Signal.SIGNALS.keySet()); } return signal; } diff --git a/src/main/java/com/troblecodings/signals/contentpacks/SEPropertyParser.java b/src/main/java/com/troblecodings/signals/contentpacks/SEPropertyParser.java index 9410ce550..1e2ee7422 100644 --- a/src/main/java/com/troblecodings/signals/contentpacks/SEPropertyParser.java +++ b/src/main/java/com/troblecodings/signals/contentpacks/SEPropertyParser.java @@ -22,7 +22,6 @@ public class SEPropertyParser { private int itemDamage = 1; private transient JsonEnum parent; - @SuppressWarnings("unchecked") public SEProperty createSEProperty(final FunctionParsingInfo info) { if (defaultState instanceof Boolean) { parent = JsonEnum.BOOLEAN; @@ -34,7 +33,8 @@ public SEProperty createSEProperty(final FunctionParsingInfo info) { if (parent == null) throw new ContentPackException(String.format("Property[%s], with class %s not found!", - name, enumClass.toLowerCase())); + name, enumClass.toLowerCase()) + " Valid EnumClasses: " + + JsonEnumHolder.PROPERTIES.keySet()); ChangeableStage stage = ChangeableStage.APISTAGE; if (changeableStage != null && !changeableStage.isEmpty()) { diff --git a/src/main/java/com/troblecodings/signals/contentpacks/SubsidiarySignalParser.java b/src/main/java/com/troblecodings/signals/contentpacks/SubsidiarySignalParser.java index 297fd3617..e52765de5 100644 --- a/src/main/java/com/troblecodings/signals/contentpacks/SubsidiarySignalParser.java +++ b/src/main/java/com/troblecodings/signals/contentpacks/SubsidiarySignalParser.java @@ -10,7 +10,7 @@ import com.troblecodings.signals.blocks.Signal; import com.troblecodings.signals.core.SubsidiaryState; import com.troblecodings.signals.parser.FunctionParsingInfo; -import com.troblecodings.signals.properties.ConfigProperty; +import com.troblecodings.signals.properties.PredicatedPropertyBase.ConfigProperty; public class SubsidiarySignalParser { @@ -36,8 +36,9 @@ public static void loadAllSubsidiarySignals() { SubsidiarySignalParser.class); final Signal signal = Signal.SIGNALS.get(parser.currentSignal.toLowerCase()); if (signal == null) - throw new ContentPackException("There doesn't exists a signal with the name '" - + parser.currentSignal + "'!"); + throw new ContentPackException( + "There doesn't exists a signal with the name '" + parser.currentSignal + + "'! Valid Signals are: " + Signal.SIGNALS.keySet()); if (SUBSIDIARY_SIGNALS.containsKey(signal)) throw new ContentPackException( "There already exists a Subsidiary Config for " + signal + "!"); @@ -62,7 +63,7 @@ private static void convertToProperites(final Signal signal, final FunctionParsi } if (enumState == null) throw new ContentPackException(enumName + " is not a valid Subsidiary State! " - + "Valid Subsidiary States are: " + SubsidiaryState.ALL_STATES); + + "Valid Subsidiary States: " + SubsidiaryState.ALL_STATES); final Map allValues = new HashMap<>(); values.forEach(str -> { final String[] value = str.split("\\."); @@ -70,7 +71,7 @@ private static void convertToProperites(final Signal signal, final FunctionParsi }); final Map properties = SUBSIDIARY_SIGNALS .computeIfAbsent(signal, _u -> new HashMap<>()); - properties.put(enumState, new ConfigProperty(allValues)); + properties.put(enumState, new ConfigProperty(t -> true, allValues)); SUBSIDIARY_SIGNALS.put(signal, properties); } diff --git a/src/main/java/com/troblecodings/signals/core/JsonEnum.java b/src/main/java/com/troblecodings/signals/core/JsonEnum.java index 7f53d6387..ec659d6ae 100644 --- a/src/main/java/com/troblecodings/signals/core/JsonEnum.java +++ b/src/main/java/com/troblecodings/signals/core/JsonEnum.java @@ -1,6 +1,5 @@ package com.troblecodings.signals.core; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -58,10 +57,7 @@ public String valueToString(final String value) { } public Collection getAllowedValues() { - if (values != null) { - return values; - } - return new ArrayList<>(); + return values; } @Override diff --git a/src/main/java/com/troblecodings/signals/core/JsonEnumHolder.java b/src/main/java/com/troblecodings/signals/core/JsonEnumHolder.java index 3ae88cc7b..2def18e4a 100644 --- a/src/main/java/com/troblecodings/signals/core/JsonEnumHolder.java +++ b/src/main/java/com/troblecodings/signals/core/JsonEnumHolder.java @@ -42,5 +42,4 @@ public static Map getProperties() { returnmap.put(JsonEnum.BOOLEAN.getName(), JsonEnum.BOOLEAN); return returnmap; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/core/LinkedPositions.java b/src/main/java/com/troblecodings/signals/core/LinkedPositions.java index 9e2c9b73e..1ea23d9fd 100644 --- a/src/main/java/com/troblecodings/signals/core/LinkedPositions.java +++ b/src/main/java/com/troblecodings/signals/core/LinkedPositions.java @@ -8,11 +8,14 @@ import com.google.common.collect.ImmutableMap; import com.troblecodings.core.NBTWrapper; +import com.troblecodings.signals.SEProperty; import com.troblecodings.signals.blocks.Signal; +import com.troblecodings.signals.contentpacks.SubsidiarySignalParser; import com.troblecodings.signals.enums.LinkType; import com.troblecodings.signals.handler.SignalBoxHandler; import com.troblecodings.signals.handler.SignalStateHandler; import com.troblecodings.signals.handler.SignalStateInfo; +import com.troblecodings.signals.properties.PredicatedPropertyBase.ConfigProperty; import com.troblecodings.signals.signalbox.config.SignalConfig; import net.minecraft.util.math.BlockPos; @@ -27,15 +30,19 @@ public class LinkedPositions { private final Map signals; private final Map linkedBlocks; + private final Map> possibleSubsidiaries; public LinkedPositions() { signals = new HashMap<>(); linkedBlocks = new HashMap<>(); + possibleSubsidiaries = new HashMap<>(); } public void addSignal(final BlockPos signalPos, final Signal signal, final World world) { signals.put(signalPos, signal); - SignalConfig.reset(new SignalStateInfo(world, signalPos, signal)); + final SignalStateInfo info = new SignalStateInfo(world, signalPos, signal); + SignalConfig.reset(info); + loadPossibleSubsidiaires(info); } public Signal getSignal(final BlockPos pos) { @@ -50,9 +57,9 @@ public boolean addLinkedPos(final BlockPos pos, final LinkType type) { } public void removeLinkedPos(final BlockPos pos) { - final LinkType type = linkedBlocks.remove(pos); - if (type != null && type.equals(LinkType.SIGNAL)) - signals.remove(pos); + linkedBlocks.remove(pos); + signals.remove(pos); + possibleSubsidiaries.remove(pos); } public boolean isEmpty() { @@ -75,16 +82,18 @@ public void unlink(final BlockPos tilePos, final World world) { .unlinkTileFromPos(new PosIdentifier(tilePos, world), entry.getKey())); linkedBlocks.clear(); signals.clear(); + possibleSubsidiaries.clear(); SignalStateHandler.unloadSignals(signalsToUnload); } public void write(final NBTWrapper wrapper) { final NBTWrapper posWrapper = new NBTWrapper(); - posWrapper.putList(LINKED_POS_LIST, linkedBlocks.entrySet().stream().map(entry -> { - final NBTWrapper item = NBTWrapper.getBlockPosWrapper(entry.getKey()); - entry.getValue().write(item); - return item; - })::iterator); + posWrapper.putList(LINKED_POS_LIST, linkedBlocks.entrySet().stream() + .filter(entry -> !entry.getValue().equals(LinkType.SIGNAL)).map(entry -> { + final NBTWrapper item = NBTWrapper.getBlockPosWrapper(entry.getKey()); + entry.getValue().write(item); + return item; + })::iterator); posWrapper.putList(LINKED_SIGNALS, signals.entrySet().stream().map(entry -> { final NBTWrapper signal = NBTWrapper.getBlockPosWrapper(entry.getKey()); signal.putString(SIGNAL_NAME, entry.getValue().getSignalTypeName()); @@ -114,6 +123,7 @@ public void loadSignals(final World world) { final List signalInfos = new ArrayList<>(); signals.forEach((pos, signal) -> signalInfos.add(new SignalStateInfo(world, pos, signal))); SignalStateHandler.loadSignals(signalInfos); + signalInfos.forEach(this::loadPossibleSubsidiaires); } public void unloadSignals(final World world) { @@ -124,14 +134,36 @@ public void unloadSignals(final World world) { SignalStateHandler.unloadSignals(signalInfos); } + private void loadPossibleSubsidiaires(final SignalStateInfo info) { + final Map properties = SignalStateHandler.getStates(info); + final Map subsidiaries = SubsidiarySignalParser.SUBSIDIARY_SIGNALS + .get(info.signal); + if (subsidiaries == null) + return; + final List validStates = new ArrayList<>(); + subsidiaries.forEach((state, config) -> { + for (final SEProperty property : config.state.keySet()) { + if (properties.containsKey(property)) { + validStates.add(state); + break; + } + } + }); + possibleSubsidiaries.put(info.pos, validStates); + } + public List getAllRedstoneIOs() { return linkedBlocks.entrySet().stream() .filter(entry -> !entry.getValue().equals(LinkType.SIGNAL)) .map(entry -> entry.getKey()).collect(Collectors.toList()); } + public Map> getValidSubsidiariesForPos() { + return ImmutableMap.copyOf(possibleSubsidiaries); + } + @Override public String toString() { - return "AllSignals = " + signals + ", AllLinkedPos = " + linkedBlocks; + return "LinkedPos [AllSignals = " + signals + ", AllLinkedPos = " + linkedBlocks + "]"; } } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/core/LinkingUpdates.java b/src/main/java/com/troblecodings/signals/core/LinkingUpdates.java index e692b8ec5..ecbea305e 100644 --- a/src/main/java/com/troblecodings/signals/core/LinkingUpdates.java +++ b/src/main/java/com/troblecodings/signals/core/LinkingUpdates.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; import com.google.common.collect.ImmutableList; import com.troblecodings.core.NBTWrapper; @@ -47,12 +48,10 @@ public List getPosToRemove() { private static final String POS_REMOVE = "posRemove"; public void writeNBT(final NBTWrapper wrapper) { - final List addList = new ArrayList<>(); - final List removeList = new ArrayList<>(); - posToAdd.forEach(pos -> addList.add(NBTWrapper.getBlockPosWrapper(pos))); - posToRemove.forEach(pos -> removeList.add(NBTWrapper.getBlockPosWrapper(pos))); - wrapper.putList(POS_ADD, addList); - wrapper.putList(POS_REMOVE, removeList); + wrapper.putList(POS_ADD, posToAdd.stream().map(pos -> NBTWrapper.getBlockPosWrapper(pos)) + .collect(Collectors.toList())); + wrapper.putList(POS_REMOVE, posToRemove.stream() + .map(pos -> NBTWrapper.getBlockPosWrapper(pos)).collect(Collectors.toList())); } public void readNBT(final NBTWrapper wrapper) { @@ -82,6 +81,6 @@ public boolean equals(final Object obj) { @Override public String toString() { - return "LinkingUpdates: PosToAdd: " + posToAdd + ", PosToRemove: " + posToRemove; + return "LinkingUpdates [PosToAdd: " + posToAdd + ", PosToRemove: " + posToRemove + "]"; } } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/core/RenderOverlayInfo.java b/src/main/java/com/troblecodings/signals/core/RenderOverlayInfo.java index f3286e87a..bba2c9be9 100644 --- a/src/main/java/com/troblecodings/signals/core/RenderOverlayInfo.java +++ b/src/main/java/com/troblecodings/signals/core/RenderOverlayInfo.java @@ -5,6 +5,7 @@ import net.minecraft.client.gui.FontRenderer; public class RenderOverlayInfo { + public final double x; public final double y; public final double z; @@ -13,7 +14,6 @@ public class RenderOverlayInfo { public RenderOverlayInfo(final double x, final double y, final double z, final FontRenderer fontRenderer) { - super(); this.x = x; this.y = y; this.z = z; diff --git a/src/main/java/com/troblecodings/signals/core/SignalProperties.java b/src/main/java/com/troblecodings/signals/core/SignalProperties.java index 5314d84f1..6bddf5f98 100644 --- a/src/main/java/com/troblecodings/signals/core/SignalProperties.java +++ b/src/main/java/com/troblecodings/signals/core/SignalProperties.java @@ -4,9 +4,7 @@ import com.troblecodings.signals.items.Placementtool; import com.troblecodings.signals.parser.ValuePack; -import com.troblecodings.signals.properties.BooleanProperty; -import com.troblecodings.signals.properties.FloatProperty; -import com.troblecodings.signals.properties.HeightProperty; +import com.troblecodings.signals.properties.PredicatedPropertyBase.PredicateProperty; import com.troblecodings.signals.properties.SoundProperty; public class SignalProperties { @@ -14,28 +12,30 @@ public class SignalProperties { public final Placementtool placementtool; public final float customNameRenderHeight; public final int defaultHeight; - public final List signalHeights; - public final List customRenderHeights; + public final List> signalHeights; + public final List> customRenderHeights; public final float signWidth; public final float offsetX; public final float offsetY; public final float signScale; public final boolean autoscale; - public final List doubleSidedText; + public final List> doubleSidedText; public final int textColor; public final boolean canLink; public final List colors; public final List sounds; public final List redstoneOutputs; + public final List redstoneOutputPacks; public final int defaultItemDamage; public SignalProperties(final Placementtool placementtool, final float customNameRenderHeight, - final int height, final List signalHeights, final float signWidth, - final float offsetX, final float offsetY, final float signScale, final boolean autoscale, - final List doubleSidedText, final int textColor, final boolean canLink, - final List colors, final List renderheights, - final List sounds, final List redstoneOutputs, - final int defaultItemDamage) { + final int height, final List> signalHeights, + final float signWidth, final float offsetX, final float offsetY, final float signScale, + final boolean autoscale, final List> doubleSidedText, + final int textColor, final boolean canLink, final List colors, + final List> renderheights, final List sounds, + final List redstoneOutputs, final int defaultItemDamage, + final List redstoneOutputPacks) { this.placementtool = placementtool; this.customNameRenderHeight = customNameRenderHeight; this.defaultHeight = height; @@ -53,5 +53,6 @@ public SignalProperties(final Placementtool placementtool, final float customNam this.sounds = sounds; this.redstoneOutputs = redstoneOutputs; this.defaultItemDamage = defaultItemDamage; + this.redstoneOutputPacks = redstoneOutputPacks; } } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/core/SignalPropertiesBuilder.java b/src/main/java/com/troblecodings/signals/core/SignalPropertiesBuilder.java index 345d9adb3..0ed9e2c1c 100644 --- a/src/main/java/com/troblecodings/signals/core/SignalPropertiesBuilder.java +++ b/src/main/java/com/troblecodings/signals/core/SignalPropertiesBuilder.java @@ -3,8 +3,10 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.function.Predicate; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Maps; import com.troblecodings.signals.OpenSignalsMain; import com.troblecodings.signals.SEProperty; import com.troblecodings.signals.contentpacks.ContentPackException; @@ -16,9 +18,7 @@ import com.troblecodings.signals.parser.LogicParser; import com.troblecodings.signals.parser.LogicalParserException; import com.troblecodings.signals.parser.ValuePack; -import com.troblecodings.signals.properties.BooleanProperty; -import com.troblecodings.signals.properties.FloatProperty; -import com.troblecodings.signals.properties.HeightProperty; +import com.troblecodings.signals.properties.PredicatedPropertyBase.PredicateProperty; import com.troblecodings.signals.properties.SoundProperty; import net.minecraft.util.SoundEvent; @@ -42,6 +42,7 @@ public class SignalPropertiesBuilder { private List colors; private Map sounds; private Map redstoneOutputs; + private Map remoteRedstoneOutputs; private int defaultItemDamage = 1; public SignalProperties build(final FunctionParsingInfo info) { @@ -53,18 +54,17 @@ public SignalProperties build(final FunctionParsingInfo info) { break; } } - if (placementtool == null) - throw new ContentPackException( - "There doesn't exists a placementtool with the name '" + placementToolName - + "'!"); } + if (placementtool == null) + throw new ContentPackException("There doesn't exists a placementtool with the name '" + + placementToolName + "'!"); - final List signalheights = new ArrayList<>(); + final List> signalheights = new ArrayList<>(); if (signalHeights != null) { signalHeights.forEach((property, height) -> { try { - signalheights - .add(new HeightProperty(LogicParser.predicate(property, info), height)); + signalheights.add(new PredicateProperty( + LogicParser.predicate(property, info), height)); } catch (final LogicalParserException e) { OpenSignalsMain.getLogger() .error("Something went wrong during the registry of a predicate in " @@ -74,12 +74,12 @@ public SignalProperties build(final FunctionParsingInfo info) { }); } - final List renderheights = new ArrayList<>(); + final List> renderheights = new ArrayList<>(); if (renderHeights != null) { renderHeights.forEach((property, height) -> { try { - renderheights - .add(new FloatProperty(LogicParser.predicate(property, info), height)); + renderheights.add(new PredicateProperty( + LogicParser.predicate(property, info), height)); } catch (final LogicalParserException e) { OpenSignalsMain.getLogger() .error("Something went wrong during the registry of a predicate in " @@ -112,22 +112,28 @@ public SignalProperties build(final FunctionParsingInfo info) { } } } + final List redstoneValuePacks = new ArrayList<>(); + final List remoteRedstoneValuePacks = new ArrayList<>(); + ImmutableList + .of(Maps.immutableEntry(redstoneOutputs, redstoneValuePacks), + Maps.immutableEntry(remoteRedstoneOutputs, remoteRedstoneValuePacks)) + .forEach((entry) -> { + if (entry.getKey() != null) { + entry.getKey().forEach((key, value) -> { + final Predicate> predicate = LogicParser + .predicate(key, info); + final SEProperty property = (SEProperty) info.getProperty(value); + entry.getValue().add(new ValuePack(property, predicate)); + }); + } + }); - final List rsOutputs = new ArrayList<>(); - if (redstoneOutputs != null) { - for (final Map.Entry outputs : redstoneOutputs.entrySet()) { - final SEProperty property = (SEProperty) info.getProperty(outputs.getValue()); - rsOutputs.add( - new ValuePack(property, LogicParser.predicate(outputs.getKey(), info))); - } - } - - final List doubleText = new ArrayList<>(); + final List> doubleText = new ArrayList<>(); if (doubleSidedText != null) { doubleSidedText.forEach((property, bool) -> { try { - doubleText - .add(new BooleanProperty(LogicParser.predicate(property, info), bool)); + doubleText.add(new PredicateProperty( + LogicParser.predicate(property, info), bool)); } catch (final LogicalParserException e) { OpenSignalsMain.getLogger() .error("Something went wrong during the registry of a predicate in " @@ -143,6 +149,7 @@ public SignalProperties build(final FunctionParsingInfo info) { ImmutableList.copyOf(signalheights), signWidth, offsetX, offsetY, signScale, autoscale, ImmutableList.copyOf(doubleText), textColor, canLink, colors, ImmutableList.copyOf(renderheights), ImmutableList.copyOf(soundProperties), - ImmutableList.copyOf(rsOutputs), defaultItemDamage); + ImmutableList.copyOf(redstoneValuePacks), defaultItemDamage, + ImmutableList.copyOf(remoteRedstoneValuePacks)); } } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/core/SignalStateListener.java b/src/main/java/com/troblecodings/signals/core/SignalStateListener.java index a52696858..ea4e631af 100644 --- a/src/main/java/com/troblecodings/signals/core/SignalStateListener.java +++ b/src/main/java/com/troblecodings/signals/core/SignalStateListener.java @@ -6,4 +6,4 @@ public interface SignalStateListener { public void update(final SignalStateInfo info, final boolean removed); -} +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/core/SubsidiaryHolder.java b/src/main/java/com/troblecodings/signals/core/SubsidiaryHolder.java new file mode 100644 index 000000000..e694c6a83 --- /dev/null +++ b/src/main/java/com/troblecodings/signals/core/SubsidiaryHolder.java @@ -0,0 +1,37 @@ +package com.troblecodings.signals.core; + +import java.util.Objects; + +import com.troblecodings.signals.signalbox.ModeSet; +import com.troblecodings.signals.signalbox.Point; + +public class SubsidiaryHolder { + + public final SubsidiaryEntry entry; + public final Point point; + public final ModeSet modeSet; + + public SubsidiaryHolder(final SubsidiaryEntry entry, final Point point, final ModeSet modeSet) { + this.entry = entry; + this.point = point; + this.modeSet = modeSet; + } + + @Override + public int hashCode() { + return Objects.hash(entry, modeSet, point); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + SubsidiaryHolder other = (SubsidiaryHolder) obj; + return Objects.equals(entry, other.entry) && Objects.equals(modeSet, other.modeSet) + && Objects.equals(point, other.point); + } +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/core/SubsidiaryState.java b/src/main/java/com/troblecodings/signals/core/SubsidiaryState.java index ab7c6e5eb..54e43d25b 100644 --- a/src/main/java/com/troblecodings/signals/core/SubsidiaryState.java +++ b/src/main/java/com/troblecodings/signals/core/SubsidiaryState.java @@ -61,4 +61,9 @@ public boolean equals(final Object obj) { final SubsidiaryState other = (SubsidiaryState) obj; return id == other.id && Objects.equals(name, other.name); } + + @Override + public String toString() { + return name; + } } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/enums/CompareValues.java b/src/main/java/com/troblecodings/signals/enums/CompareValues.java index 048a23111..fabca76b7 100644 --- a/src/main/java/com/troblecodings/signals/enums/CompareValues.java +++ b/src/main/java/com/troblecodings/signals/enums/CompareValues.java @@ -23,7 +23,7 @@ public static CompareValues of(final String name) { return value; } OpenSignalsMain.getLogger() - .warn("The string [" + name + "] is not permitted for the speed function. " + .error("The string [" + name + "] is not permitted for the speed function. " + "EQUALS was taken as default. Please fix this in your pack!"); return EQUALS; } diff --git a/src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java b/src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java index 831490eb6..8bf49d8fc 100644 --- a/src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java +++ b/src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java @@ -14,9 +14,9 @@ public enum EnumGuiMode { 0, 0.5f, 0.5f, 1 }), END(new float[] { 0.9f, 0.2f, 0.9f, 0.8f - }), PLATFORM(new float[] { - 0, 0.1f, 1, 0.1f, 0, 0.2f, 1, 0.2f - }), BUE(new float[] { + }), PLATFORM(() -> new UILines(new float[] { + 0, 0.15f, 1, 0.15f + }, 3)), BUE(new float[] { 0.3f, 0, 0.3f, 1, 0.7f, 0, 0.7f, 1 }), HP(0), VP(1), RS(2), RA10(3), SH2(4); diff --git a/src/main/java/com/troblecodings/signals/enums/EnumPathUsage.java b/src/main/java/com/troblecodings/signals/enums/EnumPathUsage.java index e7f0ee498..1aa336269 100644 --- a/src/main/java/com/troblecodings/signals/enums/EnumPathUsage.java +++ b/src/main/java/com/troblecodings/signals/enums/EnumPathUsage.java @@ -22,5 +22,4 @@ private EnumPathUsage(final int color) { public int getColor() { return color; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/enums/EnumState.java b/src/main/java/com/troblecodings/signals/enums/EnumState.java index 129bc4f30..e9ac34d39 100644 --- a/src/main/java/com/troblecodings/signals/enums/EnumState.java +++ b/src/main/java/com/troblecodings/signals/enums/EnumState.java @@ -1,6 +1,7 @@ package com.troblecodings.signals.enums; import com.troblecodings.core.interfaces.NamableWrapper; +import com.troblecodings.signals.OpenSignalsMain; import com.troblecodings.signals.core.ReadBuffer; public enum EnumState implements NamableWrapper { @@ -24,7 +25,9 @@ public static EnumState of(final String name) { return state; } } - return null; + OpenSignalsMain.getLogger().error("[" + name + + "] is not a valid state of EnumState! [DISABLED] was taken as default!"); + return EnumState.DISABLED; } public static EnumState of(final ReadBuffer buffer) { diff --git a/src/main/java/com/troblecodings/signals/enums/ShowTypes.java b/src/main/java/com/troblecodings/signals/enums/ShowTypes.java new file mode 100644 index 000000000..dceb496f4 --- /dev/null +++ b/src/main/java/com/troblecodings/signals/enums/ShowTypes.java @@ -0,0 +1,7 @@ +package com.troblecodings.signals.enums; + +public enum ShowTypes { + + ALL, SIGNAL, INPUT, OUTPUT; + +} diff --git a/src/main/java/com/troblecodings/signals/guis/ContainerPlacementtool.java b/src/main/java/com/troblecodings/signals/guis/ContainerPlacementtool.java index 6b0f0b9ca..6e6d87b45 100644 --- a/src/main/java/com/troblecodings/signals/guis/ContainerPlacementtool.java +++ b/src/main/java/com/troblecodings/signals/guis/ContainerPlacementtool.java @@ -27,19 +27,17 @@ public class ContainerPlacementtool extends ContainerBase implements INetworkSyn public final Map properties = new HashMap<>(); protected int signalID; protected String signalName = ""; - private final EntityPlayer player; private Signal signal; public ContainerPlacementtool(final GuiInfo info) { super(info); info.base = this; - this.player = info.player; info.player.openContainer = this; } @Override public void sendAllDataToRemote() { - sendItemProperties(player); + sendItemProperties(getInfo().player); } private void sendItemProperties(final EntityPlayer player) { @@ -77,7 +75,7 @@ private void sendItemProperties(final EntityPlayer player) { public void deserializeServer(final ByteBuffer buf) { final ReadBuffer buffer = new ReadBuffer(buf); final int first = buffer.getByteAsInt(); - final ItemStack stack = player.getHeldItemMainhand(); + final ItemStack stack = getInfo().player.getHeldItemMainhand(); final Placementtool tool = (Placementtool) stack.getItem(); if (first == 255) { final int id = buffer.getInt(); @@ -95,7 +93,7 @@ public void deserializeServer(final ByteBuffer buf) { wrapper.putInteger(Placementtool.BLOCK_TYPE_ID, id); this.signal = tool.getObjFromID(id); properties.clear(); - sendItemProperties(player); + sendItemProperties(getInfo().player); } else { final NBTWrapper wrapper = NBTWrapper.getOrCreateWrapper(stack); final SEProperty property = signal.getProperties().get(first); @@ -113,7 +111,7 @@ public void deserializeClient(final ByteBuffer buf) { final ReadBuffer buffer = new ReadBuffer(buf); signalID = buffer.getInt(); final int size = buffer.getByteAsInt(); - final Placementtool tool = (Placementtool) player.getHeldItemMainhand().getItem(); + final Placementtool tool = (Placementtool) getInfo().player.getHeldItemMainhand().getItem(); final Signal signal = tool.getObjFromID(signalID); final List signalProperties = signal.getProperties(); properties.clear(); diff --git a/src/main/java/com/troblecodings/signals/guis/ContainerSignalBox.java b/src/main/java/com/troblecodings/signals/guis/ContainerSignalBox.java index c988bb7fb..32b1144e5 100644 --- a/src/main/java/com/troblecodings/signals/guis/ContainerSignalBox.java +++ b/src/main/java/com/troblecodings/signals/guis/ContainerSignalBox.java @@ -1,21 +1,22 @@ package com.troblecodings.signals.guis; import java.nio.ByteBuffer; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; +import java.util.stream.Collectors; import com.troblecodings.guilib.ecs.ContainerBase; import com.troblecodings.guilib.ecs.GuiInfo; import com.troblecodings.guilib.ecs.interfaces.UIClientSync; import com.troblecodings.signals.OpenSignalsMain; -import com.troblecodings.signals.blocks.Signal; import com.troblecodings.signals.core.PosIdentifier; import com.troblecodings.signals.core.ReadBuffer; import com.troblecodings.signals.core.SubsidiaryEntry; +import com.troblecodings.signals.core.SubsidiaryState; import com.troblecodings.signals.core.WriteBuffer; import com.troblecodings.signals.enums.EnumGuiMode; import com.troblecodings.signals.enums.LinkType; @@ -36,22 +37,19 @@ public class ContainerSignalBox extends ContainerBase implements UIClientSync { + protected final Map> possibleSubsidiaries = new HashMap<>(); protected Map> enabledSubsidiaryTypes = new HashMap<>(); protected SignalBoxGrid grid; - private final AtomicReference> propertiesForType = new AtomicReference<>(); - private final AtomicReference> properties = new AtomicReference<>(); - private final AtomicReference> names = new AtomicReference<>(); - private final GuiInfo info; + private final Map propertiesForType = new HashMap<>(); private SignalBoxTileEntity tile; private EntityPlayer player; - private Consumer run; + private Consumer infoUpdates; private Consumer> colorUpdates; public ContainerSignalBox(final GuiInfo info) { super(info); this.tile = info.getTile(); info.player.openContainer = this; - this.info = info; } @Override @@ -59,16 +57,26 @@ public void sendAllDataToRemote() { final SignalBoxGrid grid = tile.getSignalBoxGrid(); final WriteBuffer buffer = new WriteBuffer(); buffer.putByte((byte) SignalBoxNetwork.SEND_GRID.ordinal()); - buffer.putBlockPos(info.pos); + buffer.putBlockPos(getInfo().pos); grid.writeNetwork(buffer); - final Map positions = SignalBoxHandler - .getAllLinkedPos(new PosIdentifier(tile.getPos(), info.world)); + final PosIdentifier identifier = new PosIdentifier(tile.getPos(), getInfo().world); + final Map> possibleSubsidiaries = SignalBoxHandler + .getPossibleSubsidiaries(identifier); + final Map positions = SignalBoxHandler.getAllLinkedPos(identifier) + .entrySet().stream().filter(e -> !e.getValue().equals(LinkType.SIGNAL)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + buffer.putInt(possibleSubsidiaries.size()); + possibleSubsidiaries.forEach((pos, list) -> { + buffer.putBlockPos(pos); + buffer.putByte((byte) list.size()); + list.forEach(state -> buffer.putByte((byte) state.getID())); + }); buffer.putInt(positions.size()); positions.forEach((pos, type) -> { buffer.putBlockPos(pos); buffer.putByte((byte) type.ordinal()); }); - OpenSignalsMain.network.sendTo(info.player, buffer.build()); + OpenSignalsMain.network.sendTo(getInfo().player, buffer.build()); } @Override @@ -79,19 +87,31 @@ public void deserializeClient(final ByteBuffer buf) { case SEND_GRID: { final BlockPos pos = buffer.getBlockPos(); if (this.tile == null) { - this.tile = (SignalBoxTileEntity) info.world.getTileEntity(pos); + this.tile = (SignalBoxTileEntity) getInfo().world.getTileEntity(pos); } grid = tile.getSignalBoxGrid(); grid.readNetwork(buffer); - enabledSubsidiaryTypes = grid.getAllSubsidiaries(); + enabledSubsidiaryTypes = new HashMap<>(grid.getAllSubsidiaries()); + propertiesForType.clear(); + possibleSubsidiaries.clear(); + final int signalSize = buffer.getInt(); + for (int i = 0; i < signalSize; i++) { + final BlockPos signalPos = buffer.getBlockPos(); + propertiesForType.put(signalPos, LinkType.SIGNAL); + final List validSubsidiaries = new ArrayList<>(); + final int listSize = buffer.getByteAsInt(); + for (int j = 0; j < listSize; j++) { + validSubsidiaries + .add(SubsidiaryState.ALL_STATES.get(buffer.getByteAsInt())); + } + possibleSubsidiaries.put(signalPos, validSubsidiaries); + } final int size = buffer.getInt(); - final Map allPos = new HashMap<>(); for (int i = 0; i < size; i++) { final BlockPos blockPos = buffer.getBlockPos(); final LinkType type = LinkType.of(buffer); - allPos.put(blockPos, type); + propertiesForType.put(blockPos, type); } - propertiesForType.set(allPos); update(); break; } @@ -100,11 +120,11 @@ public void deserializeClient(final ByteBuffer buf) { break; } case NO_PW_FOUND: { - run.accept(I18n.format("error.nopathfound")); + infoUpdates.accept(I18n.format("error.nopathfound")); break; } case NO_OUTPUT_UPDATE: { - run.accept(I18n.format("error.nooutputupdate")); + infoUpdates.accept(I18n.format("error.nooutputupdate")); break; } case OUTPUT_UPDATE: { @@ -171,7 +191,7 @@ public void deserializeServer(final ByteBuffer buf) { if (!grid.requestWay(start, end)) { final WriteBuffer error = new WriteBuffer(); error.putByte((byte) SignalBoxNetwork.NO_PW_FOUND.ordinal()); - OpenSignalsMain.network.sendTo(info.player, error.build()); + OpenSignalsMain.network.sendTo(getInfo().player, error.build()); } break; } @@ -198,16 +218,16 @@ public void deserializeServer(final ByteBuffer buf) { if (pos == null) { final WriteBuffer error = new WriteBuffer(); error.putByte((byte) SignalBoxNetwork.NO_OUTPUT_UPDATE.ordinal()); - OpenSignalsMain.network.sendTo(info.player, error.build()); + OpenSignalsMain.network.sendTo(getInfo().player, error.build()); } else { - SignalBoxHandler.updateRedstoneOutput(new PosIdentifier(pos, info.world), + SignalBoxHandler.updateRedstoneOutput(new PosIdentifier(pos, getInfo().world), state); final WriteBuffer sucess = new WriteBuffer(); sucess.putByte((byte) SignalBoxNetwork.OUTPUT_UPDATE.ordinal()); point.writeNetwork(sucess); modeSet.writeNetwork(sucess); sucess.putByte((byte) (state ? 1 : 0)); - OpenSignalsMain.network.sendTo(info.player, sucess.build()); + OpenSignalsMain.network.sendTo(getInfo().player, sucess.build()); } break; } @@ -217,7 +237,7 @@ public void deserializeServer(final ByteBuffer buf) { final SignalBoxNode node = tile.getSignalBoxGrid().getNode(point); node.setAutoPoint(state); SignalBoxHandler.updatePathwayToAutomatic( - new PosIdentifier(tile.getPos(), info.world), point); + new PosIdentifier(tile.getPos(), getInfo().world), point); break; } case SEND_NAME: { @@ -267,16 +287,8 @@ public EntityPlayer getPlayer() { return this.player; } - public Map getProperties() { - return this.properties.get(); - } - - public Map getNames() { - return this.names.get(); - } - public Map getPositionForTypes() { - return this.propertiesForType.get(); + return this.propertiesForType; } @Override @@ -291,7 +303,7 @@ public boolean canInteractWith(final EntityPlayer playerIn) { } protected void setConsumer(final Consumer run) { - this.run = run; + this.infoUpdates = run; } protected void setColorUpdater(final Consumer> updater) { diff --git a/src/main/java/com/troblecodings/signals/guis/ContainerSignalController.java b/src/main/java/com/troblecodings/signals/guis/ContainerSignalController.java index e83adeb09..5984683c8 100644 --- a/src/main/java/com/troblecodings/signals/guis/ContainerSignalController.java +++ b/src/main/java/com/troblecodings/signals/guis/ContainerSignalController.java @@ -4,7 +4,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; import com.troblecodings.core.interfaces.INetworkSync; import com.troblecodings.guilib.ecs.ContainerBase; @@ -33,9 +32,8 @@ public class ContainerSignalController extends ContainerBase implements UIClientSync, INetworkSync, IChunkLoadable { - private final AtomicReference> reference = new AtomicReference<>(); - private final AtomicReference referenceBlock = new AtomicReference<>(); - private final GuiInfo info; + private final Map properties = new HashMap<>(); + private Signal currentSignal = null; private List propertiesList; private BlockPos linkedPos; private SignalControllerTileEntity controllerEntity; @@ -51,7 +49,6 @@ public ContainerSignalController(final GuiInfo info) { super(info); info.base = this; info.player.openContainer = this; - this.info = info; } @Override @@ -60,20 +57,23 @@ public void sendAllDataToRemote() { } private void sendProperitesToClient() { - if (info.pos == null) { + if (getInfo().pos == null) { return; } - controllerEntity = (SignalControllerTileEntity) info.world.getTileEntity(info.pos); + controllerEntity = (SignalControllerTileEntity) getInfo().world + .getTileEntity(getInfo().pos); linkedPos = controllerEntity.getLinkedPosition(); if (linkedPos == null) { return; } - referenceBlock.set(controllerEntity.getLinkedSignal()); - final SignalStateInfo stateInfo = new SignalStateInfo(info.world, linkedPos, getSignal()); + currentSignal = controllerEntity.getLinkedSignal(); + final SignalStateInfo stateInfo = new SignalStateInfo(getInfo().world, linkedPos, + getSignal()); final Map properties = SignalStateHandler.getStates(stateInfo); if (properties == null || properties.isEmpty()) return; - reference.set(properties); + this.properties.clear(); + this.properties.putAll(properties); final Map propertiesToSend = new HashMap<>(); properties.forEach((property, value) -> { if ((property.isChangabelAtStage(ChangeableStage.APISTAGE) @@ -136,7 +136,7 @@ private void sendProperitesToClient() { buffer.putByte((byte) (controllerEntity.getProfileRSInput() != -1 ? 1 : 0)); if (controllerEntity.getProfileRSInput() != -1) buffer.putByte(controllerEntity.getProfileRSInput()); - OpenSignalsMain.network.sendTo(info.player, buffer.build()); + OpenSignalsMain.network.sendTo(getInfo().player, buffer.build()); } private void packPropertyToBuffer(final WriteBuffer buffer, final SignalStateInfo stateInfo, @@ -154,17 +154,14 @@ public void deserializeClient(final ByteBuffer buf) { for (int i = 0; i < nameSize; i++) { signalName[i] = buffer.getByte(); } - final Signal signal = Signal.SIGNALS.get(new String(signalName)); - referenceBlock.set(signal); + currentSignal = Signal.SIGNALS.get(new String(signalName)); currentMode = EnumMode.values()[buffer.getByteAsInt()]; final int size = buffer.getByteAsInt(); - final Map properites = new HashMap<>(); - propertiesList = signal.getProperties(); + propertiesList = currentSignal.getProperties(); for (int i = 0; i < size; i++) { final SEProperty property = propertiesList.get(buffer.getByteAsInt()); - properites.put(property, property.getObjFromID(buffer.getByteAsInt())); + properties.put(property, property.getObjFromID(buffer.getByteAsInt())); } - reference.set(properites); lastProfile = buffer.getByteAsInt(); allRSStates.clear(); final int allStatesSize = buffer.getByteAsInt(); @@ -222,7 +219,7 @@ public void deserializeServer(final ByteBuffer buf) { final String value = property.getObjFromID(buffer.getByteAsInt()); if (currentMode.equals(EnumMode.MANUELL)) { SignalStateHandler.setState( - new SignalStateInfo(info.world, linkedPos, getSignal()), property, + new SignalStateInfo(getInfo().world, linkedPos, getSignal()), property, value); } else if (currentMode.equals(EnumMode.SINGLE)) { controllerEntity.updateRedstoneProfile((byte) currentRSProfile, property, @@ -261,8 +258,8 @@ public void deserializeServer(final ByteBuffer buf) { } case UNLINK_INPUT_POS: { final BlockPos linkedInput = controllerEntity.getLinkedRSInput(); - loadChunkAndGetTile(RedstoneIOTileEntity.class, info.world, linkedInput, - (tile, _u) -> tile.unlinkController(info.pos)); + loadChunkAndGetTile(RedstoneIOTileEntity.class, getInfo().world, linkedInput, + (tile, _u) -> tile.unlinkController(getInfo().pos)); controllerEntity.setLinkedRSInput(null); break; } @@ -275,23 +272,23 @@ private static EnumFacing deserializeDirection(final ReadBuffer buffer) { return EnumFacing.values()[buffer.getByteAsInt()]; } - public Map getReference() { - return reference.get(); + public Map getProperties() { + return properties; } public Signal getSignal() { - return referenceBlock.get(); + return currentSignal; } @Override public EntityPlayer getPlayer() { - return info.player; + return getInfo().player; } @Override public boolean canInteractWith(final EntityPlayer playerIn) { if (playerIn instanceof EntityPlayerMP) { - this.info.player = playerIn; + this.getInfo().player = playerIn; } return true; } diff --git a/src/main/java/com/troblecodings/signals/guis/GuiPlacementtool.java b/src/main/java/com/troblecodings/signals/guis/GuiPlacementtool.java index ef13deca6..624e11835 100644 --- a/src/main/java/com/troblecodings/signals/guis/GuiPlacementtool.java +++ b/src/main/java/com/troblecodings/signals/guis/GuiPlacementtool.java @@ -2,7 +2,6 @@ import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.function.IntConsumer; import com.troblecodings.core.NBTWrapper; @@ -10,16 +9,11 @@ import com.troblecodings.guilib.ecs.GuiBase; import com.troblecodings.guilib.ecs.GuiElements; import com.troblecodings.guilib.ecs.GuiInfo; -import com.troblecodings.guilib.ecs.entitys.UIBlockRender; import com.troblecodings.guilib.ecs.entitys.UIBox; import com.troblecodings.guilib.ecs.entitys.UIEntity; import com.troblecodings.guilib.ecs.entitys.UIEnumerable; import com.troblecodings.guilib.ecs.entitys.UITextInput; -import com.troblecodings.guilib.ecs.entitys.input.UIDrag; import com.troblecodings.guilib.ecs.entitys.render.UILabel; -import com.troblecodings.guilib.ecs.entitys.render.UIScissor; -import com.troblecodings.guilib.ecs.entitys.transform.UIIndependentTranslate; -import com.troblecodings.guilib.ecs.entitys.transform.UIRotate; import com.troblecodings.guilib.ecs.entitys.transform.UIScale; import com.troblecodings.signals.OpenSignalsMain; import com.troblecodings.signals.SEProperty; @@ -29,7 +23,6 @@ import com.troblecodings.signals.enums.ChangeableStage; import com.troblecodings.signals.items.Placementtool; -import net.minecraft.block.state.IBlockState; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -42,7 +35,7 @@ public class GuiPlacementtool extends GuiBase { public static final int GUI_PLACEMENTTOOL = 0; private final UIEntity list = new UIEntity(); - private final UIBlockRender blockRender = new UIBlockRender(); + private final PreviewSideBar previewSidebar = new PreviewSideBar(-9); private Signal currentSelectedBlock; private final Placementtool tool; private final EntityPlayer player; @@ -70,8 +63,7 @@ public ContainerBase getNewGuiContainer(final GuiInfo info) { private void initInternal() { final UIBox vbox = new UIBox(UIBox.VBOX, 5); this.list.add(vbox); - this.list.setInheritHeight(true); - this.list.setInheritWidth(true); + this.list.setInherits(true); final UIEntity lowerEntity = new UIEntity(); lowerEntity.add(GuiElements.createSpacerH(10)); @@ -83,6 +75,7 @@ private void initInternal() { currentSelectedBlock = tool.getObjFromID(input); this.list.clearChildren(); if (container.signalID != input) { + previewSidebar.clear(); sendSignalId(input); } }); @@ -95,26 +88,10 @@ private void initInternal() { leftSide.add(list); leftSide.add(GuiElements.createPageSelect(vbox)); - final UIEntity blockRenderEntity = new UIEntity(); - blockRenderEntity.setInheritHeight(true); - blockRenderEntity.setWidth(60); - - final UIRotate rotation = new UIRotate(); - rotation.setRotateY(180); - blockRenderEntity.add( - new UIDrag((x, y) -> rotation.setRotateY((float) (rotation.getRotateY() + x)))); - - blockRenderEntity.add(new UIScissor()); - blockRenderEntity.add(new UIIndependentTranslate(35, 150, 40)); - blockRenderEntity.add(rotation); - blockRenderEntity.add(new UIIndependentTranslate(-0.5, -3.5, -0.5)); - blockRenderEntity.add(new UIScale(20, -20, 20)); - blockRenderEntity.add(blockRender); - lowerEntity.add(new UIBox(UIBox.HBOX, 5)); lowerEntity.add(leftSide); - lowerEntity.add(blockRenderEntity); + lowerEntity.add(previewSidebar.get()); lowerEntity.setInheritHeight(true); lowerEntity.setInheritWidth(true); @@ -142,6 +119,7 @@ private void initInternal() { public void of(final SEProperty property, final IntConsumer consumer, final int value) { if (property == null) return; + previewSidebar.addToRenderList(property, value); if (property.isChangabelAtStage(ChangeableStage.GUISTAGE)) { if (property.getParent().equals(JsonEnum.BOOLEAN)) { list.add(GuiElements.createBoolElement(property, consumer, value)); @@ -157,12 +135,9 @@ public void of(final SEProperty property, final IntConsumer consumer, final int public void updateFromContainer() { enumerable.setIndex(container.signalID); final List originalProperties = currentSelectedBlock.getProperties(); - final Map savedProperties = container.properties; originalProperties.forEach(property -> { - of(property, - inp -> applyPropertyChanges(currentSelectedBlock.getIDFromProperty(property), - inp), - savedProperties.get(property)); + of(property, inp -> applyPropertyChanges(property, inp), + container.properties.get(property)); }); final UIEntity textfield = new UIEntity(); textfield.setHeight(20); @@ -175,16 +150,19 @@ public void updateFromContainer() { } this.entity.update(); loaded = true; + previewSidebar.update(currentSelectedBlock); } - private void applyPropertyChanges(final int propertyId, final int valueId) { + private void applyPropertyChanges(final SEProperty property, final int valueId) { + previewSidebar.addToRenderList(property, valueId); if (loaded) { + final int propertyId = currentSelectedBlock.getIDFromProperty(property); final WriteBuffer buffer = new WriteBuffer(); buffer.putByte((byte) propertyId); buffer.putByte((byte) valueId); OpenSignalsMain.network.sendTo(player, buffer.build()); + previewSidebar.update(currentSelectedBlock); } - applyModelChanges(); } private void sendSignalId(final int id) { @@ -209,32 +187,4 @@ private void sendName(final String name) { } OpenSignalsMain.network.sendTo(player, buffer.build()); } - - public void applyModelChanges() { - @SuppressWarnings("unused") - final IBlockState ebs = currentSelectedBlock.getDefaultState(); - return; - /* - * final List enumerables = - * this.list.findRecursive(UIEnumerable.class); for (final UIEnumerable - * enumerable : enumerables) { final SEProperty sep = (SEProperty) - * lookup.get(enumerable.getID()); if (sep == null) return; ebs = - * ebs.withProperty(sep, sep.getObjFromID(enumerable.getIndex())); } - * - * final List checkbox = this.list.findRecursive(UICheckBox.class); - * for (final UICheckBox checkb : checkbox) { final SEProperty sep = - * (SEProperty) lookup.get(checkb.getID()); if (sep == null) return; if - * (sep.isChangabelAtStage(ChangeableStage.GUISTAGE)) { ebs = - * ebs.withProperty(sep, checkb.isChecked()); } else if (checkb.isChecked()) { - * ebs = ebs.withProperty(sep, sep.getDefault()); } } - * - * for (final Entry, Optional> prop : - * ebs.getUnlistedProperties() .entrySet()) { final SEProperty property = - * SEProperty.cst(prop.getKey()); if - * (property.isChangabelAtStage(ChangeableStage.APISTAGE_NONE_CONFIG)) { ebs = - * ebs.withProperty(property, property.getDefault()); } } - * - * blockRender.setBlockState(ebs); - */ - } } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/guis/GuiSignalBox.java b/src/main/java/com/troblecodings/signals/guis/GuiSignalBox.java index e20b0d3a7..468571ad0 100644 --- a/src/main/java/com/troblecodings/signals/guis/GuiSignalBox.java +++ b/src/main/java/com/troblecodings/signals/guis/GuiSignalBox.java @@ -7,19 +7,20 @@ import java.util.Map.Entry; import java.util.Optional; import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiConsumer; import java.util.stream.Collectors; import com.troblecodings.guilib.ecs.ContainerBase; import com.troblecodings.guilib.ecs.DrawUtil.BoolIntegerables; import com.troblecodings.guilib.ecs.DrawUtil.DisableIntegerable; +import com.troblecodings.guilib.ecs.DrawUtil.EnumIntegerable; import com.troblecodings.guilib.ecs.DrawUtil.SizeIntegerables; import com.troblecodings.guilib.ecs.GuiBase; import com.troblecodings.guilib.ecs.GuiElements; import com.troblecodings.guilib.ecs.GuiInfo; import com.troblecodings.guilib.ecs.entitys.UIBox; import com.troblecodings.guilib.ecs.entitys.UIEntity; -import com.troblecodings.guilib.ecs.entitys.UIStack; import com.troblecodings.guilib.ecs.entitys.UITextInput; import com.troblecodings.guilib.ecs.entitys.input.UIClickable; import com.troblecodings.guilib.ecs.entitys.input.UIDrag; @@ -33,14 +34,18 @@ import com.troblecodings.guilib.ecs.entitys.render.UITexture; import com.troblecodings.guilib.ecs.entitys.render.UIToolTip; import com.troblecodings.guilib.ecs.entitys.transform.UIScale; +import com.troblecodings.guilib.ecs.interfaces.IIntegerable; import com.troblecodings.signals.OpenSignalsMain; +import com.troblecodings.signals.config.ConfigHandler; import com.troblecodings.signals.core.JsonEnumHolder; import com.troblecodings.signals.core.SubsidiaryEntry; +import com.troblecodings.signals.core.SubsidiaryHolder; import com.troblecodings.signals.core.SubsidiaryState; import com.troblecodings.signals.core.WriteBuffer; import com.troblecodings.signals.enums.EnumGuiMode; import com.troblecodings.signals.enums.EnumPathUsage; import com.troblecodings.signals.enums.LinkType; +import com.troblecodings.signals.enums.ShowTypes; import com.troblecodings.signals.enums.SignalBoxNetwork; import com.troblecodings.signals.handler.ClientNameHandler; import com.troblecodings.signals.handler.NameStateInfo; @@ -52,19 +57,21 @@ import com.troblecodings.signals.signalbox.entrys.PathEntryType; import com.troblecodings.signals.signalbox.entrys.PathOptionEntry; +import net.minecraft.client.Minecraft; import net.minecraft.client.resources.I18n; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; public class GuiSignalBox extends GuiBase { - private static final int SELECTION_COLOR = 0x2900FF00; - private static final int BACKGROUND_COLOR = 0xFF8B8B8B; - private static final int LINE_COLOR = 0xFF5B5B5B; + public static final int SELECTION_COLOR = 0x2900FF00; + public static final int BACKGROUND_COLOR = ConfigHandler.signalboxBackgroundColor; + public static final int GRID_COLOR = 0xFF5B5B5B; + public static final int EDIT_COLOR = 0x5000A2FF; - private static final float[] ALL_LINES = getLines(); - private static final int TILE_WIDTH = 10; - private static final int TILE_COUNT = 100; + public static final float[] ALL_LINES = getLines(); + public static final int TILE_WIDTH = 10; + public static final int TILE_COUNT = 100; private static float[] getLines() { final float[] lines = new float[2 * (TILE_COUNT + 1) * 4]; @@ -87,16 +94,16 @@ private static float[] getLines() { } private final UIEntity lowerEntity = new UIEntity(); - private final ContainerSignalBox container; + protected final ContainerSignalBox container; private UISignalBoxTile lastTile = null; - @SuppressWarnings("unused") - private Page page = Page.USAGE; private UIEntity mainButton; private final GuiInfo info; private final Map changedModes = new HashMap<>(); private UIEntity plane = null; private boolean allPacketsRecived = false; private final Map allTiles = new HashMap<>(); + private SidePanel helpPage; + private final Map enabledSubsidiaries = new HashMap<>(); public GuiSignalBox(final GuiInfo info) { super(info); @@ -109,7 +116,7 @@ public GuiSignalBox(final GuiInfo info) { public void update(final String errorString) { this.resetTileSelection(); - final UIToolTip tooltip = new UIToolTip(errorString); + final UIToolTip tooltip = new UIToolTip(errorString, true); lowerEntity.add(tooltip); new Thread(() -> { try { @@ -123,9 +130,10 @@ public void update(final String errorString) { } private void resetTileSelection() { - this.entity.findRecursive(UIColor.class).stream() - .filter(color -> color.getColor() == SELECTION_COLOR) + this.entity.findRecursive(UIColor.class).stream().filter( + color -> color.getColor() == SELECTION_COLOR || color.getColor() == EDIT_COLOR) .forEach(color -> color.getParent().remove(color)); + this.lastTile = null; } private void selectLink(final UIEntity parent, final SignalBoxNode node, @@ -169,7 +177,8 @@ private void selectLink(final UIEntity parent, final SignalBoxNode node, } } - private String getSignalInfo(final BlockPos signalPos, final LinkType type) { + public static String getSignalInfo(final BlockPos signalPos, final LinkType type) { + final Minecraft mc = Minecraft.getMinecraft(); final String customName = ClientNameHandler .getClientName(new NameStateInfo(mc.world, signalPos)); return String.format("%s (x=%d, y=%d. z=%d)", @@ -193,6 +202,7 @@ private void setupModeSettings(final UIEntity parent, final EnumGuiMode mode, entity.add(modeLabel); parent.add(entity); final Set> entrySet = container.getPositionForTypes().entrySet(); + final ModeSet modeSet = new ModeSet(mode, rotation); switch (mode) { case CORNER: @@ -224,12 +234,90 @@ private void setupModeSettings(final UIEntity parent, final EnumGuiMode mode, selectLink(parent, node, option, entrySet, LinkType.OUTPUT, PathEntryType.OUTPUT, mode, rotation); - if (option.getEntry(PathEntryType.OUTPUT).isPresent()) - parent.add( - GuiElements.createBoolElement(BoolIntegerables.of("manuell_rs"), e -> { - changeRedstoneOutput(node.getPoint(), new ModeSet(mode, rotation), - e == 1 ? true : false); - }, node.containsManuellOutput(new ModeSet(mode, rotation)) ? 1 : 0)); + if (option.getEntry(PathEntryType.OUTPUT).isPresent()) { + final AtomicBoolean canBeManuelChanged = new AtomicBoolean(true); + for (final Map.Entry entry : node.getModes() + .entrySet()) { + final Optional usage = entry.getValue() + .getEntry(PathEntryType.PATHUSAGE); + if (usage.isPresent() && !usage.get().equals(EnumPathUsage.FREE)) { + canBeManuelChanged.set(false); + break; + } + } + final UILabel currentStatus = new UILabel(I18n.format("info.usage.status") + + " : " + I18n.format("info.usage.status.free")); + currentStatus.setTextColor(new UIEntity().getBasicTextColor()); + final UIEntity statusEntity = new UIEntity(); + statusEntity.setInheritWidth(true); + statusEntity.setHeight(20); + statusEntity.add(new UIScale(1.1f, 1.1f, 1)); + statusEntity.add(currentStatus); + parent.add(GuiElements.createButton(I18n.format("info.usage.manuel"), e1 -> { + final Optional usage = option + .getEntry(PathEntryType.PATHUSAGE); + final UIEntity info = new UIEntity(); + info.setInherits(true); + info.add(new UIBox(UIBox.VBOX, 5)); + info.add(new UIColor(BACKGROUND_COLOR)); + info.add(new UIClickable(_u -> pop(), 1)); + info.add(statusEntity); + final UIEntity textureEntity = new UIEntity(); + textureEntity.setHeight(40); + textureEntity.setWidth(40); + textureEntity.setX(120); + textureEntity.add(new UIToolTip(I18n.format("info.usage.rs.desc"))); + if (canBeManuelChanged.get()) { + if (node.containsManuellOutput(modeSet)) { + textureEntity.add(new UITexture(SidePanel.REDSTONE_ON)); + } else { + textureEntity.add(new UITexture(SidePanel.REDSTONE_OFF)); + } + } else { + if (usage.isPresent() && !usage.get().equals(EnumPathUsage.FREE)) { + textureEntity.add(new UITexture(SidePanel.REDSTONE_ON_BLOCKED)); + } else { + textureEntity.add(new UITexture(SidePanel.REDSTONE_OFF_BLOCKED)); + } + } + info.add(textureEntity); + final UILabel outputStatus = new UILabel( + ((usage.isPresent() && !usage.get().equals(EnumPathUsage.FREE)) + || node.containsManuellOutput(modeSet)) + ? I18n.format("info.usage.rs.true") + : I18n.format("info.usage.rs.false")); + outputStatus.setCenterY(false); + outputStatus.setTextColor(new UIEntity().getBasicTextColor()); + final UIEntity outputEntity = new UIEntity(); + outputEntity.setInheritWidth(true); + outputEntity.setHeight(20); + outputEntity.add(outputStatus); + info.add(outputEntity); + if (canBeManuelChanged.get()) { + info.add(GuiElements.createButton(I18n.format("info.usage.change"), + i -> { + final boolean turnOff = node.containsManuellOutput(modeSet); + textureEntity.clear(); + textureEntity.add( + new UIToolTip(I18n.format("info.usage.rs.desc"))); + if (turnOff) { + changeRedstoneOutput(node.getPoint(), modeSet, false); + outputStatus + .setText(I18n.format("info.usage.rs.false")); + textureEntity + .add(new UITexture(SidePanel.REDSTONE_OFF)); + } else { + changeRedstoneOutput(node.getPoint(), modeSet, true); + outputStatus.setText(I18n.format("info.usage.rs.true")); + textureEntity.add(new UITexture(SidePanel.REDSTONE_ON)); + } + })); + } + final UIEntity screen = GuiElements.createScreen(e -> e.add(info)); + push(screen); + })); + parent.add(new UIToolTip(I18n.format("info.usage.manuel.desc"))); + } selectLink(parent, node, option, entrySet, LinkType.INPUT, PathEntryType.BLOCKING, mode, rotation, ".blocking"); @@ -269,21 +357,35 @@ private void setupModeSettings(final UIEntity parent, final EnumGuiMode mode, final UIEntity list = new UIEntity(); list.setInherits(true); list.add(hbox); - list.add(GuiElements.createButton(I18n.format("btn.return"), a -> { - pop(); - })); - final ModeSet modeSet = new ModeSet(mode, rotation); - SubsidiaryState.ALL_STATES.forEach(state -> { + list.add(GuiElements.createButton(I18n.format("btn.return"), a -> pop())); + final BlockPos pos = option.getEntry(PathEntryType.SIGNAL).get(); + final List subsidiaries = container.possibleSubsidiaries + .getOrDefault(pos, SubsidiaryState.ALL_STATES); + subsidiaries.forEach(state -> { final int defaultValue = container.grid .getSubsidiaryState(node.getPoint(), modeSet, state) ? 0 : 1; list.add(GuiElements.createEnumElement(new SizeIntegerables<>( state.getName(), 2, i -> i == 1 ? "false" : "true"), a -> { final SubsidiaryEntry entry = new SubsidiaryEntry(state, a == 0 ? true : false); - sendSubsidiaryRequest(entry, node, modeSet); + sendSubsidiaryRequest(entry, node.getPoint(), modeSet); container.grid.setClientState(node.getPoint(), modeSet, entry); + final BlockPos signalPos = option + .getEntry(PathEntryType.SIGNAL).orElse(null); + if (signalPos != null) { + if (entry.state) { + enabledSubsidiaries.put(signalPos, + new SubsidiaryHolder(entry, node.getPoint(), + modeSet)); + } else { + enabledSubsidiaries.remove(signalPos); + } + } pop(); + helpPage.helpUsageMode(enabledSubsidiaries, null, + container.grid.getNodes(), + container.possibleSubsidiaries); }, defaultValue)); }); final UIEntity screen = GuiElements.createScreen(selection -> { @@ -299,7 +401,16 @@ private void setupModeSettings(final UIEntity parent, final EnumGuiMode mode, default: break; } + } + private void disableSubsidiary(final BlockPos pos, final SubsidiaryHolder holder) { + final SubsidiaryEntry entry = new SubsidiaryEntry(holder.entry.enumValue, false); + sendSubsidiaryRequest(entry, holder.point, holder.modeSet); + container.grid.setClientState(holder.point, holder.modeSet, entry); + enabledSubsidiaries.remove(pos); + helpPage.helpUsageMode(enabledSubsidiaries, null, container.grid.getNodes(), + container.possibleSubsidiaries); + this.resetTileSelection(); } private void tileEdit(final UIEntity tile, final UIMenu menu, final UISignalBoxTile sbt) { @@ -327,15 +438,13 @@ private void tileNormal(final UIEntity tile, final UISignalBoxTile currentTile) } else { if (lastTile == currentTile) { this.resetTileSelection(); - lastTile = null; return; } sendPWRequest(currentTile.getNode()); this.resetTileSelection(); - lastTile = null; } })); - tile.add(new UIClickable(e -> initializePageTileConfig(currentTile.getNode()), 1)); + tile.add(new UIClickable(e -> openNodeShortcuts(currentTile.getNode(), e), 1)); } private void resetSelection(final UIEntity entity) { @@ -346,7 +455,29 @@ private void resetSelection(final UIEntity entity) { entity.findRecursive(UIClickable.class).forEach(click -> click.setVisible(false)); } - private void initializePageTileConfig(final SignalBoxNode node) { + private void openNodeShortcuts(final SignalBoxNode node, final UIEntity entity) { + if (node.isEmpty()) + return; + final AtomicBoolean isAlreadyOpen = new AtomicBoolean(false); + entity.findRecursive(UIColor.class).stream().filter(color -> color.getColor() == EDIT_COLOR) + .forEach(color -> { + color.getParent().remove(color); + helpPage.helpUsageMode(enabledSubsidiaries, null, container.grid.getNodes(), + container.possibleSubsidiaries); + helpPage.setShowHelpPage(false); + isAlreadyOpen.set(true); + this.resetTileSelection(); + }); + if (isAlreadyOpen.get()) + return; + this.resetTileSelection(); + entity.add(new UIColor(EDIT_COLOR)); + helpPage.helpUsageMode(enabledSubsidiaries, node, container.grid.getNodes(), + container.possibleSubsidiaries); + helpPage.setShowHelpPage(true); + } + + protected void initializePageTileConfig(final SignalBoxNode node) { if (node.isEmpty()) return; reset(); @@ -370,28 +501,67 @@ private void initializePageTileConfig(final SignalBoxNode node) { node.forEach(modeSet -> setupModeSettings(list, modeSet.mode, modeSet.rotation, node, node.getOption(modeSet).get())); lowerEntity.add(GuiElements.createPageSelect(box)); - lowerEntity.add(new UIClickable(e -> { - initializeFieldUsage(mainButton); - }, 1)); - pageCheck(Page.TILE_CONFIG); + lowerEntity.add(new UIClickable(e -> initializeFieldUsage(mainButton), 1)); } - private void pageCheck(final Page page) { - this.page = page; - } + private int lastValue = 0; private void initializePageSettings(final UIEntity entity) { + this.initializePageSettings(entity, container.getPositionForTypes()); + } + + private void initializePageSettings(final UIEntity entity, + final Map types) { reset(); - this.pageCheck(Page.SETTINGS); lowerEntity.add(new UIBox(UIBox.VBOX, 2)); lowerEntity.setInheritHeight(true); lowerEntity.setInheritWidth(true); + final IIntegerable sorting = new EnumIntegerable<>(ShowTypes.class); + lowerEntity.add(GuiElements.createEnumElement(sorting, i -> { + lastValue = i; + if (i == -1) + return; + final ShowTypes option = ShowTypes.values()[i]; + switch (option) { + case ALL: { + initializePageSettings(entity); + break; + } + case INPUT: { + initializePageSettings(entity, container.getPositionForTypes().entrySet() + .stream().filter(entry -> entry.getValue().equals(LinkType.INPUT)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); + break; + } + case OUTPUT: { + initializePageSettings(entity, container.getPositionForTypes().entrySet() + .stream().filter(entry -> entry.getValue().equals(LinkType.OUTPUT)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); + break; + } + case SIGNAL: { + initializePageSettings(entity, container.getPositionForTypes().entrySet() + .stream().filter(entry -> entry.getValue().equals(LinkType.SIGNAL)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); + break; + } + default: + break; + } + }, lastValue)); + final UIEntity inputEntity = new UIEntity(); + inputEntity.setInheritWidth(true); + inputEntity.setHeight(20); + final UITextInput input = new UITextInput(""); + inputEntity.add(input); + lowerEntity.add(inputEntity); final UIEntity list = new UIEntity(); final UIBox uibox = new UIBox(UIBox.VBOX, 2); list.add(uibox); - list.setInheritHeight(true); - list.setInheritWidth(true); - container.getPositionForTypes().forEach((p, t) -> { + final Map nameToUIEntity = new HashMap<>(); + list.add(uibox); + list.setInherits(true); + types.forEach((p, t) -> { final String name = getSignalInfo(p, t); final UIEntity layout = new UIEntity(); layout.setHeight(20); @@ -412,18 +582,29 @@ private void initializePageSettings(final UIEntity entity) { list.remove(layout); })); list.add(layout); + nameToUIEntity.put(name.toLowerCase(), layout); }); lowerEntity.add(list); lowerEntity.add(GuiElements.createPageSelect(uibox)); resetSelection(entity); + input.setOnTextUpdate(string -> { + nameToUIEntity.forEach((name, e) -> { + if (!name.contains(string.toLowerCase())) { + list.remove(e); + } else { + list.add(e); + } + }); + }); } private void initializeFieldUsage(final UIEntity entity) { reset(); sendModeChanges(); - initializeFieldTemplate(this::tileNormal); + initializeFieldTemplate(this::tileNormal, false); resetSelection(entity); - this.pageCheck(Page.USAGE); + helpPage.helpUsageMode(enabledSubsidiaries, null, container.grid.getNodes(), + container.possibleSubsidiaries); } private void initializeFieldEdit(final UIEntity entity) { @@ -451,11 +632,14 @@ private void initializeFieldEdit(final UIEntity entity) { final UIMenu menu = new UIMenu(); menu.setVisible(false); initializeFieldTemplate( - (fieldEntity, name) -> this.tileEdit(fieldEntity, menu, name)); + (fieldEntity, name) -> this.tileEdit(fieldEntity, menu, name), true); lowerEntity.add(menu); + menu.setConsumer( + (selection, rotation) -> helpPage.updateNextNode(selection, rotation)); resetSelection(entity); - this.pageCheck(Page.EDIT); resetAllPathways(); + helpPage.updateNextNode(menu.getSelection(), menu.getRotation()); + this.lastTile = null; }); final UIEntity buttonNo = GuiElements.createButton(I18n.format("btn.no"), e -> { pop(); @@ -468,14 +652,10 @@ private void initializeFieldEdit(final UIEntity entity) { selectionEntity.add(buttons); }); push(screen); - pageCheck(Page.CHANGE_MODE); } - private void initializeFieldTemplate(final BiConsumer consumer) { - lowerEntity.add(new UIColor(BACKGROUND_COLOR)); - lowerEntity.add(new UIStack()); - lowerEntity.add(new UIScissor()); - + private void initializeFieldTemplate(final BiConsumer consumer, + final boolean showLines) { plane = new UIEntity(); plane.clearChildren(); plane.setWidth(TILE_COUNT * TILE_WIDTH); @@ -493,9 +673,11 @@ private void initializeFieldTemplate(final BiConsumer plane.setY(plane.getY() + y); plane.update(); }, 2)); - final UILines allLines = new UILines(ALL_LINES, 0.5F); - allLines.setColor(LINE_COLOR); - plane.add(allLines); + if (showLines) { + final UILines allLines = new UILines(ALL_LINES, 0.5F); + allLines.setColor(GRID_COLOR); + plane.add(allLines); + } final UIBox vbox = new UIBox(UIBox.VBOX, 0); vbox.setPageable(false); plane.add(vbox); @@ -534,13 +716,17 @@ private void initializeFieldTemplate(final BiConsumer } plane.add(row); } - lowerEntity.add(plane); + final UIEntity splitter = new UIEntity(); + splitter.add(new UIColor(BACKGROUND_COLOR)); + splitter.add(new UIScissor()); + splitter.add(new UIBorder(0xFF000000, 4)); + splitter.add(plane); + splitter.setInherits(true); + lowerEntity.add(new UIBox(UIBox.HBOX, 2)); + lowerEntity.add(splitter); + helpPage = new SidePanel(lowerEntity, this); + helpPage.setDisableSubdsidiary(this::disableSubsidiary); - final UIEntity frame = new UIEntity(); - frame.setInheritHeight(true); - frame.setInheritWidth(true); - frame.add(new UIBorder(0xFF000000, 4)); - lowerEntity.add(frame); buildColors(container.grid.getNodes()); } @@ -561,12 +747,13 @@ private void initializeBasicUI() { header.setHeight(20); header.add(new UIBox(UIBox.HBOX, 4)); header.add(titel); - header.add(GuiElements.createSpacerH(80)); + header.add(GuiElements.createSpacerH(40)); header.add(GuiElements.createButton(I18n.format("btn.settings"), this::initializePageSettings)); header.add(GuiElements.createButton(I18n.format("btn.edit"), this::initializeFieldEdit)); mainButton = GuiElements.createButton(I18n.format("btn.main"), this::initializeFieldUsage); header.add(mainButton); + header.add(GuiElements.createSpacerH(5)); resetSelection(mainButton); final UIEntity middlePart = new UIEntity(); @@ -578,12 +765,14 @@ private void initializeBasicUI() { lowerEntity.setInheritHeight(true); lowerEntity.setInheritWidth(true); - initializeFieldTemplate(this::tileNormal); + initializeFieldTemplate(this::tileNormal, false); this.entity.add(GuiElements.createSpacerH(10)); this.entity.add(middlePart); this.entity.add(GuiElements.createSpacerH(10)); this.entity.add(new UIBox(UIBox.HBOX, 1)); + helpPage.helpUsageMode(enabledSubsidiaries, null, container.grid.getNodes(), + container.possibleSubsidiaries); } private void sendPWRequest(final SignalBoxNode currentNode) { @@ -596,7 +785,7 @@ private void sendPWRequest(final SignalBoxNode currentNode) { OpenSignalsMain.network.sendTo(info.player, buffer.build()); } - private void resetPathwayOnServer(final SignalBoxNode node) { + protected void resetPathwayOnServer(final SignalBoxNode node) { if (!allPacketsRecived) return; final WriteBuffer buffer = new WriteBuffer(); @@ -700,19 +889,20 @@ private void removeBlockPos(final BlockPos pos) { OpenSignalsMain.network.sendTo(info.player, buffer.build()); } - private void sendSubsidiaryRequest(final SubsidiaryEntry entry, final SignalBoxNode node, + protected void sendSubsidiaryRequest(final SubsidiaryEntry entry, final Point point, final ModeSet mode) { if (!allPacketsRecived) return; final WriteBuffer buffer = new WriteBuffer(); buffer.putByte((byte) SignalBoxNetwork.REQUEST_SUBSIDIARY.ordinal()); entry.writeNetwork(buffer); - node.getPoint().writeNetwork(buffer); + point.writeNetwork(buffer); mode.writeNetwork(buffer); OpenSignalsMain.network.sendTo(info.player, buffer.build()); } - private void changeRedstoneOutput(final Point point, final ModeSet mode, final boolean state) { + protected void changeRedstoneOutput(final Point point, final ModeSet mode, + final boolean state) { if (!allPacketsRecived) return; final WriteBuffer buffer = new WriteBuffer(); @@ -723,7 +913,7 @@ private void changeRedstoneOutput(final Point point, final ModeSet mode, final b OpenSignalsMain.network.sendTo(info.player, buffer.build()); } - private void setAutoPoint(final Point point, final byte state) { + protected void setAutoPoint(final Point point, final byte state) { if (!allPacketsRecived) return; final WriteBuffer buffer = new WriteBuffer(); @@ -747,22 +937,31 @@ private void sendName(final Point point, final String name) { } private void reset() { - this.page = Page.NONE; lowerEntity.clear(); } - private static enum Page { - USAGE, EDIT, SETTINGS, TILE_CONFIG, CHANGE_MODE, NONE; - } - @Override public void updateFromContainer() { if (!allPacketsRecived) { + updateEnabledSubsidiaries(); initializeBasicUI(); allPacketsRecived = true; } } + private void updateEnabledSubsidiaries() { + container.enabledSubsidiaryTypes.forEach((point, map) -> map.forEach((modeSet, state) -> { + if (!state.state) + return; + final SignalBoxNode node = container.grid.getNode(point); + if (node == null) + return; + node.getOption(modeSet).get().getEntry(PathEntryType.SIGNAL) + .ifPresent(pos -> enabledSubsidiaries.put(pos, + new SubsidiaryHolder(state, point, modeSet))); + })); + } + private void buildColors(final List nodes) { nodes.forEach(node -> { final UISignalBoxTile tile = allTiles.get(node.getPoint()); diff --git a/src/main/java/com/troblecodings/signals/guis/GuiSignalController.java b/src/main/java/com/troblecodings/signals/guis/GuiSignalController.java index 0a3501261..d7f41249d 100644 --- a/src/main/java/com/troblecodings/signals/guis/GuiSignalController.java +++ b/src/main/java/com/troblecodings/signals/guis/GuiSignalController.java @@ -11,19 +11,13 @@ import com.troblecodings.guilib.ecs.GuiBase; import com.troblecodings.guilib.ecs.GuiElements; import com.troblecodings.guilib.ecs.GuiInfo; -import com.troblecodings.guilib.ecs.entitys.UIBlockRender; import com.troblecodings.guilib.ecs.entitys.UIBox; import com.troblecodings.guilib.ecs.entitys.UIEntity; import com.troblecodings.guilib.ecs.entitys.UIEnumerable; import com.troblecodings.guilib.ecs.entitys.input.UIClickable; -import com.troblecodings.guilib.ecs.entitys.input.UIDrag; import com.troblecodings.guilib.ecs.entitys.render.UIColor; import com.troblecodings.guilib.ecs.entitys.render.UILabel; -import com.troblecodings.guilib.ecs.entitys.render.UIScissor; import com.troblecodings.guilib.ecs.entitys.render.UITexture; -import com.troblecodings.guilib.ecs.entitys.render.UIToolTip; -import com.troblecodings.guilib.ecs.entitys.transform.UIIndependentTranslate; -import com.troblecodings.guilib.ecs.entitys.transform.UIRotate; import com.troblecodings.guilib.ecs.entitys.transform.UIScale; import com.troblecodings.guilib.ecs.interfaces.IIntegerable; import com.troblecodings.signals.OpenSignalsMain; @@ -33,6 +27,8 @@ import com.troblecodings.signals.enums.EnumMode; import com.troblecodings.signals.enums.EnumState; import com.troblecodings.signals.enums.SignalControllerNetwork; +import com.troblecodings.signals.handler.ClientSignalStateHandler; +import com.troblecodings.signals.handler.ClientSignalStateInfo; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -50,12 +46,13 @@ public class GuiSignalController extends GuiBase { private final ContainerSignalController controller; private final UIEntity lowerEntity = new UIEntity(); - private boolean previewMode = false; private boolean loaded = false; private final EntityPlayer player; private EnumMode currentMode; private int currentProfile = 0; private final BlockPos pos; + private final PreviewSideBar previewSidebar = new PreviewSideBar(-8); + private final PreviewSideBar previewRedstone = new PreviewSideBar(-8); public GuiSignalController(final GuiInfo info) { super(info); @@ -87,8 +84,7 @@ private void initMode(final EnumMode mode) { @SuppressWarnings({ "rawtypes", "unchecked" }) - private void createPageForSide(final EnumFacing face, final UIEntity leftSide, - final UIBlockRender bRender) { + private void createPageForSide(final EnumFacing face, final UIEntity leftSide) { final UIEntity middlePart = new UIEntity(); final IIntegerable profile = SizeIntegerables.of("profile", 32, @@ -97,8 +93,7 @@ private void createPageForSide(final EnumFacing face, final UIEntity leftSide, leftSide.add(GuiElements.createEnumElement(profileEnum, profile, x -> { currentProfile = x; sendRSProfile(x); - updateProfileProperties(middlePart, bRender, profileEnum); - applyModelChange(bRender); + updateProfileProperties(middlePart, profileEnum); }, this.controller.lastProfile)); currentProfile = this.controller.lastProfile; @@ -107,7 +102,7 @@ private void createPageForSide(final EnumFacing face, final UIEntity leftSide, final UIBox boxMode = new UIBox(UIBox.VBOX, 1); middlePart.add(boxMode); - updateProfileProperties(middlePart, bRender, profileEnum); + updateProfileProperties(middlePart, profileEnum); leftSide.add(middlePart); int onIndex = -1; @@ -134,32 +129,37 @@ private void createPageForSide(final EnumFacing face, final UIEntity leftSide, leftSide.add(GuiElements.createPageSelect(boxMode)); } - private void updateProfileProperties(final UIEntity middlePart, final UIBlockRender bRender, - final UIEnumerable profile) { + private void updateProfileProperties(final UIEntity middlePart, final UIEnumerable profile) { middlePart.clearChildren(); profile.setIndex(currentProfile); final Map properties = controller.allRSStates .computeIfAbsent(currentProfile, _u -> new HashMap<>()); - controller.getReference().forEach((property, value) -> { + controller.getProperties().forEach((property, value) -> { if (!properties.containsKey(property)) { properties.put(property, "DISABLED"); } }); + ClientSignalStateHandler + .getClientStates(new ClientSignalStateInfo(mc.world, controller.getPos())) + .forEach((property, value) -> { + previewRedstone.addToRenderNormal(property, + property.getParent().getIDFromValue(value)); + }); properties.forEach((property, value) -> { final UIEntity entity = GuiElements .createEnumElement(new DisableIntegerable<>(property), e -> { - applyModelChange(bRender); + previewRedstone.addToRenderNormal(property, e); sendPropertyToServer(property, e); - final Map map = controller.allRSStates - .computeIfAbsent(currentProfile, _u -> new HashMap<>()); if (e == -1) { - map.remove(property); + properties.remove(property); } else { - map.put(property, property.getObjFromID(e)); + properties.put(property, property.getObjFromID(e)); } + previewRedstone.update(controller.getSignal()); }, property.getParent().getIDFromValue(value)); middlePart.add(entity); }); + previewRedstone.update(controller.getSignal()); } private void addSingleRSMode() { @@ -170,9 +170,7 @@ private void addSingleRSMode() { leftSide.setInheritWidth(true); leftSide.add(new UIBox(UIBox.VBOX, 2)); this.lowerEntity.add(leftSide); - - final UIBlockRender bRender = new UIBlockRender(); - this.lowerEntity.add(createPreview(bRender)); + this.lowerEntity.add(previewRedstone.get()); final UIEntity rightSide = new UIEntity(); rightSide.setInheritHeight(true); @@ -180,7 +178,7 @@ private void addSingleRSMode() { rightSide.add(new UIBox(UIBox.VBOX, 4)); currentProfile = controller.lastProfile; - createPageForSide(EnumFacing.DOWN, leftSide, bRender); + createPageForSide(EnumFacing.DOWN, leftSide); final Minecraft mc = Minecraft.getMinecraft(); final IBlockState state = mc.player.world.getBlockState(pos); @@ -193,7 +191,7 @@ private void addSingleRSMode() { colors.forEach(c -> c.setColor(0x70000000)); colors.get(e).setColor(0x70FF0000); leftSide.clearChildren(); - createPageForSide(faceing, leftSide, bRender); + createPageForSide(faceing, leftSide); }); rightSide.add(toggle); for (final EnumFacing face : EnumFacing.VALUES) { @@ -279,32 +277,6 @@ private void initInternal() { this.entity.add(new UIBox(UIBox.HBOX, 1)); } - private UIEntity createPreview(final UIBlockRender blockRender) { - final UIToolTip tooltip = new UIToolTip(I18n.format("controller.preview", previewMode)); - - final UIEntity rightSide = new UIEntity(); - rightSide.setWidth(60); - rightSide.setInheritHeight(true); - final UIRotate rotation = new UIRotate(); - rotation.setRotateY(180); - rightSide.add(new UIClickable(e -> { - previewMode = !previewMode; - applyModelChange(blockRender); - tooltip.setDescripton(I18n.format("controller.preview", previewMode)); - }, 1)); - rightSide.add( - new UIDrag((x, y) -> rotation.setRotateY((float) (rotation.getRotateY() + x)))); - rightSide.add(tooltip); - - rightSide.add(new UIScissor()); - rightSide.add(new UIIndependentTranslate(35, 150, 40)); - rightSide.add(rotation); - rightSide.add(new UIIndependentTranslate(-0.5, -3.5, -0.5)); - rightSide.add(new UIScale(20, -20, 20)); - rightSide.add(blockRender); - return rightSide; - } - private void addManuellMode() { final UIEntity list = new UIEntity(); list.setInheritHeight(true); @@ -320,24 +292,30 @@ private void addManuellMode() { leftSide.add(new UIBox(UIBox.VBOX, 5)); lowerEntity.add(leftSide); - final UIBlockRender blockRender = new UIBlockRender(); - lowerEntity.add(createPreview(blockRender)); + previewSidebar.clear(); + lowerEntity.add(previewSidebar.get()); lowerEntity.add(new UIBox(UIBox.HBOX, 1)); - final Map map = this.controller.getReference(); + ClientSignalStateHandler + .getClientStates(new ClientSignalStateInfo(mc.world, controller.getPos())) + .forEach((property, value) -> previewSidebar.addToRenderNormal(property, + property.getParent().getIDFromValue(value))); + + final Map map = this.controller.getProperties(); if (map == null) return; map.forEach((property, value) -> { final UIEnumerable enumarable = new UIEnumerable(property.count(), property.getName()); final int index = property.getParent().getIDFromValue(value); list.add(GuiElements.createEnumElement(enumarable, property, e -> { + previewSidebar.addToRenderNormal(property, e); if (loaded) { sendPropertyToServer(property, enumarable.getIndex()); + previewSidebar.update(controller.getSignal()); } - applyModelChange(blockRender); }, index)); }); - applyModelChange(blockRender); + previewSidebar.update(controller.getSignal()); } private void sendAndSetProfile(final EnumFacing facing, final int profile, @@ -418,10 +396,6 @@ public void updateFromContainer() { loaded = true; } - private void applyModelChange(final UIBlockRender blockRender) { - // TODO new model system - } - @Override public ContainerBase getNewGuiContainer(final GuiInfo info) { return new ContainerSignalController(info); diff --git a/src/main/java/com/troblecodings/signals/guis/PreviewSideBar.java b/src/main/java/com/troblecodings/signals/guis/PreviewSideBar.java new file mode 100644 index 000000000..457e6f8cd --- /dev/null +++ b/src/main/java/com/troblecodings/signals/guis/PreviewSideBar.java @@ -0,0 +1,76 @@ +package com.troblecodings.signals.guis; + +import java.util.HashMap; +import java.util.Map; + +import com.troblecodings.core.QuaternionWrapper; +import com.troblecodings.guilib.ecs.entitys.UIBlockRender; +import com.troblecodings.guilib.ecs.entitys.UIEntity; +import com.troblecodings.guilib.ecs.entitys.input.UIDrag; +import com.troblecodings.guilib.ecs.entitys.render.UIColor; +import com.troblecodings.guilib.ecs.entitys.render.UIScissor; +import com.troblecodings.signals.SEProperty; +import com.troblecodings.signals.blocks.Signal; +import com.troblecodings.signals.enums.ChangeableStage; +import com.troblecodings.signals.models.ModelInfoWrapper; + +public class PreviewSideBar { + + public static final float MODIFIER = 0.1f; + + private final UIBlockRender blockRender; + private final Map properties = new HashMap<>(); + private final UIEntity blockRenderEntity = new UIEntity(); + + public PreviewSideBar(final float height) { + blockRender = new UIBlockRender(20, height); + blockRenderEntity.setInheritHeight(true); + blockRenderEntity.setWidth(60); + + blockRenderEntity.add(new UIDrag((x, y) -> blockRender + .updateRotation(QuaternionWrapper.fromXYZ(0, (float) x * MODIFIER, 0)))); + + blockRenderEntity.add(new UIScissor()); + blockRenderEntity.add(new UIColor(GuiSignalBox.BACKGROUND_COLOR)); + blockRenderEntity.add(blockRender); + } + + public UIEntity get() { + return blockRenderEntity; + } + + public void addToRenderList(final SEProperty property, final int valueId) { + if (valueId < 0) { + properties.remove(property); + return; + } + if (property.isChangabelAtStage(ChangeableStage.GUISTAGE)) { + properties.put(property, property.getObjFromID(valueId)); + } else if (property.isChangabelAtStage(ChangeableStage.APISTAGE)) { + if (valueId > 0) { + properties.put(property, property.getDefault()); + } else { + properties.remove(property); + } + } else if (property.isChangabelAtStage(ChangeableStage.APISTAGE_NONE_CONFIG)) { + properties.put(property, property.getDefault()); + } + } + + public void addToRenderNormal(final SEProperty property, final int valueId) { + if (valueId < 0) { + properties.put(property, property.getDefault()); + return; + } + properties.put(property, property.getObjFromID(valueId)); + } + + public void clear() { + properties.clear(); + } + + public void update(final Signal signal) { + blockRender.setBlockState(new ModelInfoWrapper(signal, properties)); + } + +} diff --git a/src/main/java/com/troblecodings/signals/guis/SidePanel.java b/src/main/java/com/troblecodings/signals/guis/SidePanel.java new file mode 100644 index 000000000..cc03ab421 --- /dev/null +++ b/src/main/java/com/troblecodings/signals/guis/SidePanel.java @@ -0,0 +1,551 @@ +package com.troblecodings.signals.guis; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; + +import com.troblecodings.guilib.ecs.DrawUtil.BoolIntegerables; +import com.troblecodings.guilib.ecs.DrawUtil.SizeIntegerables; +import com.troblecodings.guilib.ecs.GuiElements; +import com.troblecodings.guilib.ecs.entitys.UIBox; +import com.troblecodings.guilib.ecs.entitys.UIEntity; +import com.troblecodings.guilib.ecs.entitys.UIScrollBox; +import com.troblecodings.guilib.ecs.entitys.UITextInput; +import com.troblecodings.guilib.ecs.entitys.input.UIClickable; +import com.troblecodings.guilib.ecs.entitys.input.UIOnUpdate; +import com.troblecodings.guilib.ecs.entitys.input.UIScroll; +import com.troblecodings.guilib.ecs.entitys.render.UIBorder; +import com.troblecodings.guilib.ecs.entitys.render.UIButton; +import com.troblecodings.guilib.ecs.entitys.render.UIColor; +import com.troblecodings.guilib.ecs.entitys.render.UILabel; +import com.troblecodings.guilib.ecs.entitys.render.UIScissor; +import com.troblecodings.guilib.ecs.entitys.render.UITexture; +import com.troblecodings.guilib.ecs.entitys.render.UIToolTip; +import com.troblecodings.guilib.ecs.entitys.transform.UIRotate; +import com.troblecodings.guilib.ecs.entitys.transform.UIScale; +import com.troblecodings.signals.OpenSignalsMain; +import com.troblecodings.signals.core.SubsidiaryEntry; +import com.troblecodings.signals.core.SubsidiaryHolder; +import com.troblecodings.signals.core.SubsidiaryState; +import com.troblecodings.signals.enums.EnumGuiMode; +import com.troblecodings.signals.enums.EnumPathUsage; +import com.troblecodings.signals.handler.ClientNameHandler; +import com.troblecodings.signals.handler.NameStateInfo; +import com.troblecodings.signals.signalbox.ModeSet; +import com.troblecodings.signals.signalbox.Point; +import com.troblecodings.signals.signalbox.SignalBoxNode; +import com.troblecodings.signals.signalbox.entrys.PathEntryType; +import com.troblecodings.signals.signalbox.entrys.PathOptionEntry; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; + +public class SidePanel { + + public static final ResourceLocation REDSTONE_OFF = new ResourceLocation(OpenSignalsMain.MODID, + "gui/textures/redstone_off.png"); + public static final ResourceLocation REDSTONE_OFF_BLOCKED = new ResourceLocation( + OpenSignalsMain.MODID, "gui/textures/redstone_off_blocked.png"); + public static final ResourceLocation REDSTONE_ON = new ResourceLocation(OpenSignalsMain.MODID, + "gui/textures/redstone_on.png"); + public static final ResourceLocation REDSTONE_ON_BLOCKED = new ResourceLocation( + OpenSignalsMain.MODID, "gui/textures/redstone_on_blocked.png"); + + private boolean showHelpPage = false; + private final UIEntity helpPage = new UIEntity(); + private final UIEntity infoEntity = new UIEntity(); + private final UIButton helpPageButton = new UIButton(">"); + private final UIEntity lowerEntity; + private final UIEntity button = new UIEntity(); + private final UIEntity label = new UIEntity(); + private final UIEntity spacerEntity = new UIEntity(); + private final UIEntity helpPageSpacer = new UIEntity(); + private final GuiSignalBox gui; + + private BiConsumer disableSubsidiary; + + public SidePanel(final UIEntity lowerEntity, final GuiSignalBox gui) { + this.lowerEntity = lowerEntity; + this.gui = gui; + + infoEntity.setInherits(true); + infoEntity.add(new UIBox(UIBox.VBOX, 2)); + + helpPage.setInherits(true); + helpPage.add(new UIBox(UIBox.VBOX, 2)); + + final UIRotate rotate = new UIRotate(); + rotate.setRotateZ(90); + label.add(rotate); + final UILabel labelComponent = new UILabel(I18n.format("info.infolabel")); + labelComponent.setTextColor(new UIEntity().getBasicTextColor()); + label.add(labelComponent); + label.setX(2); + + button.setInheritWidth(true); + button.setHeight(20); + button.add(helpPageButton); + button.add(new UIClickable(entity -> { + showHelpPage = !showHelpPage; + addHelpPageToPlane(); + })); + + addHelpPageToPlane(); + + final UIEntity entity = new UIEntity(); + entity.setInherits(true); + entity.add(new UIBox(UIBox.HBOX, 0)); + entity.add(GuiElements.createSpacerH(4)); + entity.add(helpPage); + + spacerEntity.setInheritHeight(true); + spacerEntity.add(new UIBox(UIBox.VBOX, 0)); + spacerEntity.add(button); + spacerEntity.add(entity); + spacerEntity.add(new UIColor(GuiSignalBox.BACKGROUND_COLOR)); + lowerEntity.add(spacerEntity); + + helpPageSpacer.setHeight(30); + } + + public void addHelpPageToPlane() { + if (showHelpPage) { + helpPageButton.setText(I18n.format("info.info") + " >"); + spacerEntity.setWidth(80); + helpPage.clearChildren(); + helpPage.add(infoEntity); + lowerEntity.update(); + } else { + helpPageButton.setText("<"); + helpPage.clearChildren(); + helpPage.add(helpPageSpacer); + helpPage.add(label); + spacerEntity.setWidth(12); + lowerEntity.update(); + } + infoEntity.forEach(entity -> entity.setVisible(showHelpPage)); + label.setVisible(true); + button.setVisible(true); + helpPageSpacer.setVisible(true); + helpPage.update(); + } + + protected void setShowHelpPage(final boolean showHelpPage) { + this.showHelpPage = showHelpPage; + addHelpPageToPlane(); + } + + public void reset() { + + } + + public void add(final UIEntity entity) { + this.helpPage.add(entity); + } + + public void updateNextNode(final int selection, final int rotation) { + infoEntity.clearChildren(); + infoEntity.add(GuiElements.createSpacerV(2)); + infoEntity.add(GuiElements.createLabel(I18n.format("info.nextelement"), + new UIEntity().getBasicTextColor(), 0.8f)); + + final UIEntity preview = new UIEntity(); + preview.setInheritWidth(true); + preview.add(new UIOnUpdate(() -> { + if (preview.getHeight() != preview.getWidth()) { + preview.setHeight(preview.getWidth()); + helpPage.update(); + } + })); + preview.add(new UIColor(0xFFAFAFAF)); + final SignalBoxNode node = new SignalBoxNode(new Point(-1, -1)); + final EnumGuiMode modes = EnumGuiMode.values()[selection]; + node.add(new ModeSet(modes, Rotation.values()[rotation])); + final UISignalBoxTile sbt = new UISignalBoxTile(node); + preview.add(sbt); + preview.add(new UIBorder(new UIEntity().getBasicTextColor())); + + infoEntity.add(preview); + infoEntity.add(GuiElements.createSpacerV(5)); + infoEntity.add(GuiElements.createLabel("[R] = " + I18n.format("info.editor.key.r"), + new UIEntity().getInfoTextColor(), 0.5f)); + infoEntity.add(GuiElements.createLabel("[LMB] = " + I18n.format("info.editor.key.lmb"), + new UIEntity().getInfoTextColor(), 0.5f)); + infoEntity.add(GuiElements.createLabel("[RMB] = " + I18n.format("info.editor.key.rmb"), + new UIEntity().getInfoTextColor(), 0.5f)); + infoEntity.add(GuiElements.createSpacerV(5)); + infoEntity.add(GuiElements.createLabel(I18n.format("info.description"), + new UIEntity().getBasicTextColor(), 0.8f)); + infoEntity + .add(GuiElements.createLabel(I18n.format("info." + modes.toString().toLowerCase()), + new UIEntity().getInfoTextColor(), 0.5f)); + addHelpPageToPlane(); + } + + public void helpUsageMode(final Map subsidiaries, + final SignalBoxNode node, final List allNodes, + final Map> possibleSubsidiaries) { + infoEntity.clearChildren(); + + final UIEntity helpScroll = new UIEntity(); + helpScroll.setInheritHeight(true); + helpScroll.setInheritWidth(true); + helpScroll.add(new UIBox(UIBox.HBOX, 0)); + helpScroll.add(new UIScissor()); + infoEntity.add(helpScroll); + + final UIEntity helpList = new UIEntity(); + helpScroll.add(helpList); + helpList.setInheritHeight(true); + helpList.setInheritWidth(true); + + final UIScrollBox helpScrollbox = new UIScrollBox(UIBox.VBOX, 2); + + helpList.add(GuiElements.createLabel(I18n.format("info.keys"), + new UIEntity().getBasicTextColor(), 0.8f)); + helpList.add(GuiElements.createLabel("[LMB] = " + I18n.format("info.usage.key.lmb"), + new UIEntity().getInfoTextColor(), 0.5f)); + helpList.add(GuiElements.createLabel("[RMB] = " + I18n.format("info.usage.key.rmb"), + new UIEntity().getInfoTextColor(), 0.5f)); + + final Minecraft mc = Minecraft.getMinecraft(); + if (!allNodes.isEmpty()) { + final UIEntity manuelButton = GuiElements.createButton(I18n.format("info.usage.manuel"), + e -> { + final UIEntity screen = GuiElements.createScreen(searchPanel -> { + final UIEntity searchBar = new UIEntity(); + searchBar.setInheritWidth(true); + searchBar.setHeight(20); + final UITextInput input = new UITextInput(""); + searchBar.add(input); + searchPanel.add(searchBar); + + final UIEntity listWithScroll = new UIEntity(); + listWithScroll.setInheritHeight(true); + listWithScroll.setInheritWidth(true); + listWithScroll.add(new UIBox(UIBox.HBOX, 2)); + listWithScroll.add(new UIScissor()); + listWithScroll.add(new UIBorder(0xFF00FFFF)); + searchPanel.add(listWithScroll); + + final UIEntity list = new UIEntity(); + listWithScroll.add(list); + list.setInheritHeight(true); + list.setInheritWidth(true); + + final UIScrollBox scrollbox = new UIScrollBox(UIBox.VBOX, 2); + list.add(scrollbox); + final Map nameToUIEntity = new HashMap<>(); + + allNodes.forEach(currentNode -> { + final UILabel currentStatus = new UILabel( + I18n.format("info.usage.status") + " : " + + I18n.format("info.usage.status.free")); + currentStatus.setTextColor(new UIEntity().getBasicTextColor()); + final UIEntity statusEntity = new UIEntity(); + statusEntity.setInheritWidth(true); + statusEntity.setHeight(20); + statusEntity.add(new UIScale(1.1f, 1.1f, 1)); + statusEntity.add(currentStatus); + final AtomicBoolean canBeManuelChanged = new AtomicBoolean(true); + currentNode.getModes().forEach((mode, entry) -> { + final Optional pathUsage = entry + .getEntry(PathEntryType.PATHUSAGE); + if (pathUsage.isPresent() + && !pathUsage.get().equals(EnumPathUsage.FREE)) { + currentStatus.setText(I18n.format("info.usage.status") + + " : " + I18n.format("info.usage.status.blocked")); + canBeManuelChanged.set(false); + } + if (!entry.containsEntry(PathEntryType.OUTPUT)) + return; + final String name = currentNode.getPoint().toString() + " - " + + ClientNameHandler.getClientName(new NameStateInfo( + mc.world, + entry.getEntry(PathEntryType.OUTPUT).get())); + final UIEntity button = GuiElements.createButton(name, e1 -> { + gui.pop(); + final UIEntity info = new UIEntity(); + info.setInherits(true); + info.add(new UIBox(UIBox.VBOX, 5)); + info.add(new UIClickable(_u -> gui.pop(), 1)); + info.add(new UIColor(GuiSignalBox.BACKGROUND_COLOR)); + info.add(statusEntity); + final UIEntity textureEntity = new UIEntity(); + textureEntity.setHeight(40); + textureEntity.setWidth(40); + textureEntity.setX(120); + textureEntity.add( + new UIToolTip(I18n.format("info.usage.rs.desc"))); + if (canBeManuelChanged.get()) { + if (currentNode.containsManuellOutput(mode)) { + textureEntity.add(new UITexture(REDSTONE_ON)); + } else { + textureEntity.add(new UITexture(REDSTONE_OFF)); + } + } else { + if (pathUsage.isPresent() && !pathUsage.get() + .equals(EnumPathUsage.FREE)) { + textureEntity + .add(new UITexture(REDSTONE_ON_BLOCKED)); + } else { + textureEntity + .add(new UITexture(REDSTONE_OFF_BLOCKED)); + } + } + info.add(textureEntity); + final UILabel outputStatus = new UILabel(((pathUsage + .isPresent() + && !pathUsage.get().equals(EnumPathUsage.FREE)) + || currentNode.containsManuellOutput(mode)) + ? I18n.format("info.usage.rs.true") + : I18n.format("info.usage.rs.false")); + outputStatus.setCenterY(false); + outputStatus + .setTextColor(new UIEntity().getBasicTextColor()); + final UIEntity outputEntity = new UIEntity(); + outputEntity.setInheritWidth(true); + outputEntity.setHeight(20); + outputEntity.add(outputStatus); + info.add(outputEntity); + if (!canBeManuelChanged.get()) { + gui.push(GuiElements + .createScreen(entity -> entity.add(info))); + return; + } + info.add(GuiElements.createButton( + I18n.format("info.usage.change"), i -> { + final boolean turnOff = currentNode + .containsManuellOutput(mode); + textureEntity.clear(); + textureEntity.add(new UIToolTip( + I18n.format("info.usage.rs.desc"))); + if (turnOff) { + gui.changeRedstoneOutput( + currentNode.getPoint(), mode, + false); + outputStatus.setText( + I18n.format("info.usage.rs.false")); + textureEntity + .add(new UITexture(REDSTONE_OFF)); + } else { + gui.changeRedstoneOutput( + currentNode.getPoint(), mode, true); + outputStatus.setText( + I18n.format("info.usage.rs.true")); + textureEntity + .add(new UITexture(REDSTONE_ON)); + } + })); + gui.push(GuiElements + .createScreen(entity -> entity.add(info))); + }); + list.add(button); + nameToUIEntity.put(name.toLowerCase(), button); + + }); + }); + final UIScroll scroll = new UIScroll(); + final UIEntity scrollBar = GuiElements.createScrollBar(scrollbox, 10, + scroll); + scrollbox.setConsumer(size -> { + if (size > list.getHeight()) { + listWithScroll.add(scroll); + listWithScroll.add(scrollBar); + } else { + listWithScroll.remove(scrollBar); + listWithScroll.remove(scroll); + } + }); + input.setOnTextUpdate(string -> { + nameToUIEntity.forEach((name, entity) -> { + if (!name.contains(string.toLowerCase())) { + list.remove(entity); + } else { + list.add(entity); + } + }); + }); + }); + screen.add(new UIClickable(e1 -> gui.pop(), 1)); + gui.push(screen); + }); + manuelButton.setScaleX(0.8f); + manuelButton.setScaleY(0.8f); + manuelButton.setX(5); + helpList.add(manuelButton); + manuelButton.add(new UIToolTip(I18n.format("info.usage.manuel.desc"))); + } + + if (node != null) { + final Map modes = node.getModes(); + final List guiModes = modes.keySet().stream().map(mode -> mode.mode) + .collect(Collectors.toList()); + helpList.add(GuiElements.createLabel(I18n.format("info.usage.node"), + new UIEntity().getBasicTextColor(), 0.8f)); + final UIEntity reset = GuiElements.createButton(I18n.format("button.reset"), + e -> gui.resetPathwayOnServer(node)); + reset.setScaleX(0.8f); + reset.setScaleY(0.8f); + reset.setX(5); + helpList.add(reset); + reset.add(new UIToolTip(I18n.format("button.reset.desc"))); + if (guiModes.contains(EnumGuiMode.HP)) { + final UIEntity entity = GuiElements + .createBoolElement(BoolIntegerables.of("auto_pathway"), e -> { + gui.setAutoPoint(node.getPoint(), (byte) e); + node.setAutoPoint(e == 1 ? true : false); + }, node.isAutoPoint() ? 1 : 0); + entity.setScaleX(0.8f); + entity.setScaleY(0.8f); + entity.setX(5); + helpList.add(entity); + } + for (final Map.Entry mapEntry : modes.entrySet()) { + final ModeSet mode = mapEntry.getKey(); + final PathOptionEntry option = mapEntry.getValue(); + + if (option.containsEntry(PathEntryType.SIGNAL)) { + final BlockPos signalPos = option.getEntry(PathEntryType.SIGNAL).get(); + final String signalName = ClientNameHandler + .getClientName(new NameStateInfo(mc.world, signalPos)); + helpList.add(GuiElements.createLabel( + (signalName.isEmpty() ? "Rotaion: " + mode.rotation.toString() + : signalName) + " - " + mode.mode.toString(), + new UIEntity().getBasicTextColor(), 0.8f)); + final UIEntity entity = GuiElements.createButton(I18n.format("btn.subsidiary"), + e -> { + final UIBox hbox = new UIBox(UIBox.VBOX, 1); + final UIEntity list = new UIEntity(); + list.setInherits(true); + list.add(hbox); + list.add(GuiElements.createButton(I18n.format("btn.return"), + a -> gui.pop())); + final List possibleSubsidiaires = possibleSubsidiaries + .getOrDefault(signalPos, SubsidiaryState.ALL_STATES); + possibleSubsidiaires.forEach(state -> { + final int defaultValue = gui.container.grid.getSubsidiaryState( + node.getPoint(), mode, state) ? 0 : 1; + list.add(GuiElements.createEnumElement( + new SizeIntegerables<>(state.getName(), 2, + i -> i == 1 ? "false" : "true"), + a -> { + final SubsidiaryEntry entry = new SubsidiaryEntry( + state, a == 0 ? true : false); + gui.sendSubsidiaryRequest(entry, node.getPoint(), + mode); + gui.container.grid.setClientState(node.getPoint(), + mode, entry); + if (signalPos != null) { + if (entry.state) { + subsidiaries.put(signalPos, + new SubsidiaryHolder(entry, + node.getPoint(), mode)); + } else { + subsidiaries.remove(signalPos); + } + } + gui.pop(); + helpUsageMode(subsidiaries, node, allNodes, + possibleSubsidiaries); + }, defaultValue)); + }); + final UIEntity screen = GuiElements.createScreen(selection -> { + selection.add(list); + selection.add(GuiElements.createPageSelect(hbox)); + }); + gui.push(screen); + }); + entity.setScaleX(0.8f); + entity.setScaleY(0.8f); + entity.setX(5); + helpList.add(entity); + entity.add(new UIToolTip(I18n.format("btn.subsidiary.desc"))); + } + } + final UIEntity edit = GuiElements.createButton(I18n.format("info.usage.edit"), e -> { + helpUsageMode(subsidiaries, null, allNodes, possibleSubsidiaries); + gui.initializePageTileConfig(node); + }); + edit.setScaleX(0.8f); + edit.setScaleY(0.8f); + edit.setX(5); + helpList.add(edit); + edit.add(new UIToolTip(I18n.format("info.usage.edit.desc"))); + } + + if (!subsidiaries.isEmpty()) { + helpList.add(GuiElements.createLabel(I18n.format("info.usage.subsidiary"), + new UIEntity().getBasicTextColor(), 0.8f)); + subsidiaries.forEach((pos, holder) -> { + final String name = ClientNameHandler + .getClientName(new NameStateInfo(mc.world, pos)); + final UIEntity button = GuiElements.createButton(name, e -> { + final UIEntity screen = GuiElements.createScreen(selectionEntity -> { + final UIBox hbox = new UIBox(UIBox.VBOX, 3); + selectionEntity.add(hbox); + final UIEntity question = new UIEntity(); + final UILabel label = new UILabel( + name + " : " + holder.entry.enumValue.toString().toUpperCase()); + label.setTextColor(0xFFFFFFFF); + question.setScaleX(1.1f); + question.setScaleY(1.1f); + question.add(label); + question.setInherits(true); + final UILabel info = new UILabel(I18n.format("sb.disablesubsidiary")); + info.setTextColor(0xFFFFFFFF); + final UIEntity infoEntity = new UIEntity(); + infoEntity.add(info); + infoEntity.setInherits(true); + selectionEntity.add(question); + selectionEntity.add(infoEntity); + final UIEntity buttons = new UIEntity(); + final UIEntity buttonYes = GuiElements.createButton(I18n.format("btn.yes"), + e1 -> { + gui.pop(); + disableSubsidiary.accept(pos, holder); + }); + final UIEntity buttonNo = GuiElements.createButton(I18n.format("btn.no"), + e2 -> gui.pop()); + buttons.setInherits(true); + final UIBox vbox = new UIBox(UIBox.HBOX, 1); + buttons.add(vbox); + buttons.add(buttonYes); + buttons.add(buttonNo); + selectionEntity.add(buttons); + }); + gui.push(screen); + }); + button.setScaleX(0.8f); + button.setScaleY(0.8f); + button.setX(5); + helpList.add(button); + }); + } + final UIScroll helpScrolling = new UIScroll(); + final UIEntity helpScrollBar = GuiElements.createScrollBar(helpScrollbox, 7, helpScrolling); + helpScrollbox.setConsumer(size -> { + if (size > helpList.getHeight()) { + helpScroll.add(helpScroll); + helpScroll.add(helpScrollBar); + } else { + helpScroll.remove(helpScrollBar); + helpScroll.remove(helpScroll); + } + }); + helpList.add(helpScrollbox); + addHelpPageToPlane(); + } + + public void setDisableSubdsidiary(final BiConsumer consumer) { + this.disableSubsidiary = consumer; + } + +} diff --git a/src/main/java/com/troblecodings/signals/guis/UIMenu.java b/src/main/java/com/troblecodings/signals/guis/UIMenu.java index 8eac67acc..2bcafe6a0 100644 --- a/src/main/java/com/troblecodings/signals/guis/UIMenu.java +++ b/src/main/java/com/troblecodings/signals/guis/UIMenu.java @@ -1,5 +1,7 @@ package com.troblecodings.signals.guis; +import java.util.function.BiConsumer; + import com.troblecodings.guilib.ecs.entitys.DrawInfo; import com.troblecodings.guilib.ecs.entitys.UIBox; import com.troblecodings.guilib.ecs.entitys.UIComponent; @@ -22,6 +24,8 @@ public class UIMenu extends UIComponent { private double mY; private int selection = 0; private int rotation = 0; + private BiConsumer consumer = (i1, i2) -> { + }; @Override public void draw(final DrawInfo info) { @@ -65,6 +69,10 @@ public int getSelection() { return selection; } + public void setConsumer(final BiConsumer consumer) { + this.consumer = consumer; + } + @Override public void mouseEvent(final MouseEvent event) { switch (event.state) { @@ -77,6 +85,7 @@ public void mouseEvent(final MouseEvent event) { } this.selection = Math.max(0, Math.min(EnumGuiMode.values().length - 1, (int) ((event.x - this.mX) / 22.0f))); + consumer.accept(selection, rotation); this.setVisible(true); break; case RELEASE: @@ -94,10 +103,11 @@ public void keyEvent(final KeyEvent event) { this.rotation++; if (this.rotation >= Rotation.values().length) this.rotation = 0; + consumer.accept(selection, rotation); } } public int getRotation() { return rotation; } -} +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/handler/ClientNameHandler.java b/src/main/java/com/troblecodings/signals/handler/ClientNameHandler.java index 7d1c6dab0..e295b62c1 100644 --- a/src/main/java/com/troblecodings/signals/handler/ClientNameHandler.java +++ b/src/main/java/com/troblecodings/signals/handler/ClientNameHandler.java @@ -21,7 +21,7 @@ public class ClientNameHandler implements INetworkSync { public static String getClientName(final NameStateInfo info) { synchronized (CLIENT_NAMES) { - return CLIENT_NAMES.getOrDefault(info, ""); + return new String(CLIENT_NAMES.getOrDefault(info, "")); } } diff --git a/src/main/java/com/troblecodings/signals/handler/ClientSignalStateHandler.java b/src/main/java/com/troblecodings/signals/handler/ClientSignalStateHandler.java index e5e7dfa85..b3eb2d878 100644 --- a/src/main/java/com/troblecodings/signals/handler/ClientSignalStateHandler.java +++ b/src/main/java/com/troblecodings/signals/handler/ClientSignalStateHandler.java @@ -25,8 +25,7 @@ public class ClientSignalStateHandler implements INetworkSync { public static final Map getClientStates(final ClientSignalStateInfo info) { synchronized (CURRENTLY_LOADED_STATES) { - return ImmutableMap - .copyOf(CURRENTLY_LOADED_STATES.computeIfAbsent(info, _u -> new HashMap<>())); + return ImmutableMap.copyOf(CURRENTLY_LOADED_STATES.getOrDefault(info, new HashMap<>())); } } diff --git a/src/main/java/com/troblecodings/signals/handler/NameHandler.java b/src/main/java/com/troblecodings/signals/handler/NameHandler.java index 8c089b832..f2d6bf74a 100644 --- a/src/main/java/com/troblecodings/signals/handler/NameHandler.java +++ b/src/main/java/com/troblecodings/signals/handler/NameHandler.java @@ -48,7 +48,7 @@ public static void init() { channel.register(new NameHandler()); } - public static void add(final Object obj) { + public static void registerToNetworkChannel(final Object obj) { channel.register(obj); } diff --git a/src/main/java/com/troblecodings/signals/handler/SignalBoxHandler.java b/src/main/java/com/troblecodings/signals/handler/SignalBoxHandler.java index 259ab7916..ad0f9ecd1 100644 --- a/src/main/java/com/troblecodings/signals/handler/SignalBoxHandler.java +++ b/src/main/java/com/troblecodings/signals/handler/SignalBoxHandler.java @@ -19,6 +19,7 @@ import com.troblecodings.signals.core.LinkingUpdates; import com.troblecodings.signals.core.PosIdentifier; import com.troblecodings.signals.core.RedstoneUpdatePacket; +import com.troblecodings.signals.core.SubsidiaryState; import com.troblecodings.signals.enums.LinkType; import com.troblecodings.signals.init.OSBlocks; import com.troblecodings.signals.signalbox.PathwayHolder; @@ -186,6 +187,19 @@ public static void relinkAllRedstoneIOs(final PosIdentifier identifier) { holder.getAllRedstoneIOs().forEach(pos -> linkTileToPos(identifier, pos)); } + public static Map> getPossibleSubsidiaries( + final PosIdentifier identifier) { + if (identifier.world.isRemote) + return new HashMap<>(); + LinkedPositions holder; + synchronized (ALL_LINKED_POS) { + holder = ALL_LINKED_POS.get(identifier); + } + if (holder == null) + return new HashMap<>(); + return holder.getValidSubsidiariesForPos(); + } + public static Signal getSignal(final PosIdentifier identifier, final BlockPos signalPos) { if (identifier.worldNullOrClientSide()) return null; diff --git a/src/main/java/com/troblecodings/signals/handler/SignalStateHandler.java b/src/main/java/com/troblecodings/signals/handler/SignalStateHandler.java index 22974468f..cb84ab0b8 100644 --- a/src/main/java/com/troblecodings/signals/handler/SignalStateHandler.java +++ b/src/main/java/com/troblecodings/signals/handler/SignalStateHandler.java @@ -56,7 +56,7 @@ public static void init() { MinecraftForge.EVENT_BUS.register(SignalStateHandler.class); } - public static void add(final Object object) { + public static void registerToNetworkChannel(final Object object) { channel.register(object); } @@ -162,6 +162,7 @@ public static void setStates(final SignalStateInfo info, final Map getStates(final SignalStateInfo info) { diff --git a/src/main/java/com/troblecodings/signals/init/OSItems.java b/src/main/java/com/troblecodings/signals/init/OSItems.java index 41c7c9bd6..7bd42ebdf 100644 --- a/src/main/java/com/troblecodings/signals/init/OSItems.java +++ b/src/main/java/com/troblecodings/signals/init/OSItems.java @@ -104,6 +104,7 @@ private OSItems() { public static final Item SIGNAL_SHIELD = new Item().setCreativeTab(CreativeTabs.MISC); public static final Item LAMPS = new Item().setCreativeTab(CreativeTabs.MISC); public static final Item ELECTRIC_PARTS = new Item().setCreativeTab(CreativeTabs.MISC); + public static final Item MANIPULATOR = new Item().setCreativeTab(OSTabs.TAB); public static ArrayList registeredItems = new ArrayList<>(); diff --git a/src/main/java/com/troblecodings/signals/models/CustomModelLoader.java b/src/main/java/com/troblecodings/signals/models/CustomModelLoader.java index 72cf81b39..afbd379a0 100644 --- a/src/main/java/com/troblecodings/signals/models/CustomModelLoader.java +++ b/src/main/java/com/troblecodings/signals/models/CustomModelLoader.java @@ -23,7 +23,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ICustomModelLoader; import net.minecraftforge.client.model.IModel; -import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -37,7 +36,6 @@ public final class CustomModelLoader implements ICustomModelLoader { private CustomModelLoader() { } - @SuppressWarnings("unchecked") private static void loadExtention(final TextureStats texturestate, final Map extention, final String modelname, final ModelStats states, final Models models, final FunctionParsingInfo info, @@ -54,8 +52,9 @@ private static void loadExtention(final TextureStats texturestate, final Map extentionProperties = extentions.getValue(); final ModelExtention extentionValues = extention.get(extentionName); if (extentionValues == null) - throw new ContentPackException(String - .format("There doesn't exists an extention named [%s]!", extentionName)); + throw new ContentPackException( + String.format("There doesn't exists an extention named [%s]!", + extentionName) + " Valid Extentions: " + extention.keySet()); for (final Map.Entry entry : extentionValues.getExtention() .entrySet()) { @@ -98,7 +97,6 @@ private static void loadExtention(final TextureStats texturestate, } } - @SuppressWarnings("unchecked") @Override public void onResourceManagerReload(final IResourceManager manager) { registeredModels.clear(); @@ -142,7 +140,7 @@ public void onResourceManagerReload(final IResourceManager manager) { final String blockstate = texturestate.getBlockstate(); - Predicate state = null; + Predicate state = null; boolean extentionloaded = false; diff --git a/src/main/java/com/troblecodings/signals/models/ImplAutoBlockStatePredicate.java b/src/main/java/com/troblecodings/signals/models/ImplAutoBlockStatePredicate.java index 268fb090e..e7d4ffa03 100644 --- a/src/main/java/com/troblecodings/signals/models/ImplAutoBlockStatePredicate.java +++ b/src/main/java/com/troblecodings/signals/models/ImplAutoBlockStatePredicate.java @@ -3,9 +3,7 @@ import java.util.Objects; import java.util.function.Predicate; -import net.minecraftforge.common.property.IExtendedBlockState; - -public class ImplAutoBlockStatePredicate implements Predicate { +public class ImplAutoBlockStatePredicate implements Predicate { private final int id; @@ -16,7 +14,7 @@ public ImplAutoBlockStatePredicate() { } @Override - public boolean test(final IExtendedBlockState t) { + public boolean test(final ModelInfoWrapper t) { return true; } diff --git a/src/main/java/com/troblecodings/signals/models/ModelInfoWrapper.java b/src/main/java/com/troblecodings/signals/models/ModelInfoWrapper.java new file mode 100644 index 000000000..6b5e7a347 --- /dev/null +++ b/src/main/java/com/troblecodings/signals/models/ModelInfoWrapper.java @@ -0,0 +1,64 @@ +package com.troblecodings.signals.models; + +import java.util.Map; +import java.util.Optional; + +import com.troblecodings.core.interfaces.BlockModelDataWrapper; +import com.troblecodings.signals.SEProperty; + +import net.minecraft.block.Block; +import net.minecraftforge.common.property.IExtendedBlockState; +import net.minecraftforge.common.property.IUnlistedProperty; + +public class ModelInfoWrapper implements BlockModelDataWrapper { + + public IExtendedBlockState state; + + public ModelInfoWrapper(final IExtendedBlockState state) { + this.state = state; + } + + public ModelInfoWrapper(final Block block) { + this.state = (IExtendedBlockState) block.getDefaultState(); + } + + public ModelInfoWrapper(final Block block, final Map properties) { + this(block); + properties.forEach((property, value) -> state = state.withProperty(property, value)); + } + + @Override + public IExtendedBlockState getBlockState() { + return state; + } + + public boolean hasProperty(final IUnlistedProperty prop) { + return state.getUnlistedNames().contains(prop); + } + + @SuppressWarnings("unchecked") + public T getData(final IUnlistedProperty prop) { + final Optional opt = (Optional) state.getUnlistedProperties().get(prop); + if (opt.isPresent()) + return opt.get(); + return null; + } + + @SuppressWarnings("unchecked") + public T setData(final IUnlistedProperty prop, final T value) { + state = state.withProperty(prop, value); + return (T) prop; + } + + public boolean has(final SEProperty property) { + return hasProperty(property); + } + + public String get(final SEProperty property) { + return getData(property); + } + + public void set(final SEProperty property, final String value) { + setData(property, value); + } +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/models/SignalCustomModel.java b/src/main/java/com/troblecodings/signals/models/SignalCustomModel.java index e70d91c55..a853999b3 100644 --- a/src/main/java/com/troblecodings/signals/models/SignalCustomModel.java +++ b/src/main/java/com/troblecodings/signals/models/SignalCustomModel.java @@ -38,7 +38,7 @@ @SideOnly(Side.CLIENT) public class SignalCustomModel implements IModel { - private final HashMap, Pair> modelCache = new HashMap<>(); + private final HashMap, Pair> modelCache = new HashMap<>(); private List textures = new ArrayList<>(); private IBakedModel cachedModel = null; private SignalAngel angel = SignalAngel.ANGEL0; @@ -110,7 +110,9 @@ public IBakedModel bake(final IModelState state, final VertexFormat format, final IModel model = m.first(); final Vector3f f = m.second(); final TRSRTransformation baseState = new TRSRTransformation(f, null, null, null); - build.putModel(blockstate -> pr.test((IExtendedBlockState) blockstate), + build.putModel( + blockstate -> pr + .test(new ModelInfoWrapper((IExtendedBlockState) blockstate)), transform(model.bake(baseState, format, bakedTextureGetter))); }); return cachedModel = build.makeMultipartModel(); @@ -128,7 +130,7 @@ public Collection getTextures() { return textures; } - protected void register(final String name, final Predicate state, + protected void register(final String name, final Predicate state, final float x, final float y, final float z, final Map map) { IModel m = ModelLoaderRegistry.getModelOrLogError( new ResourceLocation(OpenSignalsMain.MODID, "block/" + name), diff --git a/src/main/java/com/troblecodings/signals/models/SignalModelLoaderInfo.java b/src/main/java/com/troblecodings/signals/models/SignalModelLoaderInfo.java index 54c219b7b..4c12761ac 100644 --- a/src/main/java/com/troblecodings/signals/models/SignalModelLoaderInfo.java +++ b/src/main/java/com/troblecodings/signals/models/SignalModelLoaderInfo.java @@ -3,7 +3,6 @@ import java.util.Map; import java.util.function.Predicate; -import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -11,13 +10,13 @@ public class SignalModelLoaderInfo { public final String name; - public final Predicate state; + public final Predicate state; public final float x; public final float y; public final float z; public final Map retexture; - public SignalModelLoaderInfo(final String name, final Predicate state, + public SignalModelLoaderInfo(final String name, final Predicate state, final float x, final float y, final float z, final Map retexture) { this.name = name; this.state = state; diff --git a/src/main/java/com/troblecodings/signals/parser/FunctionParsingInfo.java b/src/main/java/com/troblecodings/signals/parser/FunctionParsingInfo.java index ad3eefe9e..a3e8d1f63 100644 --- a/src/main/java/com/troblecodings/signals/parser/FunctionParsingInfo.java +++ b/src/main/java/com/troblecodings/signals/parser/FunctionParsingInfo.java @@ -8,6 +8,7 @@ import com.troblecodings.signals.SEProperty; import com.troblecodings.signals.blocks.Signal; +import com.troblecodings.signals.contentpacks.ContentPackException; @SuppressWarnings("rawtypes") public class FunctionParsingInfo { @@ -70,7 +71,8 @@ public Object getProperty(final String propertyName) { }); if (property == null) { throw new LogicalParserException( - String.format("Could not find property=%s in system=%S!", name, signalName)); + String.format("Could not make predicate=%s with system=%S!", argument, + signalName) + " Valid Properties: " + properties); } return property; } @@ -85,6 +87,9 @@ public Object getPredicate() { argument = parts[0]; final SEProperty property = (SEProperty) getProperty(); final String value = parts[1].toUpperCase(); + if (!property.getParent().isValid(new String(value))) + throw new ContentPackException("[" + value + "] is not a valid state of " + property + + "! Valid States: " + property.getParent().getAllowedValues()); return new ValuePack(property, ext -> ext.equals(value)); }); if (predicate == null) diff --git a/src/main/java/com/troblecodings/signals/parser/LogicParser.java b/src/main/java/com/troblecodings/signals/parser/LogicParser.java index 22176390f..ce0c1931a 100644 --- a/src/main/java/com/troblecodings/signals/parser/LogicParser.java +++ b/src/main/java/com/troblecodings/signals/parser/LogicParser.java @@ -6,15 +6,15 @@ import java.util.function.Predicate; import com.troblecodings.signals.SEProperty; +import com.troblecodings.signals.models.ModelInfoWrapper; import com.troblecodings.signals.parser.interm.EvaluationLevel; import com.troblecodings.signals.parser.interm.IntermidiateNode; import com.troblecodings.signals.parser.interm.LogicalSymbols; -import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.common.property.IUnlistedProperty; @SuppressWarnings({ - "rawtypes", "unchecked", "deprecation" + "rawtypes", "unchecked" }) public final class LogicParser { @@ -38,7 +38,7 @@ private LogicParser() { objects -> PredicateHolder.hasAndIsNot((SEProperty) objects[0]), SEProperty.class)); TRANSLATION_TABLE.put("check", new MethodInfo(Map.class, "check", - objects -> PredicateHolder.check((ValuePack) objects[0]), ValuePack.class)); + objects -> PredicateHolder.config((ValuePack) objects[0]), ValuePack.class)); TRANSLATION_TABLE.put("config", new MethodInfo(Map.class, "config", objects -> PredicateHolder.config((ValuePack) objects[0]), ValuePack.class)); @@ -64,7 +64,7 @@ private LogicParser() { }, info.parameter))); } - public static Predicate nDegreeFunctionParser(final String name, + public static Predicate nDegreeFunctionParser(final String name, final FunctionParsingInfo parser, final String... parameter) { final String[] arguments = parameter; final MethodInfo method = parser.getTable().get(name.toLowerCase()); @@ -145,7 +145,7 @@ public static IntermidiateLogic parse(final String input, final FunctionParsingI return logic; } - public static Predicate predicate(final String input, final FunctionParsingInfo info) { + public static Predicate predicate(final String input, final FunctionParsingInfo info) { return parse(input, info).pop().getPredicate(); } } diff --git a/src/main/java/com/troblecodings/signals/parser/PredicateHolder.java b/src/main/java/com/troblecodings/signals/parser/PredicateHolder.java index 97f2c5842..b14969659 100644 --- a/src/main/java/com/troblecodings/signals/parser/PredicateHolder.java +++ b/src/main/java/com/troblecodings/signals/parser/PredicateHolder.java @@ -5,58 +5,46 @@ import com.troblecodings.signals.SEProperty; import com.troblecodings.signals.enums.CompareValues; - -import net.minecraftforge.common.property.IExtendedBlockState; +import com.troblecodings.signals.models.ModelInfoWrapper; public final class PredicateHolder { private PredicateHolder() { } - public static Predicate has(final SEProperty property) { - return ebs -> ebs.getValue(property) != null; + public static Predicate has(final SEProperty property) { + return ebs -> ebs.get(property) != null; } - public static Predicate hasNot(final SEProperty property) { - return ebs -> ebs.getValue(property) == null; + public static Predicate hasNot(final SEProperty property) { + return ebs -> ebs.get(property) == null; } @SuppressWarnings("unchecked") - public static Predicate with(final ValuePack pack) { + public static Predicate with(final ValuePack pack) { return ebs -> { - final Object test = ebs.getValue(pack.property); + final Object test = ebs.get(pack.property); return test != null && pack.predicate.test(test); }; } - public static Predicate hasAndIs(final SEProperty property) { + public static Predicate hasAndIs(final SEProperty property) { return ebs -> { - final Boolean bool = "TRUE".equalsIgnoreCase(ebs.getValue(property)); + final Boolean bool = "TRUE".equalsIgnoreCase(ebs.get(property)); return bool.booleanValue(); }; } - public static Predicate hasAndIsNot(final SEProperty property) { + public static Predicate hasAndIsNot(final SEProperty property) { return ebs -> { - final String cacheString = ebs.getValue(property); + final String cacheString = ebs.get(property); if (cacheString == null) return false; - final Boolean bool = "TRUE".equalsIgnoreCase(ebs.getValue(property)); + final Boolean bool = "TRUE".equalsIgnoreCase(ebs.get(property)); return !bool.booleanValue(); }; } - @Deprecated - @SuppressWarnings("unchecked") - public static Predicate> check(final ValuePack pack) { - return t -> { - final String value = t.get(pack.property); - if (value == null) - return false; - return pack.predicate.test(value.toUpperCase()); - }; - } - @SuppressWarnings("unchecked") public static Predicate> config(final ValuePack pack) { return t -> { diff --git a/src/main/java/com/troblecodings/signals/parser/ValuePack.java b/src/main/java/com/troblecodings/signals/parser/ValuePack.java index f15430b96..6824e0195 100644 --- a/src/main/java/com/troblecodings/signals/parser/ValuePack.java +++ b/src/main/java/com/troblecodings/signals/parser/ValuePack.java @@ -12,7 +12,6 @@ public class ValuePack { public final Predicate predicate; public ValuePack(final SEProperty property, final Predicate predicate) { - super(); this.property = property; this.predicate = predicate; } @@ -33,4 +32,4 @@ public boolean equals(final Object obj) { && Objects.equals(property, other.property); } -} +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/properties/BooleanProperty.java b/src/main/java/com/troblecodings/signals/properties/BooleanProperty.java deleted file mode 100644 index 3520532a8..000000000 --- a/src/main/java/com/troblecodings/signals/properties/BooleanProperty.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.troblecodings.signals.properties; - -import java.util.function.Predicate; - -@SuppressWarnings("rawtypes") -public class BooleanProperty { - - public final Predicate predicate; - public final boolean doubleSided; - - public BooleanProperty(final Predicate predicate, final boolean doubleSided) { - super(); - this.predicate = predicate; - this.doubleSided = doubleSided; - } - -} diff --git a/src/main/java/com/troblecodings/signals/properties/ConfigProperty.java b/src/main/java/com/troblecodings/signals/properties/ConfigProperty.java deleted file mode 100644 index f1fdb7843..000000000 --- a/src/main/java/com/troblecodings/signals/properties/ConfigProperty.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.troblecodings.signals.properties; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Predicate; - -import com.troblecodings.signals.SEProperty; - -@SuppressWarnings("rawtypes") -public class ConfigProperty { - - public final Predicate predicate; - public Map values; - - public ConfigProperty(final SEProperty property, final String value) { - this(t -> true, property, value); - } - - public ConfigProperty(final Predicate predicate, final SEProperty property, - final String value) { - this.predicate = predicate; - this.values = new HashMap<>(); - this.values.put(property, value); - } - - public ConfigProperty(final Predicate predicate, final Map values) { - this.predicate = predicate; - this.values = values; - } - - public ConfigProperty(final Map values) { - this(t -> true, values); - } - -} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/properties/FloatProperty.java b/src/main/java/com/troblecodings/signals/properties/FloatProperty.java deleted file mode 100644 index fc7d84883..000000000 --- a/src/main/java/com/troblecodings/signals/properties/FloatProperty.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.troblecodings.signals.properties; - -import java.util.Objects; -import java.util.function.Predicate; - -@SuppressWarnings("rawtypes") -public class FloatProperty { - - public final Predicate predicate; - public final float height; - - public FloatProperty(final Predicate predicate, final float height) { - super(); - this.predicate = predicate; - this.height = height; - } - - @Override - public int hashCode() { - return Objects.hash(height, predicate); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if ((obj == null) || (getClass() != obj.getClass())) - return false; - final FloatProperty other = (FloatProperty) obj; - return Float.floatToIntBits(height) == Float.floatToIntBits(other.height) - && Objects.equals(predicate, other.predicate); - } - -} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/properties/HeightProperty.java b/src/main/java/com/troblecodings/signals/properties/HeightProperty.java deleted file mode 100644 index 29b6b63f1..000000000 --- a/src/main/java/com/troblecodings/signals/properties/HeightProperty.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.troblecodings.signals.properties; - -import java.util.Objects; -import java.util.function.Predicate; - -@SuppressWarnings("rawtypes") -public class HeightProperty { - - public final Predicate predicate; - public final int height; - - public HeightProperty(final Predicate predicate, final int height) { - super(); - this.predicate = predicate; - this.height = height; - } - - @Override - public int hashCode() { - return Objects.hash(height, predicate); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if ((obj == null) || (getClass() != obj.getClass())) - return false; - final HeightProperty other = (HeightProperty) obj; - return height == other.height && Objects.equals(predicate, other.predicate); - } -} diff --git a/src/main/java/com/troblecodings/signals/properties/PredicatedPropertyBase.java b/src/main/java/com/troblecodings/signals/properties/PredicatedPropertyBase.java new file mode 100644 index 000000000..ec30c1d08 --- /dev/null +++ b/src/main/java/com/troblecodings/signals/properties/PredicatedPropertyBase.java @@ -0,0 +1,60 @@ +package com.troblecodings.signals.properties; + +import java.util.Map; +import java.util.Objects; +import java.util.function.Predicate; + +import com.troblecodings.signals.SEProperty; + +public class PredicatedPropertyBase implements Predicate

{ + + public final Predicate

predicate; + public final T state; + + public PredicatedPropertyBase(final Predicate

predicate, final T state) { + this.predicate = Objects.requireNonNull(predicate); + this.state = state; + } + + @SuppressWarnings("unchecked") + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final PredicatedPropertyBase other = (PredicatedPropertyBase) obj; + return Objects.equals(state, other.state); + } + + @Override + public String toString() { + return "PredicatedProperty [state=" + state + "]"; + } + + @Override + public boolean test(final P t) { + return this.predicate.test(t); + } + + // Well because this language is stupid: + public static class PredicateProperty + extends PredicatedPropertyBase> { + + public PredicateProperty(final Predicate> predicate, + final T state) { + super(predicate, state); + } + } + + public static class ConfigProperty + extends PredicatedPropertyBase, Map, Object>> { + + public ConfigProperty(final Predicate, Object>> predicate, + final Map state) { + super(predicate, state); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/properties/SignalPair.java b/src/main/java/com/troblecodings/signals/properties/SignalPair.java deleted file mode 100644 index fa331e8a4..000000000 --- a/src/main/java/com/troblecodings/signals/properties/SignalPair.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.troblecodings.signals.properties; - -import java.util.Objects; - -import com.troblecodings.signals.blocks.Signal; - -public class SignalPair { - - public final Signal start; - public final Signal end; - - public SignalPair(final Signal start, final Signal end) { - super(); - this.start = Objects.requireNonNull(start); - this.end = Objects.requireNonNull(end); - } - - @Override - public int hashCode() { - return Objects.hash(end, start); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) - return true; - if ((obj == null) || (getClass() != obj.getClass())) - return false; - final SignalPair other = (SignalPair) obj; - return Objects.equals(end, other.end) && Objects.equals(start, other.start); - } -} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/properties/SoundProperty.java b/src/main/java/com/troblecodings/signals/properties/SoundProperty.java index 4bf08e7de..79084780d 100644 --- a/src/main/java/com/troblecodings/signals/properties/SoundProperty.java +++ b/src/main/java/com/troblecodings/signals/properties/SoundProperty.java @@ -1,25 +1,20 @@ package com.troblecodings.signals.properties; +import java.util.Map; import java.util.function.Predicate; +import com.troblecodings.signals.SEProperty; +import com.troblecodings.signals.properties.PredicatedPropertyBase.PredicateProperty; + import net.minecraft.util.SoundEvent; -@SuppressWarnings("rawtypes") -public class SoundProperty { +public class SoundProperty extends PredicateProperty { - public final SoundEvent sound; - public final Predicate predicate; public final int duration; - public SoundProperty() { - this(null, t -> true, -1); - } - - public SoundProperty(final SoundEvent sound, final Predicate predicate, final int duration) { - super(); - this.sound = sound; - this.predicate = predicate; + public SoundProperty(final SoundEvent sound, final Predicate> predicate, + final int duration) { + super(predicate, sound); this.duration = duration; } - -} +} \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/proxy/ClientProxy.java b/src/main/java/com/troblecodings/signals/proxy/ClientProxy.java index 483fcd120..036a41cc7 100644 --- a/src/main/java/com/troblecodings/signals/proxy/ClientProxy.java +++ b/src/main/java/com/troblecodings/signals/proxy/ClientProxy.java @@ -29,8 +29,8 @@ public class ClientProxy extends CommonProxy { @Override public void initModEvent(final FMLPreInitializationEvent event) { super.initModEvent(event); - SignalStateHandler.add(new ClientSignalStateHandler()); - NameHandler.add(new ClientNameHandler()); + SignalStateHandler.registerToNetworkChannel(new ClientSignalStateHandler()); + NameHandler.registerToNetworkChannel(new ClientNameHandler()); OpenSignalsMain.handler.addGui(Placementtool.class, GuiPlacementtool::new); OpenSignalsMain.handler.addGui(SignalController.class, GuiSignalController::new); OpenSignalsMain.handler.addGui(SignalBox.class, GuiSignalBox::new); diff --git a/src/main/java/com/troblecodings/signals/signalbox/PathwayHolder.java b/src/main/java/com/troblecodings/signals/signalbox/PathwayHolder.java index c759a45a9..fdb342034 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/PathwayHolder.java +++ b/src/main/java/com/troblecodings/signals/signalbox/PathwayHolder.java @@ -85,7 +85,8 @@ private void updatePrevious(final SignalBoxPathway pathway) { count++; } if (count == 0) { - OpenSignalsMain.getLogger().debug("Could not find previous! " + pathway); + if (OpenSignalsMain.isDebug()) + OpenSignalsMain.getLogger().debug("Could not find previous! " + pathway); } } diff --git a/src/main/java/com/troblecodings/signals/signalbox/Point.java b/src/main/java/com/troblecodings/signals/signalbox/Point.java index 02aad5470..3aa28c01e 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/Point.java +++ b/src/main/java/com/troblecodings/signals/signalbox/Point.java @@ -76,14 +76,14 @@ public String toString() { @Override public void write(final NBTWrapper tag) { - tag.putInteger("x", x); - tag.putInteger("y", y); + tag.putByte("x", (byte) x); + tag.putByte("y", (byte) y); } @Override public void read(final NBTWrapper tag) { - this.x = tag.getInteger("x"); - this.y = tag.getInteger("y"); + this.x = Byte.toUnsignedInt(tag.getByte("x")); + this.y = Byte.toUnsignedInt(tag.getByte("y")); } @Override diff --git a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxGrid.java b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxGrid.java index e35b08bfb..69f83f9eb 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxGrid.java +++ b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxGrid.java @@ -6,7 +6,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.function.Function; import java.util.stream.Collectors; import com.google.common.collect.ImmutableList; @@ -24,7 +23,7 @@ import com.troblecodings.signals.handler.SignalBoxHandler; import com.troblecodings.signals.handler.SignalStateHandler; import com.troblecodings.signals.handler.SignalStateInfo; -import com.troblecodings.signals.properties.ConfigProperty; +import com.troblecodings.signals.properties.PredicatedPropertyBase.ConfigProperty; import com.troblecodings.signals.signalbox.config.SignalConfig; import com.troblecodings.signals.signalbox.debug.SignalBoxFactory; import com.troblecodings.signals.signalbox.entrys.INetworkSavable; @@ -70,21 +69,22 @@ public void resetAllPathways() { @Override public void write(final NBTWrapper tag) { - tag.putList(NODE_LIST, modeGrid.values().stream().map(node -> { - final NBTWrapper nodeTag = new NBTWrapper(); - node.write(nodeTag); - final Map subsidiaries = enabledSubsidiaryTypes - .get(node.getPoint()); - if (subsidiaries == null) - return nodeTag; - nodeTag.putList(SUBSIDIARY_LIST, subsidiaries.entrySet().stream().map(entry -> { - final NBTWrapper subsidiaryTag = new NBTWrapper(); - entry.getKey().write(subsidiaryTag); - entry.getValue().writeNBT(tag); - return subsidiaryTag; - })::iterator); - return nodeTag; - })::iterator); + tag.putList(NODE_LIST, + modeGrid.values().stream().filter(node -> !node.isEmpty()).map(node -> { + final NBTWrapper nodeTag = new NBTWrapper(); + node.write(nodeTag); + final Map subsidiaries = enabledSubsidiaryTypes + .get(node.getPoint()); + if (subsidiaries == null) + return nodeTag; + nodeTag.putList(SUBSIDIARY_LIST, subsidiaries.entrySet().stream().map(entry -> { + final NBTWrapper subsidiaryTag = new NBTWrapper(); + entry.getKey().write(subsidiaryTag); + entry.getValue().writeNBT(subsidiaryTag); + return subsidiaryTag; + })::iterator); + return nodeTag; + })::iterator); } @Override @@ -101,7 +101,7 @@ public void read(final NBTWrapper tag) { final Map states = new HashMap<>(); subsidiaryTags.forEach(subsidiaryTag -> { final ModeSet mode = new ModeSet(subsidiaryTag); - states.put(mode, SubsidiaryEntry.of(tag)); + states.put(mode, SubsidiaryEntry.of(subsidiaryTag)); }); enabledSubsidiaryTypes.put(node.getPoint(), states); }); @@ -132,10 +132,6 @@ public String toString() { .map(entry -> entry.toString()).collect(Collectors.joining("\n")) + "]"; } - public boolean isEmpty() { - return this.modeGrid.isEmpty(); - } - public SignalBoxNode getNode(final Point point) { return modeGrid.get(point); } @@ -152,15 +148,6 @@ public void putNode(final Point point, final SignalBoxNode node) { modeGrid.put(point, node); } - public SignalBoxNode removeNode(final Point point) { - return modeGrid.remove(point); - } - - public SignalBoxNode computeIfAbsent(final Point point, - final Function funtion) { - return modeGrid.computeIfAbsent(point, funtion); - } - public void putAllNodes(final Map nodes) { modeGrid.putAll(nodes); } @@ -280,7 +267,7 @@ public void updateSubsidiarySignal(final Point point, final ModeSet mode, final SignalStateInfo info = new SignalStateInfo(world, pos.get(), signal); final Map oldProperties = SignalStateHandler.getStates(info); SignalStateHandler.setStates(info, - properties.values.entrySet().stream() + properties.state.entrySet().stream() .filter(propertyEntry -> oldProperties.containsKey(propertyEntry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); states.put(mode, entry); diff --git a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxNode.java b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxNode.java index b3939895b..84197a914 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxNode.java +++ b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxNode.java @@ -11,6 +11,7 @@ import java.util.Set; import java.util.stream.Collectors; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.troblecodings.core.NBTWrapper; import com.troblecodings.signals.core.ReadBuffer; @@ -34,7 +35,6 @@ public class SignalBoxNode implements INetworkSavable, Iterable { private final HashMap possibleModes = new HashMap<>(); private final List manuellEnabledOutputs = new ArrayList<>(); private final Point point; - private String identifier; private boolean isAutoPoint = false; private String customText = ""; @@ -44,7 +44,6 @@ public SignalBoxNode() { public SignalBoxNode(final Point point) { this.point = Objects.requireNonNull(point); - this.identifier = point.getX() + "." + point.getY(); } public void add(final ModeSet modeSet) { @@ -192,7 +191,6 @@ public void read(final NBTWrapper compound) { manuellEnabledOutputs.add(modeSet); }); this.point.read(compound); - this.identifier = point.getX() + "." + point.getY(); this.isAutoPoint = compound.getBoolean(IS_AUTO_POINT); this.customText = compound.getString(CUSTOM_NAME); post(); @@ -290,13 +288,6 @@ public Iterator iterator() { return this.possibleModes.keySet().iterator(); } - /** - * @return the identifier - */ - public String getIdentifier() { - return identifier; - } - @Override public void readNetwork(final ReadBuffer buffer) { possibleModes.clear(); @@ -394,4 +385,8 @@ public String getCustomText() { public void setCustomText(final String text) { this.customText = text; } + + public Map getModes() { + return ImmutableMap.copyOf(possibleModes); + } } \ No newline at end of file diff --git a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java index 19ee7ec3f..005dd5211 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java +++ b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxPathway.java @@ -319,8 +319,13 @@ public void compact(final Point point) { public Optional tryReset(final BlockPos position) { final SignalBoxNode node = this.mapOfResetPositions.get(position); - if (node == null) - return Optional.empty(); + if (node == null) { + if (checkReverseReset(position)) { + return Optional.of(firstPoint); + } else { + return Optional.empty(); + } + } final Point point = node.getPoint(); final AtomicBoolean atomic = new AtomicBoolean(false); foreachEntry((option, cNode) -> { @@ -335,6 +340,41 @@ public Optional tryReset(final BlockPos position) { return Optional.of(point); } + private boolean checkReverseReset(final BlockPos pos) { + final SignalBoxNode firstNode = listOfNodes.get(listOfNodes.size() - 1); + for (final Rotation rot : Rotation.values()) { + if (tryReversReset(pos, firstNode, rot)) { + return true; + } + } + return false; + } + + private boolean tryReversReset(final BlockPos pos, final SignalBoxNode node, + final Rotation rot) { + final AtomicBoolean canReset = new AtomicBoolean(false); + for (final EnumGuiMode mode : Arrays.asList(EnumGuiMode.CORNER, EnumGuiMode.STRAIGHT)) { + node.getOption(new ModeSet(mode, rot)).ifPresent( + entry -> entry.getEntry(PathEntryType.RESETING).ifPresent(blockPos -> { + if (!blockPos.equals(pos)) + return; + final AtomicBoolean atomic = new AtomicBoolean(false); + foreachEntry((option, cNode) -> { + option.getEntry(PathEntryType.BLOCKING).ifPresent(blockingPos -> { + if (isPowerd(blockingPos)) { + atomic.set(true); + } + }); + }); + if (atomic.get()) + return; + canReset.set(true); + this.resetPathway(); + })); + } + return canReset.get(); + } + private boolean isPowerd(final BlockPos pos) { final IBlockState state = world.getBlockState(pos); if (state == null || !(state.getBlock() instanceof RedstoneIO)) diff --git a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxUtil.java b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxUtil.java index 796c2e6bd..f9777de94 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/SignalBoxUtil.java +++ b/src/main/java/com/troblecodings/signals/signalbox/SignalBoxUtil.java @@ -8,6 +8,7 @@ import java.util.Optional; import java.util.Set; +import com.troblecodings.signals.config.ConfigHandler; import com.troblecodings.signals.enums.EnumPathUsage; import com.troblecodings.signals.enums.PathType; import com.troblecodings.signals.signalbox.debug.SignalBoxFactory; @@ -17,9 +18,9 @@ public final class SignalBoxUtil { - public static final int FREE_COLOR = 0xFF000000; - public static final int SELECTED_COLOR = 0xFF00FF00; - public static final int USED_COLOR = 0xFFFF0000; + public static final int FREE_COLOR = ConfigHandler.signalboxFreeColor; + public static final int SELECTED_COLOR = ConfigHandler.signalboxSelectColor; + public static final int USED_COLOR = ConfigHandler.signalboxUsedColor; private SignalBoxUtil() { } diff --git a/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java b/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java index 68b133a5e..9c1c50803 100644 --- a/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java +++ b/src/main/java/com/troblecodings/signals/signalbox/config/SignalConfig.java @@ -5,6 +5,7 @@ import java.util.Map; import java.util.stream.Collectors; +import com.google.common.collect.Maps; import com.troblecodings.signals.SEProperty; import com.troblecodings.signals.blocks.Signal; import com.troblecodings.signals.contentpacks.ChangeConfigParser; @@ -13,8 +14,7 @@ import com.troblecodings.signals.enums.PathType; import com.troblecodings.signals.handler.SignalStateHandler; import com.troblecodings.signals.handler.SignalStateInfo; -import com.troblecodings.signals.properties.ConfigProperty; -import com.troblecodings.signals.properties.SignalPair; +import com.troblecodings.signals.properties.PredicatedPropertyBase.ConfigProperty; public final class SignalConfig { @@ -26,8 +26,8 @@ public static void change(final ConfigInfo info) { if (info.type.equals(PathType.NORMAL)) { if (info.nextinfo != null) { final Signal nextSignal = info.nextinfo.signal; - final SignalPair pair = new SignalPair(currentSignal, nextSignal); - final List values = ChangeConfigParser.CHANGECONFIGS.get(pair); + final List values = ChangeConfigParser.CHANGECONFIGS + .get(Maps.immutableEntry(currentSignal, nextSignal)); if (values != null) { changeIfPresent(values, info); } else { @@ -61,11 +61,8 @@ public static void reset(final SignalStateInfo current) { } } - @SuppressWarnings({ - "rawtypes", "unchecked" - }) private static void changeIfPresent(final List values, final ConfigInfo info) { - final Map object = new HashMap<>(); + final Map, Object> object = new HashMap<>(); final Map oldProperties = SignalStateHandler .getStates(info.currentinfo); if (info.nextinfo != null) { @@ -75,8 +72,8 @@ private static void changeIfPresent(final List values, final Con object.put(String.class, info.zs2Value); final Map propertiesToSet = new HashMap<>(); values.forEach(property -> { - if (property.predicate.test(object)) { - propertiesToSet.putAll(property.values.entrySet().stream() + if (property.test(object)) { + propertiesToSet.putAll(property.state.entrySet().stream() .filter(entry -> oldProperties.containsKey(entry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); } @@ -91,7 +88,7 @@ private static void loadWithoutPredicate(final List values, final Map oldProperties = SignalStateHandler.getStates(current); final Map propertiesToSet = new HashMap<>(); values.forEach(property -> { - propertiesToSet.putAll(property.values.entrySet().stream() + propertiesToSet.putAll(property.state.entrySet().stream() .filter(entry -> oldProperties.containsKey(entry.getKey())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))); diff --git a/src/main/resources/assets/opensignals/enumdefinition/enums.json b/src/main/resources/assets/opensignals/enumdefinition/enums.json index cd5b1064f..aba421c96 100644 --- a/src/main/resources/assets/opensignals/enumdefinition/enums.json +++ b/src/main/resources/assets/opensignals/enumdefinition/enums.json @@ -559,6 +559,9 @@ "WHITE_BLACK_W", "YELLOW", "YELLOW_BLACK", - "RED_YELLOW" + "RED_YELLOW", + "BLACK_WHITE", + "BLACK_WHITE_W", + "BLACK_YELLOW" ] } \ No newline at end of file diff --git a/src/main/resources/assets/opensignals/gui/textures/redstone_off.png b/src/main/resources/assets/opensignals/gui/textures/redstone_off.png new file mode 100644 index 000000000..f04eec0ee Binary files /dev/null and b/src/main/resources/assets/opensignals/gui/textures/redstone_off.png differ diff --git a/src/main/resources/assets/opensignals/gui/textures/redstone_off_blocked.png b/src/main/resources/assets/opensignals/gui/textures/redstone_off_blocked.png new file mode 100644 index 000000000..8accf4ce3 Binary files /dev/null and b/src/main/resources/assets/opensignals/gui/textures/redstone_off_blocked.png differ diff --git a/src/main/resources/assets/opensignals/gui/textures/redstone_on.png b/src/main/resources/assets/opensignals/gui/textures/redstone_on.png new file mode 100644 index 000000000..794d859c6 Binary files /dev/null and b/src/main/resources/assets/opensignals/gui/textures/redstone_on.png differ diff --git a/src/main/resources/assets/opensignals/gui/textures/redstone_on_blocked.png b/src/main/resources/assets/opensignals/gui/textures/redstone_on_blocked.png new file mode 100644 index 000000000..0662425fc Binary files /dev/null and b/src/main/resources/assets/opensignals/gui/textures/redstone_on_blocked.png differ diff --git a/src/main/resources/assets/opensignals/lang/de_de.lang b/src/main/resources/assets/opensignals/lang/de_de.lang index 04322d5b7..27c89a08f 100644 --- a/src/main/resources/assets/opensignals/lang/de_de.lang +++ b/src/main/resources/assets/opensignals/lang/de_de.lang @@ -55,7 +55,7 @@ btn.main=Nutzung btn.yes=Ja btn.no=Nein btn.return=Zurück -btn.subsidiary=Zusatzsignale +btn.subsidiary=Zs Signal sb.allreset=Alle Fahrstraßen werden zurückgesetzt! sb.editmode=In den Edit Mode wechseln? property.STRAIGHT=Gerade @@ -94,7 +94,7 @@ property.prop.INPUT.resetting.name=Zurücksetzen property.prop.INPUT.resetting.desc=Setzt eine Fahrstraße zurück. Fahrstraßen werden direkt vor einem Signal zurückgesetzt oder auf einem freien Stück (z.B. für eine Teilfahrstraßenauflösung) msg.isblocked=Das Stellwerk wird bereits verwendet. label.linkedto=Verlinkt mit -gui.keyprompt=Drücke [LSHIFT] für mehr Informationen! +gui.keyprompt=Halte [LSHIFT] für mehr Infos!%nHalte [CTRL] zum Verstecken. property.enummode.name=Modus property.enummode.desc=Hier kannst du zwischen Manuellen Modus und Redstone Modus und MUX-Modus umschalten. im Manuellen Modus kannst du das Signal über die GUI ändern, im Redstone Modus kannst du an den Signalsteuerer Redstone anschließen, um darüber das Signal steuern. property.value.MANUELL=Manueller Modus @@ -247,7 +247,7 @@ property.ac_car.name=Ampel property.buetype.name=Bü Signale property.bueadd.name=Bü4 & Bü5 Zusatz property.bueshort.name=Bü2 Verkürzter Bremsweg -property.customname.desc=Hier kann du eine Signalbezeichnung/-beschriftung eintragen. Mit §l'[n]'§r wechselst du in die nächste Zeile. +property.customname.desc=Hier kann du eine Signalbezeichnung/-beschriftung eintragen. Mit §l[n]§r wechselst du in die nächste Zeile. property.sh_high.desc=Schutzhaltsignale erteilen ein Fahrverbot oder heben dieses auf. property.sh_mech.desc=§nSH0§r: Fahrverbot%n§nSh1§r: Fahrtverbot aufgehoben%n§nGsp2§r: Gleissperre abgelegt property.sh_light_bottom.desc=§nSH0§r: Fahrverbot%n§nSh1§r: Fahrtverbot aufgehoben%n§nKennlicht§r: Das Signal ist betrieblich abgeschaltet @@ -476,7 +476,7 @@ property.zp9.desc=Zp9 Abfahren: Das Signal wird vom Zugführer gegeben und der T property.semavr.name=Formvorsignal property.semavr.desc=Vorsignale kündigen an, was das nächste Hauptsignal zeigt.%n§nVr0§r: Halt erwarten%n§nVr1§r: Fahrt erwarten%n§nVr2§r: Langsamfahrt erwarten property.auto_pathway.name=Selbststellbetrieb -property.auto_pathway.desc=WIP +property.auto_pathway.desc=Im Selbststellbetrieb stellt sich eine manuell eingelegte Fahrstraße nach blockieren und auflösen wieder automatisch selbste ein, so lange der Selbststellbetrieb aktiv ist. property.sh1.name=Sh1 property.sh1.desc=§nSh1§r: Fahrtverbot aufgehoben property.statuslight.name=Kennlicht @@ -487,4 +487,50 @@ item.multilinkingtool.name=Signal Multi Verlinker property.value.RS_INPUT=Redstone Eingang gui.unlink=Entlinken property.lfarrow.name=Richtungspfeil -property.lfarrow.desc=Gibt die Richtung an. \ No newline at end of file +property.lfarrow.desc=Gibt die Richtung an. +info.nextelement=Nächstes Element +info.editor.key.r=Element Rotieren +info.editor.key.lmb=Element (de)platzieren +info.editor.key.rmb=Auswahl öffnen (Halten) +info.infolabel=Info & Hilfe +info.description=Beschreibung +info.straight=Gerader Pfad +info.corner=Diagonaler Pfad +info.end=Gleisabschluss +info.platform=Bahnsteig +info.bue=Bahnübergang +info.hp=Hauptsignal +info.vp=Vorsignal +info.rs=Schutzhaltsignal +info.ra10=Rangierhalttafel +info.sh2=Gleissperre +info.info=Info +info.keys=Steuerung +info.usage.key.lmb=Auswählen +info.usage.key.rmb=Config öffnen +item.manipulator.name=Manipulator +info.usage.node=Auswahl +info.usage.edit=Konfigurieren +info.usage.subsidiary=Aktive Zusatzsignale +sb.disablesubsidiary=Ausschalten +info.usage.edit.desc=Hier kommst du in den Bearbeitungsmodus für die Kachel. +btn.subsidiary.desc=Hier kannst du Zusatzsignale einschalten. +button.reset.desc=Setzt die Fahrstraße zurück. +info.usage.manuel=RS Output +info.usage.manuel.desc=Ändert den manuellen Redstone Output, z.B. für manuelle Weichensteuerung. +info.usage.status=Status +info.usage.status.free=Frei +info.usage.status.blocked=Blockiert +info.usage.rs.desc=Wenn die Fackel durchgestrichen ist, kann der manuelle Modus nicht verwendet werden, weil eine Fahrstraße anliegt. Anderenfalls kann der manuelle Redstone Modus umgestellt werden. +info.usage.rs.true=Aktiviert +info.usage.rs.false=Deaktiviert +info.usage.change=Umstellen +property.showtypes.name=Sortierung +property.showtypes.desc=Hier kannst du den Sortierungsfilter umstellen. +property.value.ALL=All +property.value.SIGNAL=Signal +property.value.INPUT=Redstone Input +property.value.OUTPUT=Redstone Output +property.value.BLACK_WHITE=Schwarz-Weiß +property.value.BLACK_WHITE_W=Schwarz-Weiß W +property.value.BLACK_YELLOW=Schwarz-Gelb \ No newline at end of file diff --git a/src/main/resources/assets/opensignals/lang/en_us.lang b/src/main/resources/assets/opensignals/lang/en_us.lang index 04fd64919..c7f6892ba 100644 --- a/src/main/resources/assets/opensignals/lang/en_us.lang +++ b/src/main/resources/assets/opensignals/lang/en_us.lang @@ -55,7 +55,7 @@ btn.main=Usage btn.yes=Yes btn.no=No btn.return=Back -btn.subsidiary=Subsidiary signals +btn.subsidiary=Subsidiary sb.allreset=All pathways will be reset! sb.editmode=Change to Edit Mode? property.STRAIGHT=Straight @@ -94,7 +94,7 @@ property.prop.INPUT.resetting.name=Resetting property.prop.INPUT.resetting.desc=Resets a path. Paths are reset directly in front of a signal or on an empty piece (e.g. for partial path resolution) msg.isblocked=The signal box is already in use. label.linkedto=Linked to -gui.keyprompt=Press [LSHIFT] for more information! +gui.keyprompt=Hold [LSHIFT] for more info!%nHold [CTRL] to hide. property.enummode.name=Mode property.enummode.desc=Here you can switch between Manual Mode and Redstone Mode and MUX Mode. In Manual Mode you can change the signal through the GUI, in Redstone Mode you can connect Redstone to the signal controller to control the signal. property.value.MANUELL=Manual Mode @@ -247,7 +247,7 @@ property.ac_car.name=Traffic Light property.buetype.name=Bü Signals property.bueadd.name=Bü4 & Bü5 Addition property.bueshort.name=Bü2 Short Brake Distance -property.customname.desc=Here you can enter a signal label/caption. Use §l'[n]'§r to move to the next line. +property.customname.desc=Here you can enter a signal label/caption. Use §l[n]§r to move to the next line. property.sh_high.desc=Protection holding signals give or lift a prohibition on driving. property.sh_mech.desc=§nSH0§r: Prohibition on driving%n§nSh1§r: Prohibition on driving lifted%n§nGsp2§r: Track block removed property.sh_light_bottom.desc=§nSH0§r: Prohibition on driving%n§nSh1§r: Prohibition on driving lifted%n§nIdentification light§r: The signal is operationally switched off @@ -476,7 +476,7 @@ property.zp9.desc=Zp9 Departure: The signal is given by the train conductor and property.semavr.name=Semaphore distant signal property.semavr.desc=Distant signals announce what the next main signal will show.%n§nVr0§r: Expect stop%n§nVr1§r: Expect go%n§nVr2§r: Expect slow property.auto_pathway.name=Auto pathways -property.auto_pathway.desc=WIP +property.auto_pathway.desc=In the auto-pathway mode, a manually set driving path automatically sets itself again after blocking and resetting, as long as the auto-pathway mode is active. property.sh1.name=Sh1 property.sh1.desc=§nSh1§r: Prohibition on driving lifted property.statuslight.name=Identify Light @@ -487,4 +487,50 @@ item.multilinkingtool.name=Signal Multi Linker property.value.RS_INPUT=Redstone Input gui.unlink=Unlink property.lfarrow.name=Direction Arrow -property.lfarrow.desc=Indicates the direction \ No newline at end of file +property.lfarrow.desc=Indicates the direction +info.nextelement=Next Element +info.editor.key.r=Rotate Element +info.editor.key.lmb=(Un)set Element +info.editor.key.rmb=Open Selection (Hold) +info.infolabel=Info & Help +info.description=Description +info.straight=Straight path +info.corner=Diagonal path +info.end=Track end tile +info.platform=Platform tile +info.bue=Level crossing tile +info.hp=Main signal +info.vp=Distant signal +info.rs=Shunting signal +info.ra10=Shunting holding sign +info.sh2=Track blocking tile +info.info=Info +info.keys=Controls +info.usage.key.lmb=Select +info.usage.key.rmb=Open config +item.manipulator.name=Manipulator +info.usage.node=Selection +info.usage.edit=Configure +info.usage.subsidiary=Active Subsidiary +sb.disablesubsidiary=Turn off +info.usage.edit.desc=Here you enter the edit mode for the tile. +btn.subsidiary.desc=Here you can turn on subsidiary signals. +button.reset.desc=Reset the drive path. +info.usage.manuel=RS Output +info.usage.manuel.desc=Change the manual redstone output, e.g. for manual switch control. +info.usage.status=Status +info.usage.status.free=Free +info.usage.status.blocked=Blocked +info.usage.rs.desc=If the torch is crossed out, the manual mode cannot be used because a driving path is present. Otherwise, the manual redstone mode can be switched. +info.usage.rs.true=Activated +info.usage.rs.false=Deactivated +info.usage.change=Change +property.showtypes.name=Sorting +property.showtypes.desc=Here you can change the sorting filter. +property.value.ALL=All +property.value.SIGNAL=Signal +property.value.INPUT=Redstone Input +property.value.OUTPUT=Redstone Output +property.value.BLACK_WHITE=Black-white +property.value.BLACK_WHITE_W=Black-white W +property.value.BLACK_YELLOW=Black-yellow \ No newline at end of file diff --git a/src/main/resources/assets/opensignals/modeldefinitions/switchhandle.json b/src/main/resources/assets/opensignals/modeldefinitions/switchhandle.json index 45df1a73d..9ddfe6df4 100644 --- a/src/main/resources/assets/opensignals/modeldefinitions/switchhandle.json +++ b/src/main/resources/assets/opensignals/modeldefinitions/switchhandle.json @@ -5,6 +5,9 @@ "handle_blackyellow": "opensignals:blocks/wn/handle_black_yellow", "handle_redyellow": "opensignals:blocks/wn/handle_red_yellow_red", "handle_yellow": "opensignals:blocks/wn/handle_yellow", + "handle_whiteblack": "opensignals:blocks/wn/handle_white_black", + "handle_whiteblack_w": "opensignals:blocks/wn/handle_white_black_w", + "handle_yellowblack": "opensignals:blocks/wn/handle_yellow_black", "wn2_2": "opensignals:blocks/wn/wn2_2", "orange": "opensignals:blocks/default/orange", "wn1_orange": "opensignals:blocks/wn/wn1_orange", @@ -21,18 +24,36 @@ "7": "handle_blackwhite" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { "7": "handle_blackwhite_w" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { "7": "handle_blackyellow" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -55,6 +76,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -65,6 +96,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -75,6 +116,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -102,6 +153,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "5": "wn2_2" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -109,6 +167,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "5": "wn2_2" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -116,6 +181,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "5": "wn2_2" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -140,6 +212,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -150,6 +232,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -160,6 +252,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -191,18 +293,36 @@ "7": "handle_blackwhite" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { "7": "handle_blackwhite_w" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { "7": "handle_blackyellow" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -225,6 +345,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -235,6 +365,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -245,6 +385,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -272,6 +422,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "5": "wn2_2" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -279,6 +436,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "5": "wn2_2" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -286,6 +450,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "5": "wn2_2" + } + }, { "blockstate": "hasandis(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -310,6 +481,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -320,6 +501,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -330,6 +521,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandis(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -361,18 +562,36 @@ "7": "handle_blackwhite" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { "7": "handle_blackwhite_w" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { "7": "handle_blackyellow" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -395,6 +614,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -405,6 +634,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -415,6 +654,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandisnot(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -442,6 +691,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "5": "wn2_2" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -449,6 +705,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "5": "wn2_2" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -456,6 +719,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "5": "wn2_2" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -480,6 +750,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -490,6 +770,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -500,6 +790,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandis(SWITCHSIDE) && hasandisnot(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -531,18 +831,36 @@ "7": "handle_blackwhite" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { "7": "handle_blackwhite_w" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { "7": "handle_blackyellow" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -565,6 +883,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -575,6 +903,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -585,6 +923,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_1_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandisnot(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -612,6 +960,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "5": "wn2_2" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -619,6 +974,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "5": "wn2_2" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -626,6 +988,13 @@ "5": "wn2_2" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "5": "wn2_2" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandisnot(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -650,6 +1019,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.WHITE_BLACK_W) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -660,6 +1039,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_WHITE_W) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_whiteblack_w", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.YELLOW_BLACK) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { @@ -670,6 +1059,16 @@ "6": "wn2_3_orange" } }, + { + "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.BLACK_YELLOW) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", + "retexture": { + "7": "handle_yellowblack", + "0": "orange", + "4": "wn1_orange", + "5": "wn2_2_orange", + "6": "wn2_3_orange" + } + }, { "blockstate": "hasandisnot(POWERED) && hasandis(FALLBACK_SWITCH) && with(WEIGHTCOLOR.RED_YELLOW) && hasandis(SWITCHSIDE) && hasandis(SWITCHPLACESIDE) && hasandis(MANUAL)", "retexture": { diff --git a/src/main/resources/assets/opensignals/models/block/other_signals/circle.json b/src/main/resources/assets/opensignals/models/block/other_signals/circle.json index a9f31de4d..e44e3946c 100644 --- a/src/main/resources/assets/opensignals/models/block/other_signals/circle.json +++ b/src/main/resources/assets/opensignals/models/block/other_signals/circle.json @@ -1 +1,132 @@ -{"credit": "Made with Blockbench by Mc_Jeronimo", "textures": {"0": "opensignals:blocks/default/shield_gray", "1": "opensignals:blocks/default/shield_black", "2": "opensignals:blocks/other_signals/circle", "particle": "opensignals:blocks/default/shield_gray", "overlay": "opensignals:blocks/other_signals/no_pass"}, "elements": [{"from": [4, 4, 5.98], "to": [12, 12, 5.98], "faces": {"north": {"uv": [0, 0, 16, 16], "texture": "#overlay", "tintindex": 0}}}, {"from": [7, 0, 7], "to": [9, 8, 9], "faces": {"north": {"uv": [0, 0, 2, 5], "texture": "#0"}, "east": {"uv": [0, 0, 2, 5], "texture": "#0"}, "south": {"uv": [0, 0, 2, 5], "texture": "#0"}, "west": {"uv": [0, 0, 2, 5], "texture": "#0"}, "up": {"uv": [0, 0, 2, 2], "texture": "#0"}, "down": {"uv": [0, 0, 2, 2], "texture": "#0"}}}, {"from": [2, 6, 6], "to": [14, 10, 7], "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, "faces": {"north": {"uv": [2, 4, 14, 8], "rotation": 180, "texture": "#2"}, "east": {"uv": [0, 0, 5, 1.5], "rotation": 180, "texture": "#1"}, "south": {"uv": [0, 0, 5, 1.5], "rotation": 180, "texture": "#1"}, "west": {"uv": [0, 0, 5, 1.5], "rotation": 180, "texture": "#1"}, "up": {"uv": [0, 0, 5, 1.5], "rotation": 180, "texture": "#1"}}}, {"from": [6, 2, 6], "to": [10, 3, 7], "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, "faces": {"north": {"uv": [6, 11, 10, 12], "rotation": 180, "texture": "#2"}, "east": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, "south": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, "west": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, "up": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}}}, {"from": [4, 3, 6], "to": [12, 4, 7], "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, "faces": {"north": {"uv": [4, 10, 12, 11], "rotation": 180, "texture": "#2"}, "east": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, "south": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, "west": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, "up": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}}}, {"from": [3, 4, 6], "to": [13, 6, 7], "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, "faces": {"north": {"uv": [3, 8, 13, 10], "rotation": 180, "texture": "#2"}, "east": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, "south": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, "west": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, "up": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}}}, {"from": [6, 13, 6], "to": [10, 14, 7], "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, "faces": {"north": {"uv": [6, 0, 10, 1], "rotation": 180, "texture": "#2"}, "east": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, "south": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, "west": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, "up": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}}}, {"from": [4, 12, 6], "to": [12, 13, 7], "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, "faces": {"north": {"uv": [4, 1, 12, 2], "rotation": 180, "texture": "#2"}, "east": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, "south": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, "west": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, "up": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}}}, {"from": [3, 10, 6], "to": [13, 12, 7], "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, "faces": {"north": {"uv": [3, 2, 13, 4], "rotation": 180, "texture": "#2"}, "east": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, "south": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, "west": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, "up": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}}}], "groups": [0, 1, {"name": "sign", "origin": [8, 8, 8], "color": 0, "children": [2, 3, 4, 5, 6, 7, 8]}]} \ No newline at end of file +{ + "credit": "Made with Blockbench by Mc_Jeronimo", + "textures": { + "0": "opensignals:blocks/default/shield_gray", + "1": "opensignals:blocks/default/shield_black", + "2": "opensignals:blocks/other_signals/circle", + "particle": "opensignals:blocks/default/shield_gray", + "overlay": "opensignals:blocks/other_signals/no_pass" + }, + "elements": [ + { + "from": [4, 4, 5.98], + "to": [12, 12, 5.98], + "faces": { + "north": {"uv": [0, 0, 16, 16], "texture": "#overlay", "tintindex": 0} + } + }, + { + "from": [7, 0, 7], + "to": [9, 8, 9], + "faces": { + "north": {"uv": [0, 0, 2, 5], "texture": "#0"}, + "east": {"uv": [0, 0, 2, 5], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 5], "texture": "#0"}, + "west": {"uv": [0, 0, 2, 5], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 2], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 2], "texture": "#0"} + } + }, + { + "from": [2, 6, 6], + "to": [14, 10, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, + "faces": { + "north": {"uv": [2, 4, 14, 8], "rotation": 180, "texture": "#2"}, + "east": {"uv": [0, 0, 5, 1.5], "rotation": 180, "texture": "#1"}, + "south": {"uv": [0, 0, 5, 1.5], "rotation": 180, "texture": "#1"}, + "west": {"uv": [0, 0, 5, 1.5], "rotation": 180, "texture": "#1"}, + "up": {"uv": [0, 0, 5, 1.5], "rotation": 180, "texture": "#1"}, + "down": {"uv": [0, 0, 5, 1.5], "texture": "#1"} + } + }, + { + "from": [6, 2, 6], + "to": [10, 3, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, + "faces": { + "north": {"uv": [6, 11, 10, 12], "rotation": 180, "texture": "#2"}, + "east": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, + "south": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, + "west": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, + "up": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, + "down": {"uv": [0, 0, 3, 1.5], "texture": "#1"} + } + }, + { + "from": [4, 3, 6], + "to": [12, 4, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, + "faces": { + "north": {"uv": [4, 10, 12, 11], "rotation": 180, "texture": "#2"}, + "east": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1.5], "texture": "#1"} + } + }, + { + "from": [3, 4, 6], + "to": [13, 6, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, + "faces": { + "north": {"uv": [3, 8, 13, 10], "rotation": 180, "texture": "#2"}, + "east": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, + "south": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, + "west": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, + "up": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, + "down": {"uv": [0, 0, 9, 1.5], "texture": "#1"} + } + }, + { + "from": [6, 13, 6], + "to": [10, 14, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, + "faces": { + "north": {"uv": [6, 0, 10, 1], "rotation": 180, "texture": "#2"}, + "east": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, + "south": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, + "west": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, + "up": {"uv": [0, 0, 3, 1.5], "rotation": 180, "texture": "#1"}, + "down": {"uv": [0, 0, 3, 1.5], "texture": "#1"} + } + }, + { + "from": [4, 12, 6], + "to": [12, 13, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, + "faces": { + "north": {"uv": [4, 1, 12, 2], "rotation": 180, "texture": "#2"}, + "east": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, + "south": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, + "west": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, + "up": {"uv": [0, 0, 1, 1.5], "rotation": 180, "texture": "#1"}, + "down": {"uv": [0, 0, 1, 1.5], "texture": "#1"} + } + }, + { + "from": [3, 10, 6], + "to": [13, 12, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 5.5, 6.5]}, + "faces": { + "north": {"uv": [3, 2, 13, 4], "rotation": 180, "texture": "#2"}, + "east": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, + "south": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, + "west": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, + "up": {"uv": [0, 0, 9, 1.5], "rotation": 180, "texture": "#1"}, + "down": {"uv": [0, 0, 9, 1.5], "texture": "#1"} + } + } + ], + "groups": [ + 0, + 1, + { + "name": "sign", + "origin": [8, 8, 8], + "color": 0, + "children": [2, 3, 4, 5, 6, 7, 8] + } + ] +} diff --git a/src/main/resources/assets/opensignals/models/item/manipulator.json b/src/main/resources/assets/opensignals/models/item/manipulator.json new file mode 100644 index 000000000..f0aa2b33a --- /dev/null +++ b/src/main/resources/assets/opensignals/models/item/manipulator.json @@ -0,0 +1 @@ +{"parent": "minecraft:item/generated", "textures": {"layer0": "opensignals:items/manipulator"}, "credit": "Made with Blockbench by Mc_Jeronimo"} \ No newline at end of file diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/hl_hl_config.json b/src/main/resources/assets/opensignals/signalconfigs/change/hl_hl_config.json index aca94bfb1..d01a70f79 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/hl_hl_config.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/hl_hl_config.json @@ -9,10 +9,10 @@ "100": "config(mainlightsignallightbar.GREEN)" }, "values": { - "map(stop) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL10", "mainlightsignal_distant.HL10", "exitsignal.HL1", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(>=.6) && speed(<=.9)": ["mainlightsignallightbar.YELLOW", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(==.10)": ["mainlightsignallightbar.GREEN", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], + "map(stop) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL10", "mainlightsignal_distant.HL10", "exitsignal.HL1", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(>=.6) && speed(<=.9)": ["mainlightsignallightbar.YELLOW", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(==.10)": ["mainlightsignallightbar.GREEN", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], "map(drive) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL1", "mainlightsignal_distant.HL1", "exitsignal.HL1", "blocksignal.HL1", "blockexitsignal.HL1"], "map(drive) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL2_3", "mainlightsignal_distant.HL1", "exitsignal.HL2_3", "blocksignal.HL1", "blockexitsignal.HL1"], diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/hl_hv_config.json b/src/main/resources/assets/opensignals/signalconfigs/change/hl_hv_config.json index e2ea5e28a..b64809bc5 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/hl_hv_config.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/hl_hv_config.json @@ -9,10 +9,10 @@ "100": "config(zs3.Z10) || config(zs3plate.Z10)" }, "values": { - "map(stop) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL10", "mainlightsignal_distant.HL10", "exitsignal.HL1", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(>=.6) && speed(<=.9)": ["mainlightsignallightbar.YELLOW", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(==.10)": ["mainlightsignallightbar.GREEN", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], + "map(stop) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL10", "mainlightsignal_distant.HL10", "exitsignal.HL1", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(>=.6) && speed(<=.9)": ["mainlightsignallightbar.YELLOW", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(==.10)": ["mainlightsignallightbar.GREEN", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], "map(drive) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL1", "mainlightsignal_distant.HL1", "exitsignal.HL1", "blocksignal.HL1", "blockexitsignal.HL1"], "map(drive) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL2_3", "mainlightsignal_distant.HL1", "exitsignal.HL2_3", "blocksignal.HL1", "blockexitsignal.HL1"], diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/hl_ks_config.json b/src/main/resources/assets/opensignals/signalconfigs/change/hl_ks_config.json index d406b3a00..bdcf4df51 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/hl_ks_config.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/hl_ks_config.json @@ -8,10 +8,10 @@ "100": "config(zs3.Z10) || config(zs3plate.Z10)" }, "values": { - "map(stop) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL10", "mainlightsignal_distant.HL10", "exitsignal.HL1", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(>=.6) && speed(<=.9)": ["mainlightsignallightbar.YELLOW", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(==.10)": ["mainlightsignallightbar.GREEN", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], + "map(stop) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL10", "mainlightsignal_distant.HL10", "exitsignal.HL1", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(>=.6) && speed(<=.9)": ["mainlightsignallightbar.YELLOW", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(==.10)": ["mainlightsignallightbar.GREEN", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], "map(drive) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL1", "mainlightsignal_distant.HL1", "exitsignal.HL1", "blocksignal.HL1", "blockexitsignal.HL1"], "map(drive) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL2_3", "mainlightsignal_distant.HL1", "exitsignal.HL2_3", "blocksignal.HL1", "blockexitsignal.HL1"], diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/hl_sema_config.json b/src/main/resources/assets/opensignals/signalconfigs/change/hl_sema_config.json index 51d44be08..d37b7bd44 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/hl_sema_config.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/hl_sema_config.json @@ -2,17 +2,17 @@ "currentSignal": "hlsignal", "nextSignal": "semaphoresignal", "savedPredicates": { - "stop": "config(wing1.FALSE) && config(wing2.FALSE)", - "drive": "config(wing1.TRUE) && config(wing2.FALSE)", + "stop": "(config(wing1.FALSE) && config(wing2.FALSE)) || config(wing1.FALSE)", + "drive": "(config(wing1.TRUE) && config(wing2.FALSE)) || config(wing1.TRUE)", "slow": "config(wing1.TRUE) && config(wing2.TRUE)", "40_60": "config(zs3.Z1) || config(zs3plate.Z1) || config(zs3.Z2) || config(zs3plate.Z2) || config(zs3.Z3) || config(zs3plate.Z3) || config(zs3.Z4) || config(zs3plate.Z4) || config(zs3.Z5) || config(zs3plate.Z5) || config(zs3.Z6) || config(zs3plate.Z6) || config(zs3.Z7) || config(zs3plate.Z7) || config(zs3.Z8) || config(zs3plate.Z8) || config(zs3.Z9) || config(zs3plate.Z9)", "100": "config(zs3.Z10) || config(zs3plate.Z10)" }, "values": { - "map(stop) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL10", "mainlightsignal_distant.HL10", "exitsignal.HL1", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(>=.6) && speed(<=.9)": ["mainlightsignallightbar.YELLOW", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], - "map(stop) && speed(==.10)": ["mainlightsignallightbar.GREEN", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1"], + "map(stop) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL10", "mainlightsignal_distant.HL10", "exitsignal.HL1", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(>=.6) && speed(<=.9)": ["mainlightsignallightbar.YELLOW", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], + "map(stop) && speed(==.10)": ["mainlightsignallightbar.GREEN", "mainlightsignal.HL11_12", "mainlightsignal_distant.HL10", "exitsignal.HL2_3", "blocksignal.HL10", "blockexitsignal.HL1", "zs2v.OFF"], "map(drive) && (speed(<.1) || speed(>=.11))": ["mainlightsignallightbar.OFF", "mainlightsignal.HL1", "mainlightsignal_distant.HL1", "exitsignal.HL1", "blocksignal.HL1", "blockexitsignal.HL1"], "map(drive) && speed(>=.1) && speed(<=.5)": ["mainlightsignallightbar.OFF", "mainlightsignal.HL2_3", "mainlightsignal_distant.HL1", "exitsignal.HL2_3", "blocksignal.HL1", "blockexitsignal.HL1"], diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/hv_hl_config.json b/src/main/resources/assets/opensignals/signalconfigs/change/hv_hl_config.json index 275277283..a6168ccd8 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/hv_hl_config.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/hv_hl_config.json @@ -3,7 +3,7 @@ "nextSignal": "hlsignal", "savedPredicates": { "stop": "(config(mainlightsignal.HP0) || config(mainlightsignal.HP0_ALTERNATE_RED) || config(mainlightsignal.HL_ZS1) || config(mainlightsignal.HL_SHUNTING) || config(exitsignal.HP0) || config(exitsignal.HP0_ALTERNATE_RED) || config(exitsignal.HL_ZS1) || config(exitsignal.HL_SHUNTING) || config(blocksignal.HP0) || config(blocksignal.HP0_ALTERNATE_RED) || config(blocksignal.HL_ZS1) || config(blockexitsignal.HP0) || config(blockexitsignal.HL_ZS1) || config(blockexitsignal.HL_SHUNTING)) && config(mainlightsignallightbar.OFF)", - "drive": "(config(mainlightsignal.HL1) || config(mainlightsignal.HL4) || config(mainlightsignal.HL7) || config(mainlightsignal.HL10) || config(exitsignal.HL1) || config(blocksignal.HL1) || config(blocksignal.HL10) || config(blockexitsignal.HL1)) && config(mainlightsignallightbar.OFF)", + "drive": "(config(mainlightsignal.HL1) || config(mainlightsignal.HL4) || config(mainlightsignal.HL7) || config(mainlightsignal.HL10) || config(exitsignal.HL1) || config(blocksignal.HL1) || config(blocksignal.HL10) || config(blockexitsignal.HL1)) && (config(mainlightsignallightbar.OFF) || !(config(mainlightsignallightbar.OFF) || config(mainlightsignallightbar.YELLOW) || config(mainlightsignallightbar.GREEN)))", "slow": "config(mainlightsignal.HL2_3) || config(mainlightsignal.HL5_6) || config(mainlightsignal.HL8_9) || config(mainlightsignal.HL11_12) || config(exitsignal.HL2_3)" }, "values": { diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/hv_sema.json b/src/main/resources/assets/opensignals/signalconfigs/change/hv_sema.json index dfd79f51b..7cde8f7ca 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/hv_sema.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/hv_sema.json @@ -2,8 +2,8 @@ "currentSignal": "hvsignal", "nextSignal": "semaphoresignal", "savedPredicates": { - "stop": "config(wing1.FALSE) && config(wing2.FALSE)", - "drive": "config(wing1.TRUE) && config(wing2.FALSE)", + "stop": "(config(wing1.FALSE) && config(wing2.FALSE)) || config(wing1.FALSE)", + "drive": "(config(wing1.TRUE) && config(wing2.FALSE)) || config(wing1.TRUE)", "slow": "config(wing1.TRUE) && config(wing2.TRUE)" }, "values": { diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/ks_hl_config.json b/src/main/resources/assets/opensignals/signalconfigs/change/ks_hl_config.json index cbe501f9e..094536f48 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/ks_hl_config.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/ks_hl_config.json @@ -3,11 +3,11 @@ "nextSignal": "hlsignal", "savedPredicates": { "stop": "(config(mainlightsignal.HP0) || config(mainlightsignal.HP0_ALTERNATE_RED) || config(mainlightsignal.HL_ZS1) || config(mainlightsignal.HL_SHUNTING) || config(exitsignal.HP0) || config(exitsignal.HP0_ALTERNATE_RED) || config(exitsignal.HL_ZS1) || config(exitsignal.HL_SHUNTING) || config(blocksignal.HP0) || config(blocksignal.HP0_ALTERNATE_RED) || config(blocksignal.HL_ZS1) || config(blockexitsignal.HP0) || config(blockexitsignal.HL_ZS1) || config(blockexitsignal.HL_SHUNTING)) && config(mainlightsignallightbar.OFF)", - "drive": "(config(mainlightsignal.HL1) || config(mainlightsignal.HL4) || config(mainlightsignal.HL7) || config(mainlightsignal.HL10) || config(exitsignal.HL1) || config(blocksignal.HL1) || config(blocksignal.HL10) || config(blockexitsignal.HL1)) && config(mainlightsignallightbar.OFF)", + "drive": "(config(mainlightsignal.HL1) || config(mainlightsignal.HL4) || config(mainlightsignal.HL7) || config(mainlightsignal.HL10) || config(exitsignal.HL1) || config(blocksignal.HL1) || config(blocksignal.HL10) || config(blockexitsignal.HL1)) && (config(mainlightsignallightbar.OFF) || !(config(mainlightsignallightbar.OFF) || config(mainlightsignallightbar.YELLOW) || config(mainlightsignallightbar.GREEN)))", "slow": "config(mainlightsignal.HL2_3) || config(mainlightsignal.HL5_6) || config(mainlightsignal.HL8_9) || config(mainlightsignal.HL11_12) || config(exitsignal.HL2_3)" }, "values": { - "map(stop)": ["kombisignal.KS2", "kombisignal_main.KS1", "kombisignal_distant.KS2", "zs3v.OFF"], + "map(stop)": ["kombisignal.KS2", "kombisignal_main.KS1", "kombisignal_distant.KS2", "zs3v.OFF", "zs2v.OFF"], "map(drive)": ["kombisignal.KS1", "kombisignal_main.KS1", "kombisignal_distant.KS1"], "map(slow) && config(mainlightsignallightbar.OFF)": ["zs3v.Z4", "kombisignal.KS1_BLINK", "kombisignal_main.KS1", "kombisignal_distant.KS1_BLINK"], diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/ks_hv_config.json b/src/main/resources/assets/opensignals/signalconfigs/change/ks_hv_config.json index d8f7e8227..381b6d340 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/ks_hv_config.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/ks_hv_config.json @@ -23,7 +23,7 @@ "(config(zs3.Z14) || config(zs3plate.Z14))": ["zs3v.Z14"], "(config(zs3.Z15) || config(zs3plate.Z15))": ["zs3v.Z15"], - "map(stop)": ["kombisignal.KS2", "kombisignal_main.KS1", "kombisignal_distant.KS2", "zs3v.OFF"], + "map(stop)": ["kombisignal.KS2", "kombisignal_main.KS1", "kombisignal_distant.KS2", "zs3v.OFF", "zs2v.OFF"], "map(drive)": ["kombisignal.KS1", "kombisignal_main.KS1", "kombisignal_distant.KS1"], "map(drive) && map(zs3)": ["kombisignal.KS1_BLINK", "kombisignal_main.KS1", "kombisignal_distant.KS1_BLINK"], diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/ks_ks_config.json b/src/main/resources/assets/opensignals/signalconfigs/change/ks_ks_config.json index 95b8ab9bf..025fa1757 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/ks_ks_config.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/ks_ks_config.json @@ -23,7 +23,7 @@ "(config(zs3.Z14) || config(zs3plate.Z14))": ["zs3v.Z14"], "(config(zs3.Z15) || config(zs3plate.Z15))": ["zs3v.Z15"], - "map(stop)": ["kombisignal.KS2", "kombisignal_main.KS1", "kombisignal_distant.KS2", "zs3v.OFF"], + "map(stop)": ["kombisignal.KS2", "kombisignal_main.KS1", "kombisignal_distant.KS2", "zs3v.OFF", "zs2v.OFF"], "map(drive)": ["kombisignal.KS1", "kombisignal_main.KS1", "kombisignal_distant.KS1"], "map(drive) && map(zs3)": ["kombisignal.KS1_BLINK", "kombisignal_main.KS1", "kombisignal_distant.KS1_BLINK"], diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/ks_sema.json b/src/main/resources/assets/opensignals/signalconfigs/change/ks_sema.json index c1c510112..8e05d6931 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/ks_sema.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/ks_sema.json @@ -2,8 +2,8 @@ "currentSignal": "kssignal", "nextSignal": "semaphoresignal", "savedPredicates": { - "stop": "config(wing1.FALSE) && config(wing2.FALSE)", - "drive": "config(wing1.TRUE) && config(wing2.FALSE)", + "stop": "(config(wing1.FALSE) && config(wing2.FALSE)) || config(wing1.FALSE)", + "drive": "(config(wing1.TRUE) && config(wing2.FALSE)) || config(wing1.TRUE)", "slow": "config(wing1.TRUE) && config(wing2.TRUE)", "zs3": "config(zs3.Z1) || config(zs3.Z2) || config(zs3.Z3) || config(zs3.Z4) || config(zs3.Z5) || config(zs3.Z6) || config(zs3.Z7) || config(zs3.Z8) || config(zs3.Z9) || config(zs3.Z10) || config(zs3.Z11) || config(zs3.Z12) || config(zs3.Z13) || config(zs3.Z14) || config(zs3.Z15) || config(zs3plate.Z1) || config(zs3plate.Z2) || config(zs3plate.Z3) || config(zs3plate.Z4) || config(zs3plate.Z5) || config(zs3plate.Z6) || config(zs3plate.Z7) || config(zs3plate.Z8) || config(zs3plate.Z9) || config(zs3plate.Z10) || config(zs3plate.Z11) || config(zs3plate.Z12) || config(zs3plate.Z13) || config(zs3plate.Z14) || config(zs3plate.Z15)" }, @@ -24,7 +24,7 @@ "(config(zs3.Z14) || config(zs3plate.Z14))": ["zs3v.Z14"], "(config(zs3.Z15) || config(zs3plate.Z15))": ["zs3v.Z15"], - "map(stop)": ["kombisignal.KS2", "kombisignal_main.KS1", "kombisignal_distant.KS2", "zs3v.OFF"], + "map(stop)": ["kombisignal.KS2", "kombisignal_main.KS1", "kombisignal_distant.KS2", "zs3v.OFF", "zs2v.OFF"], "map(drive) || map(slow)": ["kombisignal.KS1", "kombisignal_main.KS1", "kombisignal_distant.KS1"], "(map(drive) || map(slow)) && map(zs3)": ["kombisignal.KS1_BLINK", "kombisignal_main.KS1", "kombisignal_distant.KS1_BLINK"], diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/sema_hl.json b/src/main/resources/assets/opensignals/signalconfigs/change/sema_hl.json index 91af0422e..6720daca3 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/sema_hl.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/sema_hl.json @@ -3,7 +3,7 @@ "nextSignal": "hlsignal", "savedPredicates": { "stop": "(config(mainlightsignal.HP0) || config(mainlightsignal.HP0_ALTERNATE_RED) || config(mainlightsignal.HL_ZS1) || config(mainlightsignal.HL_SHUNTING) || config(exitsignal.HP0) || config(exitsignal.HP0_ALTERNATE_RED) || config(exitsignal.HL_ZS1) || config(exitsignal.HL_SHUNTING) || config(blocksignal.HP0) || config(blocksignal.HP0_ALTERNATE_RED) || config(blocksignal.HL_ZS1) || config(blockexitsignal.HP0) || config(blockexitsignal.HL_ZS1) || config(blockexitsignal.HL_SHUNTING)) && config(mainlightsignallightbar.OFF)", - "drive": "(config(mainlightsignal.HL1) || config(mainlightsignal.HL4) || config(mainlightsignal.HL7) || config(mainlightsignal.HL10) || config(exitsignal.HL1) || config(blocksignal.HL1) || config(blocksignal.HL10) || config(blockexitsignal.HL1)) && config(mainlightsignallightbar.OFF)", + "drive": "(config(mainlightsignal.HL1) || config(mainlightsignal.HL4) || config(mainlightsignal.HL7) || config(mainlightsignal.HL10) || config(exitsignal.HL1) || config(blocksignal.HL1) || config(blocksignal.HL10) || config(blockexitsignal.HL1)) && (config(mainlightsignallightbar.OFF) || !(config(mainlightsignallightbar.OFF) || config(mainlightsignallightbar.YELLOW) || config(mainlightsignallightbar.GREEN)))", "slow": "config(mainlightsignal.HL2_3) || config(mainlightsignal.HL5_6) || config(mainlightsignal.HL8_9) || config(mainlightsignal.HL11_12) || config(exitsignal.HL2_3)" }, "values": { diff --git a/src/main/resources/assets/opensignals/signalconfigs/change/sema_sema.json b/src/main/resources/assets/opensignals/signalconfigs/change/sema_sema.json index 8ad0bab9e..94aa517fa 100644 --- a/src/main/resources/assets/opensignals/signalconfigs/change/sema_sema.json +++ b/src/main/resources/assets/opensignals/signalconfigs/change/sema_sema.json @@ -2,8 +2,8 @@ "currentSignal": "semaphoresignal", "nextSignal": "semaphoresignal", "savedPredicates": { - "stop": "config(wing1.FALSE) && config(wing2.FALSE)", - "drive": "config(wing1.TRUE) && config(wing2.FALSE)", + "stop": "(config(wing1.FALSE) && config(wing2.FALSE)) || config(wing1.FALSE)", + "drive": "(config(wing1.TRUE) && config(wing2.FALSE)) || config(wing1.TRUE)", "slow": "config(wing1.TRUE) && config(wing2.TRUE)" }, "values": { diff --git a/src/main/resources/assets/opensignals/signalsystems/switchhandle.json b/src/main/resources/assets/opensignals/signalsystems/switchhandle.json index c5e7eb6f3..c7ae7cf64 100644 --- a/src/main/resources/assets/opensignals/signalsystems/switchhandle.json +++ b/src/main/resources/assets/opensignals/signalsystems/switchhandle.json @@ -4,7 +4,10 @@ "canLink": true, "defaultHeight": 0, "redstoneOutputs": { - "config(manual.TRUE)" : "powered" + "config(manual.TRUE)": "powered" + }, + "remoteRedstoneOutputs": { + "config(manual.FALSE)": "powered" } }, "seProperties": [ @@ -17,8 +20,7 @@ "name": "powered", "defaultState": false, "changeableStage": "APISTAGE_NONE_CONFIG", - "autoname": true, - "dependencies": "config(MANUAL.TRUE)" + "autoname": true }, { "name": "fallback_switch", diff --git a/src/main/resources/assets/opensignals/textures/blocks/wn/handle_white_black.png b/src/main/resources/assets/opensignals/textures/blocks/wn/handle_white_black.png new file mode 100644 index 000000000..f3fb846a4 Binary files /dev/null and b/src/main/resources/assets/opensignals/textures/blocks/wn/handle_white_black.png differ diff --git a/src/main/resources/assets/opensignals/textures/blocks/wn/handle_white_black_w.png b/src/main/resources/assets/opensignals/textures/blocks/wn/handle_white_black_w.png new file mode 100644 index 000000000..b820c42a6 Binary files /dev/null and b/src/main/resources/assets/opensignals/textures/blocks/wn/handle_white_black_w.png differ diff --git a/src/main/resources/assets/opensignals/textures/blocks/wn/handle_yellow_black.png b/src/main/resources/assets/opensignals/textures/blocks/wn/handle_yellow_black.png new file mode 100644 index 000000000..2bcd9636c Binary files /dev/null and b/src/main/resources/assets/opensignals/textures/blocks/wn/handle_yellow_black.png differ diff --git a/src/main/resources/assets/opensignals/textures/items/manipulator.png b/src/main/resources/assets/opensignals/textures/items/manipulator.png new file mode 100644 index 000000000..ec71202a5 Binary files /dev/null and b/src/main/resources/assets/opensignals/textures/items/manipulator.png differ