Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new feats to 1.18 #219

Merged
merged 46 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
7cac285
fix: issue with Reverse Reset and ReRequest of PW
Uhutown Dec 8, 2023
ee902a3
added files for new SignalStateFile
Uhutown Dec 8, 2023
2262fdf
add missing models
Jeronimo97 Dec 8, 2023
d0f3aec
fix: Scroll of Info&Help Page
Uhutown Dec 8, 2023
1560190
fix: code and decode of BlockPos
Uhutown Dec 12, 2023
c9fb4e0
fix/feat: new SignalStateFileV2
Uhutown Dec 13, 2023
fe34f29
ref: removed unused sync statements
Uhutown Dec 13, 2023
63d2d3e
ref: better code performance
Uhutown Dec 13, 2023
3506e8e
feat: added occupied marker for SignalStateFileV2
Uhutown Dec 14, 2023
33aaae4
added -1 when State is deletd
Uhutown Dec 14, 2023
f5add16
feat: added method for Getting All Entries
Uhutown Dec 14, 2023
959b487
added test for Migration V1 -> V2
Uhutown Dec 14, 2023
67f220f
fix tests
Uhutown Dec 14, 2023
be348c8
feat: added new SignalStateFile and Migration System
Uhutown Dec 18, 2023
77d42c4
added new NameHandlerFile and Migration
Uhutown Dec 18, 2023
3105062
feat: added system for partly blocking
Uhutown Dec 18, 2023
a620fb6
fix: partly blocking of Pathway
Uhutown Dec 18, 2023
489542b
feat: added train number system and removed partly blocking
Uhutown Dec 22, 2023
10b990d
better UI for Train Number Changes
Uhutown Dec 22, 2023
056c6d2
feat: added system to set properties when special items right-click o…
Uhutown Dec 22, 2023
0eb1f82
fix: interaction system and example
Uhutown Dec 22, 2023
e5d4ff5
removeing text when changeing train number
Uhutown Dec 22, 2023
61e9115
ref: removed unused boolean
Uhutown Dec 22, 2023
f6f7437
adher to checkstyle
Uhutown Dec 22, 2023
f40a2e7
Merge branch '1.18-master' into feats/1.18
Uhutown Dec 22, 2023
c086672
ref: better TrainNumber UI
Uhutown Dec 27, 2023
ef22ded
Merge branch 'feats/1.18' of https://github.com/MrTroble/Open-Signals…
Uhutown Dec 27, 2023
f22cbcc
feat: added block to change train number
Uhutown Dec 28, 2023
a994c0a
fix: issue with next PWs
Uhutown Dec 29, 2023
460f0ce
update guilib
Uhutown Dec 29, 2023
0f37e9b
ref: removed interaction system
Uhutown Dec 29, 2023
656aa41
fix: issues with Paths
Uhutown Dec 29, 2023
691465f
adher to checkstyle
Uhutown Dec 29, 2023
2f7da04
added delete statement for files
Uhutown Dec 29, 2023
bf46bb0
fix: IO Exceptions
Uhutown Dec 29, 2023
0455523
train number block assets
Jeronimo97 Dec 29, 2023
53d7662
fix: deleting of old files
Uhutown Dec 29, 2023
78d21d5
fix missing lang keys
Jeronimo97 Dec 29, 2023
830d744
ref: changelog and versioning
Jeronimo97 Dec 29, 2023
f31ea17
fix: lang keys
Jeronimo97 Dec 30, 2023
29051dc
fix: issue in PWR Gui and no counting by shunting PWs
Uhutown Dec 31, 2023
a770546
fix: empty linking list
Uhutown Jan 1, 2024
d1e3d7f
fix: signals in UI
Uhutown Jan 1, 2024
7208e1d
fix: signal position in UI
Uhutown Jan 1, 2024
c2cc64b
Update guilib
Jeronimo97 Jan 1, 2024
594c3ed
Update changelog.md
Uhutown Jan 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.0'
APPVEYOR_BUILD_VERSION: '3.3.0'
CURSETOKEN: ${{ secrets.CURSETOKEN }}
steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ minecraft {
dependencies {
minecraft 'net.minecraftforge:forge:1.18.2-40.1.86'
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
Expand Down
14 changes: 14 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## [1.18.2 - 3.3.0]

* feat: new SignalFile system (V2) now in world folder and migration from old system
* feat: added train number system
* feat: added train number changing block
* fix: issue with reverse reset and rerequest of PW
* fix: missing models
* fix: scroll in Info&Help page
* fix: issue with next PWs
* fix: visual signal feedback in signalbox
* fix: issue in UIPreview

**When starting the world for the first time, the migration of the SignalFiles may take a moment.**

## [1.18.2 - 3.2.0]

* feat: added customName to signalcontroller
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/troblecodings/signals/blocks/Signal.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
Expand Down Expand Up @@ -370,8 +371,8 @@ public InteractionResult use(final BlockState blockstate, final Level level,
}
final SignalStateInfo stateInfo = new SignalStateInfo(level, blockPos, this);
final boolean customname = canHaveCustomname(SignalStateHandler.getStates(stateInfo));
if (placer.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(OSItems.MANIPULATOR)
&& (canBeLinked() || customname)) {
final Item item = placer.getItemInHand(InteractionHand.MAIN_HAND).getItem();
if (item.equals(OSItems.MANIPULATOR) && (canBeLinked() || customname)) {
OpenSignalsMain.handler.invokeGui(Signal.class, placer, level, blockPos, "signal");
return InteractionResult.SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.troblecodings.signals.blocks;

import java.util.Optional;

import com.troblecodings.signals.OpenSignalsMain;
import com.troblecodings.signals.core.TileEntitySupplierWrapper;
import com.troblecodings.signals.init.OSItems;
import com.troblecodings.signals.tileentitys.TrainNumberTileEntity;

import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition.Builder;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.phys.BlockHitResult;

public class TrainNumberBlock extends BasicBlock {

public static final BooleanProperty POWERD = BooleanProperty.create("powerd");
public static final TileEntitySupplierWrapper WRAPPER = TrainNumberTileEntity::new;

public TrainNumberBlock() {
super(Properties.of(Material.STONE));
}

@Override
protected void createBlockStateDefinition(final Builder<Block, BlockState> builder) {
builder.add(POWERD);
}

@Override
public void neighborChanged(final BlockState state, final Level world, final BlockPos pos,
final Block block, final BlockPos toPos, final boolean moveing) {
if (world.isClientSide)
return;
if (world.hasNeighborSignal(pos)) {
if (!state.getValue(POWERD)) {
world.setBlockAndUpdate(pos, state.setValue(POWERD, true));
final BlockEntity entity = world.getBlockEntity(pos);
if (entity instanceof TrainNumberTileEntity) {
((TrainNumberTileEntity) entity).updateTrainNumberViaRedstone();
}
}
} else {
world.setBlockAndUpdate(pos, state.setValue(POWERD, false));
}
}

@Override
public InteractionResult use(final BlockState state, final Level world, final BlockPos pos,
final Player player, final InteractionHand hand, final BlockHitResult result) {
final Item item = player.getMainHandItem().getItem();
if (!(item.equals(OSItems.LINKING_TOOL) && item.equals(OSItems.MULTI_LINKING_TOOL))) {
OpenSignalsMain.handler.invokeGui(TrainNumberBlock.class, player, world, pos,
"pathwayrequester");
return InteractionResult.SUCCESS;
}
return InteractionResult.FAIL;
}

@Override
public Optional<TileEntitySupplierWrapper> getSupplierWrapper() {
return Optional.of(WRAPPER);
}

@Override
public Optional<String> getSupplierWrapperName() {
return Optional.of("trainnumberchanger");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static class Client {
public final ConfigValue<Integer> signalboxSelectColor;
public final ConfigValue<Integer> signalboxUsedColor;
public final ConfigValue<Integer> signalboxPreparedColor;
public final ConfigValue<Integer> signalboxTrainNumberColor;

public Client(final ForgeConfigSpec.Builder builder) {
String desc;
Expand All @@ -68,6 +69,10 @@ public Client(final ForgeConfigSpec.Builder builder) {
signalboxPreparedColor = builder.comment(desc).define("Signalbox prepared color",
0xffff00);

desc = "Change the color of the TrainNumber in the UI. Default: -1";
signalboxTrainNumberColor = builder.comment(desc).define("Signalbox TrainNumber color",
0xFFFFFFFF);

desc = "Change the color of a default text. Default: -16777216";
GuiConfigHandler.basicTextColor = builder.comment(desc).define("Basic text color",
0xFF000000);
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/troblecodings/signals/core/PathGetter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.troblecodings.signals.core;

import java.nio.file.Path;
import java.nio.file.Paths;

import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.Level;

public final class PathGetter {
Uhutown marked this conversation as resolved.
Show resolved Hide resolved

private PathGetter() {

}

public static Path getNewPathForFiles(final Level world, final String subDirectory) {
final MinecraftServer server = world.getServer();
Path path = Paths.get("osfiles");
if (!world.isClientSide && server != null && server.isDedicatedServer()) {
path = Paths.get(world.getServer().getWorldData().getLevelName().replace("/", "_")
.replace(".", "_") + "/osfiles/" + subDirectory + "/"
+ world.dimension().location().toString().replace(":", ""));
} else if (!world.isClientSide && (server == null || !server.isDedicatedServer())) {
path = Paths.get("saves/"
+ world.getServer().getWorldData().getLevelName().replace("/", "_").replace(".",
"_")
+ "/osfiles/" + subDirectory + "/"
+ world.dimension().location().toString().replace(":", ""));
}
return path;
}
}
62 changes: 62 additions & 0 deletions src/main/java/com/troblecodings/signals/core/TrainNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.troblecodings.signals.core;

import java.util.Objects;

import com.troblecodings.core.NBTWrapper;
import com.troblecodings.core.ReadBuffer;
import com.troblecodings.core.WriteBuffer;

public class TrainNumber {

private static final String TRAIN_NUMBER = "trainNumber";
public static final TrainNumber DEFAULT = new TrainNumber();

public final String trainNumber;

private TrainNumber() {
this("");
}

public TrainNumber(final String trainNumber) {
this.trainNumber = trainNumber;
}

public static TrainNumber of(final ReadBuffer buffer) {
return new TrainNumber(buffer.getString());
}

public static TrainNumber of(final NBTWrapper wrapper) {
return new TrainNumber(wrapper.getString(TRAIN_NUMBER));
}

public void writeTag(final NBTWrapper wrapper) {
wrapper.putString(TRAIN_NUMBER, trainNumber);
}

public void writeNetwork(final WriteBuffer buffer) {
buffer.putString(trainNumber);
}

@Override
public int hashCode() {
return Objects.hash(trainNumber);
}

@Override
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final TrainNumber other = (TrainNumber) obj;
return Objects.equals(trainNumber, other.trainNumber);
}

@Override
public String toString() {
return trainNumber;
}

}
24 changes: 12 additions & 12 deletions src/main/java/com/troblecodings/signals/enums/EnumGuiMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,31 @@ private EnumGuiMode(final int id, final boolean unused) {
this((state) -> {
switch (state) {
case GREEN: {
return new UITexture(UISignalBoxTile.SIGNALS, id * 0.067f, 0,
id * 0.067f + 0.06f, 1);
return new UITexture(UISignalBoxTile.SIGNALS, id * 0.0667f, 0,
id * 0.066667f + 0.06f, 1);
}
case RED: {
return new UITexture(UISignalBoxTile.SIGNALS, id * 0.067f + 3 * 0.067f, 0,
id * 0.067f + 3 * 0.067f + 0.06f, 1);
return new UITexture(UISignalBoxTile.SIGNALS, id * 0.067f + 3 * 0.0666667f, 0,
id * 0.066667f + 3 * 0.067f + 0.06f, 1);
}
case OFF: {
return new UITexture(UISignalBoxTile.SIGNALS, id * 0.067f + 6 * 0.067f, 0,
id * 0.067f + 6 * 0.067f + 0.06f, 1);
return new UITexture(UISignalBoxTile.SIGNALS, id * 0.067f + 6 * 0.0666667f, 0,
id * 0.066667f + 6 * 0.067f + 0.06f, 1);
}
case SUBSIDIARY_GREEN: {
final int factor = 9;
return new UITexture(UISignalBoxTile.SIGNALS, (id + factor) * 0.067f, 0,
id * 0.067f + factor * 0.067f + 0.06f, 1);
return new UITexture(UISignalBoxTile.SIGNALS, (id + factor) * 0.0666667f, 0,
id * 0.066667f + factor * 0.067f + 0.06f, 1);
}
case SUBSIDIARY_RED: {
final int factor = 10;
return new UITexture(UISignalBoxTile.SIGNALS, (id + factor) * 0.067f, 0,
(id + factor) * 0.067f + 0.06f, 1);
return new UITexture(UISignalBoxTile.SIGNALS, (id + factor) * 0.0666667f, 0,
(id + factor) * 0.066667f + 0.06f, 1);
}
case SUBSIDIARY_OFF: {
final int factor = 11;
return new UITexture(UISignalBoxTile.SIGNALS, (id + factor) * 0.067f, 0,
(id + factor) * 0.067f + 0.06f, 1);
return new UITexture(UISignalBoxTile.SIGNALS, (id + factor) * 0.0666667f, 0,
(id + factor) * 0.066667f + 0.06f, 1);
}
default:
return new UITexture(UISignalBoxTile.SIGNALS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public enum SignalBoxNetwork {
SEND_PW_UPDATE, RESET_ALL_PW, SEND_CHANGED_MODES, REQUEST_LINKED_POS, NO_PW_FOUND,
REQUEST_SUBSIDIARY, SEND_ZS2_ENTRY, UPDATE_RS_OUTPUT, OUTPUT_UPDATE, RESET_SUBSIDIARY,
SET_AUTO_POINT, SEND_NAME, SEND_SIGNAL_REPEATER, ADDED_TO_SAVER, REMOVE_SAVEDPW,
SEND_POINT_ENTRY, SET_SIGNALS, SEND_COUNTER;
SEND_POINT_ENTRY, SET_SIGNALS, SEND_COUNTER, SEND_TRAIN_NUMBER;

}
Loading
Loading