-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Ore Vein Diagram. * Ore Vein Diagram. * Ore Vein Diagram. * Ore Vein Diagram. * Ore Vein Diagram. * Ore Vein Diagram. * Ore Vein Diagram. * Fix Ore Processing Diagram Signed-off-by: Arborsm <[email protected]> * Fix Ore Processing Diagram Signed-off-by: Arborsm <[email protected]> --------- Signed-off-by: Arborsm <[email protected]> Co-authored-by: Arborsm <[email protected]>
- Loading branch information
Showing
22 changed files
with
888 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
common/src/main/java/com/gregtechceu/gtceu/integration/GTOreVeinWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
package com.gregtechceu.gtceu.integration; | ||
|
||
import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; | ||
import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; | ||
import com.gregtechceu.gtceu.api.registry.GTRegistries; | ||
import com.lowdragmc.lowdraglib.gui.texture.TextTexture; | ||
import com.lowdragmc.lowdraglib.gui.widget.*; | ||
import com.lowdragmc.lowdraglib.jei.IngredientIO; | ||
import com.lowdragmc.lowdraglib.misc.FluidStorage; | ||
import com.lowdragmc.lowdraglib.misc.ItemStackTransfer; | ||
import com.lowdragmc.lowdraglib.side.fluid.FluidStack; | ||
import com.lowdragmc.lowdraglib.utils.LocalizationUtils; | ||
import lombok.Getter; | ||
import net.minecraft.core.NonNullList; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.levelgen.heightproviders.HeightProvider; | ||
import net.minecraft.world.level.levelgen.heightproviders.UniformHeight; | ||
import net.minecraft.world.level.material.Fluid; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author Arbor | ||
* @implNote GTOreVeinWidget | ||
*/ | ||
@Getter | ||
public class GTOreVeinWidget extends WidgetGroup { | ||
private final String name; | ||
private final int weight; | ||
private final String range; | ||
private final String dimensions; | ||
private final Set<ResourceKey<Level>> dimensionFilter; | ||
public final static int width = 120; | ||
|
||
public GTOreVeinWidget(GTOreDefinition oreDefinition) { | ||
super(0, 0, width, 160); | ||
this.name = getOreName(oreDefinition); | ||
this.weight = oreDefinition.getWeight(); | ||
this.dimensionFilter = oreDefinition.getDimensionFilter(); | ||
this.dimensions = dimensions(); | ||
this.range = range(oreDefinition); | ||
setClientSideWidget(); | ||
setupBaseGui(oreDefinition); | ||
setupText(oreDefinition); | ||
} | ||
|
||
public GTOreVeinWidget(BedrockFluidDefinition fluid) { | ||
super(0, 0, width, 140); | ||
this.name = getFluidName(fluid); | ||
this.weight = fluid.getWeight(); | ||
this.dimensionFilter = fluid.getDimensionFilter(); | ||
this.dimensions = dimensions(); | ||
this.range = "NULL"; | ||
setClientSideWidget(); | ||
setupBaseGui(fluid); | ||
setupText(fluid); | ||
} | ||
|
||
private String range(GTOreDefinition oreDefinition) { | ||
HeightProvider height = oreDefinition.getRange().height; | ||
int minHeight = 0, maxHeight = 0; | ||
if (height instanceof UniformHeight uniform) { | ||
minHeight = uniform.minInclusive.resolveY(null); | ||
maxHeight = uniform.maxInclusive.resolveY(null); | ||
} | ||
return String.format("%d - %d", minHeight, maxHeight); | ||
} | ||
|
||
private void setupBaseGui(GTOreDefinition oreDefinition){ | ||
NonNullList<ItemStack> containedOresAsItemStacks = NonNullList.create(); | ||
List<BlockState> blocks = oreDefinition.getVeinGenerator().getAllBlocks(); | ||
List<Integer> chances = oreDefinition.getVeinGenerator().getAllChances(); | ||
blocks.forEach(block -> containedOresAsItemStacks.add(block.getBlock().asItem().getDefaultInstance())); | ||
int n = containedOresAsItemStacks.size(); | ||
int x = (width - 18 * n) / 2; | ||
for (int i = 0; i < n; i++) { | ||
SlotWidget oreSlot = new SlotWidget(new ItemStackTransfer(containedOresAsItemStacks), i, x, 18, false, false); | ||
int finalI = i; | ||
oreSlot.setOnAddedTooltips((stack, tooltips) -> | ||
tooltips.add(Component.nullToEmpty(LocalizationUtils.format("gtceu.jei.ore_vein_diagram.chance", chances.get(finalI))))); | ||
oreSlot.setIngredientIO(IngredientIO.OUTPUT); | ||
addWidget(oreSlot); | ||
x += 18; | ||
} | ||
} | ||
|
||
private void setupBaseGui(BedrockFluidDefinition fluid){ | ||
Fluid storedFluid = fluid.getStoredFluid().get(); | ||
TankWidget fluidSlot = new TankWidget( | ||
new FluidStorage(FluidStack.create(storedFluid, 1000)), 51, 18, false, false); | ||
fluidSlot.setIngredientIO(IngredientIO.OUTPUT); | ||
addWidget(fluidSlot); | ||
} | ||
|
||
private void setupText(GTOreDefinition oreDefinition){ | ||
addWidget(new ImageWidget(5, 0, width - 10, 16, | ||
new TextTexture("gtceu.jei.ore_vein." + name).setType(TextTexture.TextType.LEFT_ROLL).setWidth(width - 10))); | ||
addWidget(new LabelWidget(5, 40, | ||
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.spawn_range"))); | ||
addWidget(new LabelWidget(5, 50, range)); | ||
|
||
addWidget(new LabelWidget(5, 60, | ||
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.weight", weight))); | ||
addWidget(new LabelWidget(5, 70, | ||
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.dimensions"))); | ||
addWidget(new LabelWidget(5, 80, dimensions)); | ||
} | ||
|
||
private void setupText(BedrockFluidDefinition fluid){ | ||
addWidget(new ImageWidget(5, 0, width - 10, 16, | ||
new TextTexture("gtceu.jei.bedrock_fluid." + name).setType(TextTexture.TextType.LEFT_ROLL).setWidth(width - 10))); | ||
addWidget(new LabelWidget(5, 40, | ||
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.weight", weight))); | ||
addWidget(new LabelWidget(5, 50, | ||
LocalizationUtils.format("gtceu.jei.ore_vein_diagram.dimensions"))); | ||
addWidget(new LabelWidget(5, 60, dimensions)); | ||
} | ||
|
||
private String dimensions() { | ||
if (dimensionFilter == null) return "Any"; | ||
return dimensionFilter.stream() | ||
.map(dimension -> dimension.location().toString()) | ||
.collect(Collectors.joining("\n")); | ||
} | ||
|
||
|
||
public String getOreName(GTOreDefinition oreDefinition) { | ||
ResourceLocation id = GTRegistries.ORE_VEINS.getKey(oreDefinition); | ||
return id.getPath(); | ||
} | ||
|
||
public String getFluidName(BedrockFluidDefinition fluid) { | ||
ResourceLocation id = GTRegistries.BEDROCK_FLUID_DEFINITIONS.getKey(fluid); | ||
return id.getPath(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
common/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockFluid.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.gregtechceu.gtceu.integration.emi.orevein; | ||
|
||
import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; | ||
import com.gregtechceu.gtceu.api.registry.GTRegistries; | ||
import com.gregtechceu.gtceu.integration.GTOreVeinWidget; | ||
import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; | ||
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; | ||
import dev.emi.emi.api.recipe.EmiRecipeCategory; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class GTBedrockFluid extends ModularEmiRecipe<WidgetGroup> { | ||
private final BedrockFluidDefinition fluid; | ||
public GTBedrockFluid(BedrockFluidDefinition fluid) { | ||
super(() -> new GTOreVeinWidget(fluid)); | ||
this.fluid = fluid; | ||
} | ||
|
||
@Override | ||
public EmiRecipeCategory getCategory() { | ||
return GTBedrockFluidEmiCategory.CATEGORY; | ||
} | ||
|
||
@Override | ||
public @Nullable ResourceLocation getId() { | ||
return GTRegistries.BEDROCK_FLUID_DEFINITIONS.getKey(fluid); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...rc/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTBedrockFluidEmiCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.gregtechceu.gtceu.integration.emi.orevein; | ||
|
||
import com.gregtechceu.gtceu.GTCEu; | ||
import com.gregtechceu.gtceu.api.data.worldgen.bedrockfluid.BedrockFluidDefinition; | ||
import com.gregtechceu.gtceu.api.registry.GTRegistries; | ||
import com.gregtechceu.gtceu.common.data.GTItems; | ||
import com.gregtechceu.gtceu.common.data.GTMaterials; | ||
import com.lowdragmc.lowdraglib.emi.ModularUIEmiRecipeCategory; | ||
import dev.emi.emi.api.EmiRegistry; | ||
import dev.emi.emi.api.stack.EmiStack; | ||
import net.minecraft.network.chat.Component; | ||
|
||
public class GTBedrockFluidEmiCategory extends ModularUIEmiRecipeCategory { | ||
public static final GTBedrockFluidEmiCategory CATEGORY = new GTBedrockFluidEmiCategory(); | ||
|
||
public GTBedrockFluidEmiCategory() { | ||
super(GTCEu.id("bedrock_fluid_diagram"), EmiStack.of(GTMaterials.Oil.getFluid().getBucket().asItem())); | ||
} | ||
|
||
public static void registerDisplays(EmiRegistry registry) { | ||
for (BedrockFluidDefinition fluid : GTRegistries.BEDROCK_FLUID_DEFINITIONS) { | ||
registry.addRecipe(new GTBedrockFluid(fluid)); | ||
} | ||
} | ||
|
||
public static void registerWorkStations(EmiRegistry registry) { | ||
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LV.asStack())); | ||
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_HV.asStack())); | ||
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LUV.asStack())); | ||
} | ||
|
||
@Override | ||
public Component getName() { | ||
return Component.translatable("gtceu.jei.bedrock_fluid_diagram"); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
common/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTEmiOreVein.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.gregtechceu.gtceu.integration.emi.orevein; | ||
|
||
import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; | ||
import com.gregtechceu.gtceu.api.registry.GTRegistries; | ||
import com.gregtechceu.gtceu.integration.GTOreVeinWidget; | ||
import com.lowdragmc.lowdraglib.emi.ModularEmiRecipe; | ||
import com.lowdragmc.lowdraglib.gui.widget.WidgetGroup; | ||
import dev.emi.emi.api.recipe.EmiRecipeCategory; | ||
import net.minecraft.resources.ResourceLocation; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class GTEmiOreVein extends ModularEmiRecipe<WidgetGroup> { | ||
private final GTOreDefinition oreDefinition; | ||
|
||
public GTEmiOreVein(GTOreDefinition oreDefinition){ | ||
super(() -> new GTOreVeinWidget(oreDefinition)); | ||
this.oreDefinition = oreDefinition; | ||
} | ||
|
||
@Override | ||
public EmiRecipeCategory getCategory() { | ||
return GTOreVeinEmiCategory.CATEGORY; | ||
} | ||
|
||
@Override | ||
public @Nullable ResourceLocation getId() { | ||
return GTRegistries.ORE_VEINS.getKey(oreDefinition); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
common/src/main/java/com/gregtechceu/gtceu/integration/emi/orevein/GTOreVeinEmiCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.gregtechceu.gtceu.integration.emi.orevein; | ||
|
||
import com.gregtechceu.gtceu.GTCEu; | ||
import com.gregtechceu.gtceu.api.data.worldgen.GTOreDefinition; | ||
import com.gregtechceu.gtceu.api.registry.GTRegistries; | ||
import com.gregtechceu.gtceu.common.data.GTItems; | ||
import com.lowdragmc.lowdraglib.emi.ModularUIEmiRecipeCategory; | ||
import dev.emi.emi.api.EmiRegistry; | ||
import dev.emi.emi.api.stack.EmiStack; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.item.Items; | ||
|
||
|
||
public class GTOreVeinEmiCategory extends ModularUIEmiRecipeCategory { | ||
public static final GTOreVeinEmiCategory CATEGORY = new GTOreVeinEmiCategory(); | ||
|
||
public GTOreVeinEmiCategory() { | ||
super(GTCEu.id("ore_vein_diagram"), EmiStack.of(Items.IRON_INGOT)); | ||
} | ||
|
||
public static void registerDisplays(EmiRegistry registry) { | ||
for (GTOreDefinition oreDefinition : GTRegistries.ORE_VEINS){ | ||
registry.addRecipe(new GTEmiOreVein(oreDefinition)); | ||
} | ||
} | ||
|
||
public static void registerWorkStations(EmiRegistry registry) { | ||
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LV.asStack())); | ||
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_HV.asStack())); | ||
registry.addWorkstation(CATEGORY, EmiStack.of(GTItems.PROSPECTOR_LUV.asStack())); | ||
} | ||
|
||
@Override | ||
public Component getName() { | ||
return Component.translatable("gtceu.jei.ore_vein_diagram"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.