Skip to content

Commit

Permalink
Add support for inverting the QIO Redstone Adapter's output signal (m…
Browse files Browse the repository at this point in the history
  • Loading branch information
pupnewfster committed Feb 29, 2024
1 parent 2a15e50 commit fe1c679
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 1.20.4 2024-02-23T17:35:02.1656729 ComputerHelp: mekanism
// 1.20.4 2024-02-28T16:59:29.0604283 ComputerHelp: mekanism
94b6d2a203a16827e2f54f7489e90159992acdb3 data/mekanism/computer_help/enums.csv
b38b847919651e2a55bc3eb8c719b2d92f76de7a data/mekanism/computer_help/enums.json
37e9c9a2db521caf46932e0a269b5ef3ba991a5e data/mekanism/computer_help/jekyll.md
689abb71930a1add755f00691dbe84641f7b4a11 data/mekanism/computer_help/methods.csv
3f051c2899a4d634c3fcdfcf11fa4036ab877a50 data/mekanism/computer_help/methods.json
dc3e48a25d124681852d8ebf194a0548e28246d1 data/mekanism/computer_help/jekyll.md
e11332cfebf5acd64a3ddc3bb9058d6e28692ec6 data/mekanism/computer_help/methods.csv
3fd2213d194601d6e7ddf5b85b164f030fe150e9 data/mekanism/computer_help/methods.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.4 2024-02-28T13:59:07.0276977 Loot Tables
// 1.20.4 2024-02-28T16:59:29.0634054 Loot Tables
b4a05e7ba50da33988cfbf7827826c6dc5a141d9 data/mekanism/loot_tables/blocks/advanced_bin.json
cd266e7b4a5bde833aa11e1caf17d86631197626 data/mekanism/loot_tables/blocks/advanced_chemical_tank.json
6829ad29ae722d1ef741fc103dfd5704c1874a66 data/mekanism/loot_tables/blocks/advanced_combining_factory.json
Expand Down Expand Up @@ -137,7 +137,7 @@ c93f6d48138eea1ef6219fbe4a261e1219ca0b0c data/mekanism/loot_tables/blocks/nutrit
e173588162075874da89da6450bf3111572a13c8 data/mekanism/loot_tables/blocks/qio_drive_array.json
7a50e1708345efae43254f594657e12a2af4c8db data/mekanism/loot_tables/blocks/qio_exporter.json
2950b52bf92ea19b0dd81c1fa3ba457a9a04cb4e data/mekanism/loot_tables/blocks/qio_importer.json
e622d5379b909f769c4c910c33cd27248aab5a3a data/mekanism/loot_tables/blocks/qio_redstone_adapter.json
9bf9bc1bedb91bd0cc25a93b1d99d72bb5646f9a data/mekanism/loot_tables/blocks/qio_redstone_adapter.json
5f09276294e2367e32102c287f0e2a61facee062 data/mekanism/loot_tables/blocks/quantum_entangloporter.json
a83942e741e98eec7bb60a34fc43be78b599a64e data/mekanism/loot_tables/blocks/radioactive_waste_barrel.json
3c2da914833207168dafcef0869a603f10e54c95 data/mekanism/loot_tables/blocks/resistive_heater.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 1.20.4 2024-02-28T15:25:16.3656249 Languages: en_us for mod: mekanism
// 1.20.4 2024-02-28T21:26:49.3914969 Languages: en_us for mod: mekanism
0e98b8c7cddc1a598c7667ea29f63dcf18723bbe assets/mekanism/lang/en_au.json
0e98b8c7cddc1a598c7667ea29f63dcf18723bbe assets/mekanism/lang/en_gb.json
51ba90f999a7c570e8297ba47b6c8195777ebc90 assets/mekanism/lang/en_ud.json
feaa7621abd7677181d223e10d3fc935febf89e8 assets/mekanism/lang/en_us.json
817af7b8294e041a4650eab53d144f4364c00bbc assets/mekanism/lang/en_ud.json
adfc00cc2e0b154de1066f14ec287c31471ab0b1 assets/mekanism/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,12 @@
"gas_mode.mekanism.idle": "ǝꞁpI",
"generic.mekanism.block_pos": "%3$s '%s '%1$s",
"generic.mekanism.fraction": "%2$s/%1$s",
"generic.mekanism.greater_equal": "%s ⪕",
"generic.mekanism.greater_than": "%s <",
"generic.mekanism.hex": "%s#",
"generic.mekanism.hours_minutes": "ɯ%2$s ɥ%1$s",
"generic.mekanism.less_than": "%s >",
"generic.mekanism.less_than_equal": "%s ⪖",
"generic.mekanism.list": "%s -",
"generic.mekanism.mb": "ᗺɯ %s",
"generic.mekanism.minutes": "ɯ%s",
Expand Down Expand Up @@ -1445,6 +1449,7 @@
"radial.mekanism.vein": "ᵷuᴉuᴉW uᴉǝΛ",
"radial.mekanism.vein.extended": "uᴉǝΛ pǝpuǝʇxƎ",
"radial.mekanism.vein.normal": "uᴉǝΛ",
"redstone_adapter.mekanism.toggle_signal": "uoᴉsɹǝʌuᴉ ꞁɐuᵷᴉs ʇndʇno ǝꞁᵷᵷo⟘",
"redstone_control.mekanism.disabled": "ᗡƎᴚON⅁I :uoᴉʇɔǝʇǝᗡ ǝuoʇspǝᴚ",
"redstone_control.mekanism.high": "ꞀⱯWᴚON :uoᴉʇɔǝʇǝᗡ ǝuoʇspǝᴚ",
"redstone_control.mekanism.low": "ᗡƎ⟘ᴚƎΛNI :uoᴉʇɔǝʇǝᗡ ǝuoʇspǝᴚ",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"advancements.mekanism.advanced_control_circuit.description": "Craft an Advanced Control Circuit",
"advancements.mekanism.advanced_control_circuit.title": "He's Really Advanced For His Age",
"advancements.mekanism.advanced_qio_drive.description": "Increase the storage bandwidth of your QIO Drive",
Expand Down Expand Up @@ -922,8 +922,12 @@
"gas_mode.mekanism.idle": "Idle",
"generic.mekanism.block_pos": "%1$s, %2$s, %3$s",
"generic.mekanism.fraction": "%1$s/%2$s",
"generic.mekanism.greater_equal": "≥ %1$s",
"generic.mekanism.greater_than": "> %1$s",
"generic.mekanism.hex": "#%1$s",
"generic.mekanism.hours_minutes": "%1$sh %2$sm",
"generic.mekanism.less_than": "< %1$s",
"generic.mekanism.less_than_equal": "≤ %1$s",
"generic.mekanism.list": "- %1$s",
"generic.mekanism.mb": "%1$s mB",
"generic.mekanism.minutes": "%1$sm",
Expand Down Expand Up @@ -1445,6 +1449,7 @@
"radial.mekanism.vein": "Vein Mining",
"radial.mekanism.vein.extended": "Extended Vein",
"radial.mekanism.vein.normal": "Vein",
"redstone_adapter.mekanism.toggle_signal": "Toggle output signal inversion",
"redstone_control.mekanism.disabled": "Redstone Detection: IGNORED",
"redstone_control.mekanism.high": "Redstone Detection: NORMAL",
"redstone_control.mekanism.low": "Redstone Detection: INVERTED",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3906,12 +3906,24 @@ methods:
returns:
javaType: long
type: Number (long)
- methodName: invertSignal
requiresPublicSecurity: true
- methodName: isInverted
returns:
javaType: boolean
type: boolean
- methodName: setFuzzyMode
params:
- javaType: boolean
name: fuzzy
type: boolean
requiresPublicSecurity: true
- methodName: setSignalInverted
params:
- javaType: boolean
name: inverted
type: boolean
requiresPublicSecurity: true
- methodName: setTargetItem
params:
- javaType: net.minecraft.resources.ResourceLocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,10 @@ QIO Redstone Adapter,clearTargetItem,,,,true,
QIO Redstone Adapter,getFuzzyMode,,boolean,,false,
QIO Redstone Adapter,getTargetItem,,Table (ItemStack),,false,
QIO Redstone Adapter,getTriggerAmount,,Number (long),,false,
QIO Redstone Adapter,invertSignal,,,,true,
QIO Redstone Adapter,isInverted,,boolean,,false,
QIO Redstone Adapter,setFuzzyMode,fuzzy: boolean,,,true,
QIO Redstone Adapter,setSignalInverted,inverted: boolean,,,true,
QIO Redstone Adapter,setTargetItem,itemName: String (ResourceLocation),,,true,
QIO Redstone Adapter,setTriggerAmount,amount: Number (long),,,true,
QIO Redstone Adapter,toggleFuzzyMode,,,,true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5787,6 +5787,17 @@
"javaType": "long"
}
},
{
"methodName": "invertSignal",
"requiresPublicSecurity": true
},
{
"methodName": "isInverted",
"returns": {
"type": "boolean",
"javaType": "boolean"
}
},
{
"methodName": "setFuzzyMode",
"params": [
Expand All @@ -5798,6 +5809,17 @@
],
"requiresPublicSecurity": true
},
{
"methodName": "setSignalInverted",
"params": [
{
"type": "boolean",
"javaType": "boolean",
"name": "inverted"
}
],
"requiresPublicSecurity": true
},
{
"methodName": "setTargetItem",
"params": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"source": "fuzzyMode",
"target": "mekanism:fuzzy"
},
{
"source": "inverse",
"target": "mekanism:inverse"
},
{
"source": "singleItem",
"target": "mekanism:item_target"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,8 @@ private void addMisc() {
add(MekanismLang.LIST_SORT_DESCENDING_DESC, "Sort items in descending order.");
add(MekanismLang.LIST_SEARCH, "Search:");
add(MekanismLang.LIST_SORT, "Sort:");
//QIO Redstone Adapter
add(MekanismLang.REDSTONE_ADAPTER_TOGGLE_SIGNAL, "Toggle output signal inversion");
//JEI
add(MekanismLang.JEI_AMOUNT_WITH_CAPACITY, "%1$s / %2$s mB");
add(MekanismLang.JEI_INFO_HEAVY_WATER, "%1$s mB of Heavy Water can be extracted from a water source block via an electric pump with a filter upgrade installed.");
Expand Down Expand Up @@ -762,6 +764,10 @@ private void addMisc() {
add(MekanismLang.GENERIC_LIST, "- %1$s");
add(MekanismLang.GENERIC_MINUTES, "%1$sm");
add(MekanismLang.GENERIC_HOURS_MINUTES, "%1$sh %2$sm");
add(MekanismLang.GENERIC_GREATER_THAN, "> %1$s");
add(MekanismLang.GENERIC_GREATER_EQUAL, "≥ %1$s");
add(MekanismLang.GENERIC_LESS_THAN, "< %1$s");
add(MekanismLang.GENERIC_LESS_THAN_EQUAL, "≤ %1$s");
//Directions
add(APILang.DOWN, "Down");
add(APILang.UP, "Up");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public void convert(String key, List<Component> splitEnglish) {
private static final String normal = "abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"0123456789" +
",.?!;\"'`&_^()[]{}<>";
",.?!;\"'`&_^()[]{}<>≤≥";
private static final char[] upside_down = ("ɐqɔpǝɟᵷɥᴉɾʞꞁɯuodbɹsʇnʌʍxʎz" +
"ⱯᗺƆᗡƎℲ⅁HIՐꞰꞀWNOԀꝹᴚS⟘∩ΛMX⅄Z" +
"0⥝ᘔƐ߈ϛ9ㄥ86" +
"'˙¿¡؛„,,⅋‾v)(][}{><").toCharArray();
"'˙¿¡؛„,,⅋‾v)(][}{><⪖⪕").toCharArray();

private static char flip(char c) {
int index = normal.indexOf(c);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import java.util.ArrayList;
import java.util.List;
import mekanism.api.text.ILangEntry;
import mekanism.client.gui.GuiMekanismTile;
import mekanism.client.gui.element.GuiInnerScreen;
import mekanism.client.gui.element.button.MekanismImageButton;
import mekanism.client.gui.element.button.ToggleButton;
import mekanism.client.gui.element.slot.GuiSlot;
import mekanism.client.gui.element.slot.SlotType;
import mekanism.client.gui.element.tab.GuiQIOFrequencyTab;
Expand Down Expand Up @@ -55,6 +57,8 @@ protected void addGuiElements() {
updateStack((ItemStack) ingredient);
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(MekanismSounds.BEEP, 1.0F));
});
addRenderableWidget(new ToggleButton(this, 9, 64, 14, tile::isInverted,
() -> PacketUtils.sendToServer(new PacketGuiInteract(GuiInteraction.INVERSE_BUTTON, tile)), getOnHover(MekanismLang.REDSTONE_ADAPTER_TOGGLE_SIGNAL)));
addRenderableWidget(new MekanismImageButton(this, 9, 80, 14, getButtonLocation("fuzzy"),
() -> PacketUtils.sendToServer(new PacketGuiInteract(GuiInteraction.QIO_REDSTONE_ADAPTER_FUZZY, tile)), getOnHover(MekanismLang.FUZZY_MODE)));
addRenderableWidget(new GuiInnerScreen(this, 7, 16, imageWidth - 15, 12, GuiQIOFilterHandler.getFrequencyText(tile))
Expand All @@ -63,7 +67,8 @@ protected void addGuiElements() {
List<Component> list = new ArrayList<>();
ItemStack itemType = tile.getItemType();
list.add(itemType.isEmpty() ? MekanismLang.QIO_ITEM_TYPE_UNDEFINED.translate() : itemType.getHoverName());
list.add(MekanismLang.QIO_TRIGGER_COUNT.translate(TextUtils.format(tile.getCount())));
ILangEntry match = tile.isInverted() ? MekanismLang.GENERIC_LESS_THAN : MekanismLang.GENERIC_GREATER_EQUAL;
list.add(MekanismLang.QIO_TRIGGER_COUNT.translate(match.translate(TextUtils.format(tile.getCount()))));
if (!itemType.isEmpty() && tile.getQIOFrequency() != null) {
list.add(MekanismLang.QIO_STORED_COUNT.translate(TextUtils.format(tile.getStoredCount())));
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/mekanism/common/MekanismLang.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public enum MekanismLang implements ILangEntry {
LIST_SORT_DESCENDING_DESC("qio", "sort_descending_desc"),
LIST_SEARCH("qio", "list_search"),
LIST_SORT("qio", "list_sort"),
//Adapter
REDSTONE_ADAPTER_TOGGLE_SIGNAL("redstone_adapter", "toggle_signal"),
//JEI
JEI_AMOUNT_WITH_CAPACITY("tooltip", "jei.amount.with.capacity"),
JEI_INFO_HEAVY_WATER("info", "jei.heavy_water"),
Expand Down Expand Up @@ -128,6 +130,10 @@ public enum MekanismLang implements ILangEntry {
GENERIC_LIST("generic", "list"),
GENERIC_MINUTES("generic", "minutes"),
GENERIC_HOURS_MINUTES("generic", "hours_minutes"),
GENERIC_GREATER_THAN("generic", "greater_than"),
GENERIC_GREATER_EQUAL("generic", "greater_equal"),
GENERIC_LESS_THAN("generic", "less_than"),
GENERIC_LESS_THAN_EQUAL("generic", "less_than_equal"),
//Hold for
HOLD_FOR_DETAILS("tooltip", "hold_for_details"),
HOLD_FOR_DESCRIPTION("tooltip", "hold_for_description"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ public enum GuiInteraction {//TODO: Cleanup this enum/the elements in it as it i
INVERSE_BUTTON((tile, player, extra) -> {
if (tile instanceof TileEntityDigitalMiner miner) {
miner.toggleInverse();
} else if (tile instanceof TileEntityQIORedstoneAdapter adapter) {
adapter.invertSignal();
}
}),
INVERSE_REQUIRES_REPLACEMENT_BUTTON((tile, player, extra) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class TileEntityQIORedstoneAdapter extends TileEntityQIOComponent {
@Nullable
private HashedItem itemType = null;
private boolean fuzzy;
private boolean inverted;
private long count = 0;
private long clientStoredCount = 0;

Expand Down Expand Up @@ -76,11 +77,23 @@ private void setFuzzyMode(boolean fuzzy) {
}
}

public void invertSignal() {
setSignalInverted(!inverted);
}

private void setSignalInverted(boolean inverted) {
if (this.inverted != inverted) {
this.inverted = inverted;
markForSave();
}
}

@Override
protected void onUpdateServer() {
super.onUpdateServer();
long stored = getFreqStored();
setActive(stored > 0 && stored >= count);
boolean hasStored = stored > 0 && stored >= count;
setActive(hasStored != inverted);
}

@Override
Expand All @@ -91,6 +104,7 @@ public void writeSustainedData(CompoundTag dataMap) {
}
dataMap.putLong(NBTConstants.AMOUNT, count);
dataMap.putBoolean(NBTConstants.FUZZY_MODE, fuzzy);
dataMap.putBoolean(NBTConstants.INVERSE, inverted);
}

@Override
Expand All @@ -99,6 +113,7 @@ public void readSustainedData(CompoundTag dataMap) {
NBTUtils.setItemStackIfPresent(dataMap, NBTConstants.SINGLE_ITEM, item -> itemType = HashedItem.create(item));
NBTUtils.setLongIfPresent(dataMap, NBTConstants.AMOUNT, value -> count = value);
NBTUtils.setBooleanIfPresent(dataMap, NBTConstants.FUZZY_MODE, value -> fuzzy = value);
NBTUtils.setBooleanIfPresent(dataMap, NBTConstants.INVERSE, value -> inverted = value);
}

@Override
Expand All @@ -107,6 +122,7 @@ public Map<String, Holder<AttachmentType<?>>> getTileDataAttachmentRemap() {
remap.put(NBTConstants.SINGLE_ITEM, MekanismAttachmentTypes.ITEM_TARGET);
remap.put(NBTConstants.AMOUNT, MekanismAttachmentTypes.LONG_AMOUNT);
remap.put(NBTConstants.FUZZY_MODE, MekanismAttachmentTypes.FUZZY);
remap.put(NBTConstants.INVERSE, MekanismAttachmentTypes.INVERSE);
return remap;
}

Expand All @@ -118,6 +134,7 @@ public void writeToStack(ItemStack stack) {
}
stack.setData(MekanismAttachmentTypes.LONG_AMOUNT, count);
stack.setData(MekanismAttachmentTypes.FUZZY, fuzzy);
stack.setData(MekanismAttachmentTypes.INVERSE, inverted);
}

@Override
Expand All @@ -129,6 +146,7 @@ public void readFromStack(ItemStack stack) {
.orElse(null);
count = stack.getData(MekanismAttachmentTypes.LONG_AMOUNT);
fuzzy = stack.getData(MekanismAttachmentTypes.FUZZY);
inverted = stack.getData(MekanismAttachmentTypes.INVERSE);
}

@ComputerMethod(nameOverride = "getTargetItem")
Expand All @@ -146,6 +164,11 @@ public boolean getFuzzyMode() {
return fuzzy;
}

@ComputerMethod
public boolean isInverted() {
return inverted;
}

public long getStoredCount() {
return clientStoredCount;
}
Expand All @@ -162,6 +185,7 @@ public void addContainerTrackers(MekanismContainer container) {
}));
container.track(SyncableLong.create(this::getCount, value -> count = value));
container.track(SyncableBoolean.create(this::getFuzzyMode, value -> fuzzy = value));
container.track(SyncableBoolean.create(this::isInverted, value -> inverted = value));
container.track(SyncableLong.create(this::getFreqStored, value -> clientStoredCount = value));
}

Expand Down Expand Up @@ -202,5 +226,17 @@ void computerSetFuzzyMode(boolean fuzzy) throws ComputerException {
validateSecurityIsPublic();
setFuzzyMode(fuzzy);
}

@ComputerMethod(nameOverride = "invertSignal", requiresPublicSecurity = true)
void computerInvertSignal() throws ComputerException {
validateSecurityIsPublic();
invertSignal();
}

@ComputerMethod(nameOverride = "setSignalInverted", requiresPublicSecurity = true)
void computerSetSignalInverted(boolean inverted) throws ComputerException {
validateSecurityIsPublic();
setSignalInverted(inverted);
}
//End methods IComputerTile
}

0 comments on commit fe1c679

Please sign in to comment.