Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"chars": [
"a"
],
"file": "little_big_redstone:font/logic/pulse_throttler.png",
"file": "little_big_redstone:font/logic/sequencer.png",
"height": 7
},
{
Expand All @@ -15,7 +15,7 @@
"chars": [
"b"
],
"file": "little_big_redstone:font/logic/selector.png",
"file": "little_big_redstone:font/logic/pulse_throttler.png",
"height": 7
},
{
Expand All @@ -24,7 +24,7 @@
"chars": [
"c"
],
"file": "little_big_redstone:font/logic/randomizer.png",
"file": "little_big_redstone:font/logic/selector.png",
"height": 7
},
{
Expand All @@ -33,7 +33,7 @@
"chars": [
"d"
],
"file": "little_big_redstone:font/logic/t_flip_flop.png",
"file": "little_big_redstone:font/logic/randomizer.png",
"height": 7
},
{
Expand All @@ -42,6 +42,15 @@
"chars": [
"e"
],
"file": "little_big_redstone:font/logic/t_flip_flop.png",
"height": 7
},
{
"type": "bitmap",
"ascent": 7,
"chars": [
"f"
],
"file": "little_big_redstone:font/logic/rs_nor_latch.png",
"height": 7
},
Expand Down Expand Up @@ -123,7 +132,7 @@
"chars": [
"8"
],
"file": "little_big_redstone:font/logic/reader.png",
"file": "little_big_redstone:font/logic/calculator.png",
"height": 7
},
{
Expand All @@ -132,7 +141,7 @@
"chars": [
"9"
],
"file": "little_big_redstone:font/logic/sequencer.png",
"file": "little_big_redstone:font/logic/reader.png",
"height": 7
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"item.little_big_redstone.brown_floppy_disk": "Brown Floppy Disk",
"item.little_big_redstone.brown_logic_array": "Brown Logic Array",
"item.little_big_redstone.brown_sticky_note": "Brown Sticky Note",
"item.little_big_redstone.calculator": "Calculator",
"item.little_big_redstone.cyan_floppy_disk": "Cyan Floppy Disk",
"item.little_big_redstone.cyan_logic_array": "Cyan Logic Array",
"item.little_big_redstone.cyan_sticky_note": "Cyan Sticky Note",
Expand Down Expand Up @@ -133,6 +134,8 @@
"text.little_big_redstone.logic_config_button_label_sequencer_reset_port": "Reset Port",
"text.little_big_redstone.logic_config_button_label_ticks_and_seconds": "%s ticks (%ss)",
"text.little_big_redstone.logic_config_button_label_ticks_and_seconds_singular": "%s tick (%ss)",
"text.little_big_redstone.logic_config_button_tooltip_calculator_addition": "The output will be the sum of all of the inputs.",
"text.little_big_redstone.logic_config_button_tooltip_calculator_subtraction": "The output will be the difference of all of the inputs.",
"text.little_big_redstone.logic_config_button_tooltip_duration": "The time for the output to be on.",
"text.little_big_redstone.logic_config_button_tooltip_inputs": "The number of inputs that this component can accept.",
"text.little_big_redstone.logic_config_button_tooltip_io_direction": "The direction this port should interact with redstone power on.",
Expand All @@ -159,6 +162,8 @@
"text.little_big_redstone.logic_config_button_tooltip_sequencer_mode_strong": "While input is ON, the sequencer will increment until it has met X ticks and then emit an output of ON. While input is OFF, the sequencer will decrement.",
"text.little_big_redstone.logic_config_button_tooltip_sequencer_mode_weak": "After an ON input signal, the sequencer will wait X ticks and then emit an output of ON.",
"text.little_big_redstone.logic_config_button_tooltip_sequencer_reset_port": "Whether a second wire port should be added that will forcefully reset the sequencer's progress.",
"text.little_big_redstone.logic_config_math_operation_addition": "Addition",
"text.little_big_redstone.logic_config_math_operation_subtraction": "Subtraction",
"text.little_big_redstone.logic_config_selector_mode_counter": "Counter",
"text.little_big_redstone.logic_config_selector_mode_setter": "Setter",
"text.little_big_redstone.logic_config_sequencer_mode_counter": "Counter",
Expand All @@ -171,6 +176,7 @@
"text.little_big_redstone.logic_config_tooltip_duration": " Duration: %d",
"text.little_big_redstone.logic_config_tooltip_inputs": " Inputs: %s",
"text.little_big_redstone.logic_config_tooltip_io_signal": " Signal: %s",
"text.little_big_redstone.logic_config_tooltip_math_operation": " Operation: %s",
"text.little_big_redstone.logic_config_tooltip_mode": " Mode: %s",
"text.little_big_redstone.logic_config_tooltip_outputs": " Outputs: %s",
"text.little_big_redstone.logic_config_tooltip_reader_fill": " Fill: %s",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"parent": "minecraft:item/generated",
"board_textures": {
"addition": "little_big_redstone:logic/calculator_addition",
"background": "little_big_redstone:logic/background_square",
"border": "little_big_redstone:logic/border_square",
"subtraction": "little_big_redstone:logic/calculator_subtraction"
},
"color_palette": {
"black": {
"background": "ff000000",
"foreground": "ff726d81"
},
"blue": {
"background": "ff000000",
"foreground": "ff4ba6f1"
},
"brown": {
"background": "ff000000",
"foreground": "ffc66a1a"
},
"cyan": {
"background": "ff000000",
"foreground": "ff47d5af"
},
"gray": {
"background": "ff000000",
"foreground": "ffa8abbf"
},
"green": {
"background": "ff000000",
"foreground": "ff18af2f"
},
"light_blue": {
"background": "ff000000",
"foreground": "ff6ae4ff"
},
"light_gray": {
"background": "ff000000",
"foreground": "ffc5d2e0"
},
"lime": {
"background": "ff000000",
"foreground": "ffa4eb00"
},
"magenta": {
"background": "ff000000",
"foreground": "ffff80f7"
},
"orange": {
"background": "ff000000",
"foreground": "ffff920f"
},
"pink": {
"background": "ff000000",
"foreground": "ffffb8ea"
},
"purple": {
"background": "ff000000",
"foreground": "ffd857ff"
},
"red": {
"background": "ff000000",
"foreground": "ffff0000"
},
"white": {
"background": "ff000000",
"foreground": "ffeff5ff"
},
"yellow": {
"background": "ff000000",
"foreground": "ffffe800"
}
},
"item_textures": {
"background": "little_big_redstone:item/logic_background_square",
"border": "little_big_redstone:item/logic_border_square",
"icon": "little_big_redstone:item/calculator"
},
"loader": "little_big_redstone:logic"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"G": {
"tag": "c:ingots/gold"
},
"Q": {
"tag": "c:gems/quartz"
},
"R": {
"tag": "c:dusts/redstone"
},
"r": {
"item": "little_big_redstone:redstone_bit"
}
},
"pattern": [
"GG ",
"QrR",
"GG "
],
"result": {
"count": 1,
"id": "little_big_redstone:calculator"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"values": [
"little_big_redstone:and_gate",
"little_big_redstone:calculator",
"little_big_redstone:debugger",
"little_big_redstone:io",
"little_big_redstone:nand_gate",
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/swedz/little_big_redstone/LBRText.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public enum LBRText implements TranslatableTextEnum
LOGIC_CONFIG_BUTTON_TOOLTIP_IO_SIGNAL_COMPARISON_MODE_GREATER_THAN_OR_EQUAL_TO("The input signal must be greater than or equal to %s."),
LOGIC_CONFIG_BUTTON_TOOLTIP_IO_SIGNAL_COMPARISON_MODE_LESS_THAN_OR_EQUAL_TO("The input signal must be less than or equal to %s."),
LOGIC_CONFIG_BUTTON_TOOLTIP_IO_SIGNAL_COMPARISON_OUTPUT("The output signal will be equal to %s."),
LOGIC_CONFIG_BUTTON_TOOLTIP_CALCULATOR_ADDITION("The output will be the sum of all of the inputs."),
LOGIC_CONFIG_BUTTON_TOOLTIP_CALCULATOR_SUBTRACTION("The output will be the difference of all of the inputs."),
LOGIC_CONFIG_BUTTON_TOOLTIP_IO_SIGNAL_STRENGTH_INPUT("The redstone signal strength required for the output to be on."),
LOGIC_CONFIG_BUTTON_TOOLTIP_IO_SIGNAL_STRENGTH_OUTPUT("The redstone signal strength that will be outputted."),
LOGIC_CONFIG_BUTTON_TOOLTIP_OUTPUTS("The number of outputs that this component can yield."),
Expand Down Expand Up @@ -94,6 +96,9 @@ public enum LBRText implements TranslatableTextEnum
LOGIC_CONFIG_TOOLTIP_DIRECTION(" Direction: %s"),
LOGIC_CONFIG_TOOLTIP_DURATION(" Duration: %d"),
LOGIC_CONFIG_TOOLTIP_INPUTS(" Inputs: %s"),
LOGIC_CONFIG_TOOLTIP_MATH_OPERATION(" Operation: %s"),
LOGIC_CONFIG_MATH_OPERATION_ADDITION("Addition"),
LOGIC_CONFIG_MATH_OPERATION_SUBTRACTION("Subtraction"),
LOGIC_CONFIG_TOOLTIP_IO_SIGNAL(" Signal: %s"),
LOGIC_CONFIG_TOOLTIP_MODE(" Mode: %s"),
LOGIC_CONFIG_TOOLTIP_OUTPUTS(" Outputs: %s"),
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/net/swedz/little_big_redstone/LBRTooltips.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextColor;
import net.swedz.little_big_redstone.microchip.object.logic.config.LogicComparisonMode;
import net.swedz.little_big_redstone.microchip.object.logic.math.MathOperationType;
import net.swedz.little_big_redstone.microchip.object.logic.reader.LogicReaderMode;
import net.swedz.little_big_redstone.microchip.object.logic.selector.LogicSelectorMode;
import net.swedz.little_big_redstone.microchip.object.logic.sequencer.LogicSequencerMode;
Expand Down Expand Up @@ -50,6 +51,12 @@ public static Style directionStyle(Direction direction)
case EAST -> LBRText.DIRECTION_EAST;
}).text().withStyle(directionStyle(direction));

public static final Parser<MathOperationType> MATH_OPERATION_PARSER = (type) -> (switch (type)
{
case ADDITION -> LBRText.LOGIC_CONFIG_MATH_OPERATION_ADDITION;
case SUBTRACTION -> LBRText.LOGIC_CONFIG_MATH_OPERATION_SUBTRACTION;
}).text().withStyle(HIGHLIGHT_STYLE);

public static final Parser<Boolean> BOOLEAN_YES_NO_PARSER = (value) -> value ? LBRText.YES.text().withStyle(YES_STYLE) : LBRText.NO.text().withStyle(NO_STYLE);

public static final Parser<LogicReaderMode> READER_MODE_PARSER = (value) -> (switch (value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.swedz.little_big_redstone.client.model.logic.LogicBakingModelData;
import net.swedz.little_big_redstone.microchip.object.logic.LogicType;
import net.swedz.little_big_redstone.microchip.object.logic.LogicTypes;
import net.swedz.little_big_redstone.microchip.object.logic.math.MathOperationType;

import java.util.Locale;
import java.util.Set;
Expand Down Expand Up @@ -40,6 +41,14 @@ private void registerLogicModels()
this.logicComponent(LogicTypes.NOR, BackgroundType.SQUARE, true);
this.logicComponent(LogicTypes.XOR, BackgroundType.SQUARE, true);

this.logicComponent(LogicTypes.CALCULATOR, BackgroundType.SQUARE, false, (b) ->
{
for(var type : MathOperationType.values())
{
b.boardTexture(type.textureName(), LBR.id("logic/calculator_%s".formatted(type.textureName())));
}
});

this.logicComponent(LogicTypes.READER, BackgroundType.CIRCLE, true);

this.logicComponent(LogicTypes.SEQUENCER, BackgroundType.SQUARE, false, (b) -> b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ protected void buildRecipes(RecipeOutput output, HolderLookup.Provider registrie
.define('1', LBRItems.valueOf("and_gate"))
.define('2', LBRItems.valueOf("nor_gate")));

logicComponent(output, LogicTypes.CALCULATOR, (b) -> b
.pattern("GG ")
.pattern("QrR")
.pattern("GG "));

logicComponent(output, LogicTypes.READER, (b) -> b
.pattern("R ")
.pattern("QrR")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import net.swedz.little_big_redstone.LBR;
import net.swedz.little_big_redstone.gui.microchip.logic.renderer.IORenderer;
import net.swedz.little_big_redstone.gui.microchip.logic.renderer.CalculatorLogicRenderer;
import net.swedz.little_big_redstone.gui.microchip.logic.renderer.OnOffLogicRenderer;
import net.swedz.little_big_redstone.gui.microchip.logic.renderer.SequencerRenderer;
import net.swedz.little_big_redstone.gui.microchip.logic.renderer.SimpleLogicRenderer;
Expand Down Expand Up @@ -32,6 +34,8 @@ public final class LogicRenderers
register(LogicTypes.NOR, SimpleLogicRenderer::new);
register(LogicTypes.XOR, SimpleLogicRenderer::new);

register(LogicTypes.CALCULATOR, CalculatorLogicRenderer::new);

register(LogicTypes.READER, SimpleLogicRenderer::new);

register(LogicTypes.SEQUENCER, SequencerRenderer::new);
Expand All @@ -46,6 +50,24 @@ public final class LogicRenderers
public static void init()
{
RENDERERS = createRenderers();
assertAllTypesAreRegistered();
}

private static void assertAllTypesAreRegistered()
{
boolean missing = false;
for(var type : LogicTypes.values())
{
if(!RENDERERS.containsKey(type))
{
missing = true;
LBR.LOGGER.error("Did not register renderer for logic type {}, did you forget?", type.id());
}
}
if(missing)
{
throw new IllegalStateException("Missing renderers for some logic types");
}
}

private static <L extends LogicComponent> void register(LogicType<L> type, LogicRendererProvider<L> provider)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package net.swedz.little_big_redstone.gui.microchip.logic.renderer;

import net.swedz.little_big_redstone.LBR;
import net.swedz.little_big_redstone.LBRClientShaders;
import net.swedz.little_big_redstone.gui.microchip.logic.LogicRenderer;
import net.swedz.little_big_redstone.microchip.object.logic.math.Calculator;
import net.swedz.tesseract.neoforge.helper.guigraphics.TesseractGuiGraphics;

public final class CalculatorLogicRenderer extends LogicRenderer<Calculator>
{
@Override
public void render(Context context, TesseractGuiGraphics graphics, Calculator component, int x, int y)
{
var size = component.size();

this.renderAllPorts(context, graphics, x, y, component, 1, 1, 1);
this.renderBackground(context, graphics, x, y, component);

graphics.setColor(context.foregroundColor());
graphics.setTextureShader(
LBRClientShaders::logicScanline,
(shader) -> shader.getUniform("LogicUV").set(16f, 16f)
);
graphics.setTextures(
context.getTexture(component.config().operation.textureName()),
LBR.id("textures/logic/scanline.png")
);
int centerX = x + size.centerX() - 8;
int centerY = y + size.centerY() - 8;
graphics.blit(centerX, centerY, 0, 0, 16, 16, 16, 16);
graphics.resetTextureShader();
graphics.resetColor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void render(Context context, TesseractGuiGraphics graphics, L component,
(shader) -> shader.getUniform("LogicUV").set(16f, 16f)
);
graphics.setTextures(
context.getTexture(component.output(0) ? "on" : "off"),
context.getTexture(component.output(0) > 0 ? "on" : "off"),
LBR.id("textures/logic/scanline.png")
);
int centerX = x + size.centerX() - 8;
Expand Down
Loading