Skip to content

Commit

Permalink
Added missing localization and added IItemHandler support to ModularSlot
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon3055 committed Feb 13, 2024
1 parent ad0cc61 commit c59e0a7
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// 1.20.1 2023-09-08T20:35:35.335872512 codechickenlib Languages: en_us
ce1ce42a962941336b9de69689e94a97219ad7d9 assets/codechickenlib/lang/en_us.json
ce1ce42a962941336b9de69689e94a97219ad7d9 data/codechickenlib/lang/en_us.json
// 1.20.1 2024-02-13T15:00:40.20834201 codechickenlib Languages: en_us
d535acbe9649e564744ed63aef209ce1508ec451 assets/codechickenlib/lang/en_us.json
d535acbe9649e564744ed63aef209ce1508ec451 data/codechickenlib/lang/en_us.json
11 changes: 10 additions & 1 deletion src/main/generated/assets/codechickenlib/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@
"ccl.commands.killall.fail": "Found no entities.",
"ccl.commands.killall.fail.player": "You cannot kill players with this command.",
"ccl.commands.killall.success": "Killed %s entities.",
"ccl.commands.killall.success.line": "Killed %s"
"ccl.commands.killall.success.line": "Killed %s",
"ccl.energy_bar.capacity": "Capacity:",
"ccl.energy_bar.energy_storage": "Energy Storage",
"ccl.energy_bar.rf": "RF",
"ccl.energy_bar.stored": "Stored:",
"ccl.fluid_tank.capacity": "Capacity:",
"ccl.fluid_tank.contains": "Contains:",
"ccl.fluid_tank.fluid_storage": "Fluid Storage",
"ccl.fluid_tank.mb": "mB",
"ccl.fluid_tank.stored": "Stored:"
}
11 changes: 10 additions & 1 deletion src/main/generated/data/codechickenlib/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@
"ccl.commands.killall.fail": "Found no entities.",
"ccl.commands.killall.fail.player": "You cannot kill players with this command.",
"ccl.commands.killall.success": "Killed %s entities.",
"ccl.commands.killall.success.line": "Killed %s"
"ccl.commands.killall.success.line": "Killed %s",
"ccl.energy_bar.capacity": "Capacity:",
"ccl.energy_bar.energy_storage": "Energy Storage",
"ccl.energy_bar.rf": "RF",
"ccl.energy_bar.stored": "Stored:",
"ccl.fluid_tank.capacity": "Capacity:",
"ccl.fluid_tank.contains": "Contains:",
"ccl.fluid_tank.fluid_storage": "Fluid Storage",
"ccl.fluid_tank.mb": "mB",
"ccl.fluid_tank.stored": "Stored:"
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,27 @@ public static EnergyBar simpleBar(@NotNull GuiParent<?> parent) {
public static BiFunction<Long, Long, List<Component>> defaultFormatter() {
return (energy, capacity) -> {
List<Component> tooltip = new ArrayList<>();
tooltip.add(Component.translatable("energy_bar.polylib.energy_storage").withStyle(DARK_AQUA));
tooltip.add(Component.translatable("ccl.energy_bar.energy_storage").withStyle(DARK_AQUA));
boolean shift = Screen.hasShiftDown();
tooltip.add(Component.translatable("energy_bar.polylib.capacity")
tooltip.add(Component.translatable("ccl.energy_bar.capacity")
.withStyle(GOLD)
.append(" ")
.append(Component.literal(shift ? FormatUtil.addCommas(capacity) : FormatUtil.formatNumber(capacity))
.withStyle(GRAY)
.append(" ")
.append(Component.translatable("energy_bar.polylib.rf")
.append(Component.translatable("ccl.energy_bar.rf")
.withStyle(GRAY)
)
)
);
tooltip.add(Component.translatable("energy_bar.polylib.stored")
tooltip.add(Component.translatable("ccl.energy_bar.stored")
.withStyle(GOLD)
.append(" ")
.append(Component.literal(shift ? FormatUtil.addCommas(energy) : FormatUtil.formatNumber(energy))
.withStyle(GRAY)
)
.append(" ")
.append(Component.translatable("energy_bar.polylib.rf")
.append(Component.translatable("ccl.energy_bar.rf")
.withStyle(GRAY)
)
.append(Component.literal(String.format(" (%.2f%%)", ((double) energy / (double) capacity) * 100D))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ private double computeGaugeSpacing() {
public static BiFunction<FluidStack, Long, List<Component>> defaultFormatter() {
return (fluidStack, capacity) -> {
List<Component> tooltip = new ArrayList<>();
tooltip.add(Component.translatable("fluid_tank.polylib.fluid_storage").withStyle(DARK_AQUA));
tooltip.add(Component.translatable("ccl.fluid_tank.fluid_storage").withStyle(DARK_AQUA));
if (!fluidStack.isEmpty()) {
tooltip.add(Component.translatable("fluid_tank.polylib.contains")
tooltip.add(Component.translatable("ccl.fluid_tank.contains")
.withStyle(GOLD)
.append(" ")
.append(fluidStack.getDisplayName().copy()
Expand All @@ -195,25 +195,25 @@ public static BiFunction<FluidStack, Long, List<Component>> defaultFormatter() {
);
}

tooltip.add(Component.translatable("fluid_tank.polylib.capacity")
tooltip.add(Component.translatable("ccl.fluid_tank.capacity")
.withStyle(GOLD)
.append(" ")
.append(Component.literal(FormatUtil.addCommas(capacity))
.withStyle(GRAY)
.append(" ")
.append(Component.translatable("fluid_tank.polylib.mb")
.append(Component.translatable("ccl.fluid_tank.mb")
.withStyle(GRAY)
)
)
);
tooltip.add(Component.translatable("fluid_tank.polylib.stored")
tooltip.add(Component.translatable("ccl.fluid_tank.stored")
.withStyle(GOLD)
.append(" ")
.append(Component.literal(FormatUtil.addCommas(fluidStack.getAmount()))
.withStyle(GRAY)
)
.append(" ")
.append(Component.translatable("fluid_tank.polylib.mb")
.append(Component.translatable("ccl.fluid_tank.mb")
.withStyle(GRAY)
)
.append(Component.literal(String.format(" (%.2f%%)", ((double) fluidStack.getAmount() / (double) capacity) * 100D))
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/codechicken/lib/internal/DataGenerators.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ protected void addTranslations() {
addServer("ccl.commands.killall.success.line", "Killed %s");
addServer("ccl.commands.count.fail", "Found no entities.");
addServer("ccl.commands.count.total", "Found %s entities.");

addServer("ccl.energy_bar.energy_storage", "Energy Storage");
addServer("ccl.energy_bar.capacity", "Capacity:");
addServer("ccl.energy_bar.stored", "Stored:");
addServer("ccl.energy_bar.rf", "RF");
addServer("ccl.fluid_tank.fluid_storage", "Fluid Storage");
addServer("ccl.fluid_tank.capacity", "Capacity:");
addServer("ccl.fluid_tank.stored", "Stored:");
addServer("ccl.fluid_tank.mb", "mB");
addServer("ccl.fluid_tank.contains", "Contains:");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler;
import net.minecraftforge.items.wrapper.InvWrapper;

import java.util.function.*;

Expand All @@ -13,7 +16,7 @@
* <p>
* Created by brandon3055 on 10/09/2023
*/
public class ModularSlot extends Slot {
public class ModularSlot extends SlotItemHandler {
private boolean canPlace = true;
private boolean checkContainer = true;
private Supplier<Boolean> enabled = () -> true;
Expand All @@ -23,11 +26,19 @@ public class ModularSlot extends Slot {
private BiConsumer<ItemStack, ItemStack> onSet = (oldStack, newStack) -> {};

public ModularSlot(Container container, int index) {
this(container, index, 0, 0);
this(new InvWrapper(container), index, 0, 0);
}

public ModularSlot(IItemHandler itemHandler, int index) {
this(itemHandler, index, 0, 0);
}

public ModularSlot(Container container, int index, int xPos, int yPos) {
super(container, index, xPos, yPos);
super(new InvWrapper(container), index, xPos, yPos);
}

public ModularSlot(IItemHandler itemHandler, int index, int xPos, int yPos) {
super(itemHandler, index, xPos, yPos);
}

/**
Expand Down

0 comments on commit c59e0a7

Please sign in to comment.