Initial Setup and Classes

This commit is contained in:
2022-05-12 00:18:53 +02:00
commit 16c24ce795
48 changed files with 1370 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
package com.example.examplemod;
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);
}

View File

@@ -0,0 +1,13 @@
package me.hypherionmc.craterlib.api;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
public interface ISidedTickable {
public void serverTick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
public void clientTick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.api.blockentities;public interface ITickable {
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.api.rendering;public interface CustomRenderType {
}

View File

@@ -0,0 +1,12 @@
package me.hypherionmc.craterlib.api.rendering;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.world.item.DyeColor;
public interface DyeAble {
BlockColors dyeHandler();
DyeColor defaultDyeColor();
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.api.rendering;public interface ItemDyable {
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.client.gui.widgets;public class TimeSliderWidget {
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.client.rendering;public class ItemColorHandler {
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.common.item;public class BlockItemDyable {
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.common.item;public class DyableWaterBottle {
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.common.item;public class DyableWaterBucker {
}

View File

@@ -0,0 +1,20 @@
package com.example.examplemod.platform;
import com.example.examplemod.Constants;
import com.example.examplemod.platform.services.IPlatformHelper;
import java.util.ServiceLoader;
public class Services {
public static final IPlatformHelper PLATFORM = load(IPlatformHelper.class);
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;
}
}

View File

@@ -0,0 +1,26 @@
package com.example.examplemod.platform.services;
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();
}

View File

@@ -0,0 +1,91 @@
package me.hypherionmc.craterlib.systems;
import net.minecraft.nbt.CompoundTag;
/***
* Loosely based on the Forge Energy System
*/
public class CustomEnergyStorage {
protected int powerLevel;
protected int powerCapacity;
protected int maxInput;
protected int maxOutput;
public CustomEnergyStorage(int capacity) {
this(capacity, capacity, capacity, 0);
}
public CustomEnergyStorage(int powerCapacity, int maxTransfer) {
this(powerCapacity, maxTransfer, maxTransfer, 0);
}
public CustomEnergyStorage(int powerCapacity, int maxInput, int maxOutput) {
this(powerCapacity, maxInput, maxOutput, 0);
}
public CustomEnergyStorage(int capacity, int maxInput, int maxOutput, int initialPower) {
this.powerLevel = initialPower;
this.maxInput = maxInput;
this.maxOutput = maxOutput;
this.powerCapacity = capacity;
}
public CompoundTag writeNBT(CompoundTag compoundTag) {
compoundTag.putInt("powerLevel", this.powerLevel);
return compoundTag;
}
public void readNBT(CompoundTag compoundTag) {
if (compoundTag.contains("powerLevel")) {
this.powerLevel = compoundTag.getInt("powerLevel");
}
}
public int receiveEnergyInternal(int toReceive, boolean test) {
int energyReceived = Math.min(this.powerCapacity - this.powerLevel, Math.min(this.maxInput, toReceive));
if (!test)
this.powerLevel += energyReceived;
return energyReceived;
}
public int receiveEnergy(int toReceive, boolean test) {
if (this.maxInput < 1) {
return 0;
}
return this.receiveEnergyInternal(toReceive, test);
}
public int extractEnergyInternal(int toExtract, boolean test) {
int energyExtracted = Math.min(this.powerLevel, Math.min(this.powerCapacity, toExtract));
if (!test)
this.powerLevel -= energyExtracted;
return energyExtracted;
}
public int extractEnergy(int toExtract, boolean test) {
if (this.maxOutput < 1) {
return 0;
}
int energyExtracted = Math.min(this.powerLevel, Math.min(this.maxOutput, toExtract));
if (!test)
this.powerLevel -= energyExtracted;
return energyExtracted;
}
public int getPowerLevel() {
return powerLevel;
}
public int getMaxInput() {
return maxInput;
}
public int getMaxOutput() {
return maxOutput;
}
public int getPowerCapacity() {
return powerCapacity;
}
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.util;public class BlockStateUtils {
}

View File

@@ -0,0 +1,26 @@
package me.hypherionmc.hyperlighting.utils;
import net.minecraft.text.BaseText;
import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
public class LangUtils {
public static BaseText getTooltipTitle(String key) {
return new LiteralText(Formatting.YELLOW + new TranslatableText(key).getString());
}
public static String resolveTranslation(String key) {
return new TranslatableText(key).getString();
}
public static BaseText getTranslation(String key) {
return new TranslatableText(key);
}
public static BaseText makeComponent(String text) {
return new LiteralText(text);
}
}

View File

@@ -0,0 +1,21 @@
package me.hypherionmc.hyperlighting.utils;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
public class MathUtils {
public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) {
VoxelShape[] buffer = new VoxelShape[]{ shape, VoxelShapes.empty() };
int times = (to.ordinal() - from.ordinal() + 4) % 4;
for (int i = 0; i < times; i++) {
buffer[0].forEachBox((minX, minY, minZ, maxX, maxY, maxZ) -> buffer[1] = VoxelShapes.union(buffer[1], VoxelShapes.cuboid(1-maxZ, minY, minX, 1-minZ, maxY, maxX)));
buffer[0] = buffer[1];
buffer[1] = VoxelShapes.empty();
}
return buffer[0];
}
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.util;public class OptifineUtils {
}

View File

@@ -0,0 +1,2 @@
package me.hypherionmc.craterlib.util;public class RenderUtils {
}

View File

@@ -0,0 +1,17 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.example.examplemod.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"ExampleCommonMixin"
],
"server": [
],
"injectors": {
"defaultRequire": 1
},
"refmap": "${refmap_target}refmap.json"
}

View File

@@ -0,0 +1,6 @@
{
"pack": {
"description": "${mod_name}",
"pack_format": 8
}
}