Always craft computer with built-in flash.

This commit is contained in:
Florian Nücke
2021-07-17 15:24:55 +02:00
parent 7d3e7941b6
commit b97bdfea69
3 changed files with 34 additions and 7 deletions

View File

@@ -47,6 +47,7 @@ import java.util.List;
import static li.cil.oc2.common.Constants.BLOCK_ENTITY_TAG_NAME_IN_ITEM;
import static li.cil.oc2.common.Constants.ITEMS_TAG_NAME;
import static li.cil.oc2.common.util.NBTUtils.makeInventoryTag;
import static li.cil.oc2.common.util.TranslationUtils.text;
public final class ComputerBlock extends HorizontalBlock {
// We bake the "screen" indent on the front into the collision shape to prevent stuff being
@@ -76,8 +77,7 @@ public final class ComputerBlock extends HorizontalBlock {
@Override
public void fillItemCategory(final ItemGroup group, final NonNullList<ItemStack> items) {
super.fillItemCategory(group, items);
items.add(getComputerWithFlash());
items.add(getPreconfiguredComputer());
}
@@ -218,11 +218,23 @@ public final class ComputerBlock extends HorizontalBlock {
///////////////////////////////////////////////////////////////////
private ItemStack getComputerWithFlash() {
final ItemStack computer = new ItemStack(this);
final CompoundNBT itemsTag = NBTUtils.getOrCreateChildTag(computer.getOrCreateTag(), BLOCK_ENTITY_TAG_NAME_IN_ITEM, ITEMS_TAG_NAME);
itemsTag.put(DeviceTypes.FLASH_MEMORY.getRegistryName().toString(), makeInventoryTag(
new ItemStack(Items.FLASH_MEMORY_CUSTOM.get())
));
return computer;
}
private ItemStack getPreconfiguredComputer() {
final ItemStack computer = new ItemStack(Items.COMPUTER.get());
final ItemStack computer = getComputerWithFlash();
final CompoundNBT itemsTag = NBTUtils.getOrCreateChildTag(computer.getOrCreateTag(), BLOCK_ENTITY_TAG_NAME_IN_ITEM, ITEMS_TAG_NAME);
itemsTag.put(DeviceTypes.MEMORY.getRegistryName().toString(), makeInventoryTag(
new ItemStack(Items.MEMORY_LARGE.get()),
new ItemStack(Items.MEMORY_LARGE.get()),
new ItemStack(Items.MEMORY_LARGE.get()),
new ItemStack(Items.MEMORY_LARGE.get())
@@ -230,13 +242,12 @@ public final class ComputerBlock extends HorizontalBlock {
itemsTag.put(DeviceTypes.HARD_DRIVE.getRegistryName().toString(), makeInventoryTag(
new ItemStack(Items.HARD_DRIVE_CUSTOM.get())
));
itemsTag.put(DeviceTypes.FLASH_MEMORY.getRegistryName().toString(), makeInventoryTag(
new ItemStack(Items.FLASH_MEMORY_CUSTOM.get())
));
itemsTag.put(DeviceTypes.CARD.getRegistryName().toString(), makeInventoryTag(
new ItemStack(Items.NETWORK_INTERFACE_CARD.get())
));
computer.setHoverName(text("block.{mod}.computer.preconfigured"));
return computer;
}
}

View File

@@ -3,6 +3,7 @@
"block.oc2.computer": "Computer",
"block.oc2.computer.desc": "Use a Scrench or compatible wrench to add and remove components.",
"block.oc2.computer.preconfigured": "Preconfigured Computer",
"block.oc2.bus_cable": "Bus Cable",
"block.oc2.bus_cable.desc": "Used in combination with Bus Interfaces to connect external devices to computers.",
"block.oc2.network_connector": "Network Connector",

View File

@@ -23,6 +23,21 @@
}
},
"result": {
"item": "oc2:computer"
"item": "oc2:computer",
"nbt": {
"BlockEntityTag": {
"items": {
"oc2:flash_memory": {
"Items": [
{
"Slot": 0,
"Count": 1,
"id": "oc2:flash_memory_custom"
}
]
}
}
}
}
}
}