Code cleanup and refactoring before porting
This commit is contained in:
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -9,6 +9,9 @@
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<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>
|
||||
|
@@ -0,0 +1,10 @@
|
||||
package com.hypherionmc.craterlib;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CraterConstants {
|
||||
public static final String MOD_ID = "craterlib";
|
||||
public static final String MOD_NAME = "CraterLib";
|
||||
public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME);
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.api.blockentities;
|
||||
package com.hypherionmc.craterlib.api.blockentity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -11,14 +11,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
*/
|
||||
public interface ISidedTickable {
|
||||
|
||||
/**
|
||||
* Server Tick Event
|
||||
*/
|
||||
public void serverTick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
|
||||
|
||||
/**
|
||||
* Client Tick Event
|
||||
*/
|
||||
public void clientTick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
|
||||
void serverTick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
|
||||
void clientTick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.api.blockentities;
|
||||
package com.hypherionmc.craterlib.api.blockentity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -11,9 +11,6 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
*/
|
||||
public interface ITickable {
|
||||
|
||||
/**
|
||||
* The Tick Event. Can be either Server or Client Sided
|
||||
*/
|
||||
public void tick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
|
||||
void tick(Level level, BlockPos pos, BlockState state, BlockEntity blockEntity);
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package com.hypherionmc.craterlib.api.blockentity.caps;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Wrapper class for Forge capabilities to remove duplicate code from modules
|
||||
*/
|
||||
public enum CraterCapabilityHandler {
|
||||
ENERGY,
|
||||
ITEM,
|
||||
FLUID
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.api.blockentities.caps;
|
||||
package com.hypherionmc.craterlib.api.blockentity.caps;
|
||||
|
||||
import net.minecraft.core.Direction;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -11,6 +11,6 @@ import java.util.Optional;
|
||||
*/
|
||||
public interface ICraterCapProvider {
|
||||
|
||||
public <T> Optional<T> getCapability(CapabilityHandler handler, @Nullable Direction side);
|
||||
<T> Optional<T> getCapability(CraterCapabilityHandler handler, @Nullable Direction side);
|
||||
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package me.hypherionmc.craterlib.api.inventory;
|
||||
package com.hypherionmc.craterlib.api.creativetab;
|
||||
|
||||
import me.hypherionmc.craterlib.systems.internal.CreativeTabRegistry;
|
||||
import com.hypherionmc.craterlib.core.systems.internal.CreativeTabRegistry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
@@ -8,10 +8,6 @@ import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Extention to allow mods to add their own creative tabs, without relying on loader events
|
||||
*/
|
||||
public class CraterCreativeModeTab implements Supplier<CreativeModeTab> {
|
||||
|
||||
private final ResourceLocation resourceLocation;
|
||||
@@ -28,7 +24,7 @@ public class CraterCreativeModeTab implements Supplier<CreativeModeTab> {
|
||||
}
|
||||
|
||||
public ResourceLocation getResourceLocation() {
|
||||
return this.resourceLocation;
|
||||
return resourceLocation;
|
||||
}
|
||||
|
||||
public Supplier<ItemStack> getIcon() {
|
||||
@@ -52,12 +48,12 @@ public class CraterCreativeModeTab implements Supplier<CreativeModeTab> {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public Builder setIcon(Supplier<ItemStack> icon) {
|
||||
public CraterCreativeModeTab.Builder setIcon(Supplier<ItemStack> icon) {
|
||||
stack = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder backgroundSuffix(String backgroundSuffix) {
|
||||
public CraterCreativeModeTab.Builder backgroundSuffix(String backgroundSuffix) {
|
||||
this.backgroundSuffix = backgroundSuffix;
|
||||
return this;
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package com.hypherionmc.craterlib.api.event.client;
|
||||
|
||||
import com.hypherionmc.craterlib.core.event.CraterEvent;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* A wrapped event to allow Block and Item Color Registration
|
||||
*/
|
||||
public class ColorRegistrationEvent {
|
||||
|
||||
public static class Blocks extends CraterEvent {
|
||||
|
||||
private final BlockColors colors;
|
||||
|
||||
public Blocks(BlockColors colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
public BlockColors getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCancel() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Items extends CraterEvent {
|
||||
|
||||
private final ItemColors colors;
|
||||
|
||||
public Items(ItemColors colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
public ItemColors getColors() {
|
||||
return colors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCancel() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.api.rendering;
|
||||
package com.hypherionmc.craterlib.api.rendering;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.api.rendering;
|
||||
package com.hypherionmc.craterlib.api.rendering;
|
||||
|
||||
import net.minecraft.client.color.block.BlockColor;
|
||||
import net.minecraft.world.item.DyeColor;
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.api.rendering;
|
||||
package com.hypherionmc.craterlib.api.rendering;
|
||||
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
@@ -1,12 +1,12 @@
|
||||
package me.hypherionmc.craterlib.client.gui.config;
|
||||
package com.hypherionmc.craterlib.client.gui.config;
|
||||
|
||||
import com.hypherionmc.craterlib.CraterConstants;
|
||||
import com.hypherionmc.craterlib.client.gui.config.widgets.*;
|
||||
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.SubConfig;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.Tooltip;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import me.hypherionmc.craterlib.CraterConstants;
|
||||
import me.hypherionmc.craterlib.client.gui.config.widgets.*;
|
||||
import me.hypherionmc.craterlib.common.config.ModuleConfig;
|
||||
import me.hypherionmc.craterlib.common.config.annotations.SubConfig;
|
||||
import me.hypherionmc.craterlib.common.config.annotations.Tooltip;
|
||||
import me.hypherionmc.moonconfig.core.conversion.SpecComment;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
@@ -33,7 +33,6 @@ import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 03/07/2022
|
||||
*/
|
||||
public class CraterConfigScreen extends Screen {
|
||||
public static final float SCROLLBAR_BOTTOM_COLOR = .5f;
|
||||
@@ -43,7 +42,6 @@ public class CraterConfigScreen extends Screen {
|
||||
private final Screen parent;
|
||||
private final List<Option<?>> options = new ArrayList<>();
|
||||
private final ModuleConfig config;
|
||||
private final Object subConfig;
|
||||
public double scrollerAmount;
|
||||
private boolean dragging;
|
||||
|
||||
@@ -51,7 +49,6 @@ public class CraterConfigScreen extends Screen {
|
||||
super(Component.translatable("cl." + config.getClass().getSimpleName().toLowerCase() + ".title"));
|
||||
this.parent = parent;
|
||||
this.config = config;
|
||||
this.subConfig = subConfig;
|
||||
if (subConfig != null) {
|
||||
setupScreenFromConfig(subConfig, subConfig.getClass());
|
||||
} else {
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
|
||||
/** Copied from Cloth Config Lite
|
||||
* https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/AbstractWidgetOption.java
|
||||
* <a href="https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/AbstractWidgetOption.java">...</a>
|
||||
*/
|
||||
public class AbstractConfigWidget<T, W extends AbstractWidget> extends BaseWidget<T> {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.network.chat.TextColor;
|
||||
|
||||
/**
|
||||
* Copied from Cloth Config Lite
|
||||
* https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/BaseOption.java
|
||||
* <a href="https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/BaseOption.java">...</a>
|
||||
*/
|
||||
public class BaseWidget<T> extends Option<T> {
|
||||
|
@@ -1,13 +1,16 @@
|
||||
package me.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import me.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import net.minecraft.client.gui.components.AbstractButton;
|
||||
import net.minecraft.client.gui.narration.NarratedElementType;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class InternalConfigButton extends AbstractButton {
|
||||
|
||||
CraterConfigScreen screen;
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -16,7 +16,7 @@ import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Copied from Cloth Config Lite
|
||||
* https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/Option.java
|
||||
* <a href="https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/Option.java">...</a>
|
||||
*/
|
||||
public abstract class Option<T> extends AbstractContainerEventHandler {
|
||||
|
@@ -1,14 +1,17 @@
|
||||
package me.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import me.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import me.hypherionmc.craterlib.common.config.ModuleConfig;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class SubConfigWidget<T> extends AbstractConfigWidget<T, Button> {
|
||||
|
||||
private final Object subConfig;
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -8,7 +8,7 @@ import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Copied from Cloth Config Lite
|
||||
* https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/TextFieldOption.java
|
||||
* <a href="https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/TextFieldOption.java">...</a>
|
||||
*/
|
||||
public class TextConfigOption <T> extends AbstractConfigWidget<T, WrappedEditBox> {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -8,7 +8,7 @@ import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Copied from Cloth Config Lite
|
||||
* https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/ToggleOption.java
|
||||
* <a href="https://github.com/shedaniel/cloth-config-lite/blob/1.17/src/main/java/me/shedaniel/clothconfiglite/impl/option/ToggleOption.java">...</a>
|
||||
*/
|
||||
public class ToggleButton <T> extends AbstractConfigWidget<T, Button> {
|
||||
|
@@ -1,14 +1,18 @@
|
||||
package me.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class WrappedEditBox extends EditBox {
|
||||
|
||||
public WrappedEditBox(Font font, int i, int j, int k, int l, Component component) {
|
||||
public WrappedEditBox(Font font, int i, int j, int k, int l, @NotNull Component component) {
|
||||
super(font, i, j, k, l, component);
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package me.hypherionmc.craterlib.client.gui.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.gui.components.AbstractSliderButton;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* A custom slider widget used for Time. Mostly used by the Hyper Lighting Smoke Machine
|
||||
*/
|
||||
public class TimeSliderWidget extends AbstractSliderButton {
|
@@ -0,0 +1,60 @@
|
||||
package com.hypherionmc.craterlib.client.registry;
|
||||
|
||||
import com.hypherionmc.craterlib.api.rendering.DyableBlock;
|
||||
import com.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import com.hypherionmc.craterlib.client.rendering.ItemColorHandler;
|
||||
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
import me.hypherionmc.craterlib.systems.reg.RegistrationProvider;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Helper for registering Block and Item color handlers
|
||||
*/
|
||||
public class ClientRegistry {
|
||||
|
||||
/**
|
||||
* Register Block Color Handlers
|
||||
*
|
||||
* @param colors Existing block colors obtained from {@link com.hypherionmc.craterlib.api.event.client.ColorRegistrationEvent}
|
||||
* @param blocks The blocks registered for the module
|
||||
*/
|
||||
public static void registerBlockColors(@NotNull BlockColors colors, @NotNull 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 Existing item colors obtained from {@link com.hypherionmc.craterlib.api.event.client.ColorRegistrationEvent}
|
||||
* @param items The items registered for the module
|
||||
*/
|
||||
public static void registerItemColors(@NotNull ItemColors colors, @NotNull RegistrationProvider<Item> items) {
|
||||
items.getEntries().forEach(itemRegistryObject -> {
|
||||
if (itemRegistryObject.get() instanceof ItemDyable itemDyable) {
|
||||
colors.register(new ItemColorHandler(), (Item) itemDyable);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a {@link net.minecraft.client.renderer.blockentity.BlockEntityRenderer} for a BlockEntity
|
||||
* @param blockEntityType The BlockEntity the renderer belongs to
|
||||
* @param blockEntityRendererFactory The renderer factory
|
||||
*/
|
||||
public static void registerBlockEntityRenderer(@NotNull BlockEntityType<? extends BlockEntity> blockEntityType, @NotNull BlockEntityRendererProvider blockEntityRendererFactory) {
|
||||
ClientPlatform.CLIENT_HELPER.registerBlockEntityRenderer(blockEntityType, blockEntityRendererFactory);
|
||||
}
|
||||
|
||||
}
|
@@ -1,33 +1,35 @@
|
||||
package me.hypherionmc.craterlib.client.rendering;
|
||||
package com.hypherionmc.craterlib.client.rendering;
|
||||
|
||||
import me.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import me.hypherionmc.craterlib.util.RenderUtils;
|
||||
import com.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import com.hypherionmc.craterlib.util.RenderUtils;
|
||||
import net.minecraft.client.color.item.ItemColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* 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
|
||||
* @param stack The ItemStack to read the color from
|
||||
* @param tintIndex No Comment
|
||||
* @return Integer value of the color
|
||||
*/
|
||||
@Override
|
||||
public int getColor(ItemStack stack, int tintIndex) {
|
||||
public int getColor(@NotNull ItemStack stack, int tintIndex) {
|
||||
return this.getColorFromStack(stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color for the specific items stack, or return BLACK (0)
|
||||
*
|
||||
* @param stack
|
||||
* @return
|
||||
* @param stack The ItemStack to read the color from
|
||||
* @return Integer value of the color
|
||||
*/
|
||||
private int getColorFromStack(ItemStack stack) {
|
||||
private int getColorFromStack(@NotNull ItemStack stack) {
|
||||
if (stack.getItem() instanceof ItemDyable itemDyable) {
|
||||
return RenderUtils.renderColorFromDye(itemDyable.getColor(stack));
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
package me.hypherionmc.craterlib.common.blockentity;
|
||||
package com.hypherionmc.craterlib.common.blockentity;
|
||||
|
||||
import me.hypherionmc.craterlib.api.blockentities.caps.CapabilityHandler;
|
||||
import me.hypherionmc.craterlib.api.blockentities.caps.ICraterCapProvider;
|
||||
import com.hypherionmc.craterlib.api.blockentity.caps.CraterCapabilityHandler;
|
||||
import com.hypherionmc.craterlib.api.blockentity.caps.ICraterCapProvider;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -15,7 +15,6 @@ import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 24/09/2022
|
||||
* A Wrapped Block Entity to incorporate CraterLib's universal capability provider
|
||||
*/
|
||||
public class CraterBlockEntity extends BlockEntity implements ICraterCapProvider {
|
||||
@@ -43,7 +42,7 @@ public class CraterBlockEntity extends BlockEntity implements ICraterCapProvider
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> getCapability(CapabilityHandler handler, @Nullable Direction side) {
|
||||
public <T> Optional<T> getCapability(CraterCapabilityHandler handler, @Nullable Direction side) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
package me.hypherionmc.craterlib.common.blockentity;
|
||||
package com.hypherionmc.craterlib.common.blockentity;
|
||||
|
||||
import me.hypherionmc.craterlib.api.blockentities.caps.CapabilityHandler;
|
||||
import me.hypherionmc.craterlib.platform.Platform;
|
||||
import me.hypherionmc.craterlib.systems.fluid.CraterFluidTank;
|
||||
import com.hypherionmc.craterlib.api.blockentity.caps.CraterCapabilityHandler;
|
||||
import com.hypherionmc.craterlib.core.platform.Platform;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.CraterFluidTank;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -13,6 +13,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* A wrapped BlockEntity containing a fluid tank
|
||||
*/
|
||||
public class FluidContainerBlockEntity extends CraterBlockEntity {
|
||||
|
||||
public final CraterFluidTank fluidTank;
|
||||
@@ -41,8 +45,8 @@ public class FluidContainerBlockEntity extends CraterBlockEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> getCapability(CapabilityHandler handler, @Nullable Direction side) {
|
||||
if (handler == CapabilityHandler.FLUID) {
|
||||
public <T> Optional<T> getCapability(CraterCapabilityHandler handler, @Nullable Direction side) {
|
||||
if (handler == CraterCapabilityHandler.FLUID) {
|
||||
return (Optional<T>) Optional.of(fluidTank);
|
||||
}
|
||||
return super.getCapability(handler, side);
|
@@ -1,10 +1,10 @@
|
||||
package me.hypherionmc.craterlib.common.item;
|
||||
package com.hypherionmc.craterlib.common.item;
|
||||
|
||||
import me.hypherionmc.craterlib.api.rendering.DyableBlock;
|
||||
import me.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import me.hypherionmc.craterlib.platform.ClientPlatform;
|
||||
import me.hypherionmc.craterlib.platform.Platform;
|
||||
import me.hypherionmc.craterlib.platform.services.Environment;
|
||||
import com.hypherionmc.craterlib.api.rendering.DyableBlock;
|
||||
import com.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
import com.hypherionmc.craterlib.core.platform.Platform;
|
||||
import com.hypherionmc.craterlib.core.platform.services.Environment;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
@@ -19,6 +19,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Base Item for Blocks that implement @link {DyableBlock}.
|
||||
*/
|
||||
public class BlockItemDyable extends BlockItem implements ItemDyable {
|
||||
@@ -33,7 +34,6 @@ public class BlockItemDyable extends BlockItem implements ItemDyable {
|
||||
|
||||
/**
|
||||
* Get the Item Color from the block
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
@@ -1,6 +1,6 @@
|
||||
package me.hypherionmc.craterlib.common.item;
|
||||
package com.hypherionmc.craterlib.common.item;
|
||||
|
||||
import me.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import com.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
@@ -18,6 +18,7 @@ import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Custom Water Bottle item that supports Dye and can be used as Dye
|
||||
*/
|
||||
public class DyableWaterBottle extends DyeItem implements ItemDyable {
|
@@ -1,12 +1,13 @@
|
||||
package me.hypherionmc.craterlib.common.item;
|
||||
package com.hypherionmc.craterlib.common.item;
|
||||
|
||||
import me.hypherionmc.craterlib.api.rendering.ItemDyable;
|
||||
import com.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;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* A custom water bucket that supports Dye Colors
|
||||
*/
|
||||
public class DyableWaterBucket extends BucketItem implements ItemDyable {
|
@@ -1,8 +1,9 @@
|
||||
package me.hypherionmc.craterlib.common.particles;
|
||||
package com.hypherionmc.craterlib.common.particles;
|
||||
|
||||
import net.minecraft.core.particles.SimpleParticleType;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Helper Class for exposing a hidden constructor in the vanilla particle type
|
||||
*/
|
||||
public class WrappedSimpleParticleType extends SimpleParticleType {
|
@@ -1,12 +1,13 @@
|
||||
package me.hypherionmc.craterlib.common.config;
|
||||
package com.hypherionmc.craterlib.core.config;
|
||||
|
||||
import me.hypherionmc.craterlib.CraterConstants;
|
||||
import com.hypherionmc.craterlib.CraterConstants;
|
||||
import me.hypherionmc.moonconfig.core.file.FileWatcher;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Controls Config File Reloads and Events
|
||||
*/
|
||||
public final class ConfigController implements Serializable {
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.common.config;
|
||||
package com.hypherionmc.craterlib.core.config;
|
||||
|
||||
import me.hypherionmc.moonconfig.core.CommentedConfig;
|
||||
import me.hypherionmc.moonconfig.core.Config;
|
||||
@@ -8,7 +8,9 @@ import me.hypherionmc.moonconfig.core.file.CommentedFileConfig;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Base Config class containing the save, upgrading and loading logic. All config classes must extend this class
|
||||
* @author HypherionSA
|
||||
* Base Config class containing the save, upgrading and loading logic.
|
||||
* All config classes must extend this class
|
||||
*/
|
||||
public class ModuleConfig {
|
||||
|
@@ -1,11 +1,10 @@
|
||||
package me.hypherionmc.craterlib.common.config.annotations;
|
||||
package com.hypherionmc.craterlib.core.config.annotations;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 06/08/2022
|
||||
* Allows Modules to disable Automatic Config Screens
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.common.config.annotations;
|
||||
package com.hypherionmc.craterlib.core.config.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -7,7 +7,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 03/07/2022
|
||||
* Used to determine if a Config section should be rendered as a separate screen
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.common.config.annotations;
|
||||
package com.hypherionmc.craterlib.core.config.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -6,6 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* //TODO Currently unused, but to be used with Config Syncing in the future
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.common.config.annotations;
|
||||
package com.hypherionmc.craterlib.core.config.annotations;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -7,7 +7,6 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 03/07/2022
|
||||
* Provides tooltips to the config GUI
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
@@ -0,0 +1,27 @@
|
||||
package com.hypherionmc.craterlib.core.event;
|
||||
|
||||
import com.hypherionmc.craterlib.core.event.exception.CraterEventCancellationException;
|
||||
|
||||
public abstract class CraterEvent {
|
||||
|
||||
private boolean canceled = false;
|
||||
|
||||
public abstract boolean canCancel();
|
||||
|
||||
public void cancelEvent() {
|
||||
try {
|
||||
if (!this.canCancel()) {
|
||||
throw new CraterEventCancellationException("Tried to cancel non-cancelable event: " + this.getClass().getName());
|
||||
}
|
||||
|
||||
this.canceled = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean wasCancelled() {
|
||||
return this.canceled;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,233 @@
|
||||
package com.hypherionmc.craterlib.core.event;
|
||||
|
||||
import com.hypherionmc.craterlib.CraterConstants;
|
||||
import com.hypherionmc.craterlib.core.event.annot.CraterEventListener;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public final class CraterEventBus {
|
||||
|
||||
private static final Logger LOGGER = CraterConstants.LOG;
|
||||
|
||||
public static final CraterEventBus INSTANCE = new CraterEventBus();
|
||||
private final Map<Class<? extends CraterEvent>, List<ListenerContainer>> events = new HashMap<>();
|
||||
|
||||
public void postEvent(CraterEvent event) {
|
||||
if (eventsRegisteredForType(event.getClass())) {
|
||||
List<ListenerContainer> l = new ArrayList<>(events.get(event.getClass()));
|
||||
l.sort((o1, o2) -> Integer.compare(o2.priority, o1.priority));
|
||||
|
||||
for (ListenerContainer c : l) {
|
||||
c.notifyListener(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void registerEventListener(Class<?> clazz) {
|
||||
this.registerListenerMethods(this.getEventMethodsOf(clazz));
|
||||
}
|
||||
|
||||
public void registerEventListener(Object object) {
|
||||
this.registerListenerMethods(this.getEventMethodsOf(object));
|
||||
}
|
||||
|
||||
private void registerListenerMethods(List<EventMethod> methods) {
|
||||
for (EventMethod m : methods) {
|
||||
Consumer<CraterEvent> listener = (event) -> {
|
||||
try {
|
||||
m.method.invoke(m.parentObject, event);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
};
|
||||
|
||||
ListenerContainer container = new ListenerContainer(m.eventType, listener, m.priority);
|
||||
container.listenerParentClassName = m.parentClass.getName();
|
||||
container.listenerMethodName = m.method.getName();
|
||||
this.registerListener(container);
|
||||
}
|
||||
}
|
||||
|
||||
private List<EventMethod> getEventMethodsOf(Object objectOrClass) {
|
||||
List<EventMethod> l = new ArrayList<>();
|
||||
try {
|
||||
if (objectOrClass != null) {
|
||||
boolean isClass = (objectOrClass instanceof Class<?>);
|
||||
Class<?> c = isClass ? (Class<?>) objectOrClass : objectOrClass.getClass();
|
||||
for (Method m : c.getMethods()) {
|
||||
if (isClass && Modifier.isStatic(m.getModifiers())) {
|
||||
EventMethod em = EventMethod.tryCreateFrom(new AnalyzedMethod(m, c));
|
||||
if (em != null) l.add(em);
|
||||
}
|
||||
if (!isClass && !Modifier.isStatic(m.getModifiers())) {
|
||||
EventMethod em = EventMethod.tryCreateFrom(new AnalyzedMethod(m, objectOrClass));
|
||||
if (em != null) l.add(em);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public void registerListener(Consumer<CraterEvent> listener, Class<? extends CraterEvent> eventType) {
|
||||
this.registerListener(listener, eventType, 0);
|
||||
}
|
||||
|
||||
public void registerListener(Consumer<CraterEvent> listener, Class<? extends CraterEvent> eventType, int priority) {
|
||||
this.registerListener(new ListenerContainer(eventType, listener, priority));
|
||||
}
|
||||
|
||||
private void registerListener(ListenerContainer listenerContainer) {
|
||||
try {
|
||||
if (!eventsRegisteredForType(listenerContainer.eventType)) {
|
||||
events.put(listenerContainer.eventType, new ArrayList<>());
|
||||
}
|
||||
events.get(listenerContainer.eventType).add(listenerContainer);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean eventsRegisteredForType(Class<? extends CraterEvent> eventType) {
|
||||
if (eventType == null) {
|
||||
return false;
|
||||
}
|
||||
return this.events.containsKey(eventType);
|
||||
}
|
||||
|
||||
protected final static class ListenerContainer {
|
||||
|
||||
private final Consumer<CraterEvent> listener;
|
||||
private final Class<? extends CraterEvent> eventType;
|
||||
private final int priority;
|
||||
private String listenerParentClassName = "[unknown]";
|
||||
private String listenerMethodName = "[unknown]";
|
||||
|
||||
private ListenerContainer(Class<? extends CraterEvent> eventType, Consumer<CraterEvent> listener, int priority) {
|
||||
this.eventType = eventType;
|
||||
this.listener = listener;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
private void notifyListener(CraterEvent event) {
|
||||
try {
|
||||
this.listener.accept(event);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("##################################");
|
||||
LOGGER.error("Failed to notify event listener!");
|
||||
LOGGER.error("Event Type: " + this.eventType.getName());
|
||||
LOGGER.error("Listener Parent Class Name: " + this.listenerParentClassName);
|
||||
LOGGER.error("Listener Method Name In Parent Class: " + this.listenerMethodName);
|
||||
LOGGER.error("##################################");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static class AnalyzedMethod {
|
||||
|
||||
protected Method method;
|
||||
protected Object parentObject;
|
||||
protected Class<?> parentClass;
|
||||
protected boolean isStatic;
|
||||
protected List<Annotation> annotations = new ArrayList<>();
|
||||
|
||||
protected AnalyzedMethod() {
|
||||
}
|
||||
|
||||
protected AnalyzedMethod(Method method, Object parentObjectOrClass) {
|
||||
this.method = method;
|
||||
this.parentObject = parentObjectOrClass;
|
||||
this.parentClass = this.tryGetParentClass();
|
||||
this.isStatic = Modifier.isStatic(method.getModifiers());
|
||||
collectMethodAnnotations(this.isStatic ? null : this.parentObject.getClass(), this.method, this.annotations);
|
||||
}
|
||||
|
||||
protected Class<?> tryGetParentClass() {
|
||||
if (this.parentObject instanceof Class<?>) {
|
||||
return (Class<?>) this.parentObject;
|
||||
}
|
||||
return this.parentObject.getClass();
|
||||
}
|
||||
|
||||
protected static void collectMethodAnnotations(Class<?> c, Method m, List<Annotation> addToList) {
|
||||
try {
|
||||
addToList.addAll(Arrays.asList(m.getAnnotations()));
|
||||
if (!Modifier.isStatic(m.getModifiers()) && (c != null)) {
|
||||
Class<?> sc = c.getSuperclass();
|
||||
if (sc != null) {
|
||||
try {
|
||||
Method sm = sc.getMethod(m.getName(), m.getParameterTypes());
|
||||
collectMethodAnnotations(sc, sm, addToList);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected static class EventMethod extends AnalyzedMethod {
|
||||
|
||||
protected final int priority;
|
||||
protected final Class<? extends CraterEvent> eventType;
|
||||
|
||||
protected static EventMethod tryCreateFrom(AnalyzedMethod method) {
|
||||
EventMethod em = new EventMethod(method);
|
||||
return (em.eventType != null) ? em : null;
|
||||
}
|
||||
|
||||
protected EventMethod(AnalyzedMethod method) {
|
||||
|
||||
super();
|
||||
this.method = method.method;
|
||||
this.parentObject = method.parentObject;
|
||||
this.parentClass = method.parentClass;
|
||||
this.isStatic = method.isStatic;
|
||||
this.annotations = method.annotations;
|
||||
|
||||
this.priority = this.tryGetPriority();
|
||||
this.eventType = this.tryGetEventType();
|
||||
|
||||
}
|
||||
|
||||
protected Class<? extends CraterEvent> tryGetEventType() {
|
||||
try {
|
||||
if (this.method != null) {
|
||||
Class<?>[] params = this.method.getParameterTypes();
|
||||
if (params.length > 0) {
|
||||
Class<?> firstParam = params[0];
|
||||
if (CraterEvent.class.isAssignableFrom(firstParam)) {
|
||||
return (Class<? extends CraterEvent>) firstParam;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int tryGetPriority() {
|
||||
try {
|
||||
for (Annotation a : this.annotations) {
|
||||
if (a instanceof CraterEventListener craterEventListener) {
|
||||
return craterEventListener.priority();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.hypherionmc.craterlib.core.event;
|
||||
|
||||
public class CraterEventPriority {
|
||||
|
||||
public static final int LOWEST = -3;
|
||||
public static final int LOWER = -2;
|
||||
public static final int LOW = -1;
|
||||
public static final int NORMAL = 0;
|
||||
public static final int HIGH = 1;
|
||||
public static final int HIGHER = 2;
|
||||
public static final int HIGHEST = 3;
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package com.hypherionmc.craterlib.core.event.annot;
|
||||
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventPriority;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CraterEventListener {
|
||||
int priority() default CraterEventPriority.NORMAL;
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package com.hypherionmc.craterlib.core.event.exception;
|
||||
|
||||
public class CraterEventCancellationException extends Exception {
|
||||
|
||||
public CraterEventCancellationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* The event system code in this package is based on, and adapted from Acara (https://github.com/Keksuccino/acara/)
|
||||
* and is licensed under MIT by Keksuccino
|
||||
*/
|
||||
package com.hypherionmc.craterlib.core.event;
|
@@ -1,7 +1,7 @@
|
||||
package me.hypherionmc.craterlib.network;
|
||||
package com.hypherionmc.craterlib.core.network;
|
||||
|
||||
import me.hypherionmc.craterlib.platform.ClientPlatform;
|
||||
import me.hypherionmc.craterlib.platform.Platform;
|
||||
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
import com.hypherionmc.craterlib.core.platform.Platform;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 24/09/2022
|
||||
*/
|
||||
public interface CraterNetworkHandler {
|
||||
|
@@ -1,11 +1,10 @@
|
||||
package me.hypherionmc.craterlib.network;
|
||||
package com.hypherionmc.craterlib.core.network;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 24/09/2022
|
||||
*/
|
||||
public interface CraterPacket<T extends CraterPacket<T>> {
|
||||
|
@@ -1,8 +1,7 @@
|
||||
package me.hypherionmc.craterlib.network;
|
||||
package com.hypherionmc.craterlib.core.network;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 24/09/2022
|
||||
*/
|
||||
public enum PacketDirection {
|
||||
TO_SERVER,
|
@@ -1,13 +1,12 @@
|
||||
package me.hypherionmc.craterlib.platform;
|
||||
package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
import me.hypherionmc.craterlib.CraterConstants;
|
||||
import me.hypherionmc.craterlib.platform.services.LibClientHelper;
|
||||
import com.hypherionmc.craterlib.CraterConstants;
|
||||
import com.hypherionmc.craterlib.core.platform.services.LibClientHelper;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 25/09/2022
|
||||
*/
|
||||
public class ClientPlatform {
|
||||
|
@@ -1,12 +1,15 @@
|
||||
package me.hypherionmc.craterlib.platform;
|
||||
package com.hypherionmc.craterlib.core.platform;
|
||||
|
||||
import me.hypherionmc.craterlib.CraterConstants;
|
||||
import me.hypherionmc.craterlib.platform.services.ILoaderHelper;
|
||||
import me.hypherionmc.craterlib.platform.services.LibCommonHelper;
|
||||
import me.hypherionmc.craterlib.platform.services.LibFluidHelper;
|
||||
import com.hypherionmc.craterlib.CraterConstants;
|
||||
import com.hypherionmc.craterlib.core.platform.services.ILoaderHelper;
|
||||
import com.hypherionmc.craterlib.core.platform.services.LibCommonHelper;
|
||||
import com.hypherionmc.craterlib.core.platform.services.LibFluidHelper;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public class Platform {
|
||||
|
||||
public static final ILoaderHelper LOADER = load(ILoaderHelper.class);
|
@@ -1,8 +1,7 @@
|
||||
package me.hypherionmc.craterlib.platform.services;
|
||||
package com.hypherionmc.craterlib.core.platform.services;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 24/09/2022
|
||||
*/
|
||||
public enum Environment {
|
||||
CLIENT,
|
@@ -0,0 +1,19 @@
|
||||
package com.hypherionmc.craterlib.core.platform.services;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Helper class to provide information about the ModLoader
|
||||
*/
|
||||
public interface ILoaderHelper {
|
||||
|
||||
boolean isFabric();
|
||||
String getGameVersion();
|
||||
File getGameFolder();
|
||||
File getConfigFolder();
|
||||
File getModsFolder();
|
||||
Environment getEnvironment();
|
||||
boolean isModLoaded(String modid);
|
||||
boolean isDevEnv();
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package com.hypherionmc.craterlib.core.platform.services;
|
||||
|
||||
import com.hypherionmc.craterlib.common.item.BlockItemDyable;
|
||||
import com.hypherionmc.craterlib.core.network.CraterPacket;
|
||||
import me.hypherionmc.craterlib.systems.reg.RegistryObject;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public interface LibClientHelper {
|
||||
|
||||
void registerItemProperty(@NotNull BlockItemDyable item, @NotNull String property);
|
||||
|
||||
void registerCustomRenderTypes(
|
||||
@NotNull Collection<RegistryObject<Block>> blocks,
|
||||
@NotNull Collection<RegistryObject<Item>> items
|
||||
);
|
||||
|
||||
Minecraft getClientInstance();
|
||||
|
||||
Player getClientPlayer();
|
||||
|
||||
Level getClientLevel();
|
||||
|
||||
Connection getClientConnection();
|
||||
|
||||
void registerClientReceiver(@NotNull ResourceLocation channelName, @NotNull Function<FriendlyByteBuf, @NotNull CraterPacket<?>> factory);
|
||||
|
||||
void registerBlockEntityRenderer(@NotNull BlockEntityType<? extends BlockEntity> blockEntityType, @NotNull BlockEntityRendererProvider blockEntityRendererFactory);
|
||||
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package com.hypherionmc.craterlib.core.platform.services;
|
||||
|
||||
import com.hypherionmc.craterlib.api.blockentity.caps.CraterCapabilityHandler;
|
||||
import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
|
||||
import com.hypherionmc.craterlib.core.network.CraterPacket;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.apache.commons.lang3.function.TriFunction;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public interface LibCommonHelper {
|
||||
|
||||
CraterNetworkHandler createPacketHandler(String modid);
|
||||
|
||||
MinecraftServer getMCServer();
|
||||
|
||||
void openMenu(ServerPlayer player, MenuProvider menu, @Nullable Consumer<FriendlyByteBuf> initialData);
|
||||
|
||||
<T extends AbstractContainerMenu> MenuType<T> createMenuType(TriFunction<Integer, Inventory, FriendlyByteBuf, T> constructor);
|
||||
|
||||
/* FABRIC ONLY */
|
||||
void registerServerReceiver(ResourceLocation channelName, Function<FriendlyByteBuf, CraterPacket<?>> factory);
|
||||
|
||||
<T> Optional<T> getCapabilityHandler(BlockEntity entity, Direction side, CraterCapabilityHandler capability);
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.hypherionmc.craterlib.core.platform.services;
|
||||
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.CraterFluidTank;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.FluidHolder;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.ICraterFluidHandler;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public interface LibFluidHelper {
|
||||
|
||||
CraterFluidTank createFluidTank(int capacity);
|
||||
|
||||
CraterFluidTank createFluidTank(int capacity, Fluid... validFluids);
|
||||
|
||||
boolean interactWithFluidHandler(Player player, InteractionHand hand, ICraterFluidHandler fluidHandler);
|
||||
|
||||
boolean interactWithFluidHandler(@NotNull Player player, @NotNull InteractionHand hand, @NotNull Level level, @NotNull BlockPos pos, @Nullable Direction side);
|
||||
|
||||
TextureAtlasSprite getFluidTexture(FluidHolder fluidHolder);
|
||||
|
||||
int getFluidColor(Fluid fluid);
|
||||
|
||||
}
|
@@ -1,8 +1,9 @@
|
||||
package me.hypherionmc.craterlib.systems.energy;
|
||||
package com.hypherionmc.craterlib.core.systems.energy;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
/***
|
||||
* @author HypherionSA
|
||||
* Loosely based on the Forge Energy System
|
||||
*/
|
||||
public class CustomEnergyStorage implements ICraterEnergyStorage {
|
@@ -0,0 +1,24 @@
|
||||
package com.hypherionmc.craterlib.core.systems.energy;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
*/
|
||||
public interface ICraterEnergyStorage {
|
||||
|
||||
default CompoundTag writeNBT(CompoundTag tag) { return tag; }
|
||||
default void readNBT(CompoundTag tag) {}
|
||||
|
||||
int receiveEnergy(int toReceive, boolean test);
|
||||
int extractEnergy(int toExtract, boolean test);
|
||||
|
||||
int getPowerLevel();
|
||||
|
||||
int getMaxInput();
|
||||
|
||||
int getMaxOutput();
|
||||
|
||||
int getPowerCapacity();
|
||||
|
||||
}
|
@@ -1,12 +1,14 @@
|
||||
package me.hypherionmc.craterlib.systems.fluid;
|
||||
package com.hypherionmc.craterlib.core.systems.fluid;
|
||||
|
||||
import me.hypherionmc.craterlib.util.FluidUtils;
|
||||
import com.hypherionmc.craterlib.util.FluidUtils;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* A cross Modloader FluidTank implementation
|
||||
*/
|
||||
public class CraterFluidTank implements ICraterFluidHandler {
|
||||
|
||||
private final int capacity;
|
@@ -1,12 +1,16 @@
|
||||
package me.hypherionmc.craterlib.systems.fluid;
|
||||
package com.hypherionmc.craterlib.core.systems.fluid;
|
||||
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Cross Modloader "FluidStack" implementation
|
||||
*/
|
||||
public class FluidHolder {
|
||||
|
||||
private Fluid fluid;
|
||||
private final Fluid fluid;
|
||||
private int amount;
|
||||
|
||||
public FluidHolder(FluidHolder holder) {
|
@@ -0,0 +1,35 @@
|
||||
package com.hypherionmc.craterlib.core.systems.fluid;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Cross modloader fluid handler implementation
|
||||
*/
|
||||
public interface ICraterFluidHandler {
|
||||
|
||||
enum FluidAction {
|
||||
EXECUTE,
|
||||
SIMULATE;
|
||||
|
||||
public boolean simulate() {
|
||||
return this == SIMULATE;
|
||||
}
|
||||
|
||||
public boolean execute() {
|
||||
return this == EXECUTE;
|
||||
}
|
||||
}
|
||||
|
||||
int insert(FluidHolder fluidHolder, CraterFluidTank.FluidAction action);
|
||||
FluidHolder extract(FluidHolder fluidHolder, CraterFluidTank.FluidAction action);
|
||||
FluidHolder extract(int amount, CraterFluidTank.FluidAction action);
|
||||
boolean isTankEmpty();
|
||||
FluidHolder getFluidInTank();
|
||||
int getTankLevel();
|
||||
int getTankCapacity();
|
||||
|
||||
default CompoundTag writeToNBT(CompoundTag tag) { return tag; }
|
||||
|
||||
default void readFromNBT(CompoundTag tag) {};
|
||||
}
|
@@ -1,15 +1,17 @@
|
||||
package me.hypherionmc.craterlib.systems.internal;
|
||||
package com.hypherionmc.craterlib.core.systems.internal;
|
||||
|
||||
import me.hypherionmc.craterlib.api.inventory.CraterCreativeModeTab;
|
||||
import com.hypherionmc.craterlib.api.creativetab.CraterCreativeModeTab;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ApiStatus.Internal
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* A helper class to make registering creative tabs easier across modloaders
|
||||
*/
|
||||
public class CreativeTabRegistry {
|
||||
|
||||
private static final List<CraterCreativeModeTab> TABS = new ArrayList<>();
|
||||
@@ -25,7 +27,7 @@ public class CreativeTabRegistry {
|
||||
TABS.add(tab);
|
||||
}
|
||||
|
||||
public static List<CraterCreativeModeTab> getTABS() {
|
||||
public static List<CraterCreativeModeTab> getTabs() {
|
||||
return TABS;
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.systems.inventory;
|
||||
package com.hypherionmc.craterlib.core.systems.inventory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 24/09/2022
|
||||
* A crossmodloader inventory implementation
|
||||
*/
|
||||
public class SimpleInventory implements Clearable {
|
||||
|
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* 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 com.hypherionmc.craterlib.core.systems.reg;
|
@@ -1,7 +1,7 @@
|
||||
package me.hypherionmc.craterlib.mixin.colors;
|
||||
package com.hypherionmc.craterlib.mixin.colors;
|
||||
|
||||
import me.hypherionmc.craterlib.client.events.ColorRegistrationEvent;
|
||||
import me.hypherionmc.craterlib.events.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.api.event.client.ColorRegistrationEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -10,7 +10,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 17/06/2022
|
||||
* Mixin to accommodate Block Color Registration across multiple Modloaders
|
||||
*/
|
||||
@Mixin(BlockColors.class)
|
||||
@@ -18,11 +17,11 @@ public class BlockColorsMixin {
|
||||
|
||||
/**
|
||||
* Inject into Vanilla code to fire off our event
|
||||
* @param cir
|
||||
*/
|
||||
@Inject(method = "createDefault", at = @At("RETURN"))
|
||||
private static void injectBlockColors(CallbackInfoReturnable<BlockColors> cir) {
|
||||
CraterEventBus.post(new ColorRegistrationEvent.BLOCKS(cir.getReturnValue()));
|
||||
ColorRegistrationEvent.Blocks blockEvent = new ColorRegistrationEvent.Blocks(cir.getReturnValue());
|
||||
CraterEventBus.INSTANCE.postEvent(blockEvent);
|
||||
}
|
||||
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
package me.hypherionmc.craterlib.mixin.colors;
|
||||
package com.hypherionmc.craterlib.mixin.colors;
|
||||
|
||||
import me.hypherionmc.craterlib.client.events.ColorRegistrationEvent;
|
||||
import me.hypherionmc.craterlib.events.CraterEventBus;
|
||||
import com.hypherionmc.craterlib.api.event.client.ColorRegistrationEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -11,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 17/06/2022
|
||||
* Mixin to accommodate Item Color Registration across multiple Modloaders
|
||||
*/
|
||||
@Mixin(ItemColors.class)
|
||||
@@ -23,7 +22,8 @@ public class ItemColorsMixin {
|
||||
*/
|
||||
@Inject(method = "createDefault", at = @At("RETURN"))
|
||||
private static void injectItemColors(BlockColors $$0, CallbackInfoReturnable<ItemColors> cir) {
|
||||
CraterEventBus.post(new ColorRegistrationEvent.ITEMS(cir.getReturnValue()));
|
||||
ColorRegistrationEvent.Items itemColorEvent = new ColorRegistrationEvent.Items(cir.getReturnValue());
|
||||
CraterEventBus.INSTANCE.postEvent(itemColorEvent);
|
||||
}
|
||||
|
||||
}
|
@@ -1,17 +1,21 @@
|
||||
package me.hypherionmc.craterlib.util;
|
||||
package com.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;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Helper class to create light levels from BlockState values
|
||||
*/
|
||||
public class BlockStateUtils {
|
||||
|
||||
public static ToIntFunction<BlockState> createLightLevelFromLitBlockState(int litLevel) {
|
||||
public static ToIntFunction<BlockState> lightLevelFromLitBlockState(int litLevel) {
|
||||
return state -> state.getValue(BlockStateProperties.LIT) ? litLevel : 0;
|
||||
}
|
||||
|
||||
public static ToIntFunction<BlockState> createLightLevelFromPoweredBlockState(int litLevel) {
|
||||
public static ToIntFunction<BlockState> lightLevelFromPoweredBlockState(int litLevel) {
|
||||
return state -> state.getValue(BlockStateProperties.POWERED) ? litLevel : 0;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package me.hypherionmc.craterlib.util;
|
||||
package com.hypherionmc.craterlib.util;
|
||||
|
||||
import me.hypherionmc.craterlib.common.item.BlockItemDyable;
|
||||
import com.hypherionmc.craterlib.common.item.BlockItemDyable;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
|
||||
import net.minecraft.util.Mth;
|
||||
@@ -11,7 +11,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 03/07/2022
|
||||
*/
|
||||
public class ColorPropertyFunction implements ClampedItemPropertyFunction {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.util;
|
||||
package com.hypherionmc.craterlib.util;
|
||||
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -7,6 +7,10 @@ import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Utility class for interacting with fluids across modloaders
|
||||
*/
|
||||
public class FluidUtils {
|
||||
|
||||
public static int fluidColorFromDye(DyeColor color) {
|
@@ -1,8 +1,12 @@
|
||||
package me.hypherionmc.craterlib.util;
|
||||
package com.hypherionmc.craterlib.util;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Utility class to handle Translation Keys and Formatting
|
||||
*/
|
||||
public class LangUtils {
|
||||
|
||||
public static Component getTooltipTitle(String key) {
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.util;
|
||||
package com.hypherionmc.craterlib.util;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -6,6 +6,10 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Utility class to handle various mathematical functions
|
||||
*/
|
||||
public class MathUtils {
|
||||
|
||||
public static VoxelShape rotateShape(Direction from, Direction to, VoxelShape shape) {
|
@@ -1,30 +1,32 @@
|
||||
package me.hypherionmc.craterlib.util;
|
||||
package com.hypherionmc.craterlib.util;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Utility class for Optifine compatibility
|
||||
*/
|
||||
public class OptifineUtils {
|
||||
|
||||
private static boolean hasOptifine = false;
|
||||
private static final boolean hasOptifine = checkOptifine();
|
||||
|
||||
public static void checkOptifine() {
|
||||
private static boolean checkOptifine() {
|
||||
try {
|
||||
Class ofConfigClass = Class.forName("net.optifine.Config");
|
||||
hasOptifine = true;
|
||||
return;
|
||||
Class<?> ofConfigClass = Class.forName("net.optifine.Config");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Optifine is probably not present. Ignore the error
|
||||
hasOptifine = false;
|
||||
return;
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
hasOptifine = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isRenderRegions() {
|
||||
try {
|
||||
Class ofConfigClass = Class.forName("net.optifine.Config");
|
||||
Class<?> ofConfigClass = Class.forName("net.optifine.Config");
|
||||
Method rrField = ofConfigClass.getMethod("isRenderRegions");
|
||||
return (boolean) rrField.invoke(null);
|
||||
} catch (ClassNotFoundException | InvocationTargetException | NoSuchMethodException |
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.util;
|
||||
package com.hypherionmc.craterlib.util;
|
||||
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -7,6 +7,10 @@ import org.joml.Vector4f;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Utility class for various rendering functions
|
||||
*/
|
||||
public class RenderUtils {
|
||||
|
||||
public static Vector4f colorIntToRGBA(int color) {
|
@@ -1,10 +0,0 @@
|
||||
package me.hypherionmc.craterlib;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class CraterConstants {
|
||||
public static final String MOD_ID = "craterlib";
|
||||
public static final String MOD_NAME = "CraterLib";
|
||||
public static final Logger LOG = LogManager.getLogger(MOD_NAME);
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
package me.hypherionmc.craterlib.api.blockentities.caps;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* Wrapper Class for Forge Capabilities to remove duplicate code from Modules
|
||||
*/
|
||||
public enum CapabilityHandler {
|
||||
ENERGY,
|
||||
ITEM,
|
||||
FLUID
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
package me.hypherionmc.craterlib.client.events;
|
||||
|
||||
import me.hypherionmc.craterlib.events.Event;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 17/06/2022
|
||||
* A wrapped event to allow Block and Item Color Registration
|
||||
*/
|
||||
public class ColorRegistrationEvent {
|
||||
|
||||
public static class BLOCKS extends Event {
|
||||
|
||||
private BlockColors colors;
|
||||
|
||||
public BLOCKS() {}
|
||||
|
||||
public BLOCKS(BlockColors colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
public BlockColors getColors() {
|
||||
return colors;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ITEMS extends Event {
|
||||
|
||||
private ItemColors colors;
|
||||
|
||||
public ITEMS() {}
|
||||
|
||||
public ITEMS(ItemColors colors) {
|
||||
this.colors = colors;
|
||||
}
|
||||
|
||||
public ItemColors getColors() {
|
||||
return colors;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
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.platform.ClientPlatform;
|
||||
import me.hypherionmc.craterlib.systems.reg.RegistrationProvider;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerBlockEntityRenderer(BlockEntityType<? extends BlockEntity> blockEntityType, BlockEntityRendererProvider blockEntityRendererFactory) {
|
||||
ClientPlatform.CLIENT_HELPER.registerBlockEntityRenderer(blockEntityType, blockEntityRendererFactory);
|
||||
}
|
||||
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package me.hypherionmc.craterlib.common.block;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.Shapes;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
|
||||
public abstract class ShapeShiftingBlock extends Block {
|
||||
|
||||
public ShapeShiftingBlock(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
abstract protected VoxelShape getVoxelShape(BlockState state);
|
||||
|
||||
protected static VoxelShape mergeShapes(VoxelShape shape, VoxelShape shape2) {
|
||||
return Shapes.or(shape, shape2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getCollisionShape(BlockState state, BlockGetter levelReader, BlockPos blockPos, CollisionContext collisionContext) {
|
||||
return getVoxelShape(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, BlockGetter levelReader, BlockPos blockPos, CollisionContext collisionContext) {
|
||||
return getVoxelShape(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getInteractionShape(BlockState state, BlockGetter levelReader, BlockPos blockPos) {
|
||||
return getVoxelShape(state);
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
package me.hypherionmc.craterlib.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 21/06/2022
|
||||
* Event Bus handler for CraterLib Events
|
||||
*/
|
||||
public class CraterEventBus {
|
||||
|
||||
/** List of registered events **/
|
||||
private static final ConcurrentHashMap<Class<? extends Event>, List<IEventExecutor<?>>> map = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Register an event to be processed
|
||||
* @param clazz a Class implementing @link{Event}
|
||||
* @param handler - The callback for when the Event is Fired
|
||||
* @param <T>
|
||||
*/
|
||||
public static <T extends Event> void register(Class<T> clazz, IEventExecutor<T> handler) {
|
||||
if (!map.containsKey(clazz)) map.put(clazz, new ArrayList<>());
|
||||
map.get(clazz).add(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used internally to fire events
|
||||
* @param event The type of event that will be fired
|
||||
* @return True or False based on if the event is cancelled or not
|
||||
*/
|
||||
public static boolean post(Event event) {
|
||||
Class<? extends Event> clazz = event.getClass();
|
||||
if (map.containsKey(clazz)) {
|
||||
List<IEventExecutor<?>> handlers = map.get(clazz);
|
||||
for (IEventExecutor handler : handlers) {
|
||||
handler.execute(event);
|
||||
if (event.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package me.hypherionmc.craterlib.events;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 21/06/2022
|
||||
* CraterLib universal event
|
||||
*/
|
||||
public class Event {
|
||||
private boolean cancelled;
|
||||
|
||||
/**
|
||||
* Can the event be cancelled. Override this method to control the behaviour
|
||||
* @return
|
||||
*/
|
||||
public boolean isCancellable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the event
|
||||
* @param canceled True to cancel the event
|
||||
*/
|
||||
public void setCancelled(boolean canceled) {
|
||||
if (!this.isCancellable()) {
|
||||
throw new RuntimeException("Cannot cancel event " + this);
|
||||
}
|
||||
this.cancelled = canceled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used Internally to check if the event is cancelled
|
||||
* @return
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
package me.hypherionmc.craterlib.events;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 21/06/2022
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IEventExecutor<T extends Event> {
|
||||
void execute(T event);
|
||||
}
|
@@ -1,19 +0,0 @@
|
||||
package me.hypherionmc.craterlib.platform.services;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Helper class to provide information about the ModLoader
|
||||
*/
|
||||
public interface ILoaderHelper {
|
||||
|
||||
public boolean isFabric();
|
||||
public boolean isForge();
|
||||
public String getGameVersion();
|
||||
public File getGameFolder();
|
||||
public File getConfigFolder();
|
||||
public File getModsFolder();
|
||||
public Environment getEnvironment();
|
||||
public boolean isModLoaded(String modid);
|
||||
public boolean isDevEnv();
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
package me.hypherionmc.craterlib.platform.services;
|
||||
|
||||
import me.hypherionmc.craterlib.common.item.BlockItemDyable;
|
||||
import me.hypherionmc.craterlib.network.CraterPacket;
|
||||
import me.hypherionmc.craterlib.systems.reg.RegistryObject;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 16/06/2022
|
||||
*/
|
||||
public interface LibClientHelper {
|
||||
|
||||
public void registerItemProperty(BlockItemDyable item, String property);
|
||||
|
||||
public void registerCustomRenderTypes(
|
||||
Collection<RegistryObject<Block>> blocks,
|
||||
Collection<RegistryObject<Item>> items
|
||||
);
|
||||
|
||||
public Minecraft getClientInstance();
|
||||
|
||||
public Player getClientPlayer();
|
||||
|
||||
public Level getClientLevel();
|
||||
|
||||
public Connection getClientConnection();
|
||||
|
||||
public void registerClientReceiver(ResourceLocation channelName, Function<FriendlyByteBuf, CraterPacket<?>> factory);
|
||||
|
||||
public void registerBlockEntityRenderer(BlockEntityType<? extends BlockEntity> blockEntityType, BlockEntityRendererProvider blockEntityRendererFactory);
|
||||
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package me.hypherionmc.craterlib.platform.services;
|
||||
|
||||
import me.hypherionmc.craterlib.api.blockentities.caps.CapabilityHandler;
|
||||
import me.hypherionmc.craterlib.network.CraterNetworkHandler;
|
||||
import me.hypherionmc.craterlib.network.CraterPacket;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.apache.commons.lang3.function.TriFunction;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 24/09/2022
|
||||
*/
|
||||
public interface LibCommonHelper {
|
||||
|
||||
public CraterNetworkHandler createPacketHandler(String modid);
|
||||
|
||||
public MinecraftServer getMCServer();
|
||||
|
||||
public void openMenu(ServerPlayer player, MenuProvider menu, @Nullable Consumer<FriendlyByteBuf> initialData);
|
||||
|
||||
public <T extends AbstractContainerMenu> MenuType<T> createMenuType(TriFunction<Integer, Inventory, FriendlyByteBuf, T> constructor);
|
||||
|
||||
/* FABRIC ONLY */
|
||||
public void registerServerReceiver(ResourceLocation channelName, Function<FriendlyByteBuf, CraterPacket<?>> factory);
|
||||
|
||||
public <T> Optional<T> getCapabilityHandler(BlockEntity entity, Direction side, CapabilityHandler capability);
|
||||
}
|
@@ -1,30 +0,0 @@
|
||||
package me.hypherionmc.craterlib.platform.services;
|
||||
|
||||
import me.hypherionmc.craterlib.systems.fluid.CraterFluidTank;
|
||||
import me.hypherionmc.craterlib.systems.fluid.FluidHolder;
|
||||
import me.hypherionmc.craterlib.systems.fluid.ICraterFluidHandler;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface LibFluidHelper {
|
||||
|
||||
public CraterFluidTank createFluidTank(int capacity);
|
||||
|
||||
public CraterFluidTank createFluidTank(int capacity, Fluid... validFluids);
|
||||
|
||||
public boolean interactWithFluidHandler(Player player, InteractionHand hand, ICraterFluidHandler fluidHandler);
|
||||
|
||||
public boolean interactWithFluidHandler(@NotNull Player player, @NotNull InteractionHand hand, @NotNull Level level, @NotNull BlockPos pos, @Nullable Direction side);
|
||||
|
||||
public TextureAtlasSprite getFluidTexture(FluidHolder fluidHolder);
|
||||
|
||||
public int getFluidColor(Fluid fluid);
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package me.hypherionmc.craterlib.systems.energy;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public interface ICraterEnergyStorage {
|
||||
|
||||
public default CompoundTag writeNBT(CompoundTag tag) { return tag; }
|
||||
public default void readNBT(CompoundTag tag) {}
|
||||
|
||||
public int receiveEnergy(int toReceive, boolean test);
|
||||
public int extractEnergy(int toExtract, boolean test);
|
||||
|
||||
public int getPowerLevel();
|
||||
|
||||
public int getMaxInput();
|
||||
|
||||
public int getMaxOutput();
|
||||
|
||||
public int getPowerCapacity();
|
||||
|
||||
}
|
@@ -1,32 +0,0 @@
|
||||
package me.hypherionmc.craterlib.systems.fluid;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
|
||||
public interface ICraterFluidHandler {
|
||||
|
||||
enum FluidAction {
|
||||
EXECUTE,
|
||||
SIMULATE;
|
||||
|
||||
public boolean simulate() {
|
||||
return this == SIMULATE;
|
||||
}
|
||||
|
||||
public boolean execute() {
|
||||
return this == EXECUTE;
|
||||
}
|
||||
}
|
||||
|
||||
public int insert(FluidHolder fluidHolder, CraterFluidTank.FluidAction action);
|
||||
public FluidHolder extract(FluidHolder fluidHolder, CraterFluidTank.FluidAction action);
|
||||
public FluidHolder extract(int amount, CraterFluidTank.FluidAction action);
|
||||
public boolean isTankEmpty();
|
||||
public FluidHolder getFluidInTank();
|
||||
public int getTankLevel();
|
||||
public int getTankCapacity();
|
||||
|
||||
public default CompoundTag writeToNBT(CompoundTag tag) { return tag; }
|
||||
|
||||
public default void readFromNBT(CompoundTag tag) {};
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
/**
|
||||
* 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;
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "me.hypherionmc.craterlib.mixin",
|
||||
"package": "com.hypherionmc.craterlib.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package me.hypherionmc.craterlib;
|
||||
package com.hypherionmc.craterlib;
|
||||
|
||||
import me.hypherionmc.craterlib.common.FabricCommonHelper;
|
||||
import com.hypherionmc.craterlib.common.FabricCommonHelper;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
|
@@ -1,18 +1,17 @@
|
||||
package me.hypherionmc.craterlib;
|
||||
package com.hypherionmc.craterlib;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import com.hypherionmc.craterlib.core.config.ConfigController;
|
||||
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.NoConfigScreen;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import me.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import me.hypherionmc.craterlib.common.config.ConfigController;
|
||||
import me.hypherionmc.craterlib.common.config.ModuleConfig;
|
||||
import me.hypherionmc.craterlib.common.config.annotations.NoConfigScreen;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 06/08/2022
|
||||
*/
|
||||
public class CraterLibModMenuIntegration implements ModMenuApi {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.client;
|
||||
package com.hypherionmc.craterlib.client;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
@@ -1,11 +1,11 @@
|
||||
package me.hypherionmc.craterlib.client;
|
||||
package com.hypherionmc.craterlib.client;
|
||||
|
||||
import me.hypherionmc.craterlib.api.rendering.CustomRenderType;
|
||||
import me.hypherionmc.craterlib.common.item.BlockItemDyable;
|
||||
import me.hypherionmc.craterlib.network.CraterPacket;
|
||||
import me.hypherionmc.craterlib.platform.services.LibClientHelper;
|
||||
import com.hypherionmc.craterlib.api.rendering.CustomRenderType;
|
||||
import com.hypherionmc.craterlib.common.item.BlockItemDyable;
|
||||
import com.hypherionmc.craterlib.core.network.CraterPacket;
|
||||
import com.hypherionmc.craterlib.core.platform.services.LibClientHelper;
|
||||
import com.hypherionmc.craterlib.util.ColorPropertyFunction;
|
||||
import me.hypherionmc.craterlib.systems.reg.RegistryObject;
|
||||
import me.hypherionmc.craterlib.util.ColorPropertyFunction;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
@@ -33,7 +33,6 @@ import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 16/06/2022
|
||||
*/
|
||||
public class FabricClientHelper implements LibClientHelper {
|
||||
|
@@ -1,12 +1,11 @@
|
||||
package me.hypherionmc.craterlib.client.gui.widgets;
|
||||
package com.hypherionmc.craterlib.client.gui.widgets;
|
||||
|
||||
import com.hypherionmc.craterlib.systems.fluid.FluidTank;
|
||||
import com.hypherionmc.craterlib.util.RenderUtils;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import me.hypherionmc.craterlib.systems.fluid.FluidTank;
|
||||
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;
|
||||
@@ -19,7 +18,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
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
|
||||
* Modified from <a href="https://github.com/SleepyTrousers/EnderIO-Rewrite/blob/dev/1.18.x/enderio-machines/src/main/java/com/enderio/machines/client/FluidStackWidget.java">...</a>
|
||||
*/
|
||||
public class FluidStackWidget extends AbstractWidget {
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package me.hypherionmc.craterlib.common;
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import me.hypherionmc.craterlib.api.blockentities.caps.CapabilityHandler;
|
||||
import me.hypherionmc.craterlib.api.blockentities.caps.ICraterCapProvider;
|
||||
import me.hypherionmc.craterlib.network.CraterNetworkHandler;
|
||||
import me.hypherionmc.craterlib.network.CraterPacket;
|
||||
import me.hypherionmc.craterlib.network.FabricNetworkHandler;
|
||||
import me.hypherionmc.craterlib.platform.services.LibCommonHelper;
|
||||
import com.hypherionmc.craterlib.api.blockentity.caps.CraterCapabilityHandler;
|
||||
import com.hypherionmc.craterlib.api.blockentity.caps.ICraterCapProvider;
|
||||
import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
|
||||
import com.hypherionmc.craterlib.core.network.CraterPacket;
|
||||
import com.hypherionmc.craterlib.core.platform.services.LibCommonHelper;
|
||||
import com.hypherionmc.craterlib.network.FabricNetworkHandler;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
|
||||
@@ -32,7 +32,6 @@ import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 24/09/2022
|
||||
*/
|
||||
public class FabricCommonHelper implements LibCommonHelper {
|
||||
|
||||
@@ -85,7 +84,7 @@ public class FabricCommonHelper implements LibCommonHelper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> getCapabilityHandler(BlockEntity entity, Direction side, CapabilityHandler capability) {
|
||||
public <T> Optional<T> getCapabilityHandler(BlockEntity entity, Direction side, CraterCapabilityHandler capability) {
|
||||
if (entity instanceof ICraterCapProvider capProvider) {
|
||||
return capProvider.getCapability(capability, side);
|
||||
}
|
@@ -1,9 +1,12 @@
|
||||
package me.hypherionmc.craterlib.common;
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import me.hypherionmc.craterlib.platform.services.LibFluidHelper;
|
||||
import me.hypherionmc.craterlib.systems.fluid.*;
|
||||
import com.hypherionmc.craterlib.core.platform.services.LibFluidHelper;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.CraterFluidTank;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.FluidHolder;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.ICraterFluidHandler;
|
||||
import com.hypherionmc.craterlib.systems.fluid.FabricFluidUtils;
|
||||
import com.hypherionmc.craterlib.systems.fluid.FluidTank;
|
||||
import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.fabricmc.fabric.impl.transfer.fluid.FluidVariantImpl;
|
||||
import net.fabricmc.fabric.mixin.transfer.BucketItemAccessor;
|
@@ -1,7 +1,7 @@
|
||||
package me.hypherionmc.craterlib.common;
|
||||
package com.hypherionmc.craterlib.common;
|
||||
|
||||
import me.hypherionmc.craterlib.platform.services.Environment;
|
||||
import me.hypherionmc.craterlib.platform.services.ILoaderHelper;
|
||||
import com.hypherionmc.craterlib.core.platform.services.Environment;
|
||||
import com.hypherionmc.craterlib.core.platform.services.ILoaderHelper;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -19,11 +19,6 @@ public class FabricLoaderHelper implements ILoaderHelper {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForge() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGameVersion() {
|
||||
return SharedConstants.VERSION_STRING;
|
@@ -1,6 +1,6 @@
|
||||
package me.hypherionmc.craterlib.mixin;
|
||||
package com.hypherionmc.craterlib.mixin;
|
||||
|
||||
import me.hypherionmc.craterlib.systems.internal.CreativeTabRegistry;
|
||||
import com.hypherionmc.craterlib.core.systems.internal.CreativeTabRegistry;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -18,7 +18,7 @@ public class MinecraftMixin {
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void injectCraterLateInit(GameConfig gameConfig, CallbackInfo ci) {
|
||||
CreativeTabRegistry.getTABS().forEach(tab -> {
|
||||
CreativeTabRegistry.getTabs().forEach(tab -> {
|
||||
CreativeModeTab finalTab = FabricItemGroup.builder(tab.getResourceLocation())
|
||||
.title(Component.translatable("itemGroup." +
|
||||
tab.getResourceLocation().toString().replace(":", ".")
|
@@ -1,8 +1,11 @@
|
||||
package me.hypherionmc.craterlib.network;
|
||||
package com.hypherionmc.craterlib.network;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import me.hypherionmc.craterlib.platform.ClientPlatform;
|
||||
import me.hypherionmc.craterlib.platform.Platform;
|
||||
import com.hypherionmc.craterlib.core.network.CraterNetworkHandler;
|
||||
import com.hypherionmc.craterlib.core.network.CraterPacket;
|
||||
import com.hypherionmc.craterlib.core.network.PacketDirection;
|
||||
import com.hypherionmc.craterlib.core.platform.ClientPlatform;
|
||||
import com.hypherionmc.craterlib.core.platform.Platform;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
@@ -1,4 +1,4 @@
|
||||
package me.hypherionmc.craterlib.systems.fluid;
|
||||
package com.hypherionmc.craterlib.systems.fluid;
|
||||
|
||||
import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
@@ -1,5 +1,7 @@
|
||||
package me.hypherionmc.craterlib.systems.fluid;
|
||||
package com.hypherionmc.craterlib.systems.fluid;
|
||||
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.CraterFluidTank;
|
||||
import com.hypherionmc.craterlib.core.systems.fluid.FluidHolder;
|
||||
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;
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.FabricLoaderHelper
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.client.FabricClientHelper
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.FabricCommonHelper
|
@@ -0,0 +1 @@
|
||||
com.hypherionmc.craterlib.common.FabricFluidHelper
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user