Initial 1.20 port. Still untested

This commit is contained in:
2023-05-11 19:30:00 +02:00
parent 8e72212bf6
commit 5b6bf5fd8a
20 changed files with 60 additions and 50 deletions

View File

@@ -4,8 +4,8 @@ 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.core.systems.reg.RegistryObject;
import com.hypherionmc.craterlib.util.ColorPropertyFunction;
import me.hypherionmc.craterlib.systems.reg.RegistryObject;
import net.fabricmc.api.EnvType;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;

View File

@@ -3,9 +3,9 @@ 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 net.fabricmc.fabric.api.transfer.v1.client.fluid.FluidVariantRendering;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.client.gui.screens.Screen;
@@ -35,7 +35,7 @@ public class FluidStackWidget extends AbstractWidget {
}
@Override
public void renderWidget(@NotNull PoseStack matrices, int mouseX, int mouseY, float delta) {
public void renderWidget(@NotNull GuiGraphics matrices, int mouseX, int mouseY, float delta) {
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.defaultBlendFunc();
RenderSystem.enableDepthTest();
@@ -62,18 +62,18 @@ public class FluidStackWidget extends AbstractWidget {
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);
matrices.pose().pushPose();
matrices.pose().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;
// TODO Double Check this
blit(matrices, getX(), getY() + notDrawingHeight, 0, still.getU0() * atlasWidth, still.getV0() * atlasHeight + notDrawingHeight, this.width, drawingHeight, atlasWidth, atlasHeight);
matrices.translate(0, -16, 0);
matrices.blit(TextureAtlas.LOCATION_BLOCKS, getX(), getY() + notDrawingHeight, 0, still.getU0() * atlasWidth, still.getV0() * atlasHeight + notDrawingHeight, this.width, drawingHeight, atlasWidth, atlasHeight);
matrices.pose().translate(0, -16, 0);
}
RenderSystem.setShaderColor(1, 1, 1, 1);
matrices.popPose();
matrices.pose().popPose();
}
//renderToolTip(matrices, mouseX, mouseY);
}

View File

@@ -46,7 +46,7 @@ public class FabricFluidHelper implements LibFluidHelper {
if (fluidVariant.isBlank())
return false;
if (fluidHandler.insert(new FluidHolder(fluidVariant.getFluid(), 1000), ICraterFluidHandler.FluidAction.EXECUTE) > 0) {
player.level.playSound(null, player.getOnPos(), SoundEvents.BUCKET_EMPTY, SoundSource.BLOCKS, 1.0f, 1.0f);
player.level().playSound(null, player.getOnPos(), SoundEvents.BUCKET_EMPTY, SoundSource.BLOCKS, 1.0f, 1.0f);
return true;
}
}

View File

@@ -19,7 +19,7 @@ public class MinecraftMixin {
@Inject(method = "<init>", at = @At("RETURN"))
private void injectCraterLateInit(GameConfig gameConfig, CallbackInfo ci) {
CreativeTabRegistry.getTabs().forEach(tab -> {
CreativeModeTab finalTab = FabricItemGroup.builder(tab.getResourceLocation())
CreativeModeTab finalTab = FabricItemGroup.builder()
.title(Component.translatable("itemGroup." +
tab.getResourceLocation().toString().replace(":", ".")
))
@@ -28,7 +28,7 @@ public class MinecraftMixin {
tab.setTab(finalTab);
ItemGroupEvents.modifyEntriesEvent(finalTab).register(entries -> CreativeTabRegistry
ItemGroupEvents.modifyEntriesEvent(tab.getResourceKey()).register(entries -> CreativeTabRegistry
.getTabItems()
.stream().filter(t -> t.getLeft().get() == finalTab && t.getRight() != null)
.map(Pair::getRight).forEach(itm -> entries.accept(itm.get())));

View File

@@ -34,7 +34,7 @@
"depends": {
"fabricloader": ">=0.14",
"fabric": "*",
"minecraft": ">=1.19.4",
"minecraft": ">=1.20",
"java": ">=17"
}
}