Skip to content

Commit

Permalink
update to new LDLib recipe viewer changes (#1067)
Browse files Browse the repository at this point in the history
* update to new LDLib recipe viewer changes which make us no longer use oh so many REI & EMI internals.

* fix things

* fix errors

* fixes update-ldlib-recipeviewer-changes bugs (#1075)

* fix data bank pattern errors, network switch not transmitting data (#1073)

* fix number formatting in recipe widget (#1070)

* Port multiblock fluid tanks (#1072)

* feat: add multiblock tanks

* feat: add tank valve behavior

* fix: tank valve rendering

* fix: tank valve rotation

* chore: run datagen

* refactor: decouple used filter from isMetal in multiblock tanks

* feat: add tooltips to multiblock tanks and valves

* chore: fix file copy error

* fixes

* back REI

* lang

* fix emi PatternPreviewWidget

---------

Co-authored-by: screret <[email protected]>
Co-authored-by: Mikerooni <[email protected]>

---------

Co-authored-by: Arbor <[email protected]>
Co-authored-by: Mikerooni <[email protected]>
  • Loading branch information
3 people authored Apr 8, 2024
1 parent e78af4d commit 01a1683
Show file tree
Hide file tree
Showing 31 changed files with 318 additions and 279 deletions.
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.24.c"
def ldLibVersion = "1.0.25.b"
def mixinextrasVersion = "0.2.0"
def shimmerVersion = "0.2.2"

Expand Down
2 changes: 1 addition & 1 deletion src/generated/resources/assets/gtceu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -3292,7 +3292,7 @@
"gtceu.recipe.cleanroom_sterile.display_name": "Sterile Cleanroom",
"gtceu.recipe.computation_per_tick": "Min. Computation: %s CWU/t",
"gtceu.recipe.dimensions": "Dimensions: %s",
"gtceu.recipe.duration": "Duration: %,.2f secs",
"gtceu.recipe.duration": "Duration: %s secs",
"gtceu.recipe.eu": "Usage: %s EU/t",
"gtceu.recipe.eu_inverted": "Generation: %s EU/t",
"gtceu.recipe.eu_to_start": "Energy To Start: %sEU",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet;
import com.gregtechceu.gtceu.api.data.chemical.material.properties.*;
import com.gregtechceu.gtceu.api.data.chemical.material.stack.MaterialStack;
import com.gregtechceu.gtceu.api.data.tag.TagUtil;
import com.gregtechceu.gtceu.api.fluids.FluidBuilder;
import com.gregtechceu.gtceu.api.fluids.FluidState;
import com.gregtechceu.gtceu.api.fluids.store.FluidStorageKey;
Expand All @@ -28,6 +29,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.level.material.Fluid;
Expand Down Expand Up @@ -243,6 +245,14 @@ public FluidStack getFluid(@NotNull FluidStorageKey key, long amount) {
return FluidStack.create(getFluid(key), amount);
}

/**
* @return a {@code TagKey<Fluid>} with the material's name as the tag key
* @see #getFluid(FluidStorageKey, long)
*/
public TagKey<Fluid> getFluidTag() {
return TagUtil.createFluidTag(this.getName());
}

/**
* Retrieves a fluid builder from the material.
* <br/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.gregtechceu.gtceu.api.data.chemical.material.properties;

import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.mojang.datafixers.util.Pair;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.util.Mth;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;

import org.jetbrains.annotations.Nullable;
Expand All @@ -17,31 +19,31 @@ public class OreProperty implements IMaterialProperty<OreProperty> {
* <p>
* Default: none, meaning only this property's Material.
*/
//@ZenProperty
@Getter
private final List<Material> oreByProducts = new ArrayList<>();

/**
* Crushed Ore output amount multiplier during Maceration.
* <p>
* Default: 1 (no multiplier).
*/
//@ZenProperty
@Getter @Setter
private int oreMultiplier;

/**
* Byproducts output amount multiplier during Maceration.
* <p>
* Default: 1 (no multiplier).
*/
//@ZenProperty
@Getter @Setter
private int byProductMultiplier;

/**
* Should ore block use the emissive texture.
* <p>
* Default: false.
*/
//@ZenProperty
@Getter @Setter
private boolean emissive;

/**
Expand All @@ -50,7 +52,7 @@ public class OreProperty implements IMaterialProperty<OreProperty> {
* Material will have a Dust Property.
* Default: none.
*/
//@ZenProperty
@Getter @Setter
@Nullable
private Material directSmeltResult;

Expand All @@ -60,7 +62,7 @@ public class OreProperty implements IMaterialProperty<OreProperty> {
* Material will have a Fluid Property.
* Default: none.
*/
//@ZenProperty
@Setter
@Nullable
private Material washedIn;

Expand All @@ -80,7 +82,7 @@ public class OreProperty implements IMaterialProperty<OreProperty> {
* Material will have a Dust Property.
* Default: none.
*/
//@ZenProperty
@Getter
private final List<Material> separatedInto = new ArrayList<>();

public OreProperty(int oreMultiplier, int byProductMultiplier) {
Expand All @@ -102,43 +104,6 @@ public OreProperty() {
this(1, 1);
}

public void setOreMultiplier(int multiplier) {
this.oreMultiplier = multiplier;
}

public int getOreMultiplier() {
return this.oreMultiplier;
}

public void setByProductMultiplier(int multiplier) {
this.byProductMultiplier = multiplier;
}

public int getByProductMultiplier() {
return this.byProductMultiplier;
}

public boolean isEmissive() {
return emissive;
}

public void setEmissive(boolean emissive) {
this.emissive = emissive;
}

public void setDirectSmeltResult(@Nullable Material m) {
this.directSmeltResult = m;
}

@Nullable
public Material getDirectSmeltResult() {
return this.directSmeltResult;
}

public void setWashedIn(@Nullable Material m) {
this.washedIn = m;
}

public void setWashedIn(@Nullable Material m, int washedAmount) {
this.washedIn = m;
this.washedAmount = washedAmount;
Expand All @@ -152,19 +117,10 @@ public void setSeparatedInto(Material... materials) {
this.separatedInto.addAll(Arrays.asList(materials));
}

@Nullable
public List<Material> getSeparatedInto() {
return this.separatedInto;
}

public void setOreByProducts(Material... materials) {
this.oreByProducts.addAll(Arrays.asList(materials));
}

public List<Material> getOreByProducts() {
return this.oreByProducts;
}

@Nullable
public final Material getOreByProduct(int index) {
if (this.oreByProducts.isEmpty()) return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.lowdragmc.lowdraglib.utils.ItemStackKey;
import com.lowdragmc.lowdraglib.utils.TrackedDummyWorld;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import dev.emi.emi.screen.RecipeScreen;
import it.unimi.dsi.fastutil.longs.LongSet;
import it.unimi.dsi.fastutil.longs.LongSets;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
Expand All @@ -37,8 +37,8 @@
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import org.jetbrains.annotations.NotNull;

import java.util.*;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -51,6 +51,7 @@
*/
@OnlyIn(Dist.CLIENT)
public class PatternPreviewWidget extends WidgetGroup {
private int i;
private static TrackedDummyWorld LEVEL;
private static BlockPos LAST_POS = new BlockPos(0, 50, 0);
private static final Map<MultiblockMachineDefinition, MBPattern[]> CACHE = new HashMap<>();
Expand Down Expand Up @@ -242,6 +243,11 @@ public static BlockPos locateNextRegion(int range) {
@Override
public void updateScreen() {
super.updateScreen();
// I can only think of this way
if (LDLib.isEmiLoaded() && Minecraft.getInstance().screen instanceof RecipeScreen && i == 0) {
setPage(i);
++i;
}
}

@Override
Expand Down Expand Up @@ -293,7 +299,7 @@ private MBPattern initializePattern(MultiblockShapeInfo shapeInfo, HashSet<ItemS
if (two.isTile && !one.isTile) return +1;
if (one.blockId != two.blockId) return two.blockId - one.blockId;
return two.amount - one.amount;
}).map(PartInfo::getItemStack).filter(list -> !list.isEmpty()).toList(), predicateMap, controllerBase);
}).map(PartInfo::getItemStack).filter(list -> !list.isEmpty()).collect(Collectors.toList()), predicateMap, controllerBase);
}

private void loadControllerFormed(Collection<BlockPos> poses, IMultiController controllerBase) {
Expand Down Expand Up @@ -371,7 +377,7 @@ private static class MBPattern {
final IMultiController controllerBase;
final int maxY, minY;

public MBPattern(@NotNull Map<BlockPos, BlockInfo> blockMap, List<List<ItemStack>> parts, @NotNull Map<BlockPos, TraceabilityPredicate> predicateMap, @NotNull IMultiController controllerBase) {
public MBPattern(@NotNull Map<BlockPos, BlockInfo> blockMap, @NotNull List<List<ItemStack>> parts, @NotNull Map<BlockPos, TraceabilityPredicate> predicateMap, @NotNull IMultiController controllerBase) {
this.parts = parts;
this.blockMap = blockMap;
this.predicateMap = predicateMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.lowdragmc.lowdraglib.side.fluid.FluidHelper;
import com.lowdragmc.lowdraglib.side.fluid.FluidStack;
import com.lowdragmc.lowdraglib.side.fluid.IFluidStorage;
import com.lowdragmc.lowdraglib.side.fluid.IFluidTransfer;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.util.Mth;
import net.minecraftforge.api.distmarker.Dist;
Expand Down Expand Up @@ -63,20 +64,20 @@ public void handleClientAction(int id, FriendlyByteBuf buffer) {
}

private void handleScrollAction(long delta) {
IFluidStorage tank = getFluidTank();
if (tank == null)
IFluidTransfer fluidTank = getFluidTank();
if (fluidTank == null)
return;

FluidStack fluid = tank.getFluid();
FluidStack fluid = fluidTank.getFluidInTank(tank);
if (fluid.isEmpty())
return;

if (fluid.isEmpty())
return;

fluid.setAmount(Math.min(Math.max(fluid.getAmount() + delta, 0L), tank.getCapacity()));
fluid.setAmount(Math.min(Math.max(fluid.getAmount() + delta, 0L), fluidTank.getTankCapacity(tank)));
if (fluid.getAmount() <= 0L) {
tank.setFluid(FluidStack.empty());
fluidTank.setFluidInTank(tank, FluidStack.empty());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public List<Long> handleRecipeInner(IO io, GTRecipe recipe, List<Long> left, @Nu
long sum = left.stream().reduce(0L, Long::sum);
long realSum = (long) Math.ceil(sum * conversionRate);
if (realSum > 0) {
var steam = io == IO.IN ? FluidIngredient.of(CustomTags.STEAM, realSum) : FluidIngredient.of(GTMaterials.Steam.getFluid(realSum));
var steam = io == IO.IN ? FluidIngredient.of(GTMaterials.Steam.getFluidTag(), realSum) : FluidIngredient.of(GTMaterials.Steam.getFluid(realSum));
var list = new ArrayList<FluidIngredient>();
list.add(steam);
var leftSteam = steamTank.handleRecipeInner(io, recipe, list, slotName, simulate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public SteamMachine(IMachineBlockEntity holder, boolean isHighPressure, Object..
super(holder);
this.isHighPressure = isHighPressure;
this.steamTank = createSteamTank(args);
this.steamTank.setFilter(fluidStack -> fluidStack.getFluid().is(CustomTags.STEAM));
this.steamTank.setFilter(fluidStack -> fluidStack.getFluid().is(GTMaterials.Steam.getFluidTag()));
}

//////////////////////////////////////
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 @@ -33,6 +33,7 @@
import com.lowdragmc.lowdraglib.utils.CycleItemStackHandler;
import com.lowdragmc.lowdraglib.utils.Position;
import com.lowdragmc.lowdraglib.utils.Size;
import com.lowdragmc.lowdraglib.utils.TagOrCycleFluidTransfer;
import dev.emi.emi.api.EmiApi;
import it.unimi.dsi.fastutil.bytes.Byte2ObjectArrayMap;
import it.unimi.dsi.fastutil.bytes.Byte2ObjectMap;
Expand Down Expand Up @@ -210,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 Expand Up @@ -274,7 +275,11 @@ public IEditableUI<WidgetGroup, RecipeHolder> createEditableUITemplate(final boo
WidgetUtils.widgetByIdForEach(template, "^%s_[0-9]+$".formatted(FluidRecipeCapability.CAP.slotName(IO.IN)), TankWidget.class, tank -> {
var index = WidgetUtils.widgetIdIndex(tank);
if (index >= 0 && index < recipeHolder.importFluids.getTanks()) {
tank.setFluidTank(new OverlayingFluidStorage(recipeHolder.importFluids, index));
if (recipeHolder.importFluids instanceof TagOrCycleFluidTransfer fluidTransfer) {
tank.setFluidTank(fluidTransfer, index);
} else {
tank.setFluidTank(new OverlayingFluidStorage(recipeHolder.importFluids, index));
}
tank.setIngredientIO(IngredientIO.INPUT);
tank.setAllowClickFilled(!isJEI);
tank.setAllowClickDrained(!isJEI);
Expand All @@ -284,7 +289,11 @@ public IEditableUI<WidgetGroup, RecipeHolder> createEditableUITemplate(final boo
WidgetUtils.widgetByIdForEach(template, "^%s_[0-9]+$".formatted(FluidRecipeCapability.CAP.slotName(IO.OUT)), TankWidget.class, tank -> {
var index = WidgetUtils.widgetIdIndex(tank);
if (index >= 0 && index < recipeHolder.exportFluids.getTanks()) {
tank.setFluidTank(new OverlayingFluidStorage(recipeHolder.exportFluids, index));
if (recipeHolder.exportFluids instanceof TagOrCycleFluidTransfer fluidTransfer) {
tank.setFluidTank(fluidTransfer, index);
} else {
tank.setFluidTank(new OverlayingFluidStorage(recipeHolder.exportFluids, index));
}
tank.setIngredientIO(IngredientIO.OUTPUT);
tank.setAllowClickFilled(!isJEI);
tank.setAllowClickDrained(false);
Expand Down
Loading

0 comments on commit 01a1683

Please sign in to comment.