Skip to content

Commit

Permalink
Fixed hand rendering bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LatvianModder committed Jun 21, 2024
1 parent 657ebd4 commit f2a8d05
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static void hudPostDraw(RenderGuiEvent.Post event) {
var mc = Minecraft.getInstance();

if (mc.screen == null) {
KubedexHighlight.INSTANCE.afterEverything(mc, event.getPartialTick().getGameTimeDeltaPartialTick(false));
KubedexHighlight.INSTANCE.afterEverything(mc, event.getGuiGraphics(), event.getPartialTick().getGameTimeDeltaPartialTick(false));
}
}

Expand All @@ -214,7 +214,7 @@ public static void screenPostDraw(ScreenEvent.Render.Post event) {
KubedexHighlight.INSTANCE.screen(mc, event.getGuiGraphics(), screen, event.getMouseX(), event.getMouseY(), event.getPartialTick());
}

KubedexHighlight.INSTANCE.afterEverything(mc, event.getPartialTick());
KubedexHighlight.INSTANCE.afterEverything(mc, event.getGuiGraphics(), event.getPartialTick());
}

@SubscribeEvent
Expand All @@ -238,6 +238,7 @@ public static void worldRender(RenderLevelStageEvent event) {
depth.bindWrite(false);
depth.clear(Minecraft.ON_OSX);
depth.copyDepthFrom(mc.getMainRenderTarget());
mc.getMainRenderTarget().bindWrite(false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.util.FormattedCharSequence;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import org.jetbrains.annotations.Nullable;

import java.awt.Desktop;
Expand Down Expand Up @@ -168,7 +166,6 @@ public int getRowWidth() {
}
}

@OnlyIn(Dist.CLIENT)
public static class Entry extends ObjectSelectionList.Entry<Entry> {
private final ErrorList errorList;
private final Minecraft minecraft;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,13 @@ public void screen(Minecraft mc, GuiGraphics graphics, AbstractContainerScreen<?
mc.getMainRenderTarget().bindWrite(false);
}

public void afterEverything(Minecraft mc, float delta) {
public void afterEverything(Minecraft mc, GuiGraphics graphics, float delta) {
if (renderOutput == null || postChain == null || !renderAnything) {
return;
}

graphics.flush();

postChain.process(delta);
mc.getMainRenderTarget().bindWrite(false);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
package dev.latvian.mods.kubejs.recipe.special;

import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import dev.latvian.mods.kubejs.recipe.KubeJSRecipeSerializers;
import dev.latvian.mods.kubejs.recipe.ingredientaction.IngredientActionHolder;
import it.unimi.dsi.fastutil.chars.CharArraySet;
import it.unimi.dsi.fastutil.chars.CharSet;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.NonNullList;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.CraftingBookCategory;
import net.minecraft.world.item.crafting.CraftingInput;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.ShapedRecipe;
import net.minecraft.world.item.crafting.ShapedRecipePattern;
import net.minecraft.world.level.Level;

import java.util.List;
import java.util.Optional;

public class ShapedKubeJSRecipe extends ShapedRecipe implements KubeJSCraftingRecipe {
private final boolean mirror;
Expand Down Expand Up @@ -139,33 +134,4 @@ public StreamCodec<RegistryFriendlyByteBuf, ShapedKubeJSRecipe> streamCodec() {
return STREAM_CODEC;
}
}

private static DataResult<ShapedRecipePattern> unpackNoShrink(ShapedRecipePattern.Data data) {
var pattern = data.pattern();
// we can assume that the pattern is rectangular
// because the codec has already validated that
var width = pattern.getFirst().length();
var height = pattern.size();
NonNullList<Ingredient> nonNullList = NonNullList.withSize(width * height, Ingredient.EMPTY);
CharSet charSet = new CharArraySet(data.key().keySet());

for (int row = 0; row < pattern.size(); ++row) {
String string = pattern.get(row);

for (int cell = 0; cell < string.length(); ++cell) {
char symbol = string.charAt(cell);
Ingredient ingredient = symbol == ' ' ? Ingredient.EMPTY : data.key().get(symbol);
if (ingredient == null) {
return DataResult.error(() -> "Pattern references symbol '" + symbol + "' but it's not defined in the key");
}

charSet.remove(symbol);
nonNullList.set(cell + width * row, ingredient);
}
}

return !charSet.isEmpty()
? DataResult.error(() -> "Key defines symbols that aren't used in pattern: " + charSet)
: DataResult.success(new ShapedRecipePattern(width, height, nonNullList, Optional.of(data)));
}
}

0 comments on commit f2a8d05

Please sign in to comment.