Last 1.18 initial work. Getting ready for 1.19
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -9,7 +9,7 @@
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SwUserDefinedSpecifications">
|
||||
|
@@ -2,11 +2,13 @@ plugins {
|
||||
id 'java'
|
||||
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
id 'com.github.johnrengelman.shadow' version '7.0.0'
|
||||
}
|
||||
|
||||
archivesBaseName = "${mod_name}-common-${minecraft_version}"
|
||||
|
||||
minecraft {
|
||||
accessWideners(project.file("src/main/resources/craterlib.aw"))
|
||||
version(minecraft_version)
|
||||
runs {
|
||||
if (project.hasProperty('common_runs_enabled') ? project.findProperty('common_runs_enabled').toBoolean() : true) {
|
||||
@@ -22,7 +24,7 @@ minecraft {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
|
||||
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -32,6 +34,20 @@ processResources {
|
||||
expand buildProps
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependencies {
|
||||
include(dependency('me.hypherionmc.night-config:toml:3.6.5_custom'))
|
||||
include(dependency('me.hypherionmc.night-config:core:3.6.5_custom'))
|
||||
|
||||
//relocate 'me.hypherionmc.nightconfig', 'shadow.hypherionmc.nightconfig'
|
||||
}
|
||||
classifier ''
|
||||
}
|
||||
|
||||
build.dependsOn shadowJar
|
||||
reg.configureJarTask(shadowJar)
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
@@ -39,12 +55,26 @@ publishing {
|
||||
artifactId project.archivesBaseName
|
||||
version project.version
|
||||
from components.java
|
||||
pom.withXml {
|
||||
Node pomNode = asNode()
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
it.artifactId.text() == 'regutils-joined-fabric' ||
|
||||
it.artifactId.text() == 'core' ||
|
||||
it.artifactId.text() == 'toml'
|
||||
}.each() {
|
||||
it.parent().remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + System.getenv("local_maven")
|
||||
url "https://maven.firstdarkdev.xyz/" + (project.isSnapshot ? "snapshots" : "releases")
|
||||
credentials {
|
||||
username System.getenv("MAVEN_USER")
|
||||
password System.getenv("MAVEN_PASS")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class Constants {
|
||||
public static final String MOD_ID = "craterlib";
|
||||
public static final String MOD_NAME = "CraterLib";
|
||||
public static final Logger LOG = LogManager.getLogger(MOD_NAME);
|
||||
public static final String MOD_ID = "craterlib";
|
||||
public static final String MOD_NAME = "CraterLib";
|
||||
public static final Logger LOG = LogManager.getLogger(MOD_NAME);
|
||||
}
|
||||
|
@@ -5,9 +5,29 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/**
|
||||
* Helper Interface for BlockEntities that tick both Client and Server Side
|
||||
*/
|
||||
public interface ISidedTickable {
|
||||
|
||||
/**
|
||||
* Server Tick Event
|
||||
*
|
||||
* @param level
|
||||
* @param pos
|
||||
* @param state
|
||||
* @param blockEntity
|
||||
*/
|
||||
public void serverTick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
|
||||
|
||||
/**
|
||||
* Client Tick Event
|
||||
*
|
||||
* @param level
|
||||
* @param pos
|
||||
* @param state
|
||||
* @param blockEntity
|
||||
*/
|
||||
public void clientTick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
|
||||
|
||||
}
|
||||
|
@@ -5,8 +5,19 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/**
|
||||
* Helper Interface for BlockEntities that only tick on a single side
|
||||
*/
|
||||
public interface ITickable {
|
||||
|
||||
/**
|
||||
* The Tick Event. Can be either Server or Client Sided
|
||||
*
|
||||
* @param level
|
||||
* @param pos
|
||||
* @param state
|
||||
* @param blockEntity
|
||||
*/
|
||||
public void tick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
|
||||
|
||||
}
|
||||
|
@@ -1,9 +1,17 @@
|
||||
package me.hypherionmc.craterlib.api.rendering;
|
||||
|
||||
import net.minecraft.client.renderer.entity.layers.RenderLayer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
||||
/**
|
||||
* Helper Interface for defining Block render types
|
||||
*/
|
||||
public interface CustomRenderType {
|
||||
|
||||
RenderLayer getCustomRenderType();
|
||||
/**
|
||||
* Get the render type of the block
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
RenderType getCustomRenderType();
|
||||
|
||||
}
|
||||
|
@@ -1,12 +1,25 @@
|
||||
package me.hypherionmc.craterlib.api.rendering;
|
||||
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
|
||||
/**
|
||||
* Helper Interface for Dyable Blocks
|
||||
*/
|
||||
public interface DyableBlock {
|
||||
|
||||
BlockColors dyeHandler();
|
||||
/**
|
||||
* Get the BlockColor handler for the block
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
BlockColor dyeHandler();
|
||||
|
||||
/**
|
||||
* Get the default Dye Color for Un-dyed states
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
DyeColor defaultDyeColor();
|
||||
|
||||
}
|
||||
|
@@ -2,8 +2,16 @@ package me.hypherionmc.craterlib.api.rendering;
|
||||
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
|
||||
/**
|
||||
* Helper Interface for Dyable Items
|
||||
*/
|
||||
public interface ItemDyable {
|
||||
|
||||
/**
|
||||
* Get the DyeColor of the Item
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DyeColor getColor();
|
||||
|
||||
}
|
||||
|
@@ -4,6 +4,9 @@ import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* A custom slider widget used for Time. Mostly used by the Hyper Lighting Smoke Machine
|
||||
*/
|
||||
public class TimeSliderWidget extends AbstractSliderButton {
|
||||
|
||||
private final double maxValue;
|
||||
|
@@ -0,0 +1,45 @@
|
||||
package me.hypherionmc.craterlib.client.registry;
|
||||
|
||||
import me.hypherionmc.craterlib.api.rendering.DyableBlock;
|
||||
import me.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import me.hypherionmc.craterlib.client.rendering.ItemColorHandler;
|
||||
import me.hypherionmc.craterlib.systems.reg.RegistrationProvider;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
/**
|
||||
* Helper for registering Block and Item color handlers
|
||||
*/
|
||||
public class ClientRegistry {
|
||||
|
||||
/**
|
||||
* Register Block Color Handlers
|
||||
*
|
||||
* @param colors
|
||||
* @param blocks
|
||||
*/
|
||||
public static void registerBlockColors(BlockColors colors, RegistrationProvider<Block> blocks) {
|
||||
blocks.getEntries().forEach(blockRegistryObject -> {
|
||||
if (blockRegistryObject.get() instanceof DyableBlock dyableBlock) {
|
||||
colors.register(dyableBlock.dyeHandler(), (Block) dyableBlock);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Item Color Handlers
|
||||
*
|
||||
* @param colors
|
||||
* @param items
|
||||
*/
|
||||
public static void registerItemColors(ItemColors colors, RegistrationProvider<Item> items) {
|
||||
items.getEntries().forEach(itemRegistryObject -> {
|
||||
if (itemRegistryObject.get() instanceof ItemDyable itemDyable) {
|
||||
colors.register(new ItemColorHandler(), (Item) itemDyable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -1,18 +1,31 @@
|
||||
package me.hypherionmc.craterlib.client.rendering;
|
||||
|
||||
import me.hypherionmc.craterlib.api.rendering.DyableBlock;
|
||||
import me.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import me.hypherionmc.craterlib.common.item.BlockItemDyable;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class ItemColorHandler extends ItemColors {
|
||||
/**
|
||||
* Helper Class for Dyable Items implementing a simple color handler
|
||||
*/
|
||||
public class ItemColorHandler implements ItemColor {
|
||||
|
||||
/***
|
||||
* Get the color for the Item/ItemStack
|
||||
* @param stack
|
||||
* @param tintIndex
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getColor(ItemStack stack, int tintIndex) {
|
||||
return this.getColorFromStack(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color for the specific items stack, or return BLACK (0)
|
||||
*
|
||||
* @param stack
|
||||
* @return
|
||||
*/
|
||||
private int getColorFromStack(ItemStack stack) {
|
||||
if (stack.getItem() instanceof ItemDyable itemDyable) {
|
||||
return itemDyable.getColor().getMaterialColor().col;
|
||||
|
@@ -0,0 +1,42 @@
|
||||
package me.hypherionmc.craterlib.common.config;
|
||||
|
||||
import me.hypherionmc.craterlib.Constants;
|
||||
import me.hypherionmc.nightconfig.core.file.FileWatcher;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Controls Config File Reloads and Events
|
||||
*/
|
||||
public class ConfigController implements Serializable {
|
||||
|
||||
/**
|
||||
* Cache of registered configs
|
||||
*/
|
||||
private static final HashMap<Object, FileWatcher> monitoredConfigs = new HashMap<>();
|
||||
|
||||
/**
|
||||
* INTERNAL METHOD - Register and watch the config
|
||||
*
|
||||
* @param config - The config class to register and watch
|
||||
*/
|
||||
static void register_config(ModuleConfig config) {
|
||||
if (monitoredConfigs.containsKey(config)) {
|
||||
Constants.LOG.error("Failed to register " + config.getConfigPath().getName() + ". Config already registered");
|
||||
} else {
|
||||
FileWatcher configWatcher = new FileWatcher();
|
||||
try {
|
||||
configWatcher.setWatch(config.getConfigPath(), () -> {
|
||||
Constants.LOG.info("Sending Reload Event for: " + config.getConfigPath().getName());
|
||||
config.configReloaded();
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Constants.LOG.error("Failed to register " + config.getConfigPath().getName() + " for auto reloading. " + e.getMessage());
|
||||
}
|
||||
monitoredConfigs.put(config, configWatcher);
|
||||
Constants.LOG.info("Registered " + config.getConfigPath().getName() + " successfully!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,147 @@
|
||||
package me.hypherionmc.craterlib.common.config;
|
||||
|
||||
import me.hypherionmc.nightconfig.core.CommentedConfig;
|
||||
import me.hypherionmc.nightconfig.core.Config;
|
||||
import me.hypherionmc.nightconfig.core.conversion.ObjectConverter;
|
||||
import me.hypherionmc.nightconfig.core.file.CommentedFileConfig;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Base Config class containing the save, upgrading and loading logic. All config classes must extend this class
|
||||
*/
|
||||
public class ModuleConfig {
|
||||
|
||||
/* Final Variables */
|
||||
private final transient File configPath;
|
||||
private final transient String networkID;
|
||||
|
||||
/**
|
||||
* Set up the config
|
||||
*
|
||||
* @param modId - The ID of the Mod/Module the config belongs to
|
||||
* @param configName - The name of the config file, excluding extension
|
||||
*/
|
||||
public ModuleConfig(String modId, String configName) {
|
||||
this(modId, "", configName);
|
||||
}
|
||||
|
||||
public ModuleConfig(String modId, String subFolder, String configName) {
|
||||
/* Preserve the order of the config values */
|
||||
Config.setInsertionOrderPreserved(true);
|
||||
|
||||
/* Configure Paths and Network SYNC ID */
|
||||
File configDir = new File("config" + (subFolder.isEmpty() ? "" : File.separator + subFolder));
|
||||
configPath = new File(configDir + File.separator + configName + ".toml");
|
||||
networkID = modId + ":conf_" + configName.replace("-", "_");
|
||||
|
||||
/* Check if the required directories exists, otherwise we create them */
|
||||
if (!configDir.exists()) {
|
||||
configDir.mkdirs();
|
||||
}
|
||||
|
||||
/* Register the Config for Watching and events */
|
||||
ConfigController.register_config(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method has to be called in the config constructor. This creates or upgrades the config file as needed
|
||||
*
|
||||
* @param config - The config class to use
|
||||
*/
|
||||
public void registerAndSetup(ModuleConfig config) {
|
||||
if (!configPath.exists() || configPath.length() < 10) {
|
||||
saveConfig(config);
|
||||
} else {
|
||||
migrateConfig(config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the config to the disk
|
||||
*
|
||||
* @param conf - The config class to serialize and save
|
||||
*/
|
||||
public void saveConfig(ModuleConfig conf) {
|
||||
/* Set up the Serializer and Config Object */
|
||||
ObjectConverter converter = new ObjectConverter();
|
||||
CommentedFileConfig config = CommentedFileConfig.builder(configPath).build();
|
||||
|
||||
/* Save the config and fire the reload event */
|
||||
converter.toConfig(conf, config);
|
||||
config.save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the config from the file into a Class
|
||||
*
|
||||
* @param conf - The config Class to load
|
||||
* @return - Returns the loaded version of the class
|
||||
*/
|
||||
public <T> T loadConfig(Object conf) {
|
||||
/* Set up the Serializer and Config Object */
|
||||
ObjectConverter converter = new ObjectConverter();
|
||||
CommentedFileConfig config = CommentedFileConfig.builder(configPath).build();
|
||||
config.load();
|
||||
|
||||
/* Load the config and return the loaded config */
|
||||
converter.toObject(config, conf);
|
||||
return (T) conf;
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL METHOD - Upgrades the config files in the event the config structure changes
|
||||
*
|
||||
* @param conf - The config class to load
|
||||
*/
|
||||
private void migrateConfig(ModuleConfig conf) {
|
||||
/* Set up the Serializer and Config Objects */
|
||||
CommentedFileConfig config = CommentedFileConfig.builder(configPath).build();
|
||||
CommentedFileConfig newConfig = CommentedFileConfig.builder(configPath).build();
|
||||
config.load();
|
||||
|
||||
/* Upgrade the config */
|
||||
new ObjectConverter().toConfig(conf, newConfig);
|
||||
updateConfigValues(config, newConfig, CommentedConfig.copy(newConfig), "");
|
||||
newConfig.save();
|
||||
}
|
||||
|
||||
private void updateConfigValues(CommentedConfig oldConfig, CommentedConfig newConfig, CommentedConfig outputConfig, String subKey) {
|
||||
/* Loop over the config keys and check what has changed */
|
||||
newConfig.valueMap().forEach((key, value) -> {
|
||||
String finalKey = subKey + (subKey.isEmpty() ? "" : ".") + key;
|
||||
if (value instanceof CommentedConfig commentedConfig) {
|
||||
updateConfigValues(oldConfig, commentedConfig, outputConfig, finalKey);
|
||||
} else {
|
||||
outputConfig.set(finalKey,
|
||||
oldConfig.contains(finalKey) ? oldConfig.get(finalKey) : value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the location of the config file
|
||||
*
|
||||
* @return - The FILE object containing the config file
|
||||
*/
|
||||
public File getConfigPath() {
|
||||
return configPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the NETWORK SYNC ID
|
||||
*
|
||||
* @return - Returns the Sync ID in format modid:config_name
|
||||
*/
|
||||
public String getNetworkID() {
|
||||
return networkID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired whenever changes to the config are detected
|
||||
*/
|
||||
public void configReloaded() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package me.hypherionmc.craterlib.common.config.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Syncable {
|
||||
}
|
@@ -6,12 +6,20 @@ import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
/**
|
||||
* Base Item for Blocks that implement @link {DyableBlock}.
|
||||
*/
|
||||
public class BlockItemDyable extends BlockItem implements ItemDyable {
|
||||
|
||||
public BlockItemDyable(Block block, Properties properties) {
|
||||
super(block, properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Item Color from the block
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
if (this.getBlock() instanceof DyableBlock dyableBlock) {
|
||||
|
@@ -17,6 +17,9 @@ import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Custom Water Bottle item that supports Dye and can be used as Dye
|
||||
*/
|
||||
public class DyableWaterBottle extends DyeItem implements ItemDyable {
|
||||
|
||||
private final DyeColor color;
|
||||
@@ -28,16 +31,35 @@ public class DyableWaterBottle extends DyeItem implements ItemDyable {
|
||||
this.isGlowing = isGlowing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normally this is used for enchanted items, in this case, it's used to check if the fluid is a glowing fluid
|
||||
*
|
||||
* @param stack
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isFoil(ItemStack stack) {
|
||||
return this.isGlowing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the color of the item for the Color Handler
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public DyeColor getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is basically the same as the vanilla method for water bottles
|
||||
*
|
||||
* @param stack
|
||||
* @param level
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity user) {
|
||||
Player playerEntity;
|
||||
|
@@ -6,6 +6,9 @@ import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
/**
|
||||
* A custom water bucket that supports Dye Colors
|
||||
*/
|
||||
public class DyableWaterBucket extends BucketItem implements ItemDyable {
|
||||
|
||||
private final DyeColor color;
|
||||
@@ -17,6 +20,12 @@ public class DyableWaterBucket extends BucketItem implements ItemDyable {
|
||||
this.isGlowing = isGlowing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normally this is used for enchanted items, in this case, it's used to check if the fluid is a glowing fluid
|
||||
*
|
||||
* @param stack
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isFoil(ItemStack stack) {
|
||||
return this.isGlowing;
|
||||
|
@@ -0,0 +1,28 @@
|
||||
package me.hypherionmc.craterlib.common.network;
|
||||
|
||||
import me.hypherionmc.craterlib.Constants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
// TODO: FINISH NETWORK IMPLEMENTATION
|
||||
public interface BaseNetworkPacket {
|
||||
|
||||
Map<String, Handler<?>> PACKETS = Util.make(new HashMap<>(), map -> {
|
||||
Constants.LOG.info("Registering Config Packets");
|
||||
});
|
||||
|
||||
void write(FriendlyByteBuf buf);
|
||||
|
||||
void handle(Level level);
|
||||
|
||||
record Handler<T extends BaseNetworkPacket>(Class<T> clazz, BiConsumer<T, FriendlyByteBuf> write,
|
||||
Function<FriendlyByteBuf, T> read,
|
||||
BiConsumer<T, Level> handle) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package me.hypherionmc.craterlib.common.particles;
|
||||
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
|
||||
/**
|
||||
* Helper Class for exposing a hidden constructor in the vanilla particle type
|
||||
*/
|
||||
public class WrappedSimpleParticleType extends SimpleParticleType {
|
||||
|
||||
public WrappedSimpleParticleType(boolean alwaysShow) {
|
||||
super(alwaysShow);
|
||||
}
|
||||
}
|
@@ -7,4 +7,5 @@ public interface IPlatformHelper {
|
||||
boolean isModLoaded(String modId);
|
||||
|
||||
boolean isDevelopmentEnvironment();
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* So, if you got here, most probably you want to see the registration system of this mod.
|
||||
* Well, you are in the wrong place. This mod uses <a href="https://github.com/Matyrobbrt/RegistrationUtils">RegistrationUtils</a> for
|
||||
* all its registration needs.
|
||||
*/
|
||||
package me.hypherionmc.craterlib.systems.reg;
|
@@ -9,11 +9,11 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
public class MathUtils {
|
||||
|
||||
public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) {
|
||||
VoxelShape[] buffer = new VoxelShape[]{ shape, Shapes.empty() };
|
||||
VoxelShape[] buffer = new VoxelShape[]{shape, Shapes.empty()};
|
||||
|
||||
int times = (to.ordinal() - from.ordinal() + 4) % 4;
|
||||
for (int i = 0; i < times; i++) {
|
||||
buffer[0].forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = Shapes.or(buffer[1], Shapes.box(1-maxZ, minY, minX, 1-minZ, maxY, maxX)));
|
||||
buffer[0].forAllBoxes((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = Shapes.or(buffer[1], Shapes.box(1 - maxZ, minY, minX, 1 - minZ, maxY, maxX)));
|
||||
buffer[0] = buffer[1];
|
||||
buffer[1] = Shapes.empty();
|
||||
}
|
||||
|
@@ -25,7 +25,8 @@ public class OptifineUtils {
|
||||
Class ofConfigClass = Class.forName("net.optifine.Config");
|
||||
Method rrField = ofConfigClass.getMethod("isRenderRegions");
|
||||
return (boolean) rrField.invoke(null);
|
||||
} catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
|
||||
} catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException |
|
||||
IllegalAccessException e) {
|
||||
// Optifine is probably not present. Ignore the error
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
|
@@ -39,12 +39,15 @@ public class RenderUtils {
|
||||
public static int alpha(int pPackedColor) {
|
||||
return pPackedColor >>> 24;
|
||||
}
|
||||
|
||||
public static int red(int pPackedColor) {
|
||||
return pPackedColor >> 16 & 255;
|
||||
}
|
||||
|
||||
public static int green(int pPackedColor) {
|
||||
return pPackedColor >> 8 & 255;
|
||||
}
|
||||
|
||||
public static int blue(int pPackedColor) {
|
||||
return pPackedColor & 255;
|
||||
}
|
||||
|
3
Common/src/main/resources/craterlib.aw
Normal file
3
Common/src/main/resources/craterlib.aw
Normal file
@@ -0,0 +1,3 @@
|
||||
accessWidener v1 named
|
||||
|
||||
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "${mod_name}",
|
||||
"pack_format": 8
|
||||
}
|
||||
}
|
||||
"pack": {
|
||||
"description": "${mod_name}",
|
||||
"pack_format": 8
|
||||
}
|
||||
}
|
||||
|
@@ -11,10 +11,13 @@ dependencies {
|
||||
mappings loom.officialMojangMappings()
|
||||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
|
||||
include 'me.hypherionmc.night-config:toml:3.6.5_custom'
|
||||
include 'me.hypherionmc.night-config:core:3.6.5_custom'
|
||||
implementation project(":Common")
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = project(":Common").file("src/main/resources/craterlib.aw")
|
||||
runs {
|
||||
client {
|
||||
client()
|
||||
@@ -62,12 +65,26 @@ publishing {
|
||||
artifactId project.archivesBaseName
|
||||
version project.version
|
||||
from components.java
|
||||
pom.withXml {
|
||||
Node pomNode = asNode()
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
it.artifactId.text() == 'regutils-joined-fabric' ||
|
||||
it.artifactId.text() == 'core' ||
|
||||
it.artifactId.text() == 'toml'
|
||||
}.each() {
|
||||
it.parent().remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + System.getenv("local_maven")
|
||||
url "https://maven.firstdarkdev.xyz/" + (project.isSnapshot ? "snapshots" : "releases")
|
||||
credentials {
|
||||
username System.getenv("MAVEN_USER")
|
||||
password System.getenv("MAVEN_PASS")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,14 @@
|
||||
package me.hypherionmc.craterlib;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.minecraft.server.packs.PackType;
|
||||
|
||||
public class CraterLibInitializer implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
var resources = ResourceManagerHelper.get(PackType.CLIENT_RESOURCES);
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,42 +1,39 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "craterlib",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "CraterLib",
|
||||
"description": "A library mod used by HypherionSA's Mods",
|
||||
"authors": [
|
||||
"Me!"
|
||||
"schemaVersion": 1,
|
||||
"id": "craterlib",
|
||||
"version": "${version}",
|
||||
"name": "CraterLib",
|
||||
"description": "A library mod used by HypherionSA's Mods",
|
||||
"authors": [
|
||||
"Me!"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://fabricmc.net/",
|
||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "assets/modid/icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"me.hypherionmc.craterlib.CraterLibInitializer"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://fabricmc.net/",
|
||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
||||
},
|
||||
|
||||
"license": "MIT",
|
||||
"icon": "assets/modid/icon.png",
|
||||
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"me.hypherionmc.craterlib.CraterLibInitializer"
|
||||
],
|
||||
"client": [
|
||||
"me.hypherionmc.craterlib.client.CraterLibClientInitializer"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"craterlib.mixins.json",
|
||||
"craterlib.fabric.mixins.json"
|
||||
],
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.18.x",
|
||||
"java": ">=17"
|
||||
},
|
||||
"suggests": {
|
||||
"another-mod": "*"
|
||||
}
|
||||
"client": [
|
||||
"me.hypherionmc.craterlib.client.CraterLibClientInitializer"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"craterlib.mixins.json",
|
||||
"craterlib.fabric.mixins.json"
|
||||
],
|
||||
"accessWidener": "craterlib.aw",
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.18.x",
|
||||
"java": ">=17"
|
||||
},
|
||||
"suggests": {
|
||||
"another-mod": "*"
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,9 @@ buildscript {
|
||||
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
plugins {
|
||||
id 'com.github.johnrengelman.shadow' version '7.0.0'
|
||||
}
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
@@ -97,7 +100,22 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependencies {
|
||||
include(dependency('me.hypherionmc.night-config:toml:3.6.5_custom'))
|
||||
include(dependency('me.hypherionmc.night-config:core:3.6.5_custom'))
|
||||
|
||||
//relocate 'me.hypherionmc.nightconfig', 'shadow.hypherionmc.nightconfig'
|
||||
}
|
||||
classifier ''
|
||||
}
|
||||
|
||||
reobf {
|
||||
shadowJar {}
|
||||
}
|
||||
|
||||
build.dependsOn reobfShadowJar
|
||||
reg.configureJarTask(shadowJar)
|
||||
jar.finalizedBy('reobfJar')
|
||||
|
||||
publishing {
|
||||
@@ -106,12 +124,26 @@ publishing {
|
||||
groupId project.group
|
||||
artifactId project.archivesBaseName
|
||||
version project.version
|
||||
artifact jar
|
||||
artifact shadowJar
|
||||
pom.withXml {
|
||||
Node pomNode = asNode()
|
||||
pomNode.dependencies.'*'.findAll() {
|
||||
it.artifactId.text() == 'regutils-joined-fabric' ||
|
||||
it.artifactId.text() == 'core' ||
|
||||
it.artifactId.text() == 'toml'
|
||||
}.each() {
|
||||
it.parent().remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + System.getenv("local_maven")
|
||||
url "https://maven.firstdarkdev.xyz/" + (project.isSnapshot ? "snapshots" : "releases")
|
||||
credentials {
|
||||
username System.getenv("MAVEN_USER")
|
||||
password System.getenv("MAVEN_PASS")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,4 +154,4 @@ task copyAllArtifacts(type: Copy) {
|
||||
include("*.jar")
|
||||
}
|
||||
|
||||
build.finalizedBy(copyAllArtifacts);
|
||||
build.finalizedBy(copyAllArtifacts)
|
||||
|
1
Forge/src/main/resources/META-INF/accesstransformer.cfg
Normal file
1
Forge/src/main/resources/META-INF/accesstransformer.cfg
Normal file
@@ -0,0 +1 @@
|
||||
public net.minecraft.client.renderer.LevelRenderer$RenderChunkInfo
|
@@ -1,31 +1,31 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[40,)"
|
||||
license="MIT"
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[40,)"
|
||||
license = "MIT"
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/"
|
||||
|
||||
[[mods]]
|
||||
modId="craterlib"
|
||||
version="${file.jarVersion}"
|
||||
displayName="CraterLib"
|
||||
modId = "craterlib"
|
||||
version = "${file.jarVersion}"
|
||||
displayName = "CraterLib"
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json"
|
||||
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/"
|
||||
logoFile="multiloader.png"
|
||||
logoFile = "multiloader.png"
|
||||
#credits="Thanks for this example mod goes to Java"
|
||||
authors="HypherionSA, Misha"
|
||||
description='''
|
||||
authors = "HypherionSA, Misha"
|
||||
description = '''
|
||||
A library mod used by HypherionSA's Mods
|
||||
'''
|
||||
|
||||
[[dependencies.craterlib]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[40,)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[40,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.craterlib]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.18.2,1.19)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.18.2,1.19)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
18
README.md
18
README.md
@@ -2,6 +2,24 @@
|
||||
|
||||
A library mod used by HypherionSA's mods. Mostly used by Hyper Lighting 2.
|
||||
|
||||
***
|
||||
|
||||
## Library Features
|
||||
|
||||
* Universal Config System (TOML Based)
|
||||
* Easy Cross Mod-Loader registration System
|
||||
* Built in Helper Classes for Various minecraft features
|
||||
* Built in FluidTank and Energy systems for Forge/Fabric (Forge versions are just wrappers).
|
||||
* Built in Optifine-Compat utilities
|
||||
* Various utilities for Blockstates, LANG, Math and Rendering
|
||||
* TODO: Built in Cross Mod-Loader Network system
|
||||
* TODO: Various GUI widgets and Utilities
|
||||
* TODO: Cross Mod-Loader Dynamic Lighting
|
||||
* TODO: Texture Utils
|
||||
* TODO: Sync Config From Server to Client
|
||||
|
||||
***
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
*Coming Soon*
|
||||
|
50
build.gradle
50
build.gradle
@@ -1,10 +1,31 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'com.matyrobbrt.mc.registrationutils' version '0.2.6'
|
||||
}
|
||||
|
||||
registrationUtils {
|
||||
group 'me.hypherionmc.craterlib.systems.reg'
|
||||
projects {
|
||||
Common { type 'common'; project ':Common' }
|
||||
Fabric { type 'fabric'; project ':Fabric' }
|
||||
Forge { type 'forge'; project ':Forge' }
|
||||
}
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
||||
ext {
|
||||
isSnapshot: false
|
||||
}
|
||||
|
||||
def version_base = "${project.version_major}.${project.version_minor}"
|
||||
version = "${version_base}.${project.version_patch}"
|
||||
|
||||
group = project.group
|
||||
|
||||
// Jenkins
|
||||
if (System.getenv('BUILD_NUMBER') != null) {
|
||||
project.isSnapshot = true
|
||||
version = version_base + "." + System.getenv('BUILD_NUMBER') + "d"
|
||||
}
|
||||
|
||||
@@ -17,16 +38,16 @@ subprojects {
|
||||
jar {
|
||||
manifest {
|
||||
attributes([
|
||||
'Specification-Title' : mod_name,
|
||||
'Specification-Vendor' : mod_author,
|
||||
'Specification-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Title' : project.name,
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_author,
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
'Timestampe' : System.currentTimeMillis(),
|
||||
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
|
||||
'Build-On-Minecraft' : minecraft_version
|
||||
'Specification-Title' : mod_name,
|
||||
'Specification-Vendor' : mod_author,
|
||||
'Specification-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Title' : project.name,
|
||||
'Implementation-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_author,
|
||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
'Timestampe' : System.currentTimeMillis(),
|
||||
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
|
||||
'Build-On-Minecraft' : minecraft_version
|
||||
])
|
||||
}
|
||||
}
|
||||
@@ -37,6 +58,15 @@ subprojects {
|
||||
name = 'Sponge / Mixin'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public/'
|
||||
}
|
||||
maven {
|
||||
name = 'Hypherion Maven'
|
||||
url = 'https://maven.firstdarkdev.xyz/releases/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'me.hypherionmc.night-config:toml:3.6.5_custom'
|
||||
implementation 'me.hypherionmc.night-config:core:3.6.5_custom'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
# Project
|
||||
version_major=1
|
||||
version_minor=0
|
||||
version_patch=0
|
||||
version_patch=5
|
||||
group=me.hypherionmc.craterlib
|
||||
|
||||
# Common
|
||||
@@ -10,10 +10,9 @@ common_runs_enabled=false
|
||||
common_client_run_name=Common Client
|
||||
common_server_run_name=Common Server
|
||||
|
||||
|
||||
# Forge
|
||||
forge_version=40.1.0
|
||||
//forge_ats_enabled=true
|
||||
forge_ats_enabled=true
|
||||
|
||||
# Fabric
|
||||
fabric_version=0.51.1+1.18.2
|
||||
|
Reference in New Issue
Block a user