Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arborsm committed Apr 8, 2024
1 parent f00b6e5 commit 310d2f2
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 19 deletions.
4 changes: 2 additions & 2 deletions gradle/scripts/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ dependencies {
// REI
modCompileOnly forge.rei.plugin
modCompileOnly forge.rei.api
modImplementation forge.rei.forge
modCompileOnly forge.rei.forge

// EMI
modCompileOnly("dev.emi:emi-forge:${forge.versions.emi.get()}:api")
modCompileOnly forge.emi
modImplementation forge.emi

// TOP
modCompileOnly(forge.theoneprobe) { transitive = false }
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencyResolutionManagement {
def vineFlowerVersion = "1.+"
def macheteVersion = "1.+"
def configurationVersion = "2.2.0"
def ldLibVersion = "1.0.25.a"
def ldLibVersion = "1.0.25.b"
def mixinextrasVersion = "0.2.0"
def shimmerVersion = "0.2.2"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package com.gregtechceu.gtceu.api.recipe.content;

import com.gregtechceu.gtceu.api.capability.recipe.RecipeCapability;
import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient;
import com.lowdragmc.lowdraglib.LDLib;
import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture;
import com.lowdragmc.lowdraglib.side.fluid.FluidStack;
import com.lowdragmc.lowdraglib.utils.LocalizationUtils;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import dev.emi.emi.screen.RecipeScreen;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

Expand Down Expand Up @@ -46,13 +52,36 @@ public IGuiTexture createOverlay(boolean perTick) {
@OnlyIn(Dist.CLIENT)
public void draw(GuiGraphics graphics, int mouseX, int mouseY, float x, float y, int width, int height) {
drawChance(graphics, x, y, width, height);
if (LDLib.isEmiLoaded()) {
drawEmiAmount(graphics, x, y, width, height);
}
if (perTick) {
drawTick(graphics, x, y, width, height);
}
}
};
}

@OnlyIn(Dist.CLIENT)
public void drawEmiAmount(GuiGraphics graphics, float x, float y, int width, int height) {
if (content instanceof FluidIngredient ingredient) {
graphics.pose().pushPose();
graphics.pose().translate(0, 0, 400);
graphics.pose().scale(0.5f, 0.5f, 1);
long amount = ingredient.getAmount();
String s;
if (amount >= 1000) {
amount /= 1000;
s = amount + "B";
} else {
s = amount + "mB";
}
Font fontRenderer = Minecraft.getInstance().font;
graphics.drawString(fontRenderer, s, (int) ((x + (width / 3f)) * 2 - fontRenderer.width(s) + 21), (int) ((y + (height / 3f) + 6) * 2), 0xFFFFFF, true);
graphics.pose().popPose();
}
}

@OnlyIn(Dist.CLIENT)
public void drawChance(GuiGraphics graphics, float x, float y, int width, int height) {
if (chance == 1) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public IEditableUI<WidgetGroup, RecipeHolder> createEditableUITemplate(final boo
progressWidget.setProgressSupplier(recipeHolder.progressSupplier);
progress.add(progressWidget);
});
// Then set the dual progress widgets, to override their builtin ones' suppliers, in case someone forgot to remove the id from the internal ones.
// Then set the dual-progress widgets, to override their builtin ones' suppliers, in case someone forgot to remove the id from the internal ones.
WidgetUtils.widgetByIdForEach(template, "^progress$", DualProgressWidget.class, dualProgressWidget -> {
dualProgressWidget.setProgressSupplier(recipeHolder.progressSupplier);
progress.add(dualProgressWidget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ private void setTierToMin() {
setTier(getMinTier());
}

// Maps ingredients to Either<(Tag with count), ItemStack>s
// Maps ingredients to Either <(Tag with count), ItemStack>s
@SuppressWarnings("deprecation")
private static Either<List<Pair<TagKey<Item>, Integer>>, List<ItemStack>> mapItem(Ingredient ingredient) {
if (ingredient instanceof SizedIngredient sizedIngredient) {
Expand Down Expand Up @@ -504,7 +504,7 @@ private static Either<List<Pair<TagKey<Item>, Integer>>, List<ItemStack>> mapIte
return Either.right(Arrays.stream(ingredient.getItems()).toList());
}

// Maps fluids to Either<(tag with count), ItemStack>s
// Maps fluids to Either <(tag with count), ItemStack>s
private static Either<List<Pair<TagKey<Fluid>, Long>>, List<FluidStack>> mapFluid(FluidIngredient ingredient) {
long amount = ingredient.getAmount();
CompoundTag tag = ingredient.getNbt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.gregtechceu.gtceu.integration.emi.recipe.Ae2PatternTerminalHandler;
import com.gregtechceu.gtceu.integration.emi.recipe.GTEmiRecipeHandler;
import com.gregtechceu.gtceu.integration.emi.recipe.GTRecipeTypeEmiCategory;
import com.lowdragmc.lowdraglib.gui.modular.ModularUIContainer;
import dev.emi.emi.api.EmiEntrypoint;
import dev.emi.emi.api.EmiPlugin;
import dev.emi.emi.api.EmiRegistry;
Expand Down Expand Up @@ -41,7 +42,7 @@ public void register(EmiRegistry registry) {
}
}
}
registry.addRecipeHandler(null, new GTEmiRecipeHandler());
registry.addRecipeHandler(ModularUIContainer.MENUTYPE, new GTEmiRecipeHandler());
if(GTCEu.isAE2Loaded()){
registry.addRecipeHandler(PatternEncodingTermMenu.TYPE, new Ae2PatternTerminalHandler<>());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,18 @@

import java.util.List;

public class GTEmiRecipeHandler implements StandardRecipeHandler<AbstractContainerMenu> {
public class GTEmiRecipeHandler implements StandardRecipeHandler<ModularUIContainer> {
@Override
public List<Slot> getInputSources(AbstractContainerMenu handler) {
if (!(handler instanceof ModularUIContainer))
return List.of();

return ((ModularUIContainer) handler).getModularUI().getSlotMap().values().stream()
public List<Slot> getInputSources(ModularUIContainer handler) {
return handler.getModularUI().getSlotMap().values().stream()
.filter(e -> e.getIngredientIO() == IngredientIO.INPUT || e.isPlayerContainer || e.isPlayerHotBar)
.map(SlotWidget::getHandler)
.toList();
}

@Override
public List<Slot> getCraftingSlots(AbstractContainerMenu handler) {
if (!(handler instanceof ModularUIContainer))
return List.of();

return ((ModularUIContainer) handler).getModularUI().getSlotMap().values().stream()
public List<Slot> getCraftingSlots(ModularUIContainer handler) {
return handler.getModularUI().getSlotMap().values().stream()
.filter(e -> e.getIngredientIO() == IngredientIO.INPUT)
.map(SlotWidget::getHandler)
.toList();
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/gtceu.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"TagValueAccessor",
"ae2.GenericStackInvAccessor",
"create.RotationPropagatorMixin",
"emi.EmiRecipeHandlerMixin",
"emi.FluidEmiStackMixin",
"jei.FluidHelperMixin",
"rei.InputSlotCrafterMixin",
Expand Down

0 comments on commit 310d2f2

Please sign in to comment.