Initial Setup and Classes
This commit is contained in:
52
Common/build.gradle
Normal file
52
Common/build.gradle
Normal file
@@ -0,0 +1,52 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
archivesBaseName = "${mod_name}-common-${minecraft_version}"
|
||||
|
||||
minecraft {
|
||||
version(minecraft_version)
|
||||
runs {
|
||||
if (project.hasProperty('common_runs_enabled') ? project.findProperty('common_runs_enabled').toBoolean() : true) {
|
||||
|
||||
server(project.hasProperty('common_server_run_name') ? project.findProperty('common_server_run_name') : 'vanilla_server') {
|
||||
workingDirectory(this.file("run"))
|
||||
}
|
||||
client(project.hasProperty('common_client_run_name') ? project.findProperty('common_client_run_name') : 'vanilla_client') {
|
||||
workingDirectory(this.file("run"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly group:'org.spongepowered', name:'mixin', version:'0.8.5'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
def buildProps = project.properties.clone()
|
||||
|
||||
filesMatching(['pack.mcmeta']) {
|
||||
|
||||
expand buildProps
|
||||
}
|
||||
}
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
groupId project.group
|
||||
artifactId project.archivesBaseName
|
||||
version project.version
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "file://" + System.getenv("local_maven")
|
||||
}
|
||||
}
|
||||
}
|
10
Common/src/main/java/me/hypherionmc/craterlib/Constants.java
Normal file
10
Common/src/main/java/me/hypherionmc/craterlib/Constants.java
Normal 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);
|
||||
}
|
@@ -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);
|
||||
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.api.blockentities;public interface ITickable {
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.api.rendering;public interface CustomRenderType {
|
||||
}
|
@@ -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();
|
||||
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.api.rendering;public interface ItemDyable {
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.client.gui.widgets;public class TimeSliderWidget {
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.client.rendering;public class ItemColorHandler {
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.common.item;public class BlockItemDyable {
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.common.item;public class DyableWaterBottle {
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.common.item;public class DyableWaterBucker {
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.util;public class BlockStateUtils {
|
||||
}
|
@@ -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);
|
||||
}
|
||||
|
||||
}
|
@@ -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];
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.util;public class OptifineUtils {
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
package me.hypherionmc.craterlib.util;public class RenderUtils {
|
||||
}
|
17
Common/src/main/resources/craterlib.mixins.json
Normal file
17
Common/src/main/resources/craterlib.mixins.json
Normal 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"
|
||||
}
|
6
Common/src/main/resources/pack.mcmeta
Normal file
6
Common/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "${mod_name}",
|
||||
"pack_format": 8
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user