Skip to content

Commit

Permalink
Fixes (#183)
Browse files Browse the repository at this point in the history
* fix rock breaker fluid requirement

* fix recipe viewer tooltips

* fix vial amount

* fix lava fluid cell color

* draw fluid texture for prospector
  • Loading branch information
Yefancy authored Jul 23, 2023
1 parent ac12346 commit 675f143
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture;
import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture;
import com.lowdragmc.lowdraglib.gui.texture.ProgressTexture;
import com.lowdragmc.lowdraglib.gui.util.DrawerHelper;
import com.lowdragmc.lowdraglib.side.fluid.FluidHelper;
import com.lowdragmc.lowdraglib.side.fluid.FluidStack;
import com.mojang.blaze3d.vertex.PoseStack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.network.FriendlyByteBuf;
Expand All @@ -25,11 +30,11 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Fluids;
import org.apache.commons.lang3.ArrayUtils;

import javax.annotation.Nonnull;
import java.util.*;
import java.util.stream.Stream;

/**
* @author KilaBash
Expand Down Expand Up @@ -161,7 +166,11 @@ public void scan(FluidInfo[][][] storage, LevelChunk chunk) {

@Override
public int getItemColor(FluidInfo item) {
return FluidHelper.getColor(FluidStack.create(item.fluid, item.yield));
var fluidStack = FluidStack.create(item.fluid, item.yield);
if (fluidStack.getFluid() == Fluids.LAVA) {
return 0xFFFF7000;
}
return FluidHelper.getColor(fluidStack);
}

@Override
Expand Down Expand Up @@ -205,6 +214,19 @@ public void appendTooltips(List<FluidInfo[]> items, List<Component> tooltips, St
}
}

@Override
@Environment(EnvType.CLIENT)
public void drawSpecialGrid(PoseStack poseStack, FluidInfo[] items, int x, int y, int width, int height) {
if (items.length > 0) {
var item = items[0];
double progress = item.left * 1.0 / Math.max(Math.max(item.left, 100), 1);
float drawnU = (float) ProgressTexture.FillDirection.DOWN_TO_UP.getDrawnU(progress);
float drawnV = (float) ProgressTexture.FillDirection.DOWN_TO_UP.getDrawnV(progress);
float drawnWidth = (float) ProgressTexture.FillDirection.DOWN_TO_UP.getDrawnWidth(progress);
float drawnHeight = (float) ProgressTexture.FillDirection.DOWN_TO_UP.getDrawnHeight(progress);
DrawerHelper.drawFluidForGui(poseStack, FluidStack.create(item.fluid(), item.left), 100, (int) (x + drawnU * width), (int) (y + drawnV * height), ((int) (width * drawnWidth)), ((int) (height * drawnHeight)));
}
}
};

public record OreInfo(Material material, int weight, int left, int yield) {
Expand Down Expand Up @@ -299,4 +321,7 @@ public void appendTooltips(List<OreInfo[]> items, List<Component> tooltips, Stri
public abstract T deserialize(FriendlyByteBuf buf);
public abstract Class<T> getItemClass();
public abstract void appendTooltips(List<T[]> items, List<Component> tooltips, String selected);
@Environment(EnvType.CLIENT)
public void drawSpecialGrid(PoseStack poseStack, T[] items, int x, int y, int width, int height) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ public void draw(PoseStack poseStack, int x, int y) {
bufferbuilder.vertex(matrix4f, x, y, 0).uv(0, 0).color(-1).endVertex();
tessellator.end();

//draw special grid (e.g. fluid)
for (int cx = 0; cx < radius * 2 - 1; cx++) {
for (int cz = 0; cz < radius * 2 - 1; cz++) {
if (this.data[cx][cz] != null && this.data[cx][cz].length > 0) {
var items = this.data[cx][cz];
mode.drawSpecialGrid(poseStack, items, x + cx * 16 + 1, y + cz * 16 + 1, 16, 16);
}
}
}

GuiTextures.UP.copy().setColor(ColorPattern.RED.color).rotate(direction / 2).draw(poseStack, 0, 0, x + playerXGui - 20, y + playerYGui - 20, 40, 40);

//draw red vertical line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.*;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.material.Fluids;
import net.minecraftforge.client.model.generators.ModelFile;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -325,6 +326,10 @@ public static ItemColor cellColor() {
if (index == 1) {
var held = FluidTransferHelper.getFluidContained(itemStack);
if (held != null) {
// TODO render cell with a real fluid texture in the future?
if (held.getFluid() == Fluids.LAVA) {
return 0xFFFF7000;
}
return FluidHelper.getColor(held);
}
}
Expand Down Expand Up @@ -394,7 +399,7 @@ public static ICustomDescriptionId cellName() {
.model(cellModel())
.color(() -> GTItems::cellColor)
.onRegister(modelPredicate(GTCEu.id("fluid_cell"), (itemStack) -> FluidTransferHelper.getFluidContained(itemStack) == null ? 0f : 1f))
.onRegister(attach(cellName(), ThermalFluidStats.create((int)FluidHelper.getBucket() * 1000, 1200, false, true, false, false, true), new ItemFluidContainer()))
.onRegister(attach(cellName(), ThermalFluidStats.create((int)FluidHelper.getBucket(), 1200, false, true, false, false, true), new ItemFluidContainer()))
.onRegister(materialInfo(new ItemMaterialInfo(new MaterialStack(GTMaterials.Glass, GTValues.M * 4)))).register();

// TODO Lighter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
import com.gregtechceu.gtceu.api.data.chemical.material.MarkerMaterials.Color;
import com.gregtechceu.gtceu.api.data.chemical.material.stack.UnificationEntry;
import com.gregtechceu.gtceu.common.data.GTBlocks;
import com.gregtechceu.gtceu.common.recipe.RockBreakerCondition;
import com.gregtechceu.gtceu.data.recipe.CustomTags;
import com.gregtechceu.gtceu.data.recipe.VanillaRecipeHelper;
import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder;
import com.tterrag.registrate.util.entry.ItemEntry;
import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.Fluids;

import java.util.function.Consumer;

Expand Down Expand Up @@ -81,41 +84,53 @@ public static void init(Consumer<FinishedRecipe> provider) {
.outputItems(Blocks.COBBLESTONE.asItem())
.duration(16)
.EUt(VA[ULV])
.addData("fluidA", "minecraft:lava")
.addData("fluidB", "minecraft:water")
.save(provider);

ROCK_BREAKER_RECIPES.recipeBuilder("stone")
.notConsumable(Blocks.STONE.asItem())
.outputItems(Blocks.STONE.asItem())
.duration(16)
.EUt(VA[ULV])
.addData("fluidA", "minecraft:lava")
.addData("fluidB", "minecraft:water")
.save(provider);

ROCK_BREAKER_RECIPES.recipeBuilder("andesite")
.notConsumable(Blocks.ANDESITE.asItem())
.outputItems(Blocks.ANDESITE.asItem())
.duration(16)
.EUt(60)
.addData("fluidA", "minecraft:lava")
.addData("fluidB", "minecraft:water")
.save(provider);

ROCK_BREAKER_RECIPES.recipeBuilder("granite")
.notConsumable(Blocks.GRANITE.asItem())
.outputItems(Blocks.GRANITE.asItem())
.duration(16)
.EUt(60)
.addData("fluidA", "minecraft:lava")
.addData("fluidB", "minecraft:water")
.save(provider);

ROCK_BREAKER_RECIPES.recipeBuilder("diorite")
.notConsumable(Blocks.DIORITE.asItem())
.outputItems(Blocks.DIORITE.asItem())
.duration(16)
.EUt(60)
.addData("fluidA", "minecraft:lava")
.addData("fluidB", "minecraft:water")
.save(provider);

ROCK_BREAKER_RECIPES.recipeBuilder("obsidian")
.notConsumable(dust, Redstone)
.outputItems(Blocks.OBSIDIAN.asItem())
.duration(16)
.EUt(240)
.addData("fluidA", "minecraft:lava")
.addData("fluidB", "minecraft:water")
.save(provider);

// TODO stone types
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencyResolutionManagement {
def architecturyLoomVersion = "1.0-SNAPSHOT"
def vineFlowerVersion = "1.+"
def macheteVersion = "1.+"
def ldLibVersion = "1.0.13.b"
def ldLibVersion = "1.0.14"

fabric {
def parchment = version("parchment", parchmentVersion)
Expand Down

0 comments on commit 675f143

Please sign in to comment.