Manual support now available
This commit is contained in:
parent
f8cf3e13c3
commit
07f342a9b4
11 changed files with 145 additions and 68 deletions
|
|
@ -31,7 +31,7 @@ def getGitRef() {
|
|||
}
|
||||
|
||||
version = "${semver}+${getGitRef()}"
|
||||
group = "li.cil.oc2r"
|
||||
group = "com.therealm18studios.librecomponents"
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ package com.therealm18studios.lc;
|
|||
|
||||
import com.therealm18studios.lc.common.item.ItemGroup;
|
||||
import com.therealm18studios.lc.common.item.Items;
|
||||
import com.therealm18studios.lc.manual.Manuals;
|
||||
import li.cil.oc2.common.ConfigManager;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
|
||||
|
|
@ -16,6 +19,7 @@ public final class LibreComponents {
|
|||
ConfigManager.initialize();
|
||||
|
||||
Items.initialize();
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> Manuals::initialize);
|
||||
ItemGroup.TAB_REGISTER.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public final class ItemGroup {
|
|||
// Set name of tab to display
|
||||
.title(Component.translatable("item_group." + LibreComponents.MOD_ID + ".common"))
|
||||
// Set icon of creative tab
|
||||
.icon(() -> new ItemStack(li.cil.oc2.common.item.Items.COMPUTER.get()))
|
||||
.icon(() -> new ItemStack(Items.HARD_DRIVE_EXTRA_LARGE.get()))
|
||||
// Add default items to tab
|
||||
.displayItems((params, output) -> {
|
||||
// Items
|
||||
|
|
|
|||
|
|
@ -1,91 +1,71 @@
|
|||
package com.therealm18studios.lc.common.item;
|
||||
|
||||
import com.therealm18studios.lc.LibreComponents;
|
||||
import li.cil.oc2.common.item.*;
|
||||
import li.cil.oc2.common.item.MemoryItem;
|
||||
import li.cil.oc2.common.item.HardDriveItem;
|
||||
import li.cil.oc2.common.item.CPUItem;
|
||||
import li.cil.oc2.common.item.FloppyItem;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class Items {
|
||||
private static final DeferredRegister<Item> ITEMS;
|
||||
public static final RegistryObject<MemoryItem> MEMORY_SMALL;
|
||||
public static final RegistryObject<MemoryItem> MEMORY_MEDIUM;
|
||||
public static final RegistryObject<MemoryItem> MEMORY_LARGE;
|
||||
public static final RegistryObject<MemoryItem> MEMORY_EXTRA_LARGE;
|
||||
public static final RegistryObject<HardDriveItem> HARD_DRIVE_SMALL;
|
||||
public static final RegistryObject<HardDriveItem> HARD_DRIVE_MEDIUM;
|
||||
public static final RegistryObject<HardDriveItem> HARD_DRIVE_LARGE;
|
||||
public static final RegistryObject<HardDriveItem> HARD_DRIVE_EXTRA_LARGE;
|
||||
public static final RegistryObject<CPUItem> CPU_TIER_1;
|
||||
public static final RegistryObject<CPUItem> CPU_TIER_2;
|
||||
public static final RegistryObject<CPUItem> CPU_TIER_3;
|
||||
public static final RegistryObject<CPUItem> CPU_TIER_4;
|
||||
public static final RegistryObject<FloppyItem> FLOPPY;
|
||||
public static final RegistryObject<FloppyItem> FLOPPY_MODERN;
|
||||
private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, LibreComponents.MOD_ID);
|
||||
|
||||
public Items() {
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
public static final RegistryObject<MemoryItem> MEMORY_SMALL = register("memory_small", () ->
|
||||
new MemoryItem(33554432));
|
||||
public static final RegistryObject<MemoryItem> MEMORY_MEDIUM = register("memory_medium", () ->
|
||||
new MemoryItem(67108864));
|
||||
public static final RegistryObject<MemoryItem> MEMORY_LARGE = register("memory_large", () ->
|
||||
new MemoryItem(134217728));
|
||||
public static final RegistryObject<MemoryItem> MEMORY_EXTRA_LARGE = register("memory_extra_large", () ->
|
||||
new MemoryItem(268435456));
|
||||
|
||||
public static final RegistryObject<HardDriveItem> HARD_DRIVE_SMALL = register("hard_drive_small", () ->
|
||||
new HardDriveItem(33554432, DyeColor.LIGHT_GRAY));
|
||||
public static final RegistryObject<HardDriveItem> HARD_DRIVE_MEDIUM = register("hard_drive_medium", () ->
|
||||
new HardDriveItem(67108864, DyeColor.GREEN));
|
||||
public static final RegistryObject<HardDriveItem> HARD_DRIVE_LARGE = register("hard_drive_large", () ->
|
||||
new HardDriveItem(134217728, DyeColor.CYAN));
|
||||
public static final RegistryObject<HardDriveItem> HARD_DRIVE_EXTRA_LARGE = register("hard_drive_extra_large", () ->
|
||||
new HardDriveItem(268435456, DyeColor.YELLOW));
|
||||
|
||||
public static final RegistryObject<CPUItem> CPU_TIER_1 = register("cpu_tier_1", () ->
|
||||
new CPUItem(250000000));
|
||||
public static final RegistryObject<CPUItem> CPU_TIER_2 = register("cpu_tier_2", () ->
|
||||
new CPUItem(300000000));
|
||||
public static final RegistryObject<CPUItem> CPU_TIER_3 = register("cpu_tier_3", () ->
|
||||
new CPUItem(350000000));
|
||||
public static final RegistryObject<CPUItem> CPU_TIER_4 = register("cpu_tier_4", () ->
|
||||
new CPUItem(400000000));
|
||||
|
||||
public static final RegistryObject<FloppyItem> FLOPPY = register("floppy", () ->
|
||||
new FloppyItem(2949120));
|
||||
public static final RegistryObject<FloppyItem> FLOPPY_MODERN = register("floppy_modern", () ->
|
||||
new FloppyItem(5898240));
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
public static void initialize() {
|
||||
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
}
|
||||
|
||||
private static RegistryObject<Item> register(String name) {
|
||||
return register(name, ModItem::new);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
private static <T extends Item> RegistryObject<T> register(String name, Supplier<T> factory) {
|
||||
private static <T extends Item> RegistryObject<T> register(final String name, final Supplier<T> factory) {
|
||||
return ITEMS.register(name, factory);
|
||||
}
|
||||
|
||||
static {
|
||||
ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, LibreComponents.MOD_ID);
|
||||
MEMORY_SMALL = register("memory_small", () -> {
|
||||
return new MemoryItem(33554432);
|
||||
});
|
||||
MEMORY_MEDIUM = register("memory_medium", () -> {
|
||||
return new MemoryItem(67108864);
|
||||
});
|
||||
MEMORY_LARGE = register("memory_large", () -> {
|
||||
return new MemoryItem(134217728);
|
||||
});
|
||||
MEMORY_EXTRA_LARGE = register("memory_extra_large", () -> {
|
||||
return new MemoryItem(268435456);
|
||||
});
|
||||
HARD_DRIVE_SMALL = register("hard_drive_small", () -> {
|
||||
return new HardDriveItem(33554432, DyeColor.PINK);
|
||||
});
|
||||
HARD_DRIVE_MEDIUM = register("hard_drive_medium", () -> {
|
||||
return new HardDriveItem(67108864, DyeColor.RED);
|
||||
});
|
||||
HARD_DRIVE_LARGE = register("hard_drive_large", () -> {
|
||||
return new HardDriveItem(134217728, DyeColor.BLUE);
|
||||
});
|
||||
HARD_DRIVE_EXTRA_LARGE = register("hard_drive_extra_large", () -> {
|
||||
return new HardDriveItem(268435456, DyeColor.BLACK);
|
||||
});
|
||||
CPU_TIER_1 = register("cpu_tier_1", () -> {
|
||||
return new CPUItem(250000000);
|
||||
});
|
||||
CPU_TIER_2 = register("cpu_tier_2", () -> {
|
||||
return new CPUItem(300000000);
|
||||
});
|
||||
CPU_TIER_3 = register("cpu_tier_3", () -> {
|
||||
return new CPUItem(350000000);
|
||||
});
|
||||
CPU_TIER_4 = register("cpu_tier_4", () -> {
|
||||
return new CPUItem(400000000);
|
||||
});
|
||||
FLOPPY = register("floppy", () -> {
|
||||
return new FloppyItem(2949120);
|
||||
});
|
||||
FLOPPY_MODERN = register("floppy_modern", () -> {
|
||||
return new FloppyItem(5898240);
|
||||
});
|
||||
private static <TBlock extends Block, TItem extends Item> RegistryObject<TItem> register(final RegistryObject<TBlock> block, final Function<TBlock, TItem> factory) {
|
||||
return register(block.getId().getPath(), () -> factory.apply(block.get()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
51
src/main/java/com/therealm18studios/lc/manual/Manuals.java
Normal file
51
src/main/java/com/therealm18studios/lc/manual/Manuals.java
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
package com.therealm18studios.lc.manual;
|
||||
|
||||
import com.therealm18studios.lc.LibreComponents;
|
||||
import com.therealm18studios.lc.common.item.Items;
|
||||
import li.cil.manual.api.ManualModel;
|
||||
import li.cil.manual.api.Tab;
|
||||
import li.cil.manual.api.prefab.Manual;
|
||||
import li.cil.manual.api.prefab.provider.NamespaceDocumentProvider;
|
||||
import li.cil.manual.api.prefab.provider.NamespacePathProvider;
|
||||
import li.cil.manual.api.prefab.tab.ItemStackTab;
|
||||
import li.cil.manual.api.provider.DocumentProvider;
|
||||
import li.cil.manual.api.provider.PathProvider;
|
||||
import li.cil.manual.api.util.Constants;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public final class Manuals {
|
||||
|
||||
private static final DeferredRegister<ManualModel> MANUALS = DeferredRegister.create(Constants.MANUAL_REGISTRY, Constants.MOD_ID);
|
||||
private static final DeferredRegister<PathProvider> PATH_PROVIDERS = DeferredRegister.create(Constants.PATH_PROVIDER_REGISTRY, Constants.MOD_ID);
|
||||
private static final DeferredRegister<DocumentProvider> CONTENT_PROVIDERS = DeferredRegister.create(Constants.DOCUMENT_PROVIDER_REGISTRY, Constants.MOD_ID);
|
||||
private static final DeferredRegister<Tab> TABS = DeferredRegister.create(Constants.TAB_REGISTRY, Constants.MOD_ID);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
public static final RegistryObject<ManualModel> MANUAL = MANUALS.register("manual", Manual::new);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
public static void initialize() {
|
||||
MANUALS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
|
||||
PATH_PROVIDERS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
CONTENT_PROVIDERS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
TABS.register(FMLJavaModLoadingContext.get().getModEventBus());
|
||||
|
||||
PATH_PROVIDERS.register("path_provider", () -> new NamespacePathProvider(LibreComponents.MOD_ID));
|
||||
CONTENT_PROVIDERS.register("content_provider", () -> new NamespaceDocumentProvider(LibreComponents.MOD_ID, "doc"));
|
||||
|
||||
TABS.register("librecomponents", () -> new ItemStackTab(
|
||||
ManualModel.LANGUAGE_KEY + "/librecomponents/index.md",
|
||||
Component.translatable("manual." + LibreComponents.MOD_ID + ".items"),
|
||||
new ItemStack(Items.HARD_DRIVE_EXTRA_LARGE.get())));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# The Component Handbook
|
||||
Hello, greetings, welcome! If you've come here, you either stumbled in by accident, are interested in [item](librecomponents/index.md) information?
|
||||
|
||||
If you're looking for information on a particular item, have a look at the respective glossaries:
|
||||
- [List of items](librecomponents/index.md)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Floppy
|
||||

|
||||
|
||||
We add the following:
|
||||
|
||||
- 2MB
|
||||
- 5MB
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Hard Drive
|
||||

|
||||
|
||||
We add the following:
|
||||
|
||||
- 32MB
|
||||
- 64MB
|
||||
- 128MB
|
||||
- 256MB
|
||||
|
||||
Computers *have to be shut down* before installing or removing this component. Installing it while the computer is running will have no effect, removing it may lead to system errors.
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# Items
|
||||
This index lists all documented items.
|
||||
|
||||
- [Floppy](floppy.md)
|
||||
- [Hard Drive](hard_drive.md)
|
||||
- [Memory](memory.md)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Memory
|
||||

|
||||
|
||||
We add the following:
|
||||
|
||||
- 32MB
|
||||
- 64MB
|
||||
- 128MB
|
||||
- 256MB
|
||||
|
||||
Computers *have to be shut down* before installing or removing this component. Installing it while the computer is running will have no effect, removing it may lead to system errors.
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
"item_group.librecomponents.common": "Libre Components",
|
||||
|
||||
"manual.librecomponents.items": "Libre Components",
|
||||
|
||||
"item.librecomponents.cpu_tier_1": "CPU Tier 5",
|
||||
"item.librecomponents.cpu_tier_1.desc": "Processes computer instructions.",
|
||||
"item.librecomponents.cpu_tier_2": "CPU Tier 6",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue