Skip to content

Commit

Permalink
Merge pull request #214 from MrTroble/feats/1.12.2
Browse files Browse the repository at this point in the history
Feats/1.12.2
  • Loading branch information
Uhutown authored Sep 17, 2023
2 parents 42165d9 + f92687b commit d964231
Show file tree
Hide file tree
Showing 97 changed files with 2,313 additions and 748 deletions.
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.0.2'
APPVEYOR_BUILD_VERSION: '3.1.0'
CURSETOKEN: ${{ secrets.CURSETOKEN }}
steps:
- uses: actions/checkout@v3
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/versioncheck.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion contentPackLib
4 changes: 0 additions & 4 deletions src/main/java/com/troblecodings/signals/SEProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ public boolean testMap(final Map<SEProperty, String> t) {
return this.deps.test(t);
}

public static SEProperty cst(final Object iup) {
return (SEProperty) iup;
}

public JsonEnum getParent() {
return parent;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -17,6 +19,7 @@ public class GhostBlock extends BasicBlock {

public GhostBlock() {
super(Material.GLASS);
setLightLevel(ConfigHandler.lightEmission / 15.0F);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/troblecodings/signals/blocks/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public AxisAlignedBB getBoundingBox(final IBlockState state, final IBlockAccess
final BlockPos pos) {
return BOUNDING_BOX;
}
}
}
101 changes: 48 additions & 53 deletions src/main/java/com/troblecodings/signals/blocks/Signal.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -83,7 +82,6 @@ public class Signal extends BasicBlock {
private final int id;
private List<SEProperty> signalProperties;
private final Map<SEProperty, Integer> signalPropertiesToInt = new HashMap<>();
private SEProperty powerProperty = null;

public Signal(final SignalProperties prop) {
super(Material.ROCK);
Expand All @@ -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() {
Expand All @@ -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);
Expand Down Expand Up @@ -246,11 +245,10 @@ public void breakBlock(final World worldIn, final BlockPos pos, final IBlockStat
}
}

@SuppressWarnings("unchecked")
public int getHeight(final Map<SEProperty, String> map) {
for (final HeightProperty property : this.prop.signalHeights) {
if (property.predicate.test(map))
return property.height;
for (final PredicateProperty<Integer> property : this.prop.signalHeights) {
if (property.test(map))
return property.state;
}
return this.prop.defaultHeight;
}
Expand Down Expand Up @@ -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<SEProperty, String> map = ClientSignalStateHandler.getClientStates(
Expand All @@ -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<Float> property : this.prop.customRenderHeights) {
if (property.predicate.test(map)) {
customRenderHeight = property.height;
customRenderHeight = property.state;
}
if (customRenderHeight == -1)
return;
Expand All @@ -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<Boolean> boolProp : this.prop.doubleSidedText) {
if (boolProp.predicate.test(map)) {
doubleSidedText = boolProp.doubleSided;
doubleSidedText = boolProp.state;
}
}
final SignalAngel face = state.getValue(Signal.ANGEL);
Expand Down Expand Up @@ -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;
Expand All @@ -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<Float> property : this.prop.customRenderHeights) {
if (property.predicate.test(map)) {
customRenderHeight = property.height;
customRenderHeight = property.state;
}
}
if (customRenderHeight == -1)
Expand All @@ -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<Boolean> boolProp : this.prop.doubleSidedText) {
if (boolProp.predicate.test(map)) {
doubleSidedText = boolProp.doubleSided;
doubleSidedText = boolProp.state;
}
}

Expand Down Expand Up @@ -439,44 +435,45 @@ 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<SEProperty, String> 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<SEProperty, String> properties) {
if (!this.prop.redstoneOutputs.isEmpty()) {
final Map<SEProperty, String> 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;
}
}
}
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
Expand All @@ -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<SEProperty, String> properties = SignalStateHandler.getStates(stateInfo);
for (final ValuePack pack : this.prop.redstoneOutputs) {
if (pack.predicate.test(properties)) {
return 15;
for (final List<ValuePack> 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;
Expand All @@ -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;
Expand All @@ -531,14 +527,13 @@ public void getUpdate(final World world, final BlockPos pos) {
}
}

@SuppressWarnings("unchecked")
public SoundProperty getSound(final Map<SEProperty, String> 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
Expand All @@ -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);
}

Expand Down
Loading

0 comments on commit d964231

Please sign in to comment.