Initial 1.19.3 Porting with new Creative Tab API
This commit is contained in:
@@ -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"
|
||||
|
Reference in New Issue
Block a user