Initial 1.19.3 Porting with new Creative Tab API
This commit is contained in:
5
.idea/misc.xml
generated
5
.idea/misc.xml
generated
@@ -12,9 +12,4 @@
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="SwUserDefinedSpecifications">
|
||||
<option name="specTypeByUrl">
|
||||
<map />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@@ -0,0 +1,71 @@
|
||||
package me.hypherionmc.craterlib.api.inventory;
|
||||
|
||||
import me.hypherionmc.craterlib.systems.internal.CreativeTabRegistry;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CraterCreativeModeTab implements Supplier<CreativeModeTab> {
|
||||
|
||||
private final ResourceLocation resourceLocation;
|
||||
private final ItemStack icon;
|
||||
private final String backgroundSuffix;
|
||||
private CreativeModeTab tab;
|
||||
|
||||
protected CraterCreativeModeTab(Builder builder) {
|
||||
this.resourceLocation = builder.location;
|
||||
this.icon = builder.stack == null ? ItemStack.EMPTY : builder.stack;
|
||||
this.backgroundSuffix = builder.backgroundSuffix == null ? "" : builder.backgroundSuffix;
|
||||
|
||||
CreativeTabRegistry.registerTab(this);
|
||||
}
|
||||
|
||||
public ResourceLocation getResourceLocation() {
|
||||
return this.resourceLocation;
|
||||
}
|
||||
|
||||
public ItemStack getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public String getBackgroundSuffix() {
|
||||
return backgroundSuffix;
|
||||
}
|
||||
|
||||
public void setTab(CreativeModeTab tab) {
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final ResourceLocation location;
|
||||
private ItemStack stack;
|
||||
private String backgroundSuffix;
|
||||
|
||||
public Builder(ResourceLocation location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public Builder setIcon(ItemStack icon) {
|
||||
stack = icon;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder backgroundSuffix(String backgroundSuffix) {
|
||||
this.backgroundSuffix = backgroundSuffix;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CraterCreativeModeTab build() {
|
||||
return new CraterCreativeModeTab(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreativeModeTab get() {
|
||||
return tab == null ? CreativeModeTabs.getDefaultTab() : tab;
|
||||
}
|
||||
}
|
@@ -2,7 +2,6 @@ package me.hypherionmc.craterlib.client.gui.config;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import me.hypherionmc.craterlib.CraterConstants;
|
||||
import me.hypherionmc.craterlib.client.gui.config.widgets.*;
|
||||
import me.hypherionmc.craterlib.common.config.ModuleConfig;
|
||||
@@ -17,6 +16,7 @@ import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
|
@@ -19,8 +19,8 @@ public class AbstractConfigWidget<T, W extends AbstractWidget> extends BaseWidge
|
||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
||||
int i = (widget instanceof EditBox ? 1 : 0);
|
||||
widget.x = x + width - 200 - resetButtonOffset + i;
|
||||
widget.y = y + i + 1;
|
||||
widget.setX(x + width - 200 - resetButtonOffset + i);
|
||||
widget.setY(y + i + 1);
|
||||
widget.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ import net.minecraft.network.chat.TextColor;
|
||||
public class BaseWidget<T> extends Option<T> {
|
||||
|
||||
public static final int resetButtonOffset = 48;
|
||||
private final Button resetButton = addChild(new Button(0, 0, 46, 20, Component.literal("Reset"), this::onResetPressed));
|
||||
private final Button resetButton = addChild(Button.builder(Component.literal("Reset"), this::onResetPressed).size(46, 20).build());
|
||||
private boolean hideReset = false;
|
||||
|
||||
private boolean isSubConfig = false;
|
||||
@@ -51,8 +51,8 @@ public class BaseWidget<T> extends Option<T> {
|
||||
text.withStyle(ChatFormatting.GRAY);
|
||||
}
|
||||
font.draw(matrices, text, x, y + 8, 0xFFFFFF);
|
||||
resetButton.x = x + width - 46;
|
||||
resetButton.y = y + 1;
|
||||
resetButton.setX(x + width - 46);
|
||||
resetButton.setY(y + 1);
|
||||
resetButton.active = isNotDefault();
|
||||
if (!hideReset) {
|
||||
resetButton.render(matrices, mouseX, mouseY, delta);
|
||||
|
@@ -30,6 +30,11 @@ public class InternalConfigButton extends AbstractButton {
|
||||
super.render(poseStack, i, j, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) {
|
||||
narrationElementOutput.add(NarratedElementType.USAGE, getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
if (cancel) {
|
||||
@@ -39,9 +44,5 @@ public class InternalConfigButton extends AbstractButton {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNarration(NarrationElementOutput narrationElementOutput) {
|
||||
narrationElementOutput.add(NarratedElementType.USAGE, getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -19,7 +19,8 @@ public class SubConfigWidget<T> extends AbstractConfigWidget<T, Button> {
|
||||
this.config = config;
|
||||
this.subConfig = subConfig;
|
||||
this.screen = screen;
|
||||
this.widget = addChild(new Button(0, 0, 200, buttonHeight, Component.translatable("t.clc.opensubconfig"), this::openSubConfig));
|
||||
|
||||
this.widget = addChild(Button.builder(Component.translatable("t.clc.opensubconfig"), this::openSubConfig).size(200, buttonHeight).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -18,7 +18,7 @@ public class ToggleButton <T> extends AbstractConfigWidget<T, Button> {
|
||||
public ToggleButton(List<T> options, Function<T, Component> toComponent) {
|
||||
this.options = options;
|
||||
this.toComponent = toComponent;
|
||||
this.widget = addChild(new Button(0, 0, buttonWidth, buttonHeight, Component.empty(), this::switchNext));
|
||||
this.widget = addChild(Button.builder(Component.empty(), this::switchNext).size(buttonWidth, buttonHeight).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,48 +0,0 @@
|
||||
package me.hypherionmc.craterlib.client.gui.tabs;
|
||||
|
||||
import me.hypherionmc.craterlib.platform.Platform;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
* @date 16/06/2022
|
||||
* Provides a wrapper around Forge/Fabric to create a new Creative Tab
|
||||
*/
|
||||
public class CreativeTabBuilder {
|
||||
|
||||
public static Builder builder(String modid, String tabid) {
|
||||
return new Builder(modid, tabid);
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
|
||||
private Supplier<ItemStack> tabIcon;
|
||||
private final String modid;
|
||||
private final String tabid;
|
||||
private String backgroundPrefix;
|
||||
|
||||
public Builder(String modid, String tabid) {
|
||||
this.modid = modid;
|
||||
this.tabid = tabid;
|
||||
}
|
||||
|
||||
public Builder setIcon(Supplier<ItemStack> stack) {
|
||||
this.tabIcon = stack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setBackgroundPrefix(String prefix) {
|
||||
this.backgroundPrefix = prefix;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CreativeModeTab build() {
|
||||
return Platform.COMMON_HELPER.tabBuilder(this.modid, this.tabid, this.tabIcon, this.backgroundPrefix);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
package me.hypherionmc.craterlib.common.network;
|
||||
|
||||
// TODO: FINISH NETWORK IMPLEMENTATION
|
||||
public interface BaseNetworkPacket {
|
||||
|
||||
}
|
@@ -36,5 +36,4 @@ public interface LibCommonHelper {
|
||||
/* FABRIC ONLY */
|
||||
public void registerServerReceiver(ResourceLocation channelName, Function<FriendlyByteBuf, CraterPacket<?>> factory);
|
||||
|
||||
public CreativeModeTab tabBuilder(String modid, String tabid, Supplier<ItemStack> icon, String backgroundSuf);
|
||||
}
|
||||
|
@@ -0,0 +1,21 @@
|
||||
package me.hypherionmc.craterlib.systems.internal;
|
||||
|
||||
import me.hypherionmc.craterlib.api.inventory.CraterCreativeModeTab;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class CreativeTabRegistry {
|
||||
|
||||
private static final List<CraterCreativeModeTab> TABS = new ArrayList<>();
|
||||
public static void registerTab(CraterCreativeModeTab tab) {
|
||||
TABS.add(tab);
|
||||
}
|
||||
|
||||
public static List<CraterCreativeModeTab> getTABS() {
|
||||
return TABS;
|
||||
}
|
||||
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
package me.hypherionmc.craterlib.util;
|
||||
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
@@ -3,14 +3,8 @@ package me.hypherionmc.craterlib;
|
||||
import me.hypherionmc.craterlib.common.FabricCommonHelper;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
|
||||
|
||||
public class CraterLibInitializer implements ModInitializer, PreLaunchEntrypoint {
|
||||
|
||||
@Override
|
||||
public void onPreLaunch() {
|
||||
|
||||
}
|
||||
public class CraterLibInitializer implements ModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
|
@@ -1,11 +1,12 @@
|
||||
package me.hypherionmc.craterlib.client;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
|
||||
|
||||
public class CraterLibClientInitializer implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
|
||||
ItemGroupEvents.MODIFY_ENTRIES_ALL.register(FabricClientHelper::registerCreativeItems);
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ 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;
|
||||
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
@@ -18,6 +19,7 @@ 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.CreativeModeTab;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@@ -84,4 +86,8 @@ public class FabricClientHelper implements LibClientHelper {
|
||||
client.execute(() -> packet.handle(client.player, client));
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerCreativeItems(CreativeModeTab tab, FabricItemGroupEntries entries) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -63,33 +63,35 @@ public class FluidStackWidget extends AbstractWidget {
|
||||
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()));
|
||||
int atlasWidth = (int) (still.getX() / (still.getU1() - still.getU0()));
|
||||
int atlasHeight = (int) (still.getY() / (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);
|
||||
blit(matrices, getX(), getY() + 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);
|
||||
//renderToolTip(matrices, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO Fix Tooltips
|
||||
/*@Override
|
||||
public void renderToolTip(PoseStack poseStack, int mouseX, int mouseY) {
|
||||
if (this.visible && this.isFocused() && isHoveredOrFocused()) {
|
||||
displayOn.renderTooltip(poseStack, Arrays.asList(LangUtils.getTooltipTitle(toolTipTitle), Component.literal((int) (((float) this.getFluid.get().getAmount() / this.getFluid.get().getCapacity()) * 100) + "%")), Optional.empty(), mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public void updateNarration(NarrationElementOutput narrationElementOutput) {
|
||||
protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ 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 net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketSender;
|
||||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
|
||||
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
|
||||
@@ -20,14 +19,11 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.apache.commons.lang3.function.TriFunction;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author HypherionSA
|
||||
@@ -83,19 +79,4 @@ public class FabricCommonHelper implements LibCommonHelper {
|
||||
return new ExtendedScreenHandlerType<>(constructor::apply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreativeModeTab tabBuilder(String modid, String tabid, Supplier<ItemStack> icon, String backgroundSuf) {
|
||||
FabricItemGroupBuilder tab = FabricItemGroupBuilder.create(new ResourceLocation(modid, tabid));
|
||||
|
||||
if (icon != null) {
|
||||
tab.icon(icon);
|
||||
}
|
||||
|
||||
CreativeModeTab tab1 = tab.build();
|
||||
|
||||
if (backgroundSuf != null && !backgroundSuf.isEmpty()) {
|
||||
tab1.setBackgroundSuffix(backgroundSuf);
|
||||
}
|
||||
return tab1;
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
|
||||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -28,7 +29,7 @@ public class FluidUtils {
|
||||
return FluidVariant.blank();
|
||||
|
||||
if (tag.get(key) instanceof StringTag) {
|
||||
return FluidVariant.of(Registry.FLUID.get(new ResourceLocation(tag.getString(key))));
|
||||
return FluidVariant.of(BuiltInRegistries.FLUID.get(new ResourceLocation(tag.getString(key))));
|
||||
} else {
|
||||
CompoundTag compound = tag.getCompound(key);
|
||||
if (compound.contains("fk")) {
|
||||
@@ -41,7 +42,7 @@ public class FluidUtils {
|
||||
|
||||
private static Fluid readLbaTag(CompoundTag tag) {
|
||||
if (tag.contains("ObjName") && tag.getString("Registry").equals("f")) {
|
||||
return Registry.FLUID.get(new ResourceLocation(tag.getString("ObjName")));
|
||||
return BuiltInRegistries.FLUID.get(new ResourceLocation(tag.getString("ObjName")));
|
||||
} else {
|
||||
return Fluids.EMPTY;
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.19.2",
|
||||
"minecraft": "1.19.3",
|
||||
"java": ">=17"
|
||||
}
|
||||
}
|
||||
|
@@ -41,9 +41,6 @@ public class FluidStackWidget extends AbstractWidget {
|
||||
this.toolTipTitle = toolTipTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNarration(NarrationElementOutput pNarrationElementOutput) {}
|
||||
|
||||
@Override
|
||||
public void renderButton(PoseStack pPoseStack, int pMouseX, int pMouseY, float pPartialTicks) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
@@ -74,15 +71,15 @@ public class FluidStackWidget extends AbstractWidget {
|
||||
float filledVolume = stored / capacity;
|
||||
int renderableHeight = (int)(filledVolume * height);
|
||||
|
||||
int atlasWidth = (int)(sprite.getWidth() / (sprite.getU1() - sprite.getU0()));
|
||||
int atlasHeight = (int)(sprite.getHeight() / (sprite.getV1() - sprite.getV0()));
|
||||
int atlasWidth = (int)(sprite.getY() / (sprite.getU1() - sprite.getU0()));
|
||||
int atlasHeight = (int)(sprite.getY() / (sprite.getV1() - sprite.getV0()));
|
||||
|
||||
pPoseStack.pushPose();
|
||||
pPoseStack.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(pPoseStack, x, y + notDrawingHeight, displayOn.getBlitOffset(), sprite.getU0()*atlasWidth, sprite.getV0()*atlasHeight + notDrawingHeight, this.width, drawingHeight, atlasWidth, atlasHeight);
|
||||
blit(pPoseStack, getX(), getY() + notDrawingHeight, displayOn.getBlitOffset(), sprite.getU0()*atlasWidth, sprite.getV0()*atlasHeight + notDrawingHeight, this.width, drawingHeight, atlasWidth, atlasHeight);
|
||||
pPoseStack.translate(0,-16, 0);
|
||||
}
|
||||
|
||||
@@ -90,13 +87,20 @@ public class FluidStackWidget extends AbstractWidget {
|
||||
pPoseStack.popPose();
|
||||
}
|
||||
}
|
||||
renderToolTip(pPoseStack, pMouseX, pMouseY);
|
||||
//renderToolTip(pPoseStack, pMouseX, pMouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
|
||||
|
||||
}
|
||||
|
||||
// TODO Fix Tooltips
|
||||
/*@Override
|
||||
public void renderToolTip(PoseStack pPoseStack, int pMouseX, int pMouseY) {
|
||||
if (isActive() && isHovered) {
|
||||
displayOn.renderTooltip(pPoseStack, Arrays.asList(LangUtils.getTooltipTitle(toolTipTitle).getVisualOrderText(), Component.literal((int) (((float)this.getFluid.get().getFluidAmount() / this.getFluid.get().getCapacity()) * 100) + "%").getVisualOrderText()), pMouseX, pMouseY);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@@ -0,0 +1,28 @@
|
||||
package me.hypherionmc.craterlib.common;
|
||||
|
||||
import me.hypherionmc.craterlib.CraterConstants;
|
||||
import me.hypherionmc.craterlib.systems.internal.CreativeTabRegistry;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraftforge.event.CreativeModeTabEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = CraterConstants.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class ForgeCommonEvents {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void buildContents(CreativeModeTabEvent.Register event) {
|
||||
CraterConstants.LOG.info("Registering Creative Tabs");
|
||||
CreativeTabRegistry.getTABS().forEach(tab -> {
|
||||
CreativeModeTab creativeModeTab = event.registerCreativeModeTab(tab.getResourceLocation(), builder -> {
|
||||
builder.icon(tab::getIcon);
|
||||
|
||||
if (!tab.getBackgroundSuffix().isEmpty()) {
|
||||
builder.backgroundSuffix(tab.getBackgroundSuffix());
|
||||
}
|
||||
});
|
||||
tab.setTab(creativeModeTab);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -20,6 +20,8 @@ import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
import org.apache.commons.lang3.function.TriFunction;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
@@ -30,6 +32,8 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
public class ForgeCommonHelper implements LibCommonHelper {
|
||||
|
||||
public static Map<ResourceLocation, CreativeModeTab> TABS = new HashMap<>();
|
||||
|
||||
public ForgeCommonHelper() {}
|
||||
|
||||
@Override
|
||||
@@ -60,23 +64,4 @@ public class ForgeCommonHelper implements LibCommonHelper {
|
||||
public <T extends AbstractContainerMenu> MenuType<T> createMenuType(TriFunction<Integer, Inventory, FriendlyByteBuf, T> constructor) {
|
||||
return IForgeMenuType.create(constructor::apply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreativeModeTab tabBuilder(String modid, String tabid, Supplier<ItemStack> icon, String backgroundSuf) {
|
||||
CreativeModeTab tab = new CreativeModeTab(modid + "." + tabid) {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
if (icon != null) {
|
||||
return icon.get();
|
||||
} else {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (backgroundSuf != null && !backgroundSuf.isEmpty()) {
|
||||
tab.setBackgroundSuffix(backgroundSuf);
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "[43,)"
|
||||
loaderVersion = "[44,)"
|
||||
license = "MIT"
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/"
|
||||
|
||||
@@ -19,13 +19,13 @@ A library mod used by HypherionSA's Mods
|
||||
[[dependencies.craterlib]]
|
||||
modId = "forge"
|
||||
mandatory = true
|
||||
versionRange = "[43,)"
|
||||
versionRange = "[44,)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
||||
[[dependencies.craterlib]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
versionRange = "[1.19.2,1.20)"
|
||||
versionRange = "[1.19.3,1.20)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'com.matyrobbrt.mc.registrationutils' version '1.19-1.3.0'
|
||||
id 'com.matyrobbrt.mc.registrationutils' version '1.19.3-1.0.0'
|
||||
}
|
||||
|
||||
registrationUtils {
|
||||
|
@@ -1,21 +1,21 @@
|
||||
# Project
|
||||
version_major=0
|
||||
version_minor=0
|
||||
version_patch=5d
|
||||
version_patch=6d
|
||||
group=me.hypherionmc.craterlib
|
||||
|
||||
# Common
|
||||
minecraft_version=1.19.2
|
||||
minecraft_version=1.19.3
|
||||
common_runs_enabled=false
|
||||
common_client_run_name=Common Client
|
||||
common_server_run_name=Common Server
|
||||
|
||||
# Forge
|
||||
forge_version=43.1.25
|
||||
forge_version=44.0.41
|
||||
forge_ats_enabled=true
|
||||
|
||||
# Fabric
|
||||
fabric_version=0.61.0+1.19.2
|
||||
fabric_version=0.70.0+1.19.3
|
||||
fabric_loader_version=0.14.9
|
||||
|
||||
# Mod options
|
||||
@@ -28,4 +28,4 @@ org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
|
||||
# Dependencies
|
||||
mod_menu_version=4.0.6
|
||||
mod_menu_version=5.0.2
|
||||
|
Reference in New Issue
Block a user