diff --git a/.gitignore b/.gitignore index f68d109..4bb5ed9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,24 @@ -### IntelliJ IDEA ### -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project +# eclipse +bin +*.launch .settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ +.metadata +.classpath +.project -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ +# idea +out +*.ipr +*.iws +*.iml +.idea -### VS Code ### -.vscode/ +# gradle +build +.gradle -### Mac OS ### -.DS_Store \ No newline at end of file +# other +eclipse +run + +artifacts diff --git a/.idea/misc.xml b/.idea/misc.xml index 07115cd..9c2b86f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Common/build.gradle b/Common/build.gradle index 1250ce6..0547852 100644 --- a/Common/build.gradle +++ b/Common/build.gradle @@ -8,9 +8,9 @@ archivesBaseName = "${mod_name}-common-${minecraft_version}" minecraft { version(minecraft_version) - runs { + 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")) } @@ -26,11 +26,9 @@ dependencies { } processResources { - def buildProps = project.properties.clone() filesMatching(['pack.mcmeta']) { - expand buildProps } } @@ -49,4 +47,4 @@ publishing { url "file://" + System.getenv("local_maven") } } -} \ No newline at end of file +} diff --git a/Common/src/main/java/me/hypherionmc/craterlib/Constants.java b/Common/src/main/java/me/hypherionmc/craterlib/Constants.java index c80bfa9..6a7543d 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/Constants.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/Constants.java @@ -1,4 +1,4 @@ -package com.example.examplemod; +package me.hypherionmc.craterlib; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/Common/src/main/java/me/hypherionmc/craterlib/api/blockentities/ISidedTickable.java b/Common/src/main/java/me/hypherionmc/craterlib/api/blockentities/ISidedTickable.java index 40adcac..4f18bbf 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/api/blockentities/ISidedTickable.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/api/blockentities/ISidedTickable.java @@ -1,4 +1,4 @@ -package me.hypherionmc.craterlib.api; +package me.hypherionmc.craterlib.api.blockentities; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; diff --git a/Common/src/main/java/me/hypherionmc/craterlib/api/blockentities/ITickable.java b/Common/src/main/java/me/hypherionmc/craterlib/api/blockentities/ITickable.java index df4a5e5..ffa3c86 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/api/blockentities/ITickable.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/api/blockentities/ITickable.java @@ -1,2 +1,12 @@ -package me.hypherionmc.craterlib.api.blockentities;public interface ITickable { +package me.hypherionmc.craterlib.api.blockentities; + +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 ITickable { + + public void tick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity); + } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/CustomRenderType.java b/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/CustomRenderType.java index f59d4ea..5a09023 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/CustomRenderType.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/CustomRenderType.java @@ -1,2 +1,9 @@ -package me.hypherionmc.craterlib.api.rendering;public interface CustomRenderType { +package me.hypherionmc.craterlib.api.rendering; + +import net.minecraft.client.renderer.entity.layers.RenderLayer; + +public interface CustomRenderType { + + RenderLayer getCustomRenderType(); + } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/DyableBlock.java b/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/DyableBlock.java index e3cd5e2..81bb77d 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/DyableBlock.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/DyableBlock.java @@ -3,7 +3,7 @@ package me.hypherionmc.craterlib.api.rendering; import net.minecraft.client.color.block.BlockColors; import net.minecraft.world.item.DyeColor; -public interface DyeAble { +public interface DyableBlock { BlockColors dyeHandler(); diff --git a/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/ItemDyable.java b/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/ItemDyable.java index d846a54..9ed2e2c 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/ItemDyable.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/api/rendering/ItemDyable.java @@ -1,2 +1,9 @@ -package me.hypherionmc.craterlib.api.rendering;public interface ItemDyable { +package me.hypherionmc.craterlib.api.rendering; + +import net.minecraft.world.item.DyeColor; + +public interface ItemDyable { + + public DyeColor getColor(); + } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/client/gui/widgets/TimeSliderWidget.java b/Common/src/main/java/me/hypherionmc/craterlib/client/gui/widgets/TimeSliderWidget.java index e4ec2bc..10ff84f 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/client/gui/widgets/TimeSliderWidget.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/client/gui/widgets/TimeSliderWidget.java @@ -1,2 +1,48 @@ -package me.hypherionmc.craterlib.client.gui.widgets;public class TimeSliderWidget { +package me.hypherionmc.craterlib.client.gui.widgets; + +import net.minecraft.client.gui.components.AbstractSliderButton; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; + +public class TimeSliderWidget extends AbstractSliderButton { + + private final double maxValue; + private final ISliderChanged sliderChanged; + + public TimeSliderWidget(int x, int y, int width, int height, Component text, double value, double maxValue, ISliderChanged sliderChanged) { + super(x, y, width, height, text, value / maxValue); + this.maxValue = maxValue; + this.sliderChanged = sliderChanged; + this.updateMessage(); + } + + @Override + protected void updateMessage() { + this.setMessage(getDisplayString()); + } + + @Override + protected void applyValue() { + this.sliderChanged.onSliderChange(this); + } + + private Component getDisplayString() { + long seconds = Math.round(this.value * this.maxValue / 20); + long minutes = Math.round(seconds / 60); + if (this.value * this.maxValue >= 1200) { + String appendString = (minutes == 1) ? "Minute" : "Minutes"; + String doSeconds = ((seconds - (minutes * 60)) > 0) ? ", " + (seconds - (minutes * 60)) + " Seconds" : ""; + return new TextComponent(minutes + " " + appendString + doSeconds); + } else { + return new TextComponent(seconds + " Seconds"); + } + } + + public double getValue() { + return this.value; + } + + public interface ISliderChanged { + void onSliderChange(TimeSliderWidget slider); + } } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/client/rendering/ItemColorHandler.java b/Common/src/main/java/me/hypherionmc/craterlib/client/rendering/ItemColorHandler.java index 5738822..cd2cebf 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/client/rendering/ItemColorHandler.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/client/rendering/ItemColorHandler.java @@ -1,2 +1,22 @@ -package me.hypherionmc.craterlib.client.rendering;public class ItemColorHandler { +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.world.item.ItemStack; + +public class ItemColorHandler extends ItemColors { + + @Override + public int getColor(ItemStack stack, int tintIndex) { + return this.getColorFromStack(stack); + } + + private int getColorFromStack(ItemStack stack) { + if (stack.getItem() instanceof ItemDyable itemDyable) { + return itemDyable.getColor().getMaterialColor().col; + } + return 0; + } } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/common/item/BlockItemDyable.java b/Common/src/main/java/me/hypherionmc/craterlib/common/item/BlockItemDyable.java index 77b07c2..b5f850a 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/common/item/BlockItemDyable.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/common/item/BlockItemDyable.java @@ -1,2 +1,22 @@ -package me.hypherionmc.craterlib.common.item;public class BlockItemDyable { +package me.hypherionmc.craterlib.common.item; + +import me.hypherionmc.craterlib.api.rendering.DyableBlock; +import me.hypherionmc.craterlib.api.rendering.ItemDyable; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.level.block.Block; + +public class BlockItemDyable extends BlockItem implements ItemDyable { + + public BlockItemDyable(Block block, Properties properties) { + super(block, properties); + } + + @Override + public DyeColor getColor() { + if (this.getBlock() instanceof DyableBlock dyableBlock) { + return dyableBlock.defaultDyeColor(); + } + return DyeColor.BLACK; + } } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/common/item/DyableWaterBottle.java b/Common/src/main/java/me/hypherionmc/craterlib/common/item/DyableWaterBottle.java index b3e1a9b..256f302 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/common/item/DyableWaterBottle.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/common/item/DyableWaterBottle.java @@ -1,2 +1,93 @@ -package me.hypherionmc.craterlib.common.item;public class DyableWaterBottle { +package me.hypherionmc.craterlib.common.item; + +import me.hypherionmc.craterlib.api.rendering.ItemDyable; +import net.minecraft.advancements.CriteriaTriggers; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.stats.Stats; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.*; +import net.minecraft.world.item.alchemy.PotionUtils; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.gameevent.GameEvent; + +import java.util.List; + +public class DyableWaterBottle extends DyeItem implements ItemDyable { + + private final DyeColor color; + private final boolean isGlowing; + + public DyableWaterBottle(DyeColor color, boolean isGlowing, Properties properties) { + super(color, properties); + this.color = color; + this.isGlowing = isGlowing; + } + + @Override + public boolean isFoil(ItemStack stack) { + return this.isGlowing; + } + + @Override + public DyeColor getColor() { + return this.color; + } + + @Override + public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity user) { + Player playerEntity; + Player playerEntity2 = playerEntity = user instanceof Player ? (Player) user : null; + if (playerEntity instanceof ServerPlayer) { + CriteriaTriggers.CONSUME_ITEM.trigger((ServerPlayer) playerEntity, stack); + } + if (!level.isClientSide()) { + List list = PotionUtils.getMobEffects(stack); + for (MobEffectInstance statusEffectInstance : list) { + if (statusEffectInstance.getEffect().isInstantenous()) { + statusEffectInstance.getEffect().applyInstantenousEffect(playerEntity, playerEntity, user, statusEffectInstance.getAmplifier(), 1.0); + continue; + } + user.addEffect(new MobEffectInstance(statusEffectInstance)); + } + if (stack.getItem() == this && isGlowing) { + user.addEffect(new MobEffectInstance(MobEffects.NIGHT_VISION, 3600)); + } + } + if (playerEntity != null) { + playerEntity.awardStat(Stats.ITEM_USED.get(this)); + if (!playerEntity.getAbilities().instabuild) { + stack.shrink(1); + } + } + if (playerEntity == null || !playerEntity.getAbilities().instabuild) { + if (stack.isEmpty()) { + return new ItemStack(Items.GLASS_BOTTLE); + } + if (playerEntity != null) { + playerEntity.getInventory().add(new ItemStack(Items.GLASS_BOTTLE)); + } + } + level.gameEvent(user, GameEvent.DRINKING_FINISH, user.getOnPos()); + return stack; + } + + @Override + public int getUseDuration(ItemStack stack) { + return 32; + } + + @Override + public UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.DRINK; + } + + @Override + public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + return ItemUtils.startUsingInstantly(level, player, hand); + } } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/common/item/DyableWaterBucket.java b/Common/src/main/java/me/hypherionmc/craterlib/common/item/DyableWaterBucket.java index ed2dab4..9dee392 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/common/item/DyableWaterBucket.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/common/item/DyableWaterBucket.java @@ -1,2 +1,33 @@ -package me.hypherionmc.craterlib.common.item;public class DyableWaterBucker { +package me.hypherionmc.craterlib.common.item; + +import me.hypherionmc.craterlib.api.rendering.ItemDyable; +import net.minecraft.world.item.BucketItem; +import net.minecraft.world.item.DyeColor; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.material.Fluid; + +public class DyableWaterBucket extends BucketItem implements ItemDyable { + + private final DyeColor color; + private final boolean isGlowing; + + public DyableWaterBucket(Fluid fluid, Properties properties, DyeColor color, boolean isGlowing) { + super(fluid, properties); + this.color = color; + this.isGlowing = isGlowing; + } + + @Override + public boolean isFoil(ItemStack stack) { + return this.isGlowing; + } + + @Override + public DyeColor getColor() { + return this.color; + } + + public boolean isGlowing() { + return isGlowing; + } } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/platform/Services.java b/Common/src/main/java/me/hypherionmc/craterlib/platform/Services.java index 738a418..0d46dbc 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/platform/Services.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/platform/Services.java @@ -1,7 +1,7 @@ -package com.example.examplemod.platform; +package me.hypherionmc.craterlib.platform; -import com.example.examplemod.Constants; -import com.example.examplemod.platform.services.IPlatformHelper; +import me.hypherionmc.craterlib.Constants; +import me.hypherionmc.craterlib.platform.services.IPlatformHelper; import java.util.ServiceLoader; diff --git a/Common/src/main/java/me/hypherionmc/craterlib/platform/services/IPlatformHelper.java b/Common/src/main/java/me/hypherionmc/craterlib/platform/services/IPlatformHelper.java index 21e3452..58c4a21 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/platform/services/IPlatformHelper.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/platform/services/IPlatformHelper.java @@ -1,26 +1,10 @@ -package com.example.examplemod.platform.services; +package me.hypherionmc.craterlib.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(); } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/systems/energy/CustomEnergyStorage.java b/Common/src/main/java/me/hypherionmc/craterlib/systems/energy/CustomEnergyStorage.java index 1944313..21d274d 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/systems/energy/CustomEnergyStorage.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/systems/energy/CustomEnergyStorage.java @@ -1,4 +1,4 @@ -package me.hypherionmc.craterlib.systems; +package me.hypherionmc.craterlib.systems.energy; import net.minecraft.nbt.CompoundTag; diff --git a/Common/src/main/java/me/hypherionmc/craterlib/util/BlockStateUtils.java b/Common/src/main/java/me/hypherionmc/craterlib/util/BlockStateUtils.java index c5d4139..dc333d9 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/util/BlockStateUtils.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/util/BlockStateUtils.java @@ -1,2 +1,18 @@ -package me.hypherionmc.craterlib.util;public class BlockStateUtils { +package me.hypherionmc.craterlib.util; + +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; + +import java.util.function.ToIntFunction; + +public class BlockStateUtils { + + public static ToIntFunction createLightLevelFromLitBlockState(int litLevel) { + return state -> state.getValue(BlockStateProperties.LIT) ? litLevel : 0; + } + + public static ToIntFunction createLightLevelFromPoweredBlockState(int litLevel) { + return state -> state.getValue(BlockStateProperties.POWERED) ? litLevel : 0; + } + } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/util/LangUtils.java b/Common/src/main/java/me/hypherionmc/craterlib/util/LangUtils.java index c40e610..539304e 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/util/LangUtils.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/util/LangUtils.java @@ -1,26 +1,26 @@ -package me.hypherionmc.hyperlighting.utils; +package me.hypherionmc.craterlib.util; -import net.minecraft.text.BaseText; -import net.minecraft.text.LiteralText; -import net.minecraft.text.TranslatableText; -import net.minecraft.util.Formatting; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.TranslatableComponent; public class LangUtils { - public static BaseText getTooltipTitle(String key) { - return new LiteralText(Formatting.YELLOW + new TranslatableText(key).getString()); + public static Component getTooltipTitle(String key) { + return new TextComponent(ChatFormatting.YELLOW + new TranslatableComponent(key).getString()); } public static String resolveTranslation(String key) { - return new TranslatableText(key).getString(); + return new TranslatableComponent(key).getString(); } - public static BaseText getTranslation(String key) { - return new TranslatableText(key); + public static Component getTranslation(String key) { + return new TranslatableComponent(key); } - public static BaseText makeComponent(String text) { - return new LiteralText(text); + public static Component makeComponent(String text) { + return new TranslatableComponent(text); } } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/util/MathUtils.java b/Common/src/main/java/me/hypherionmc/craterlib/util/MathUtils.java index ece0439..94d8fc1 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/util/MathUtils.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/util/MathUtils.java @@ -1,21 +1,37 @@ -package me.hypherionmc.hyperlighting.utils; +package me.hypherionmc.craterlib.util; -import net.minecraft.util.math.Direction; -import net.minecraft.util.shape.VoxelShape; -import net.minecraft.util.shape.VoxelShapes; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.world.phys.shapes.Shapes; +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, VoxelShapes.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].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].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] = VoxelShapes.empty(); + buffer[1] = Shapes.empty(); } return buffer[0]; } + public static void writeBlockPosToNBT(BlockPos pos, CompoundTag tag) { + tag.putInt("block_x", pos.getX()); + tag.putInt("block_y", pos.getY()); + tag.putInt("block_z", pos.getZ()); + } + + public static BlockPos readBlockPosFromNBT(CompoundTag tag) { + int x, y, z; + x = tag.getInt("block_x"); + y = tag.getInt("block_y"); + z = tag.getInt("block_z"); + return new BlockPos(x, y, z); + } + } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/util/OptifineUtils.java b/Common/src/main/java/me/hypherionmc/craterlib/util/OptifineUtils.java index 6c0cc62..ad1fe6e 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/util/OptifineUtils.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/util/OptifineUtils.java @@ -1,2 +1,41 @@ -package me.hypherionmc.craterlib.util;public class OptifineUtils { +package me.hypherionmc.craterlib.util; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class OptifineUtils { + + private static boolean hasOptifine = false; + + public static void checkOptifine() { + try { + Class ofConfigClass = Class.forName("net.optifine.Config"); + hasOptifine = true; + } catch (ClassNotFoundException e) { + // Optifine is probably not present. Ignore the error + hasOptifine = false; + } catch (Exception e) { + e.printStackTrace(); + } + hasOptifine = false; + } + + public static boolean isRenderRegions() { + try { + Class ofConfigClass = Class.forName("net.optifine.Config"); + Method rrField = ofConfigClass.getMethod("isRenderRegions"); + return (boolean) rrField.invoke(null); + } catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) { + // Optifine is probably not present. Ignore the error + return false; + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } + + public static boolean hasOptifine() { + return hasOptifine; + } + } diff --git a/Common/src/main/java/me/hypherionmc/craterlib/util/RenderUtils.java b/Common/src/main/java/me/hypherionmc/craterlib/util/RenderUtils.java index 1f5f771..ee17f5d 100644 --- a/Common/src/main/java/me/hypherionmc/craterlib/util/RenderUtils.java +++ b/Common/src/main/java/me/hypherionmc/craterlib/util/RenderUtils.java @@ -1,2 +1,52 @@ -package me.hypherionmc.craterlib.util;public class RenderUtils { +package me.hypherionmc.craterlib.util; + +import com.mojang.math.Vector4f; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextComponent; + +public class RenderUtils { + + public static Vector4f colorIntToRGBA(int color) { + float a = 1.0F; + float r = (color >> 16 & 0xFF) / 255.0F; + float g = (color >> 8 & 0xFF) / 255.0F; + float b = (color & 0xFF) / 255.0F; + + return new Vector4f(r, g, b, a); + } + + public static Component getFluidAmount(long amount, long capacity) { + amount = amount / 81; + capacity = capacity / 81; + String text = "" + (int) (((float) amount / capacity) * 100); + return amount > 0 ? new TextComponent(ChatFormatting.AQUA + text + "%") : new TextComponent(text + "%"); + } + + public static Component getTimeDisplayString(double value) { + long seconds = Math.round((value / 20)); + long minutes = Math.round(seconds / 60); + if (seconds >= 60) { + String appendString = (minutes == 1) ? "Minute" : "Minutes"; + String doSeconds = ((seconds - (minutes * 60)) > 0) ? ", " + (seconds - (minutes * 60)) + " Seconds" : ""; + return new TextComponent(minutes + " " + appendString + doSeconds); + } else { + return new TextComponent(seconds + " Seconds"); + } + } + + public static class ARGB32 { + 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; + } + } } diff --git a/Common/src/main/resources/craterlib.mixins.json b/Common/src/main/resources/craterlib.mixins.json index d9b16ba..7b33759 100644 --- a/Common/src/main/resources/craterlib.mixins.json +++ b/Common/src/main/resources/craterlib.mixins.json @@ -1,12 +1,11 @@ { "required": true, "minVersion": "0.8", - "package": "com.example.examplemod.mixin", + "package": "me.hypherionmc.craterlib.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ ], "client": [ - "ExampleCommonMixin" ], "server": [ ], @@ -14,4 +13,4 @@ "defaultRequire": 1 }, "refmap": "${refmap_target}refmap.json" -} \ No newline at end of file +} diff --git a/Fabric/build.gradle b/Fabric/build.gradle index 170f715..c569b4c 100644 --- a/Fabric/build.gradle +++ b/Fabric/build.gradle @@ -71,3 +71,20 @@ publishing { } } } + +task delDevJar { + doLast { + def tree = fileTree('build/libs') + tree.include '**/*-dev.jar' + tree.each { it.delete() } + } +} +build.finalizedBy delDevJar + +task copyAllArtifacts(type: Copy) { + from "$buildDir/libs" + into "$rootDir/artifacts" + include("*.jar") +} + +build.finalizedBy(copyAllArtifacts); diff --git a/Fabric/src/main/java/me/hypherionmc/craterlib/CraterLibInitializer.java b/Fabric/src/main/java/me/hypherionmc/craterlib/CraterLibInitializer.java index 9280593..1a92617 100644 --- a/Fabric/src/main/java/me/hypherionmc/craterlib/CraterLibInitializer.java +++ b/Fabric/src/main/java/me/hypherionmc/craterlib/CraterLibInitializer.java @@ -1,2 +1,11 @@ -package me.hypherionmc.craterlib;public class CraterLibInitializer { +package me.hypherionmc.craterlib; + +import net.fabricmc.api.ModInitializer; + +public class CraterLibInitializer implements ModInitializer { + + @Override + public void onInitialize() { + + } } diff --git a/Fabric/src/main/java/me/hypherionmc/craterlib/client/CraterLibClientInitializer.java b/Fabric/src/main/java/me/hypherionmc/craterlib/client/CraterLibClientInitializer.java index 2f0c541..973dd03 100644 --- a/Fabric/src/main/java/me/hypherionmc/craterlib/client/CraterLibClientInitializer.java +++ b/Fabric/src/main/java/me/hypherionmc/craterlib/client/CraterLibClientInitializer.java @@ -1,2 +1,11 @@ -package me.hypherionmc.craterlib.client;public class CraterLibClientInitializer { +package me.hypherionmc.craterlib.client; + +import net.fabricmc.api.ClientModInitializer; + +public class CraterLibClientInitializer implements ClientModInitializer { + + @Override + public void onInitializeClient() { + + } } diff --git a/Fabric/src/main/java/me/hypherionmc/craterlib/client/gui/widgets/FluidStackWidget.java b/Fabric/src/main/java/me/hypherionmc/craterlib/client/gui/widgets/FluidStackWidget.java index 84684bb..a9c66b1 100644 --- a/Fabric/src/main/java/me/hypherionmc/craterlib/client/gui/widgets/FluidStackWidget.java +++ b/Fabric/src/main/java/me/hypherionmc/craterlib/client/gui/widgets/FluidStackWidget.java @@ -1,2 +1,95 @@ -package me.hypherionmc.craterlib.client.gui.widgets;public class FluidStackWidget { +package me.hypherionmc.craterlib.client.gui.widgets; + +import com.mojang.blaze3d.systems.RenderSystem; +import com.mojang.blaze3d.vertex.PoseStack; +import me.hypherionmc.craterlib.systems.fluid.FluidTank; +import me.hypherionmc.craterlib.util.LangUtils; +import me.hypherionmc.craterlib.util.RenderUtils; +import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering; +import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.components.AbstractWidget; +import net.minecraft.client.gui.narration.NarrationElementOutput; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.renderer.texture.TextureAtlas; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.network.chat.TextComponent; + +import java.util.Arrays; +import java.util.Optional; +import java.util.function.Supplier; + +/** + * Modified from https://github.com/SleepyTrousers/EnderIO-Rewrite/blob/dev/1.18.x/enderio-machines/src/main/java/com/enderio/machines/client/FluidStackWidget.java + */ +public class FluidStackWidget extends AbstractWidget { + + private final Screen displayOn; + private final Supplier getFluid; + + private final String toolTipTitle; + + public FluidStackWidget(Screen displayOn, Supplier getFluid, int pX, int pY, int pWidth, int pHeight, String tooltipTitle) { + super(pX, pY, pWidth, pHeight, TextComponent.EMPTY); + this.displayOn = displayOn; + this.getFluid = getFluid; + this.toolTipTitle = tooltipTitle; + } + + @Override + public void renderButton(PoseStack matrices, int mouseX, int mouseY, float delta) { + Minecraft minecraft = Minecraft.getInstance(); + RenderSystem.setShader(GameRenderer::getPositionTexShader); + RenderSystem.defaultBlendFunc(); + RenderSystem.enableDepthTest(); + FluidTank fluidTank = getFluid.get(); + if (!fluidTank.getResource().isBlank()) { + FluidVariant fluidStack = fluidTank.getResource(); + TextureAtlasSprite still = FluidVariantRendering.getSprite(fluidStack); + if (still != null) { + RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_BLOCKS); + + int color = FluidVariantRendering.getColor(fluidStack); + RenderSystem.setShaderColor( + RenderUtils.ARGB32.red(color) / 255.0F, + RenderUtils.ARGB32.green(color) / 255.0F, + RenderUtils.ARGB32.blue(color) / 255.0F, + RenderUtils.ARGB32.alpha(color) / 255.0F); + RenderSystem.enableBlend(); + + long stored = fluidTank.getAmount(); + float capacity = fluidTank.getCapacity(); + float filledVolume = stored / capacity; + int renderableHeight = (int) (filledVolume * height); + + int atlasWidth = (int) (still.getWidth() / (still.getU1() - still.getU0())); + int atlasHeight = (int) (still.getHeight() / (still.getV1() - still.getV0())); + + matrices.pushPose(); + matrices.translate(0, height - 16, 0); + for (int i = 0; i < Math.ceil(renderableHeight / 16f); i++) { + int drawingHeight = Math.min(16, renderableHeight - 16 * i); + int notDrawingHeight = 16 - drawingHeight; + blit(matrices, x, y + notDrawingHeight, displayOn.getBlitOffset(), still.getU0() * atlasWidth, still.getV0() * atlasHeight + notDrawingHeight, this.width, drawingHeight, atlasWidth, atlasHeight); + matrices.translate(0, -16, 0); + } + + RenderSystem.setShaderColor(1, 1, 1, 1); + matrices.popPose(); + } + renderToolTip(matrices, mouseX, mouseY); + } + } + + @Override + public void renderToolTip(PoseStack poseStack, int mouseX, int mouseY) { + if (this.visible && this.isFocused() && isHoveredOrFocused()) { + displayOn.renderTooltip(poseStack, Arrays.asList(LangUtils.getTooltipTitle(toolTipTitle), new TextComponent((int) (((float) this.getFluid.get().getAmount() / this.getFluid.get().getCapacity()) * 100) + "%")), Optional.empty(), mouseX, mouseY); + } + } + + @Override + public void updateNarration(NarrationElementOutput narrationElementOutput) { + } } diff --git a/Fabric/src/main/java/me/hypherionmc/craterlib/systems/fluid/FluidTank.java b/Fabric/src/main/java/me/hypherionmc/craterlib/systems/fluid/FluidTank.java index 5f58ac2..d4fcea0 100644 --- a/Fabric/src/main/java/me/hypherionmc/craterlib/systems/fluid/FluidTank.java +++ b/Fabric/src/main/java/me/hypherionmc/craterlib/systems/fluid/FluidTank.java @@ -1,29 +1,28 @@ -package me.hypherionmc.hyperlighting.api.fluid; +package me.hypherionmc.craterlib.systems.fluid; -import me.hypherionmc.hyperlighting.utils.ModUtils; import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; import net.fabricmc.fabric.api.transfer.v1.storage.Storage; import net.fabricmc.fabric.api.transfer.v1.storage.StoragePreconditions; import net.fabricmc.fabric.api.transfer.v1.storage.StorageView; import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleViewIterator; import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext; -import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.CompoundTag; import java.util.Iterator; import java.util.function.Predicate; -public class FluidStorageTank implements Storage, StorageView { +public class FluidTank implements Storage, StorageView { private final long capacity; private final Predicate validFluid; private long level = 0; private FluidVariant fluid = FluidVariant.blank(); - public FluidStorageTank(long capacity) { + public FluidTank(long capacity) { this(capacity, e -> true); } - public FluidStorageTank(long capacity, Predicate validFluid) { + public FluidTank(long capacity, Predicate validFluid) { this.capacity = capacity; this.validFluid = validFluid; } @@ -87,14 +86,14 @@ public class FluidStorageTank implements Storage, StorageView=0.12", "fabric": "*", @@ -37,4 +40,3 @@ "another-mod": "*" } } - \ No newline at end of file diff --git a/Forge/build.gradle b/Forge/build.gradle index 05a3e94..921bca4 100644 --- a/Forge/build.gradle +++ b/Forge/build.gradle @@ -115,3 +115,11 @@ publishing { } } } + +task copyAllArtifacts(type: Copy) { + from "$buildDir/libs" + into "$rootDir/artifacts" + include("*.jar") +} + +build.finalizedBy(copyAllArtifacts); diff --git a/Forge/src/main/java/me/hypherionmc/craterlib/CraterLib.java b/Forge/src/main/java/me/hypherionmc/craterlib/CraterLib.java index f3ed7be..1c7c12d 100644 --- a/Forge/src/main/java/me/hypherionmc/craterlib/CraterLib.java +++ b/Forge/src/main/java/me/hypherionmc/craterlib/CraterLib.java @@ -1,34 +1,11 @@ -package com.example.examplemod; +package me.hypherionmc.craterlib; -import me.hypherionmc.craterlib.Constants; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.Mod; @Mod(Constants.MOD_ID) -public class ExampleMod { +public class CraterLib { - public ExampleMod() { + public CraterLib() { - // This method is invoked by the Forge mod loader when it is ready - // to load your mod. You can access Forge and Common code in this - // project. - - // Use Forge to bootstrap the Common mod. - Constants.LOG.info("Hello Forge world!"); - CommonClass.init(); - - // Some code like events require special initialization from the - // loader specific code. - MinecraftForge.EVENT_BUS.addListener(this::onItemTooltip); - - } - - // This method exists as a wrapper for the code in the Common project. - // It takes Forge's event object and passes the parameters along to - // the Common listener. - private void onItemTooltip(ItemTooltipEvent event) { - - CommonClass.onItemTooltip(event.getItemStack(), event.getFlags(), event.getToolTip()); } } diff --git a/Forge/src/main/resources/META-INF/mods.toml b/Forge/src/main/resources/META-INF/mods.toml index d000fe9..e6ea5ee 100644 --- a/Forge/src/main/resources/META-INF/mods.toml +++ b/Forge/src/main/resources/META-INF/mods.toml @@ -1,62 +1,31 @@ -# This is an example mods.toml file. It contains the data relating to the loading mods. -# There are several mandatory fields (#mandatory), and many more that are optional (#optional). -# The overall format is standard TOML format, v0.5.0. -# Note that there are a couple of TOML lists in this file. -# Find more information on toml format here: https://github.com/toml-lang/toml -# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml -modLoader="javafml" #mandatory -# A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[38,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. -# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. -# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. -license="All rights reserved" -# A URL to refer people to when problems occur with this mod -#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional -# A list of mods - how many allowed here is determined by the individual mod loader -[[mods]] #mandatory -# The modid of the mod -modId="multiloader" #mandatory -# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it -# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata -# see the associated build.gradle script for how to populate this completely automatically during a build -version="${file.jarVersion}" #mandatory - # A display name for the mod -displayName="Example Mod" #mandatory -# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/ -#updateJSONURL="https://change.me.example.invalid/updates.json" #optional -# A URL for the "homepage" for this mod, displayed in the mod UI -#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional -# A file name (in the root of the mod JAR) containing a logo for display -logoFile="multiloader.png" #optional -# A text field displayed in the mod UI -credits="Thanks for this example mod goes to Java" #optional -# A text field displayed in the mod UI -authors="Love, Cheese and small house plants" #optional -# The description text for the mod (multi line!) (#mandatory) +modLoader="javafml" +loaderVersion="[40,)" +license="MIT" +#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" + +[[mods]] +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" +#credits="Thanks for this example mod goes to Java" +authors="HypherionSA, Misha" description=''' -This is a long form description of the mod. You can write whatever you want here - -Have some lorem ipsum. - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis lacinia magna. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sagittis luctus odio eu tempus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque volutpat ligula eget lacus auctor sagittis. In hac habitasse platea dictumst. Nunc gravida elit vitae sem vehicula efficitur. Donec mattis ipsum et arcu lobortis, eleifend sagittis sem rutrum. Cras pharetra quam eget posuere fermentum. Sed id tincidunt justo. Lorem ipsum dolor sit amet, consectetur adipiscing elit. +A library mod used by HypherionSA's Mods ''' -# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional. -[[dependencies.multiloader]] #optional - # the modid of the dependency - modId="forge" #mandatory - # Does this dependency have to exist - if not, ordering below must be specified - mandatory=true #mandatory - # The version range of the dependency - versionRange="[38,)" #mandatory - # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory + +[[dependencies.craterlib]] + modId="forge" + mandatory=true + versionRange="[40,)" ordering="NONE" - # Side this dependency is applied on - BOTH, CLIENT or SERVER side="BOTH" -# Here's another dependency -[[dependencies.multiloader]] + +[[dependencies.craterlib]] modId="minecraft" mandatory=true -# This version range declares a minimum of the current minecraft version up to but not including the next major version - versionRange="[1.18,1.19)" + versionRange="[1.18.2,1.19)" ordering="NONE" side="BOTH" diff --git a/Forge/src/main/resources/craterlib.forge.mixins.json b/Forge/src/main/resources/craterlib.forge.mixins.json index 5964133..7b33759 100644 --- a/Forge/src/main/resources/craterlib.forge.mixins.json +++ b/Forge/src/main/resources/craterlib.forge.mixins.json @@ -1,12 +1,11 @@ { "required": true, "minVersion": "0.8", - "package": "com.example.examplemod.mixin", + "package": "me.hypherionmc.craterlib.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ ], "client": [ - "ExampleForgeMixin" ], "server": [ ], @@ -14,4 +13,4 @@ "defaultRequire": 1 }, "refmap": "${refmap_target}refmap.json" -} \ No newline at end of file +} diff --git a/LICENSE b/LICENSE index 0e259d4..cfe1daf 100644 --- a/LICENSE +++ b/LICENSE @@ -1,121 +1,21 @@ -Creative Commons Legal Code +The MIT License (MIT) -CC0 1.0 Universal +Copyright (c) 2021 - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -Statement of Purpose +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 11af880..c67c0ff 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,7 @@ -# MultiLoader Template +# CraterLib -This project provides a Gradle project template that can compile mods for both Forge and Fabric using a common sourceset. This project does not require any third party libraries or dependencies. +A library mod used by HypherionSA's mods. Mostly used by Hyper Lighting 2. -## Getting Started +## Setup Instructions -## IntelliJ IDEA -This guide will show how to import the MultiLoader Template into IntelliJ IDEA. The setup process is roughly equivalent to setting up Forge and Fabric independently and should be very familiar to anyone who has worked with their MDKs. - -1. Clone or download this repository to your computer. -2. Configure the project by editing the `group`, `mod_name`, `mod_author`, and `mod_id` properties in the `gradle.properties` file. You will also need to change the `rootProject.name` property in `settings.gradle`. -3. Open the template's root folder as a new project in IDEA. This is the folder that contains this README file and the gradlew executable. -4. If your default JVM/JDK is not Java 16 you will encounter an error when opening the project. This error is fixed by going to `File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM`and changing the value to a valid Java 16 JVM. You will also need to set the Project SDK to Java 16. This can be done by going to `File > Project Structure > Project SDK`. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project. -5. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Common > Tasks > vanilla gradle > decompile`. Run this task to decompile Minecraft. -6. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Forge > Tasks > forgegradle runs > genIntellijRuns`. Run this task to set up run configurations for Forge. -7. Open your Run/Debug Configurations. Under the Application category there should now be options to run Forge and Fabric projects. Select one of the client options and try to run it. -8. Assuming you were able to run the game in step 7 your workspace should now be set up. - -### Eclipse -While it is possible to use this template in Eclipse it is not recommended. During the development of this template multiple critical bugs and quirks related to Eclipse were found at nearly every level of the required build tools. While we continue to work with these tools to report and resolve issues support for projects like these are not there yet. For now Eclipse is considered unsupported by this project. The development cycle for build tools is notoriously slow so there are no ETAs available. - -## Development Guide -When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knwoledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the Forge or Fabric project. - -Loader specific projects such as the Forge and Fabric project are used to load the Common project into the game. These projects also define code that is specific to that loader. Loader specific projects can access all of the code in the Common project. It is important to remember that the Common project can not access code from loader specific projects. \ No newline at end of file +*Coming Soon* diff --git a/build.gradle b/build.gradle index c15265c..e52d38b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,19 @@ subprojects { - + + def version_base = "${project.version_major}.${project.version_minor}" + version = "${version_base}.${project.version_patch}" + + // Jenkins + if (System.getenv('BUILD_NUMBER') != null) { + version = version_base + "." + System.getenv('BUILD_NUMBER') + "d" + } + apply plugin: 'java' - + java.toolchain.languageVersion = JavaLanguageVersion.of(17) - java.withSourcesJar() - java.withJavadocJar() - + //java.withSourcesJar() + //java.withJavadocJar() + jar { manifest { attributes([ @@ -22,25 +30,16 @@ subprojects { ]) } } - + repositories { - mavenCentral() - maven { name = 'Sponge / Mixin' url = 'https://repo.spongepowered.org/repository/maven-public/' } - - maven { - name = 'BlameJared Maven (CrT / Bookshelf)' - url = 'https://maven.blamejared.com' - } } - tasks.withType(JavaCompile).configureEach { - it.options.encoding = 'UTF-8' it.options.release = 17 } @@ -49,7 +48,10 @@ subprojects { // metadata includes mapped dependencies which are not reasonably consumable by // other mod developers. tasks.withType(GenerateModuleMetadata) { - enabled = false } -} \ No newline at end of file + + clean { + delete "$rootDir/artifacts" + } +} diff --git a/gradle.properties b/gradle.properties index 0e8f5fd..663d90d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,27 +1,29 @@ # Project -version=1.0.0 -group=com.example.examplemod +version_major=1 +version_minor=0 +version_patch=0 +group=me.hypherionmc.craterlib # Common -minecraft_version=1.18.1 +minecraft_version=1.18.2 common_runs_enabled=false common_client_run_name=Common Client common_server_run_name=Common Server # Forge -forge_version=39.0.7 +forge_version=40.1.0 //forge_ats_enabled=true # Fabric -fabric_version=0.44.0+1.18 -fabric_loader_version=0.12.12 +fabric_version=0.51.1+1.18.2 +fabric_loader_version=0.13.3 # Mod options -mod_name=MultiLoader -mod_author=Jared -mod_id=multiloader +mod_name=CraterLib +mod_author=HypherionSA +mod_id=craterlib # Gradle org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false \ No newline at end of file +org.gradle.daemon=false diff --git a/settings.gradle b/settings.gradle index 174e944..a440972 100644 --- a/settings.gradle +++ b/settings.gradle @@ -12,5 +12,5 @@ pluginManagement { } } -rootProject.name = 'MultiLoader' -include("Common", "Fabric", "Forge") \ No newline at end of file +rootProject.name = 'CraterLib' +include("Common", "Fabric", "Forge")