first
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package net.cmr.jurassicrevived;
|
||||
|
||||
import net.cmr.jurassicrevived.block.ModBlocks;
|
||||
import net.cmr.jurassicrevived.config.JRConfigManager;
|
||||
import net.cmr.jurassicrevived.entity.ModEntities;
|
||||
import net.cmr.jurassicrevived.item.ModCreativeTabs;
|
||||
import net.cmr.jurassicrevived.item.ModItems;
|
||||
import net.cmr.jurassicrevived.platform.Services;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
// This class is part of the common project meaning it is shared between all supported loaders. Code written here can only
|
||||
// import and access the vanilla codebase, libraries used by vanilla, and optionally third party libraries that provide
|
||||
// common compatible binaries. This means common code can not directly use loader specific concepts such as Forge events
|
||||
// however it will be compatible with all supported mod loaders.
|
||||
public class CommonClass
|
||||
{
|
||||
|
||||
// The loader specific projects are able to import and use any code from the common project. This allows you to
|
||||
// write the majority of your code here and load it from your loader specific projects. This example has some
|
||||
// code that gets invoked by the entry point of the loader specific projects.
|
||||
public static void init() {
|
||||
|
||||
Constants.LOG.info("Hello from Common init on {}! we are currently in a {} environment!", Services.PLATFORM.getPlatformName(), Services.PLATFORM.getEnvironmentName());
|
||||
Constants.LOG.info("The ID for diamonds is {}", BuiltInRegistries.ITEM.getKey(Items.DIAMOND));
|
||||
|
||||
// It is common for all supported loaders to provide a similar feature that can not be used directly in the
|
||||
// common code. A popular way to get around this is using Java's built-in service loader feature to create
|
||||
// your own abstraction layer. You can learn more about this in our provided services class. In this example
|
||||
// we have an interface in the common code and use a loader specific implementation to delegate our call to
|
||||
// the platform specific approach.
|
||||
if (Services.PLATFORM.isModLoaded("examplemod")) {
|
||||
|
||||
Constants.LOG.info("Hello to examplemod");
|
||||
}
|
||||
|
||||
// Load config from the loader-specific config dir
|
||||
JRConfigManager.load(Services.PLATFORM.getConfigDir());
|
||||
|
||||
ModBlocks.register();
|
||||
ModItems.register();
|
||||
ModCreativeTabs.register();
|
||||
ModEntities.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.cmr.jurassicrevived;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Constants
|
||||
{
|
||||
|
||||
public static final String MOD_ID = "jurassicrevived";
|
||||
public static final String MOD_NAME = "JurassicRevived";
|
||||
public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.cmr.jurassicrevived.block;
|
||||
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import net.cmr.jurassicrevived.Constants;
|
||||
import net.cmr.jurassicrevived.item.ModItems;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ModBlocks {
|
||||
public static final DeferredRegister<Block> BLOCKS =
|
||||
DeferredRegister.create(Constants.MOD_ID, Registries.BLOCK);
|
||||
|
||||
// --- Examples ---
|
||||
public static final RegistrySupplier<Block> FOSSIL_ORE = registerBlock("fossil_ore",
|
||||
() -> new Block(BlockBehaviour.Properties.of().strength(3.0f)));
|
||||
|
||||
|
||||
// --- Helper Methods ---
|
||||
|
||||
/**
|
||||
* Registers a block and a corresponding BlockItem.
|
||||
*/
|
||||
|
||||
private static <T extends Block> RegistrySupplier<T> registerBlock(String name, Supplier<T> block) {
|
||||
RegistrySupplier<T> toReturn = BLOCKS.register(name, block);
|
||||
registerBlockItem(name, toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private static <T extends Block> void registerBlockItem(String name, RegistrySupplier<T> block) {
|
||||
ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties()));
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
BLOCKS.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.cmr.jurassicrevived.config;
|
||||
|
||||
public final class JRConfig {
|
||||
// Example options (replace with your real ones)
|
||||
public boolean enableDinosaurs = true;
|
||||
public int spawnWeight = 10;
|
||||
|
||||
public JRConfig() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package net.cmr.jurassicrevived.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class JRConfigManager {
|
||||
private static JRConfig config = new JRConfig();
|
||||
|
||||
private JRConfigManager() {}
|
||||
|
||||
public static JRConfig get() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loader modules should call this with the platform's config directory.
|
||||
*/
|
||||
public static void load(Path configDir) {
|
||||
Path file = configDir.resolve("jurassicrevived.json");
|
||||
if (!Files.exists(file)) {
|
||||
save(configDir);
|
||||
return;
|
||||
}
|
||||
|
||||
// Minimal placeholder IO (swap to Gson/Jackson later if you want)
|
||||
// For now: keep it simple and non-fatal.
|
||||
try {
|
||||
String text = Files.readString(file, StandardCharsets.UTF_8);
|
||||
// TODO: parse JSON into config (Gson recommended)
|
||||
// config = parsed;
|
||||
} catch (IOException e) {
|
||||
// Keep defaults if load fails
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(Path configDir) {
|
||||
try {
|
||||
Files.createDirectories(configDir);
|
||||
Path file = configDir.resolve("jurassicrevived.json");
|
||||
|
||||
// TODO: write JSON (Gson recommended)
|
||||
String text = "{\n" +
|
||||
" \"enableDinosaurs\": " + config.enableDinosaurs + ",\n" +
|
||||
" \"spawnWeight\": " + config.spawnWeight + "\n" +
|
||||
"}\n";
|
||||
|
||||
Files.writeString(file, text, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
// ignore / log via your logger if desired
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.cmr.jurassicrevived.entity;
|
||||
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import net.cmr.jurassicrevived.Constants;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
|
||||
public class ModEntities {
|
||||
public static final DeferredRegister<EntityType<?>> ENTITIES =
|
||||
DeferredRegister.create(Constants.MOD_ID, Registries.ENTITY_TYPE);
|
||||
|
||||
// --- Example (Generic Entity) ---
|
||||
// You will need your own Entity class (e.g., VelociraptorEntity::new)
|
||||
/*
|
||||
public static final RegistrySupplier<EntityType<VelociraptorEntity>> VELOCIRAPTOR = ENTITIES.register("velociraptor",
|
||||
() -> EntityType.Builder.of(VelociraptorEntity::new, MobCategory.CREATURE)
|
||||
.sized(1.0f, 2.0f)
|
||||
.build(Constants.MOD_ID + ":velociraptor"));
|
||||
*/
|
||||
|
||||
public static void register() {
|
||||
ENTITIES.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.cmr.jurassicrevived.item;
|
||||
|
||||
import dev.architectury.registry.CreativeTabRegistry;
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import net.cmr.jurassicrevived.Constants;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class ModCreativeTabs {
|
||||
public static final DeferredRegister<CreativeModeTab> TABS =
|
||||
DeferredRegister.create(Constants.MOD_ID, Registries.CREATIVE_MODE_TAB);
|
||||
|
||||
public static final RegistrySupplier<CreativeModeTab> JURASSIC_TAB = TABS.register("jurassic_tab",
|
||||
() -> CreativeTabRegistry.create(
|
||||
Component.translatable("itemGroup." + Constants.MOD_ID + ".jurassic_tab"),
|
||||
() -> new ItemStack(ModItems.AMBER_SHARD.get()) // Tab Icon
|
||||
));
|
||||
|
||||
public static void register() {
|
||||
// Items must be explicitly added to tabs in 1.20+
|
||||
// This usually goes in your Common setup, but you can trigger it here if your
|
||||
// loader-specific entry points call this method.
|
||||
|
||||
TABS.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.cmr.jurassicrevived.item;
|
||||
|
||||
import dev.architectury.registry.registries.DeferredRegister;
|
||||
import dev.architectury.registry.registries.RegistrySupplier;
|
||||
import net.cmr.jurassicrevived.Constants;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
public class ModItems {
|
||||
public static final DeferredRegister<Item> ITEMS =
|
||||
DeferredRegister.create(Constants.MOD_ID, Registries.ITEM);
|
||||
|
||||
// --- Examples ---
|
||||
public static final RegistrySupplier<Item> AMBER_SHARD = ITEMS.register("amber_shard",
|
||||
() -> new Item(new Item.Properties()));
|
||||
|
||||
public static final RegistrySupplier<Item> DNA_SYRINGE = ITEMS.register("dna_syringe",
|
||||
() -> new Item(new Item.Properties().stacksTo(1)));
|
||||
|
||||
public static void register() {
|
||||
ITEMS.register();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.cmr.jurassicrevived.mixin;
|
||||
|
||||
import net.cmr.jurassicrevived.Constants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMinecraft
|
||||
{
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "<init>")
|
||||
private void init(CallbackInfo info) {
|
||||
|
||||
Constants.LOG.info("This line is printed by an example mod common mixin!");
|
||||
Constants.LOG.info("MC Version: {}", Minecraft.getInstance().getVersionType());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.cmr.jurassicrevived.platform;
|
||||
|
||||
|
||||
import net.cmr.jurassicrevived.Constants;
|
||||
import net.cmr.jurassicrevived.platform.services.IPlatformHelper;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
// Service loaders are a built-in Java feature that allow us to locate implementations of an interface that vary from one
|
||||
// environment to another. In the context of MultiLoader we use this feature to access a mock API in the common code that
|
||||
// is swapped out for the platform specific implementation at runtime.
|
||||
public class Services
|
||||
{
|
||||
|
||||
// In this example we provide a platform helper which provides information about what platform the mod is running on.
|
||||
// For example this can be used to check if the code is running on Forge vs Fabric, or to ask the modloader if another
|
||||
// mod is loaded.
|
||||
public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class);
|
||||
|
||||
// This code is used to load a service for the current environment. Your implementation of the service must be defined
|
||||
// manually by including a text file in META-INF/services named with the fully qualified class name of the service.
|
||||
// Inside the file you should write the fully qualified class name of the implementation to load for the platform. For
|
||||
// example our file on Forge points to ForgePlatformHelper while Fabric points to FabricPlatformHelper.
|
||||
public static <T> T load(Class<T> clazz) {
|
||||
|
||||
final T loadedService = ServiceLoader.load(clazz)
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName()));
|
||||
Constants.LOG.debug("Loaded {} for service {}", loadedService, clazz);
|
||||
return loadedService;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.cmr.jurassicrevived.platform.services;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface IPlatformHelper
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets the name of the current platform
|
||||
*
|
||||
* @return The name of the current platform.
|
||||
*/
|
||||
String getPlatformName();
|
||||
|
||||
/**
|
||||
* Checks if a mod with the given id is loaded.
|
||||
*
|
||||
* @param modId The mod to check if it is loaded.
|
||||
* @return True if the mod is loaded, false otherwise.
|
||||
*/
|
||||
boolean isModLoaded(String modId);
|
||||
|
||||
/**
|
||||
* Check if the game is currently in a development environment.
|
||||
*
|
||||
* @return True if in a development environment, false otherwise.
|
||||
*/
|
||||
boolean isDevelopmentEnvironment();
|
||||
|
||||
/**
|
||||
* Gets the name of the environment type as a string.
|
||||
*
|
||||
* @return The name of the environment type.
|
||||
*/
|
||||
default String getEnvironmentName() {
|
||||
|
||||
return isDevelopmentEnvironment() ? "development":"production";
|
||||
}
|
||||
|
||||
Path getConfigDir();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
+4160
File diff suppressed because it is too large
Load Diff
+5162
File diff suppressed because it is too large
Load Diff
+3748
File diff suppressed because it is too large
Load Diff
+3607
File diff suppressed because it is too large
Load Diff
+4761
File diff suppressed because it is too large
Load Diff
+2146
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+4632
File diff suppressed because it is too large
Load Diff
+3510
File diff suppressed because it is too large
Load Diff
+3649
File diff suppressed because it is too large
Load Diff
+2047
File diff suppressed because it is too large
Load Diff
+5556
File diff suppressed because it is too large
Load Diff
+2113
File diff suppressed because it is too large
Load Diff
+2824
File diff suppressed because it is too large
Load Diff
+4072
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2416
File diff suppressed because it is too large
Load Diff
+3649
File diff suppressed because it is too large
Load Diff
+2802
File diff suppressed because it is too large
Load Diff
+3991
File diff suppressed because it is too large
Load Diff
+2696
File diff suppressed because it is too large
Load Diff
+2064
File diff suppressed because it is too large
Load Diff
+4230
File diff suppressed because it is too large
Load Diff
+2791
File diff suppressed because it is too large
Load Diff
+2145
File diff suppressed because it is too large
Load Diff
+2972
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2532
File diff suppressed because it is too large
Load Diff
+2064
File diff suppressed because it is too large
Load Diff
+3510
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+3298
File diff suppressed because it is too large
Load Diff
+4180
File diff suppressed because it is too large
Load Diff
+3332
File diff suppressed because it is too large
Load Diff
+3495
File diff suppressed because it is too large
Load Diff
+2825
File diff suppressed because it is too large
Load Diff
+4024
File diff suppressed because it is too large
Load Diff
+2900
File diff suppressed because it is too large
Load Diff
+2080
File diff suppressed because it is too large
Load Diff
+4195
File diff suppressed because it is too large
Load Diff
+4478
File diff suppressed because it is too large
Load Diff
+5676
File diff suppressed because it is too large
Load Diff
+2030
File diff suppressed because it is too large
Load Diff
+2074
File diff suppressed because it is too large
Load Diff
+4514
File diff suppressed because it is too large
Load Diff
+3243
File diff suppressed because it is too large
Load Diff
+3651
File diff suppressed because it is too large
Load Diff
+5473
File diff suppressed because it is too large
Load Diff
+4873
File diff suppressed because it is too large
Load Diff
+2828
File diff suppressed because it is too large
Load Diff
+4768
File diff suppressed because it is too large
Load Diff
+4492
File diff suppressed because it is too large
Load Diff
+3332
File diff suppressed because it is too large
Load Diff
+2002
File diff suppressed because it is too large
Load Diff
+2211
File diff suppressed because it is too large
Load Diff
+2099
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user