Skip to content
Merged
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
@@ -0,0 +1,42 @@
package li.cil.ocreloaded.minecraft.common.item;

import java.util.UUID;

import li.cil.ocreloaded.core.component.GraphicsCardComponent;
import li.cil.ocreloaded.core.network.NetworkNode;
import li.cil.ocreloaded.core.network.NetworkNode.Visibility;
import li.cil.ocreloaded.core.network.NetworkNodes;
import net.minecraft.world.item.Item;

public class APUItem extends Item implements ProcessorProviderItem, ComponentItem {

//TODO: Move this to a conifg
public static int[][] TIER_RESOLUTIONS = new int[][] {
new int[] { 50, 16 },
new int[] { 80, 25 },
new int[] { 160, 50 },
};

public static int[] TIER_DEPTHS = new int[] { 1, 4, 8 };

private final int tier;

public APUItem(Properties properties, int tier) {
super(properties);
this.tier = tier;
}

@Override
public int getTier() {
return this.tier;
}

@Override
public NetworkNode newNetworkNode(UUID uuid) {
return NetworkNodes.component(
uuid,
node -> new GraphicsCardComponent(node, TIER_RESOLUTIONS[tier - 1], TIER_DEPTHS[tier - 1]),
Visibility.NEIGHBORS);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.world.item.Item;

public class CPUItem extends Item implements TieredItem {
public class CPUItem extends Item implements ProcessorProviderItem {

private final int tier;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package li.cil.ocreloaded.minecraft.common.item;

public interface CardItem extends TieredItem, ComponentItem, SlotItem {

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import li.cil.ocreloaded.core.network.NetworkNodes;
import net.minecraft.world.item.Item;

public class EepromItem extends Item implements ComponentItem {
public class EepromItem extends Item implements SlotItem, ComponentItem {
private static final Logger LOGGER = LoggerFactory.getLogger(EepromItem.class);

private final String defaultCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import li.cil.ocreloaded.core.machine.filesystem.FileSystemSupplierRegistry;
import net.minecraft.world.item.Item;

public class FloppyDiskItem extends Item implements ComponentItem {
public class FloppyDiskItem extends Item implements SlotItem, ComponentItem {

private static FileSystemSupplierRegistry fileSystemFactory = FileSystemSupplierRegistry.getDefaultInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import li.cil.ocreloaded.core.network.NetworkNodes;
import net.minecraft.world.item.Item;

public class GraphicsCardItem extends Item implements TieredItem, ComponentItem {
public class GraphicsCardItem extends Item implements CardItem {
//TODO: Move this to a conifg
public static int[][] TIER_RESOLUTIONS = new int[][] {
new int[] { 50, 16 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import li.cil.ocreloaded.core.machine.filesystem.FileSystemSupplierRegistry;
import net.minecraft.world.item.Item;

public class HardDiskItem extends Item implements TieredItem, ComponentItem {
public class HardDiskItem extends Item implements SlotItem, TieredItem, ComponentItem {

private static FileSystemSupplierRegistry fileSystemFactory = FileSystemSupplierRegistry.getDefaultInstance();

private final int tier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import net.minecraft.world.item.Item;

public class MemoryItem extends Item implements TieredItem {
public class MemoryItem extends Item implements SlotItem, TieredItem {

private final int tier;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package li.cil.ocreloaded.minecraft.common.item;

public interface ProcessorProviderItem extends TieredItem, SlotItem {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package li.cil.ocreloaded.minecraft.common.item;

public interface SlotItem {

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
import li.cil.ocreloaded.minecraft.common.assets.SharedTextures;
import li.cil.ocreloaded.minecraft.common.container.BasicContainer;
import li.cil.ocreloaded.minecraft.common.entity.CaseBlockEntity;
import li.cil.ocreloaded.minecraft.common.item.CPUItem;
import li.cil.ocreloaded.minecraft.common.item.CardItem;
import li.cil.ocreloaded.minecraft.common.item.EepromItem;
import li.cil.ocreloaded.minecraft.common.item.FloppyDiskItem;
import li.cil.ocreloaded.minecraft.common.item.GraphicsCardItem;
import li.cil.ocreloaded.minecraft.common.item.HardDiskItem;
import li.cil.ocreloaded.minecraft.common.item.MemoryItem;
import li.cil.ocreloaded.minecraft.common.item.ProcessorProviderItem;
import li.cil.ocreloaded.minecraft.common.item.SlotItem;
import li.cil.ocreloaded.minecraft.common.network.IPlatformNetworkHelper;
import li.cil.ocreloaded.minecraft.common.network.packets.PowerPacket;
import li.cil.ocreloaded.minecraft.common.registry.CommonRegistered;
Expand All @@ -25,45 +26,44 @@
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.DataSlot;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

public class CaseMenu extends AbstractContainerMenu {

private static final List<List<ComponentSlotEntry>> COMPONENT_SLOTS = List.of(
List.of(
new ComponentSlotEntry(0, 0, GraphicsCardItem.class, SharedTextures.CARD_ICON, 1),
new ComponentSlotEntry(0, 1, GraphicsCardItem.class, SharedTextures.CARD_ICON, 1),
new ComponentSlotEntry(1, 0, CPUItem.class, SharedTextures.CPU_ICON, 1),
new ComponentSlotEntry(0, 0, CardItem.class, SharedTextures.CARD_ICON, 1),
new ComponentSlotEntry(0, 1, CardItem.class, SharedTextures.CARD_ICON, 1),
new ComponentSlotEntry(1, 0, ProcessorProviderItem.class, SharedTextures.CPU_ICON, 1),
new ComponentSlotEntry(1, 1, MemoryItem.class, SharedTextures.MEMORY_ICON, 1),
new ComponentSlotEntry(1, 2, MemoryItem.class, SharedTextures.MEMORY_ICON, 1),
new ComponentSlotEntry(2, 0, HardDiskItem.class, SharedTextures.HDD_ICON, 1)
),
List.of(
new ComponentSlotEntry(0, 0, GraphicsCardItem.class, SharedTextures.CARD_ICON, 2),
new ComponentSlotEntry(0, 1, GraphicsCardItem.class, SharedTextures.CARD_ICON, 1),
new ComponentSlotEntry(1, 0, CPUItem.class, SharedTextures.CPU_ICON, 2),
new ComponentSlotEntry(0, 0, CardItem.class, SharedTextures.CARD_ICON, 2),
new ComponentSlotEntry(0, 1, CardItem.class, SharedTextures.CARD_ICON, 1),
new ComponentSlotEntry(1, 0, ProcessorProviderItem.class, SharedTextures.CPU_ICON, 2),
new ComponentSlotEntry(1, 1, MemoryItem.class, SharedTextures.MEMORY_ICON, 2),
new ComponentSlotEntry(1, 2, MemoryItem.class, SharedTextures.MEMORY_ICON, 2),
new ComponentSlotEntry(2, 0, HardDiskItem.class, SharedTextures.HDD_ICON, 2),
new ComponentSlotEntry(2, 1, HardDiskItem.class, SharedTextures.HDD_ICON, 1)
),
List.of(
new ComponentSlotEntry(0, 0, GraphicsCardItem.class, SharedTextures.CARD_ICON, 3),
new ComponentSlotEntry(0, 1, GraphicsCardItem.class, SharedTextures.CARD_ICON, 2),
new ComponentSlotEntry(0, 2, GraphicsCardItem.class, SharedTextures.CARD_ICON, 2),
new ComponentSlotEntry(1, 0, CPUItem.class, SharedTextures.CPU_ICON, 3),
new ComponentSlotEntry(0, 0, CardItem.class, SharedTextures.CARD_ICON, 3),
new ComponentSlotEntry(0, 1, CardItem.class, SharedTextures.CARD_ICON, 2),
new ComponentSlotEntry(0, 2, CardItem.class, SharedTextures.CARD_ICON, 2),
new ComponentSlotEntry(1, 0, ProcessorProviderItem.class, SharedTextures.CPU_ICON, 3),
new ComponentSlotEntry(1, 1, MemoryItem.class, SharedTextures.MEMORY_ICON, 3),
new ComponentSlotEntry(1, 2, MemoryItem.class, SharedTextures.MEMORY_ICON, 3),
new ComponentSlotEntry(2, 0, HardDiskItem.class, SharedTextures.HDD_ICON, 3),
new ComponentSlotEntry(2, 1, HardDiskItem.class, SharedTextures.HDD_ICON, 2),
new ComponentSlotEntry(2, 2, FloppyDiskItem.class, SharedTextures.FLOPPY_ICON, 1)
),
List.of(
new ComponentSlotEntry(0, 0, GraphicsCardItem.class, SharedTextures.CARD_ICON, 3),
new ComponentSlotEntry(0, 1, GraphicsCardItem.class, SharedTextures.CARD_ICON, 3),
new ComponentSlotEntry(0, 2, GraphicsCardItem.class, SharedTextures.CARD_ICON, 3),
new ComponentSlotEntry(1, 0, CPUItem.class, SharedTextures.CPU_ICON, 3),
new ComponentSlotEntry(0, 0, CardItem.class, SharedTextures.CARD_ICON, 3),
new ComponentSlotEntry(0, 1, CardItem.class, SharedTextures.CARD_ICON, 3),
new ComponentSlotEntry(0, 2, CardItem.class, SharedTextures.CARD_ICON, 3),
new ComponentSlotEntry(1, 0, ProcessorProviderItem.class, SharedTextures.CPU_ICON, 3),
new ComponentSlotEntry(1, 1, MemoryItem.class, SharedTextures.MEMORY_ICON, 3),
new ComponentSlotEntry(1, 2, MemoryItem.class, SharedTextures.MEMORY_ICON, 3),
new ComponentSlotEntry(2, 0, HardDiskItem.class, SharedTextures.HDD_ICON, 3),
Expand Down Expand Up @@ -157,6 +157,6 @@ private void addComponentSlot(ComponentSlotEntry entry) {
entry.teir()));
}

private record ComponentSlotEntry(int x, int y, Class<? extends Item> itemClass, ResourceLocation texture, int teir) { }
private record ComponentSlotEntry(int x, int y, Class<? extends SlotItem> itemClass, ResourceLocation texture, int teir) { }

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

import javax.annotation.Nonnull;

import li.cil.ocreloaded.minecraft.common.item.SlotItem;
import li.cil.ocreloaded.minecraft.common.item.TieredItem;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;

public class ComponentSlot extends Slot {

private final Class<? extends Item> itemClass;
private final Class<? extends SlotItem> itemClass;
private final ResourceLocation texture;
private final int teir;

public ComponentSlot(Container container, int index, int x, int y, Class<? extends Item> itemClass, ResourceLocation texture, int tier) {
public ComponentSlot(Container container, int index, int x, int y, Class<? extends SlotItem> itemClass, ResourceLocation texture, int tier) {
super(container, index, x, y);
this.itemClass = itemClass;
this.texture = texture;
this.teir = tier;
}

public ComponentSlot(Container container, int index, int x, int y, Class<? extends Item> itemClass, ResourceLocation texture) {
public ComponentSlot(Container container, int index, int x, int y, Class<? extends SlotItem> itemClass, ResourceLocation texture) {
this(container, index, x, y, itemClass, texture, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import li.cil.ocreloaded.minecraft.common.entity.CaseBlockEntity;
import li.cil.ocreloaded.minecraft.common.entity.KeyboardBlockEntity;
import li.cil.ocreloaded.minecraft.common.entity.ScreenBlockEntity;
import li.cil.ocreloaded.minecraft.common.item.APUItem;
import li.cil.ocreloaded.minecraft.common.item.CPUItem;
import li.cil.ocreloaded.minecraft.common.item.DataCardItem;
import li.cil.ocreloaded.minecraft.common.item.EepromItem;
Expand Down Expand Up @@ -51,10 +52,6 @@ public class CommonRegistered {

public static void initialize() {
NetworkUtil.initialize();

/*NetworkUtil.getInstance().registerHandler("ocreloaded:power", new PowerNetworkHandler());
NetworkUtil.getInstance().registerHandler("ocreloaded:screen", new ScreenNetworkHandler());
NetworkUtil.getInstance().registerHandler("ocreloaded:sound", new SoundNetworkHandler());*/
}

// Creative mode tabs
Expand Down Expand Up @@ -106,9 +103,9 @@ public static void initialize() {

public static final RegistryObject<Item, Item> DISK = registerItem("disk", () -> new Item(DEFAULT_ITEM_PROPERTIES));

public static final RegistryObject<Item, Item> CHIP_TIER_1 = registerItem("chip1", () -> new CPUItem(DEFAULT_ITEM_PROPERTIES, 1));
public static final RegistryObject<Item, Item> CHIP_TIER_2 = registerItem("chip2", () -> new CPUItem(DEFAULT_ITEM_PROPERTIES, 2));
public static final RegistryObject<Item, Item> CHIP_TIER_3 = registerItem("chip3", () -> new CPUItem(DEFAULT_ITEM_PROPERTIES, 3));
public static final RegistryObject<Item, Item> CHIP_TIER_1 = registerItem("chip1", () -> new Item(DEFAULT_ITEM_PROPERTIES));
public static final RegistryObject<Item, Item> CHIP_TIER_2 = registerItem("chip2", () -> new Item(DEFAULT_ITEM_PROPERTIES));
public static final RegistryObject<Item, Item> CHIP_TIER_3 = registerItem("chip3", () -> new Item(DEFAULT_ITEM_PROPERTIES));

public static final RegistryObject<Item, Item> NUMPAD = registerItem("numpad", () -> new Item(DEFAULT_ITEM_PROPERTIES));

Expand All @@ -118,6 +115,10 @@ public static void initialize() {
public static final RegistryObject<Item, Item> TRANSISTOR = registerItem("transistor", () -> new Item(DEFAULT_ITEM_PROPERTIES));
public static final RegistryObject<Item, Item> MANUAL = registerItem("manual", () -> new ManualItem(DEFAULT_ITEM_PROPERTIES));

public static final RegistryObject<Item, Item> APU_TIER_1 = registerItem("apu1", () -> new APUItem(DEFAULT_ITEM_PROPERTIES, 2));
public static final RegistryObject<Item, Item> APU_TIER_2 = registerItem("apu2", () -> new APUItem(DEFAULT_ITEM_PROPERTIES, 3));
public static final RegistryObject<Item, Item> APU_TIER_3 = registerItem("apucreative", () -> new APUItem(DEFAULT_ITEM_PROPERTIES, 3));

public static final RegistryObject<Item, Item> CPU_TIER_1 = registerItem("cpu1", () -> new CPUItem(DEFAULT_ITEM_PROPERTIES, 1));
public static final RegistryObject<Item, Item> CPU_TIER_2 = registerItem("cpu2", () -> new CPUItem(DEFAULT_ITEM_PROPERTIES, 2));
public static final RegistryObject<Item, Item> CPU_TIER_3 = registerItem("cpu3", () -> new CPUItem(DEFAULT_ITEM_PROPERTIES, 3));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"gui.ocreloaded.case.power_on": "Turn on",
"gui.ocreloaded.case.power_on_line2": "§7Use an Analyzer to troubleshoot errors.§r",
"item.ocreloaded.alu": "Arithmetic Logic Unit (ALU)",
"item.ocreloaded.apu1": "Accelerated Processing Unit (APU) (Tier 2)",
"item.ocreloaded.apu2": "Accelerated Processing Unit (APU) (Tier 3)",
"item.ocreloaded.apucreative": "Accelerated Processing Unit (APU) (Creative)",
"item.ocreloaded.arrow_keys": "Arrow Keys",
"item.ocreloaded.button_group": "Button Group",
"item.ocreloaded.card": "Card Base",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "ocreloaded:item/apu1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "ocreloaded:item/apu2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "ocreloaded:item/apucreative"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"animation": {
"frametime": 1,
"frames": [
{ "index": 0, "time": 3 },
{ "index": 1, "time": 3 },
{ "index": 2, "time": 3 },
{ "index": 3, "time": 3 },
{ "index": 4, "time": 3 },
{ "index": 5, "time": 3 },
{ "index": 4, "time": 3 },
{ "index": 3, "time": 3 },
{ "index": 2, "time": 3 },
{ "index": 1, "time": 3 },
{ "index": 0, "time": 3 }
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"animation": {
"frametime": 1,
"frames": [
{ "index": 0, "time": 3 },
{ "index": 1, "time": 3 },
{ "index": 2, "time": 3 },
{ "index": 3, "time": 3 },
{ "index": 4, "time": 3 },
{ "index": 5, "time": 3 },
{ "index": 4, "time": 3 },
{ "index": 3, "time": 3 },
{ "index": 2, "time": 3 },
{ "index": 1, "time": 3 },
{ "index": 0, "time": 3 }
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"animation": {
"frametime": 1,
"frames": [
{ "index": 0, "time": 3 },
{ "index": 1, "time": 3 },
{ "index": 2, "time": 3 },
{ "index": 3, "time": 3 },
{ "index": 4, "time": 3 },
{ "index": 5, "time": 3 },
{ "index": 4, "time": 3 },
{ "index": 3, "time": 3 },
{ "index": 2, "time": 3 },
{ "index": 1, "time": 3 },
{ "index": 0, "time": 3 }
]
}
}
Loading