Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
made bath able to dye shulker boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Aug 30, 2024
1 parent b64b174 commit 65963e5
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package muramasa.gregtech.blockentity.single;

import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import muramasa.antimatter.blockentity.BlockEntityMachine;
import muramasa.antimatter.capability.machine.MachineRecipeHandler;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.recipe.IRecipe;
import muramasa.antimatter.recipe.ingredient.RecipeIngredient;
import muramasa.antimatter.util.AntimatterPlatformUtils;
import muramasa.antimatter.util.TagUtils;
import muramasa.antimatter.util.Utils;
import muramasa.gregtech.GTIRef;
import muramasa.gregtech.data.GregTechItems;
import muramasa.gregtech.data.RecipeMaps;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.state.BlockState;
import tesseract.TesseractGraphWrappers;
import tesseract.api.item.ExtendedItemContainer;

import static muramasa.antimatter.Ref.L;
import static muramasa.gregtech.data.Materials.Chlorine;
import static muramasa.gregtech.data.Materials.Glue;

public class BlockEntityBath extends BlockEntityMachine<BlockEntityBath> {
public BlockEntityBath(Machine<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
recipeHandler.set(() -> new MachineRecipeHandler<>(this){
@Override
public IRecipe findRecipe() {
IRecipe recipe = super.findRecipe();
if (recipe == null){
ExtendedItemContainer container = itemHandler.get().getInputHandler();
ItemStack input = container != null ? container.getItem(0) : ItemStack.EMPTY;
ResourceLocation id = AntimatterPlatformUtils.getIdFromItem(input.getItem());
FluidHolder fluidInput = fluidHandler.map(f -> f.getFluidInTank(0)).orElse(FluidHooks.emptyFluid());
if (!fluidInput.isEmpty()) {
if (input.getItem() == Items.SHULKER_BOX){
DyeColor color = fromFluid(fluidInput);
if (color != null && fluidInput.getFluidAmount() >= L / 2) {
ItemStack output = new ItemStack(AntimatterPlatformUtils.getItemFromID(new ResourceLocation(color.getName() + "_shulker_box")));
output.setTag(input.getTag());
return RecipeMaps.BATH.RB().recipeMapOnly().ii(RecipeIngredient.of(input.copy())).fi(Utils.ca(L / 2, fluidInput)).io(output).add(color.getName() + "_shulker_box", 64);
}
} else if (id.getPath().contains("_shulker_box") && id.getNamespace().equals("minecraft")){
if (fluidInput.matches(Chlorine.getGas(50)) && fluidInput.getFluidAmount() >= 50 * TesseractGraphWrappers.dropletMultiplier) {
ItemStack output = new ItemStack(Items.SHULKER_BOX);
output.setTag(input.getTag());
return RecipeMaps.BATH.RB().recipeMapOnly().ii(RecipeIngredient.of(input.copy())).fi(Chlorine.getGas(50)).io(output).add("shulker_box", 64);
}
}
}
}
return recipe;
}

@Override
public boolean accepts(ItemStack stack) {
ResourceLocation id = AntimatterPlatformUtils.getIdFromItem(stack.getItem());
return super.accepts(stack) || (id.getPath().contains("shulker_box") && id.getNamespace().equals("minecraft"));
}
});
}

private DyeColor fromFluid(FluidHolder f) {
for (DyeColor color : DyeColor.values()) {
if (f.getFluid().is(TagUtils.getFluidTag(new ResourceLocation(GTIRef.ID, color.getName() + "_dye")))){
return color;
}
}
return null;
}
}
2 changes: 1 addition & 1 deletion common/src/main/java/muramasa/gregtech/data/Machines.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public class Machines {
public static BasicMachine BENDER = new BasicMachine(GTIRef.ID, "bender").setMap(RecipeMaps.BENDER).addFlags(GUI, ITEM);
public static BasicMachine CANNER = new BasicMachine(GTIRef.ID, "canner").setMap(RecipeMaps.CANNER).addFlags(GUI, ITEM);
public static BasicMachine CENTRIFUGE = new BasicMachine(GTIRef.ID, "centrifuge").setMap(RecipeMaps.CENTRIFUGE).addFlags(GUI, ITEM, FLUID);
public static BasicMachine BATH = new BasicMachine(GTIRef.ID, "bath").setTiers(NONE).removeFlags(EU).setMap(RecipeMaps.BATH).addFlags(GUI, ITEM, FLUID).baseTexture(new Texture(GTIRef.ID, "block/machine/base/hv"));
public static BasicMachine BATH = new BasicMachine(GTIRef.ID, "bath").setTiers(NONE).removeFlags(EU).setMap(RecipeMaps.BATH).addFlags(GUI, ITEM, FLUID).setTile(BlockEntityBath::new).baseTexture(new Texture(GTIRef.ID, "block/machine/base/hv"));
public static BasicMachine DEHYDRATOR = new BasicMachine(GTIRef.ID, "dehydrator").setMap(RecipeMaps.DEHYDRATOR).addFlags(GUI, ITEM, FLUID).setTile(BlockEntityIUpgradedBatchMachine::new).addTooltipInfo((machine, stack, world, tooltip, flag) -> {
tooltip.add(Utils.translatable("machine.upgraded_batch.parallel", 1 << (machine.getTier().getIntegerId() - 1)));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public static void init() {
BATH.RB().fi(FluidIngredient.of(dyeLiquid, L / 8)).ii(Items.GLASS_PANE).io(AntimatterPlatformUtils.getItemFromID(new ResourceLocation(dye.getName() + "_stained_glass_pane"))).add(dye.getName() + "_stained_glass_pane", 64);
BATH.RB().fi(FluidIngredient.of(dyeLiquid, L / 8)).ii(Items.TERRACOTTA).io(AntimatterPlatformUtils.getItemFromID(new ResourceLocation(dye.getName() + "_terracotta"))).add(dye.getName() + "_terracotta", 64);
BATH.RB().fi(FluidIngredient.of(dyeLiquid, L / 2)).ii(Items.CANDLE).io(AntimatterPlatformUtils.getItemFromID(new ResourceLocation(dye.getName() + "_candle"))).add(dye.getName() + "_candle", 64);
BATH.RB().fake().ii(Items.SHULKER_BOX).fi(FluidIngredient.of(dyeLiquid, L / 2)).io(AntimatterPlatformUtils.getItemFromID(new ResourceLocation(dye.getName() + "_shulker_box"))).add(dye.getName() + "_shulker_box", 64);
BATH.RB().fake().ii(AntimatterPlatformUtils.getItemFromID(new ResourceLocation(dye.getName() + "_shulker_box"))).fi(Chlorine.getGas(50)).io(Items.SHULKER_BOX).add("shulker_box_from_" + dye.getName(), 64);

if (dye != DyeColor.WHITE){
BATH.RB().fi(FluidIngredient.of(dyeLiquid, L / 2)).ii(Items.WHITE_WOOL).io(AntimatterPlatformUtils.getItemFromID(new ResourceLocation(dye.getName() + "_wool"))).add(dye.getName() + "_wool", 64);
Expand Down

0 comments on commit 65963e5

Please sign in to comment.