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

Fix&Feats 1.12.2 #217

Merged
merged 66 commits into from
Nov 28, 2023
Merged
Changes from 20 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
c48e05e
fix: preview renderer
Jeronimo97 Oct 2, 2023
9119609
fix: issue in contentpackib and problems with loading and reading states
Uhutown Oct 8, 2023
069d9e8
ref: better code performance
Uhutown Oct 18, 2023
64834a3
feat: added new load system NOT TESTED
Uhutown Oct 18, 2023
4767759
ref: better code performance
Uhutown Oct 18, 2023
e43d4e8
ref: better code performance
Uhutown Oct 18, 2023
bb2d6ac
increased Counter for IO_SERVICE
Uhutown Oct 18, 2023
6cf7021
ref: better code performance
Uhutown Oct 19, 2023
ac3bd1b
tried new things
Uhutown Oct 19, 2023
df03456
ref: revert last commit in parts, added sync statements
Uhutown Oct 19, 2023
6aca715
ref: added more sync statements
Uhutown Oct 19, 2023
7fa5f28
ref: test
Uhutown Oct 19, 2023
a92f507
ref: changed Executor
Uhutown Oct 19, 2023
f85aeaf
fix: issue in NameHandler
Uhutown Oct 19, 2023
f290a56
added posCache to SignalStateFile
Uhutown Oct 19, 2023
8887a61
ref: changed from CacheThreadPool to FixedThreadPool
Uhutown Oct 19, 2023
46c48c6
ref: changed to Player
Uhutown Nov 4, 2023
9eea45c
added DebugOutput for problems with SignalBoxPathway
Uhutown Nov 4, 2023
706d17b
ref: changed to ImmutableMap
Uhutown Nov 4, 2023
b7faca3
added more debug output
Uhutown Nov 4, 2023
fe1d8ae
ref: changed Debug Outputs
Uhutown Nov 5, 2023
b9da29e
ref: more Debug Output
Uhutown Nov 5, 2023
d268711
ref: better code performance
Uhutown Nov 6, 2023
252017f
ref: fixed sync statement
Uhutown Nov 6, 2023
6c3b820
ref: changed Debug Outputs
Uhutown Nov 6, 2023
b8c4c03
ref: changed DebugOutput
Uhutown Nov 6, 2023
fc0b10a
Hopefully fixed bug with vanished properties
Uhutown Nov 6, 2023
ec7f323
ref: removed Debug Output
Uhutown Nov 6, 2023
665452e
ref: removed all Debug Outputs
Uhutown Nov 6, 2023
2af02cc
ref: removed more debugging and changed Input Update
Uhutown Nov 6, 2023
a98a16c
fix: issues in SignalStateHandler, removed READ_SERVICE
Uhutown Nov 9, 2023
3a302c1
fix: issue in exception message in FunctionParsingInfo
Uhutown Nov 9, 2023
31d2020
added Debug Output
Uhutown Nov 10, 2023
84e8f16
added empty Check for String
Uhutown Nov 10, 2023
420c378
ref: changed debug output
Uhutown Nov 12, 2023
0c9e65f
ref: added more debugging stuff
Uhutown Nov 12, 2023
a037fdd
ref: added more debug stuff
Uhutown Nov 12, 2023
1f97a9a
ref: removed Debugging, fix issue with to quick replace
Uhutown Nov 12, 2023
6bc8bf7
ref: more debugging
Uhutown Nov 12, 2023
3f2a4d9
ref: added call when empty map is getting sended
Uhutown Nov 12, 2023
b0e0e4c
ref: new debug output
Uhutown Nov 12, 2023
9780176
changed Debug
Uhutown Nov 12, 2023
0374994
redone last commit
Uhutown Nov 12, 2023
6f2c97a
redone alle Debugging
Uhutown Nov 12, 2023
70a4961
applied feats and fixes from 1.18
Uhutown Nov 25, 2023
50b49e8
fixed: startup issues
Uhutown Nov 25, 2023
cab48ec
ref: updated assets
Uhutown Nov 25, 2023
9479856
added new textures
Uhutown Nov 26, 2023
dfb236d
adher to checkstyle
Uhutown Nov 26, 2023
2105bbd
fix: issues with PathwayRequester
Uhutown Nov 26, 2023
baf0c35
fix: issue in SignalBoxPathway
Uhutown Nov 26, 2023
6518779
applied changelog
Uhutown Nov 26, 2023
c4a566e
adher to checkstyle
Uhutown Nov 26, 2023
f9f2367
fix: lang keys, fix: switchhandle, fix: pathwayrequester assets
Jeronimo97 Nov 26, 2023
c985023
Merge branch 'fix/1.12.2' of https://github.com/MrTroble/Open-Signals…
Jeronimo97 Nov 26, 2023
dbbc537
fix: NPE
Uhutown Nov 26, 2023
b17befa
Merge branch 'fix/1.12.2' of https://github.com/MrTroble/Open-Signals…
Uhutown Nov 26, 2023
6dc0a24
fix: pwr item model registry
Jeronimo97 Nov 26, 2023
7c49dd6
fix: issue with placeing of signals into blocks
Uhutown Nov 26, 2023
6652b7a
fix: issue with dark color
Uhutown Nov 26, 2023
a691bce
applied changelog
Uhutown Nov 26, 2023
0abacea
fix: issue with UIClickable and Info&Help Page
Uhutown Nov 26, 2023
c63f9db
applied changelog
Uhutown Nov 26, 2023
2cac18f
fix: issues with SignalBoxPW
Uhutown Nov 26, 2023
e358b30
fix: issue with Nameing in Placementtool
Uhutown Nov 26, 2023
eb12de9
ref: better code performance
Uhutown Nov 27, 2023
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
@@ -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.1.0'
APPVEYOR_BUILD_VERSION: '3.1.1'
CURSETOKEN: ${{ secrets.CURSETOKEN }}
steps:
- uses: actions/checkout@v3
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.12.2 - 3.1.1]

* fix: preview renderer

## [1.12.2 - 3.1.0]

* feat: added help panel to signalbox
2 changes: 1 addition & 1 deletion contentPackLib
2 changes: 1 addition & 1 deletion guilib
12 changes: 10 additions & 2 deletions src/main/java/com/troblecodings/signals/OpenSignalsMain.java
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import com.troblecodings.guilib.ecs.GuiHandler;
import com.troblecodings.signals.handler.NameHandler;
import com.troblecodings.signals.handler.SignalBoxHandler;
import com.troblecodings.signals.handler.SignalStateHandler;
import com.troblecodings.signals.init.OSBlocks;
import com.troblecodings.signals.init.OSItems;
import com.troblecodings.signals.init.OSSounds;
@@ -33,6 +34,7 @@
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;

@Mod(modid = OpenSignalsMain.MODID, acceptedMinecraftVersions = "[1.12.2]")
public class OpenSignalsMain {
@@ -52,6 +54,7 @@ public OpenSignalsMain() {
MinecraftForge.EVENT_BUS.register(OSItems.class);
MinecraftForge.EVENT_BUS.register(OSSounds.class);
MinecraftForge.EVENT_BUS.register(NameHandler.class);
MinecraftForge.EVENT_BUS.register(SignalStateHandler.class);
MinecraftForge.EVENT_BUS.register(SignalBoxHandler.class);
debug = true;
log = LoggerContext.getContext().getLogger(MODID);
@@ -63,8 +66,7 @@ public OpenSignalsMain() {
});
}

@SidedProxy(serverSide = "com.troblecodings.signals.proxy.CommonProxy",
clientSide = "com.troblecodings.signals.proxy.ClientProxy")
@SidedProxy(serverSide = "com.troblecodings.signals.proxy.CommonProxy", clientSide = "com.troblecodings.signals.proxy.ClientProxy")
Uhutown marked this conversation as resolved.
Show resolved Hide resolved
public static CommonProxy proxy;
private static Logger log = null;
public static GuiHandler handler = null;
@@ -79,6 +81,12 @@ public static boolean isDebug() {
return debug;
}

@EventHandler
public void onServerStop(final FMLServerStoppingEvent event) {
SignalStateHandler.onServerStop(event);
NameHandler.onServerStop(event);
}

@EventHandler
public void preinit(final FMLPreInitializationEvent event) {
debug = Files.isDirectory(event.getSourceFile().toPath());
10 changes: 5 additions & 5 deletions src/main/java/com/troblecodings/signals/blocks/RedstoneIO.java
Original file line number Diff line number Diff line change
@@ -3,10 +3,9 @@
import java.util.Optional;

import com.troblecodings.signals.OpenSignalsMain;
import com.troblecodings.signals.core.PosIdentifier;
import com.troblecodings.signals.core.StateInfo;
import com.troblecodings.signals.core.TileEntitySupplierWrapper;
import com.troblecodings.signals.handler.NameHandler;
import com.troblecodings.signals.handler.NameStateInfo;
import com.troblecodings.signals.handler.SignalBoxHandler;
import com.troblecodings.signals.init.OSItems;
import com.troblecodings.signals.tileentitys.RedstoneIOTileEntity;
@@ -41,7 +40,7 @@ public IBlockState getStateForPlacement(final World world, final BlockPos pos,
final EnumFacing facing, final float hitX, final float hitY, final float hitZ,
final int meta, final EntityLivingBase placer, final EnumHand hand) {
if (!world.isRemote)
NameHandler.createName(new NameStateInfo(world, pos), getLocalizedName());
NameHandler.createName(new StateInfo(world, pos), getLocalizedName());
return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand);
}

@@ -111,8 +110,9 @@ public TileEntity createNewTileEntity(final World worldIn, final int meta) {
public void breakBlock(final World worldIn, final BlockPos pos, final IBlockState state) {
if (!worldIn.isRemote) {
new Thread(() -> {
NameHandler.setRemoved(new NameStateInfo(worldIn, pos));
SignalBoxHandler.onPosRemove(new PosIdentifier(pos, worldIn));
final StateInfo info = new StateInfo(worldIn, pos);
NameHandler.setRemoved(info);
SignalBoxHandler.onPosRemove(info);
}, "RedstoneIO:breakBlock").start();
}
super.breakBlock(worldIn, pos, state);
18 changes: 8 additions & 10 deletions src/main/java/com/troblecodings/signals/blocks/Signal.java
Original file line number Diff line number Diff line change
@@ -14,16 +14,14 @@
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;
import com.troblecodings.signals.core.SignalAngel;
import com.troblecodings.signals.core.SignalProperties;
import com.troblecodings.signals.core.StateInfo;
import com.troblecodings.signals.core.TileEntitySupplierWrapper;
import com.troblecodings.signals.enums.ChangeableStage;
import com.troblecodings.signals.handler.ClientSignalStateHandler;
import com.troblecodings.signals.handler.ClientSignalStateInfo;
import com.troblecodings.signals.handler.NameHandler;
import com.troblecodings.signals.handler.NameStateInfo;
import com.troblecodings.signals.handler.SignalBoxHandler;
import com.troblecodings.signals.handler.SignalStateHandler;
import com.troblecodings.signals.handler.SignalStateInfo;
@@ -110,8 +108,8 @@ public AxisAlignedBB getBoundingBox(final IBlockState state, final IBlockAccess
final World world = te.getWorld();
final SignalStateInfo info = new SignalStateInfo(world, pos, this);
final Map<SEProperty, String> properties = world.isRemote
? ClientSignalStateHandler.getClientStates(new ClientSignalStateInfo(info))
: SignalStateHandler.getStates(info);
? ClientSignalStateHandler.getClientStates(new StateInfo(info.world, info.pos))
: ((SignalTileEntity) te).getProperties();
return FULL_BLOCK_AABB.expand(0, getHeight(properties), 0);
}

@@ -185,7 +183,7 @@ public IBlockState getExtendedState(final IBlockState state, final IBlockAccess
final World world = tile.getWorld();
final SignalStateInfo info = new SignalStateInfo(world, pos, this);
final Map<SEProperty, String> properties = world.isRemote
? ClientSignalStateHandler.getClientStates(new ClientSignalStateInfo(info))
? ClientSignalStateHandler.getClientStates(new StateInfo(info.world, info.pos))
: SignalStateHandler.getStates(info);
properties.forEach((property, value) -> blockState
.getAndUpdate(oldState -> oldState.withProperty(property, value)));
@@ -239,8 +237,8 @@ public void breakBlock(final World worldIn, final BlockPos pos, final IBlockStat
if (!worldIn.isRemote) {
new Thread(() -> {
SignalStateHandler.setRemoved(new SignalStateInfo(worldIn, pos, this));
NameHandler.setRemoved(new NameStateInfo(worldIn, pos));
SignalBoxHandler.onPosRemove(new PosIdentifier(pos, worldIn));
NameHandler.setRemoved(new StateInfo(worldIn, pos));
SignalBoxHandler.onPosRemove(new StateInfo(worldIn, pos));
}, "Signal:breakBlock").start();
}
}
@@ -294,7 +292,7 @@ public void renderOverlay(final RenderOverlayInfo info) {
@SideOnly(Side.CLIENT)
public void renderScaleOverlay(final RenderOverlayInfo info, final float renderHeight) {
final Map<SEProperty, String> map = ClientSignalStateHandler.getClientStates(
new ClientSignalStateInfo(info.tileEntity.getWorld(), info.tileEntity.getPos()));
new StateInfo(info.tileEntity.getWorld(), info.tileEntity.getPos()));
final String customNameState = map.get(CUSTOMNAME);
if (customNameState == null || customNameState.equalsIgnoreCase("FALSE"))
return;
@@ -355,7 +353,7 @@ public void renderSingleScaleOverlay(final RenderOverlayInfo info) {
public void renderOverlay(final RenderOverlayInfo info, final float renderHeight) {
float customRenderHeight = renderHeight;
final Map<SEProperty, String> map = ClientSignalStateHandler.getClientStates(
new ClientSignalStateInfo(info.tileEntity.getWorld(), info.tileEntity.getPos()));
new StateInfo(info.tileEntity.getWorld(), info.tileEntity.getPos()));
final String customNameState = map.get(CUSTOMNAME);
if (customNameState == null || customNameState.equalsIgnoreCase("FALSE"))
return;
6 changes: 3 additions & 3 deletions src/main/java/com/troblecodings/signals/blocks/SignalBox.java
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
import java.util.Optional;

import com.troblecodings.signals.OpenSignalsMain;
import com.troblecodings.signals.core.PosIdentifier;
import com.troblecodings.signals.core.StateInfo;
import com.troblecodings.signals.core.TileEntitySupplierWrapper;
import com.troblecodings.signals.handler.SignalBoxHandler;
import com.troblecodings.signals.init.OSItems;
@@ -64,14 +64,14 @@ public Optional<String> getSupplierWrapperName() {
@Override
public void onBlockPlacedBy(final World worldIn, final BlockPos pos, final IBlockState state,
final EntityLivingBase placer, final ItemStack stack) {
SignalBoxHandler.relinkAllRedstoneIOs(new PosIdentifier(pos, worldIn));
SignalBoxHandler.relinkAllRedstoneIOs(new StateInfo(worldIn, pos));
}

@Override
public void breakBlock(final World worldIn, final BlockPos pos, final IBlockState state) {
if (!worldIn.isRemote) {
((SignalBoxTileEntity) worldIn.getTileEntity(pos)).unlink();
SignalBoxHandler.removeSignalBox(new PosIdentifier(pos, worldIn));
SignalBoxHandler.removeSignalBox(new StateInfo(worldIn, pos));
}
super.breakBlock(worldIn, pos, state);
}
63 changes: 42 additions & 21 deletions src/main/java/com/troblecodings/signals/core/LinkedPositions.java
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import com.troblecodings.signals.SEProperty;
import com.troblecodings.signals.blocks.Signal;
import com.troblecodings.signals.contentpacks.SubsidiarySignalParser;
import com.troblecodings.signals.enums.ChangedState;
import com.troblecodings.signals.enums.LinkType;
import com.troblecodings.signals.handler.SignalBoxHandler;
import com.troblecodings.signals.handler.SignalStateHandler;
@@ -28,21 +29,30 @@ public class LinkedPositions {
private static final String SIGNAL_NAME = "signalName";
private static final String ALL_POS = "allPos";

private final Map<BlockPos, Signal> signals;
private final Map<BlockPos, LinkType> linkedBlocks;
private final Map<BlockPos, List<SubsidiaryState>> possibleSubsidiaries;
private final BlockPos thisPos;
private final Map<BlockPos, Signal> signals = new HashMap<>();
private final Map<BlockPos, LinkType> linkedBlocks = new HashMap<>();
private final Map<BlockPos, List<SubsidiaryState>> possibleSubsidiaries = new HashMap<>();

public LinkedPositions() {
signals = new HashMap<>();
linkedBlocks = new HashMap<>();
possibleSubsidiaries = new HashMap<>();
public LinkedPositions(final BlockPos thisPos) {
this.thisPos = thisPos;
}

private final SignalStateListener listener = (stateInfo, properties, changed) -> {
if (changed.equals(ChangedState.ADDED_TO_CACHE)) {
loadPossibleSubsidiaires(stateInfo, properties);
} else if (changed.equals(ChangedState.REMOVED_FROM_FILE)) {
possibleSubsidiaries.remove(stateInfo.pos);
}
};

public void addSignal(final BlockPos signalPos, final Signal signal, final World world) {
signals.put(signalPos, signal);
final SignalStateInfo info = new SignalStateInfo(world, signalPos, signal);
SignalConfig.reset(info);
loadPossibleSubsidiaires(info);
SignalStateHandler.loadSignal(
new StateLoadHolder(info, new LoadHolder<>(new StateInfo(world, thisPos))));
loadPossibleSubsidiaires(info, SignalStateHandler.getStates(info));
}

public Signal getSignal(final BlockPos pos) {
@@ -56,9 +66,12 @@ public boolean addLinkedPos(final BlockPos pos, final LinkType type) {
return true;
}

public void removeLinkedPos(final BlockPos pos) {
public void removeLinkedPos(final BlockPos pos, final World world) {
linkedBlocks.remove(pos);
signals.remove(pos);
final Signal signal = signals.remove(pos);
if (signal != null) {
SignalStateHandler.removeListener(new SignalStateInfo(world, pos, signal), listener);
}
possibleSubsidiaries.remove(pos);
}

@@ -71,15 +84,17 @@ public Map<BlockPos, LinkType> getAllLinkedPos() {
}

public void unlink(final BlockPos tilePos, final World world) {
final List<SignalStateInfo> signalsToUnload = new ArrayList<>();
final List<StateLoadHolder> signalsToUnload = new ArrayList<>();
signals.forEach((pos, signal) -> {
final SignalStateInfo info = new SignalStateInfo(world, pos, signal);
SignalConfig.reset(info);
signalsToUnload.add(info);
signalsToUnload.add(
new StateLoadHolder(info, new LoadHolder<>(new StateInfo(world, tilePos))));
SignalStateHandler.removeListener(info, listener);
});
linkedBlocks.entrySet().stream().filter(entry -> !entry.getValue().equals(LinkType.SIGNAL))
.forEach(entry -> SignalBoxHandler
.unlinkTileFromPos(new PosIdentifier(tilePos, world), entry.getKey()));
.forEach(entry -> SignalBoxHandler.unlinkTileFromPos(new StateInfo(world, tilePos),
entry.getKey()));
linkedBlocks.clear();
signals.clear();
possibleSubsidiaries.clear();
@@ -120,22 +135,28 @@ public void read(final NBTWrapper wrapper) {
public void loadSignals(final World world) {
if (world.isRemote)
return;
final List<SignalStateInfo> signalInfos = new ArrayList<>();
signals.forEach((pos, signal) -> signalInfos.add(new SignalStateInfo(world, pos, signal)));
final List<StateLoadHolder> signalInfos = new ArrayList<>();
signals.forEach((pos, signal) -> {
final SignalStateInfo info = new SignalStateInfo(world, pos, signal);
SignalStateHandler.addListener(info, listener);
signalInfos.add(
new StateLoadHolder(info, new LoadHolder<>(new StateInfo(world, thisPos))));
});
SignalStateHandler.loadSignals(signalInfos);
signalInfos.forEach(this::loadPossibleSubsidiaires);
}

public void unloadSignals(final World world) {
if (world.isRemote)
return;
final List<SignalStateInfo> signalInfos = new ArrayList<>();
signals.forEach((pos, signal) -> signalInfos.add(new SignalStateInfo(world, pos, signal)));
final List<StateLoadHolder> signalInfos = new ArrayList<>();
signals.forEach((pos, signal) -> signalInfos
.add(new StateLoadHolder(new SignalStateInfo(world, pos, signal),
new LoadHolder<>(new StateInfo(world, thisPos)))));
SignalStateHandler.unloadSignals(signalInfos);
}

private void loadPossibleSubsidiaires(final SignalStateInfo info) {
final Map<SEProperty, String> properties = SignalStateHandler.getStates(info);
private void loadPossibleSubsidiaires(final SignalStateInfo info,
final Map<SEProperty, String> properties) {
final Map<SubsidiaryState, ConfigProperty> subsidiaries = SubsidiarySignalParser.SUBSIDIARY_SIGNALS
.get(info.signal);
if (subsidiaries == null)
30 changes: 30 additions & 0 deletions src/main/java/com/troblecodings/signals/core/LoadHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.troblecodings.signals.core;

import java.util.Objects;

public class LoadHolder<T> {

public final T holder;

public LoadHolder(final T holder) {
this.holder = holder;
}

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

@Override
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final LoadHolder<?> other = (LoadHolder<?>) obj;
return Objects.equals(holder, other.holder);
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.troblecodings.signals.core;

import java.util.Map;

import com.troblecodings.signals.SEProperty;
import com.troblecodings.signals.enums.ChangedState;
import com.troblecodings.signals.handler.SignalStateInfo;

public interface SignalStateListener {

public void update(final SignalStateInfo info, final boolean removed);
public void update(final SignalStateInfo info, final Map<SEProperty, String> changedProperties,
final ChangedState changedState);

}
Loading
Loading