From 7014d90296e46ccd88f5b375efdff69eb2f692be Mon Sep 17 00:00:00 2001 From: MCTian-mi <35869948+MCTian-mi@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:14:32 +0800 Subject: [PATCH 01/18] BiomeProperty implementation --- .../recipes/builders/BiomeRecipeBuilder.java | 96 +++++++++++++++++++ .../api/recipes/properties/BiomeProperty.java | 87 +++++++++++++++++ .../resources/assets/susy/lang/en_us.lang | 4 + 3 files changed, 187 insertions(+) create mode 100644 src/main/java/supersymmetry/api/recipes/builders/BiomeRecipeBuilder.java create mode 100644 src/main/java/supersymmetry/api/recipes/properties/BiomeProperty.java diff --git a/src/main/java/supersymmetry/api/recipes/builders/BiomeRecipeBuilder.java b/src/main/java/supersymmetry/api/recipes/builders/BiomeRecipeBuilder.java new file mode 100644 index 000000000..c30b96f97 --- /dev/null +++ b/src/main/java/supersymmetry/api/recipes/builders/BiomeRecipeBuilder.java @@ -0,0 +1,96 @@ +package supersymmetry.api.recipes.builders; + +import gregtech.api.recipes.Recipe; +import gregtech.api.recipes.RecipeBuilder; +import gregtech.api.recipes.RecipeMap; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.biome.Biome; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.jetbrains.annotations.NotNull; +import supersymmetry.api.recipes.properties.BiomeProperty; + +import java.util.ArrayList; +import java.util.List; +import java.util.NoSuchElementException; + +/** + * A custom recipeBuilder, for allowing us to put our own recipeProperty {@link BiomeProperty} into a recipe + */ +public class BiomeRecipeBuilder extends RecipeBuilder { + + public BiomeRecipeBuilder() { + } + + public BiomeRecipeBuilder(Recipe recipe, RecipeMap recipeMap) { + super(recipe, recipeMap); + } + + public BiomeRecipeBuilder(RecipeBuilder recipeBuilder) { + super(recipeBuilder); + } + + @Override + public BiomeRecipeBuilder copy() { + return new BiomeRecipeBuilder(this); + } + + @Override + public boolean applyProperty(@NotNull String key, Object value) { + if (key.equals(BiomeProperty.KEY)) { + if (value instanceof BiomeProperty.BiomePropertyList list) { + BiomeProperty.BiomePropertyList biomes = getBiomePropertyList(); + if (biomes == BiomeProperty.BiomePropertyList.EMPTY_LIST) { + biomes = new BiomeProperty.BiomePropertyList(); + this.applyProperty(BiomeProperty.getInstance(), biomes); + } + biomes.merge(list); + return true; + } + return false; + } + return super.applyProperty(key, value); + } + + public BiomeRecipeBuilder biomes(String... biomes) { + return biomes(false, biomes); + } + + private BiomeRecipeBuilder biomes(boolean toBlacklist, String... biomeRLs) { + List biomes = new ArrayList<>(); + for (String biomeRL : biomeRLs) { + Biome biome = Biome.REGISTRY.getObject(new ResourceLocation(biomeRL)); + if (biome != null) { + biomes.add(biome); + } else { + throw new NoSuchElementException("No biome with ResouceLocation \"" + biomeRL + "\" found"); + } + } + return biomesInternal(toBlacklist, biomes); + } + + private BiomeRecipeBuilder biomesInternal(boolean toBlacklist, List biomes) { + BiomeProperty.BiomePropertyList biomePropertyList = getBiomePropertyList(); + if (biomePropertyList == BiomeProperty.BiomePropertyList.EMPTY_LIST) { + biomePropertyList = new BiomeProperty.BiomePropertyList(); + this.applyProperty(BiomeProperty.getInstance(), biomePropertyList); + } + for (Biome biome : biomes) { + biomePropertyList.add(biome, toBlacklist); + } + return this; + } + + public BiomeProperty.BiomePropertyList getBiomePropertyList() { + return this.recipePropertyStorage == null ? BiomeProperty.BiomePropertyList.EMPTY_LIST : + this.recipePropertyStorage.getRecipePropertyValue(BiomeProperty.getInstance(), + BiomeProperty.BiomePropertyList.EMPTY_LIST); + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .appendSuper(super.toString()) + .append("biomes", getBiomePropertyList()) + .toString(); + } +} diff --git a/src/main/java/supersymmetry/api/recipes/properties/BiomeProperty.java b/src/main/java/supersymmetry/api/recipes/properties/BiomeProperty.java new file mode 100644 index 000000000..fb973f3fc --- /dev/null +++ b/src/main/java/supersymmetry/api/recipes/properties/BiomeProperty.java @@ -0,0 +1,87 @@ +package supersymmetry.api.recipes.properties; + +import gregtech.api.recipes.recipeproperties.RecipeProperty; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; +import net.minecraft.world.biome.Biome; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class BiomeProperty extends RecipeProperty { + + public static final String KEY = "biome"; + + private static BiomeProperty INSTANCE; + + private BiomeProperty() { + super(KEY, BiomePropertyList.class); + } + + public static BiomeProperty getInstance() { + if (INSTANCE == null) + INSTANCE = new BiomeProperty(); + return INSTANCE; + } + + private static String getBiomesForRecipe(List value) { + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < value.size(); i++) { + builder.append(value.get(i).getBiomeName()); + if (i != value.size() - 1) + builder.append(", "); + } + String str = builder.toString(); + + if (str.length() >= 13) { + str = str.substring(0, 10) + ".."; + } + return str; + } + + @Override + @SideOnly(Side.CLIENT) + public void drawInfo(Minecraft minecraft, int x, int y, int color, Object value) { + BiomePropertyList list = castValue(value); + + if (list.whiteListBiomes.size() > 0) + minecraft.fontRenderer.drawString(I18n.format("susy.recipe.biomes", + getBiomesForRecipe(castValue(value).whiteListBiomes)), x, y, color); + if (list.blackListBiomes.size() > 0) + minecraft.fontRenderer.drawString(I18n.format("susy.recipe.biomes_blocked", + getBiomesForRecipe(castValue(value).blackListBiomes)), x, y, color); + } + + public static class BiomePropertyList { + + public static BiomePropertyList EMPTY_LIST = new BiomePropertyList(); + + public final List whiteListBiomes = new ObjectArrayList<>(); + public final List blackListBiomes = new ObjectArrayList<>(); + + public void add(Biome biome, boolean toBlacklist) { + if (toBlacklist) { + blackListBiomes.add(biome); + whiteListBiomes.remove(biome); + } else { + whiteListBiomes.add(biome); + blackListBiomes.remove(biome); + } + } + + public void merge(@NotNull BiomeProperty.BiomePropertyList list) { + this.whiteListBiomes.addAll(list.whiteListBiomes); + this.blackListBiomes.addAll(list.blackListBiomes); + } + + public boolean checkBiome(Biome biome) { + boolean valid = true; + if (this.blackListBiomes.size() > 0) valid = !this.blackListBiomes.contains(biome); + if (this.whiteListBiomes.size() > 0) valid = this.whiteListBiomes.contains(biome); + return valid; + } + } +} diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index a9c781054..909a59bd1 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -804,6 +804,10 @@ gregtech.block_group_members.latex_logs.name=Rubber Log # Extra recipe info susy.recipe.dimensions=Dimensions: %s +susy.recipe.biomes=Biomes: %s +susy.recipe.biomes_blocked=Blocked Biomes: %s +susy.recipe.biomeTypes=BiomeTypes: %s +susy.recipe.biomeTypes_blocked=Blocked BiomeTypes: %s # Commands From 05c1082fd6a8d19c6a9fb1dcd487e6cc75038574 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Sun, 20 Oct 2024 19:47:19 +0700 Subject: [PATCH 02/18] Create MetaTileEntityLargeFluidPump.java --- .../MetaTileEntityLargeFluidPump.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java new file mode 100644 index 000000000..b7cf6ba5a --- /dev/null +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -0,0 +1,85 @@ +package supersymmetry.common.metatileentities.multi.electric; + +import gregtech.api.capability.impl.MultiblockRecipeLogic; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtech.api.metatileentity.multiblock.IMultiblockPart; +import gregtech.api.metatileentity.multiblock.MultiblockAbility; +import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; +import gregtech.api.pattern.BlockPattern; +import gregtech.api.pattern.FactoryBlockPattern; +import gregtech.api.unification.material.Materials; +import gregtech.client.renderer.ICubeRenderer; +import gregtech.client.renderer.texture.Textures; +import gregtech.client.utils.TooltipHelper; +import gregtech.common.blocks.BlockBoilerCasing.BoilerCasingType; +import gregtech.common.blocks.BlockMetalCasing.MetalCasingType; +import gregtech.common.blocks.BlockTurbineCasing.TurbineCasingType; +import gregtech.common.blocks.MetaBlocks; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.resources.I18n; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import org.jetbrains.annotations.NotNull; +import supersymmetry.api.recipes.SuSyRecipeMaps; +import supersymmetry.client.renderer.textures.SusyTextures; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.List; + +import static gregtech.api.util.RelativeDirection.*; + +public class MetaTileEntityLargeFluidPump extends RecipeMapMultiblockController { + public MetaTileEntityLargeFluidPump(ResourceLocation metaTileEntityId) { + super(metaTileEntityId, SuSyRecipeMaps.PUMPING_RECIPES); + this.recipeMapWorkable = new MultiblockRecipeLogic(this, true); + } + + public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { + return new MetaTileEntityLargeFluidPump(this.metaTileEntityId); + } + + protected @NotNull BlockPattern createStructurePattern() { + return FactoryBlockPattern.start(RIGHT, FRONT, UP) + .aisle(" ", " P", " ") + .aisle("FCCCC ", "CCCCC P", "FCECC ") + .aisle("CCSGC ", "OPPPPPP", "FCECC ") + .aisle("FCCC ", "CCCCC ", "FCEC ") + .where(' ', any()) + .where('S', selfPredicate()) + .where('P', states(getPipeCasingState())) + .where('G', states(getGearboxState())) + .where('F', frames(Materials.Steel)) + .where('C', states(getCasingState()) + .or(abilities(MultiblockAbility.IMPORT_ITEMS))) + .where('E', states(getCasingState()) + .or(abilities(MultiblockAbility.INPUT_ENERGY))) + .where('O', abilities(MultiblockAbility.EXPORT_FLUIDS)) + .build(); + } + public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { + return Textures.SOLID_STEEL_CASING; + } + + protected static IBlockState getCasingState() { + return MetaBlocks.METAL_CASING.getState(MetalCasingType.STEEL_SOLID); + } + protected static IBlockState getPipeCasingState() { + return MetaBlocks.BOILER_CASING.getState(BoilerCasingType.STEEL_PIPE); + } + protected static IBlockState getGearboxState() { + return MetaBlocks.TURBINE_CASING.getState(TurbineCasingType.STEEL_GEARBOX); + } + + public void addInformation(ItemStack stack, @Nullable World player, @NotNull List tooltip, boolean advanced) { + super.addInformation(stack, player, tooltip, advanced); + tooltip.add(TooltipHelper.RAINBOW_SLOW + I18n.format("gregtech.machine.perfect_oc", new Object[0])); + } + + @Nonnull + protected ICubeRenderer getFrontOverlay() { + return SusyTextures.OCEANIC_DRILL_OVERLAY; + } +} From 41b8fbd7feaa029ea693bc68e029cbc81407a513 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Sun, 20 Oct 2024 19:52:19 +0700 Subject: [PATCH 03/18] commit --- src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java | 4 ++++ .../common/metatileentities/SuSyMetaTileEntities.java | 1 + 2 files changed, 5 insertions(+) diff --git a/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java b/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java index 850d3f6ad..f46ebd147 100644 --- a/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java +++ b/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java @@ -299,6 +299,10 @@ public class SuSyRecipeMaps { .setProgressBar(GuiTextures.PROGRESS_BAR_SIFT, ProgressWidget.MoveType.VERTICAL) .setSound(GTSoundEvents.BATH); + public static final RecipeMap PUMPING_RECIPES = new RecipeMap<>("large_fluid_pump", 1, 0, 0, 1, new BiomeRecipeBuilder(), false) + .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, ProgressWidget.MoveType.VERTICAL) + .setSound(GTSoundEvents.MINER); + public static final RecipeMap DRONE_PAD = new RecipeMap<>("drone_pad", 4, 9, 0, 0, new DronePadRecipeBuilder(), false); public static final RecipeMap BLENDER_RECIPES = new RecipeMap<>("blender", 9, 1, 6, 2, new SimpleRecipeBuilder().EUt(VA[LV]), false) diff --git a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java index acf52af72..bd517c10d 100644 --- a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java +++ b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java @@ -261,6 +261,7 @@ public static void init() { FROTH_FLOTATION_TANK = registerMetaTileEntity(17008, new MetaTileEntityFrothFlotationTank(susyId("froth_flotation_tank"))); MULTI_STAGE_FLASH_DISTILLER = registerMetaTileEntity(17009, new MetaTileEntityMultiStageFlashDistiller(susyId("multi_stage_flash_distiller"))); + LARGE_FLUID_PUMP = registerMetaTileEntity(17021, new MetaTileEntityLargeFluidPump(susyId("large_fluid_pump"))); OCEAN_PUMPER = registerMetaTileEntity(17011, new MetaTileEntityOceanPumper(susyId("ocean_pumper"))); HIGH_TEMPERATURE_DISTILLATION_TOWER = registerMetaTileEntity(17012, new MetaTileEntityHighTemperatureDistillationTower(susyId("high_temperature_distillation_tower"))); ROTARY_KILN = registerMetaTileEntity(17013, new MetaTileEntityRotaryKiln(susyId("rotary_kiln"))); From e61466bee91e649052f0ca713cd4b3f363d1afa5 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Sun, 20 Oct 2024 19:52:19 +0700 Subject: [PATCH 04/18] commit --- src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java | 4 ++++ .../common/metatileentities/SuSyMetaTileEntities.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java b/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java index 850d3f6ad..f46ebd147 100644 --- a/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java +++ b/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java @@ -299,6 +299,10 @@ public class SuSyRecipeMaps { .setProgressBar(GuiTextures.PROGRESS_BAR_SIFT, ProgressWidget.MoveType.VERTICAL) .setSound(GTSoundEvents.BATH); + public static final RecipeMap PUMPING_RECIPES = new RecipeMap<>("large_fluid_pump", 1, 0, 0, 1, new BiomeRecipeBuilder(), false) + .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, ProgressWidget.MoveType.VERTICAL) + .setSound(GTSoundEvents.MINER); + public static final RecipeMap DRONE_PAD = new RecipeMap<>("drone_pad", 4, 9, 0, 0, new DronePadRecipeBuilder(), false); public static final RecipeMap BLENDER_RECIPES = new RecipeMap<>("blender", 9, 1, 6, 2, new SimpleRecipeBuilder().EUt(VA[LV]), false) diff --git a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java index acf52af72..f0ba1a580 100644 --- a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java +++ b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java @@ -134,6 +134,7 @@ public class SuSyMetaTileEntities { public static MetaTileEntityFrothFlotationTank FROTH_FLOTATION_TANK; public static MetaTileEntityMultiStageFlashDistiller MULTI_STAGE_FLASH_DISTILLER; + public static MetaTileEntityLargeFluidPump LARGE_FLUID_PUMP; public static MetaTileEntityOceanPumper OCEAN_PUMPER; public static MetaTileEntityHighTemperatureDistillationTower HIGH_TEMPERATURE_DISTILLATION_TOWER; public static MetaTileEntityRotaryKiln ROTARY_KILN; @@ -261,6 +262,7 @@ public static void init() { FROTH_FLOTATION_TANK = registerMetaTileEntity(17008, new MetaTileEntityFrothFlotationTank(susyId("froth_flotation_tank"))); MULTI_STAGE_FLASH_DISTILLER = registerMetaTileEntity(17009, new MetaTileEntityMultiStageFlashDistiller(susyId("multi_stage_flash_distiller"))); + LARGE_FLUID_PUMP = registerMetaTileEntity(17021, new MetaTileEntityLargeFluidPump(susyId("large_fluid_pump"))); OCEAN_PUMPER = registerMetaTileEntity(17011, new MetaTileEntityOceanPumper(susyId("ocean_pumper"))); HIGH_TEMPERATURE_DISTILLATION_TOWER = registerMetaTileEntity(17012, new MetaTileEntityHighTemperatureDistillationTower(susyId("high_temperature_distillation_tower"))); ROTARY_KILN = registerMetaTileEntity(17013, new MetaTileEntityRotaryKiln(susyId("rotary_kiln"))); From db63aa29669969730173fd2a41a4a9cdeeb3cce2 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Sun, 20 Oct 2024 21:31:36 +0700 Subject: [PATCH 05/18] commit --- .../SuSyMetaTileEntities.java | 4 +- .../MetaTileEntityLargeFluidPump.java | 72 ++++++++++++++++++- .../resources/assets/susy/lang/en_us.lang | 3 + 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java index f0ba1a580..2fa522e27 100644 --- a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java +++ b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java @@ -261,8 +261,6 @@ public static void init() { FLARE_STACK = registerMetaTileEntity(17007, new MetaTileEntityFlareStack(susyId("flare_stack"))); FROTH_FLOTATION_TANK = registerMetaTileEntity(17008, new MetaTileEntityFrothFlotationTank(susyId("froth_flotation_tank"))); MULTI_STAGE_FLASH_DISTILLER = registerMetaTileEntity(17009, new MetaTileEntityMultiStageFlashDistiller(susyId("multi_stage_flash_distiller"))); - - LARGE_FLUID_PUMP = registerMetaTileEntity(17021, new MetaTileEntityLargeFluidPump(susyId("large_fluid_pump"))); OCEAN_PUMPER = registerMetaTileEntity(17011, new MetaTileEntityOceanPumper(susyId("ocean_pumper"))); HIGH_TEMPERATURE_DISTILLATION_TOWER = registerMetaTileEntity(17012, new MetaTileEntityHighTemperatureDistillationTower(susyId("high_temperature_distillation_tower"))); ROTARY_KILN = registerMetaTileEntity(17013, new MetaTileEntityRotaryKiln(susyId("rotary_kiln"))); @@ -275,6 +273,8 @@ public static void init() { PHASE_SEPARATOR[0] = registerMetaTileEntity(17018, new MetaTileEntityPhaseSeparator(susyId("phase_separator"))); BATH_CONDENSER[0] = registerMetaTileEntity(17019, new MetaTileEntityBathCondenser(susyId("bath_condenser"))); + LARGE_FLUID_PUMP = registerMetaTileEntity(17021, new MetaTileEntityLargeFluidPump(susyId("large_fluid_pump"))); + registerSimpleMTE(ELECTROSTATIC_SEPARATOR, 12, 17035, "electrostatic_separator", SuSyRecipeMaps.ELECTROSTATIC_SEPARATOR, SusyTextures.ELECTROSTATIC_SEPARATOR_OVERLAY, true, GTUtility.defaultTankSizeFunction); registerSimpleMTE(POLISHING_MACHINE, 12, 17048, "polishing_machine", SuSyRecipeMaps.POLISHING_MACHINE, SusyTextures.POLISHING_MACHINE_OVERLAY, true, GTUtility.defaultTankSizeFunction); registerSimpleMTE(TEXTILE_SPINNER, 12, 17061, "textile_spinner", SuSyRecipeMaps.SPINNING_RECIPES, SusyTextures.TEXTILE_SPINNER_OVERLAY, true); diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index b7cf6ba5a..81d70b361 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -8,6 +8,7 @@ import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; import gregtech.api.pattern.BlockPattern; import gregtech.api.pattern.FactoryBlockPattern; +import gregtech.api.recipes.Recipe; import gregtech.api.unification.material.Materials; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.texture.Textures; @@ -20,9 +21,11 @@ import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import supersymmetry.api.recipes.SuSyRecipeMaps; +import supersymmetry.api.recipes.properties.BiomeProperty; import supersymmetry.client.renderer.textures.SusyTextures; import javax.annotation.Nonnull; @@ -34,18 +37,36 @@ public class MetaTileEntityLargeFluidPump extends RecipeMapMultiblockController { public MetaTileEntityLargeFluidPump(ResourceLocation metaTileEntityId) { super(metaTileEntityId, SuSyRecipeMaps.PUMPING_RECIPES); - this.recipeMapWorkable = new MultiblockRecipeLogic(this, true); + + this.recipeMapWorkable = new LargePumpRecipeLogic(this); } public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { return new MetaTileEntityLargeFluidPump(this.metaTileEntityId); } + @Override + public boolean isMultiblockPartWeatherResistant(@Nonnull IMultiblockPart part) { + return true; + } + + @Override + public boolean getIsWeatherOrTerrainResistant() { + return true; + } + + @Override + public boolean allowsExtendedFacing() { + return false; + } + + protected @NotNull BlockPattern createStructurePattern() { return FactoryBlockPattern.start(RIGHT, FRONT, UP) + .aisle(" ", " P", " ") .aisle(" ", " P", " ") .aisle("FCCCC ", "CCCCC P", "FCECC ") - .aisle("CCSGC ", "OPPPPPP", "FCECC ") + .aisle("CCSGC ", "OPPPPPP", "CCECC ") .aisle("FCCC ", "CCCCC ", "FCEC ") .where(' ', any()) .where('S', selfPredicate()) @@ -53,7 +74,8 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { .where('G', states(getGearboxState())) .where('F', frames(Materials.Steel)) .where('C', states(getCasingState()) - .or(abilities(MultiblockAbility.IMPORT_ITEMS))) + .or(abilities(MultiblockAbility.IMPORT_ITEMS).setMaxGlobalLimited(1)) + .or(autoAbilities(true, false))) .where('E', states(getCasingState()) .or(abilities(MultiblockAbility.INPUT_ENERGY))) .where('O', abilities(MultiblockAbility.EXPORT_FLUIDS)) @@ -74,6 +96,8 @@ protected static IBlockState getGearboxState() { } public void addInformation(ItemStack stack, @Nullable World player, @NotNull List tooltip, boolean advanced) { + tooltip.add(I18n.format("gregtech.machine.large_fluid_pump.tooltip.1")); + tooltip.add(I18n.format("gregtech.machine.large_fluid_pump.tooltip.2")); super.addInformation(stack, player, tooltip, advanced); tooltip.add(TooltipHelper.RAINBOW_SLOW + I18n.format("gregtech.machine.perfect_oc", new Object[0])); } @@ -82,4 +106,46 @@ public void addInformation(ItemStack stack, @Nullable World player, @NotNull Lis protected ICubeRenderer getFrontOverlay() { return SusyTextures.OCEANIC_DRILL_OVERLAY; } + + /** + * A custom recipeLogic class, for adding our check for biomes + * This can be moved out to a stand-alone class. + * But generally speaking if you do not plan to re-use this, making it an inner class should be fine. + * CEu itself has many such cases. + */ + public static class LargePumpRecipeLogic extends MultiblockRecipeLogic { + + public LargePumpRecipeLogic(RecipeMapMultiblockController tileEntity) { + super(tileEntity, true); + } + + + /** + * Overriding this to add our own custom checks + * Don't forget super calls + */ + @Override + public boolean checkRecipe(@NotNull Recipe recipe) { + return checkHeightRequirement() && checkBiomeRequirement(recipe) && super.checkRecipe(recipe); + } + + public boolean checkHeightRequirement() { + return getMetaTileEntity().getPos().getY() == 64; + } + /** + * This is a method for biome checking + */ + public boolean checkBiomeRequirement(@NotNull Recipe recipe) { + if (!recipe.hasProperty(BiomeProperty.getInstance())) return true; + BlockPos tempPos = getMetaTileEntity().getPos(); + return recipe.getProperty(BiomeProperty.getInstance(), BiomeProperty.BiomePropertyList.EMPTY_LIST) + .checkBiome(getMetaTileEntity().getWorld().getBiome(getMetaTileEntity().getPos())); + } + + @Override + public int getParallelLimit() { + return 256; + } + } + } diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index 909a59bd1..15fbcd4de 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -256,6 +256,9 @@ gregtech.machine.primitive_mud_pump.name=Primitive Mud Pump gregtech.machine.primitive_mud_pump.tooltip=Works only in River biomes between Y=64 and Y=80 gregtech.machine.basic_steam_turbine.name=Large Steam Turbine gregtech.machine.basic_gas_turbine.name=Large Gas Turbine +gregtech.machine.large_fluid_pump.name=Large Fluid Pump +gregtech.machine.large_fluid_pump.tooltip.1=This would definitely affect the local trout population. +gregtech.machine.large_fluid_pump.tooltip.2=Only works when the controller is at Y=64 gregtech.machine.ocean_pumper.name=Ocean Pumper gregtech.machine.ocean_pumper.tooltip=Works only in Ocean biomes between Y=70 and Y=75 gregtech.machine.advanced_arc_furnace.name=Advanced Arc Furnace From c19512b1b57c3dc26091581983a9b7ae4b076580 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Sun, 20 Oct 2024 21:31:36 +0700 Subject: [PATCH 06/18] commit --- .../SuSyMetaTileEntities.java | 4 +- .../MetaTileEntityLargeFluidPump.java | 74 ++++++++++++++++++- .../resources/assets/susy/lang/en_us.lang | 3 + 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java index f0ba1a580..2fa522e27 100644 --- a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java +++ b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java @@ -261,8 +261,6 @@ public static void init() { FLARE_STACK = registerMetaTileEntity(17007, new MetaTileEntityFlareStack(susyId("flare_stack"))); FROTH_FLOTATION_TANK = registerMetaTileEntity(17008, new MetaTileEntityFrothFlotationTank(susyId("froth_flotation_tank"))); MULTI_STAGE_FLASH_DISTILLER = registerMetaTileEntity(17009, new MetaTileEntityMultiStageFlashDistiller(susyId("multi_stage_flash_distiller"))); - - LARGE_FLUID_PUMP = registerMetaTileEntity(17021, new MetaTileEntityLargeFluidPump(susyId("large_fluid_pump"))); OCEAN_PUMPER = registerMetaTileEntity(17011, new MetaTileEntityOceanPumper(susyId("ocean_pumper"))); HIGH_TEMPERATURE_DISTILLATION_TOWER = registerMetaTileEntity(17012, new MetaTileEntityHighTemperatureDistillationTower(susyId("high_temperature_distillation_tower"))); ROTARY_KILN = registerMetaTileEntity(17013, new MetaTileEntityRotaryKiln(susyId("rotary_kiln"))); @@ -275,6 +273,8 @@ public static void init() { PHASE_SEPARATOR[0] = registerMetaTileEntity(17018, new MetaTileEntityPhaseSeparator(susyId("phase_separator"))); BATH_CONDENSER[0] = registerMetaTileEntity(17019, new MetaTileEntityBathCondenser(susyId("bath_condenser"))); + LARGE_FLUID_PUMP = registerMetaTileEntity(17021, new MetaTileEntityLargeFluidPump(susyId("large_fluid_pump"))); + registerSimpleMTE(ELECTROSTATIC_SEPARATOR, 12, 17035, "electrostatic_separator", SuSyRecipeMaps.ELECTROSTATIC_SEPARATOR, SusyTextures.ELECTROSTATIC_SEPARATOR_OVERLAY, true, GTUtility.defaultTankSizeFunction); registerSimpleMTE(POLISHING_MACHINE, 12, 17048, "polishing_machine", SuSyRecipeMaps.POLISHING_MACHINE, SusyTextures.POLISHING_MACHINE_OVERLAY, true, GTUtility.defaultTankSizeFunction); registerSimpleMTE(TEXTILE_SPINNER, 12, 17061, "textile_spinner", SuSyRecipeMaps.SPINNING_RECIPES, SusyTextures.TEXTILE_SPINNER_OVERLAY, true); diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index b7cf6ba5a..79e460bcc 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -8,6 +8,7 @@ import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; import gregtech.api.pattern.BlockPattern; import gregtech.api.pattern.FactoryBlockPattern; +import gregtech.api.recipes.Recipe; import gregtech.api.unification.material.Materials; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.texture.Textures; @@ -20,9 +21,11 @@ import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import supersymmetry.api.recipes.SuSyRecipeMaps; +import supersymmetry.api.recipes.properties.BiomeProperty; import supersymmetry.client.renderer.textures.SusyTextures; import javax.annotation.Nonnull; @@ -34,18 +37,36 @@ public class MetaTileEntityLargeFluidPump extends RecipeMapMultiblockController { public MetaTileEntityLargeFluidPump(ResourceLocation metaTileEntityId) { super(metaTileEntityId, SuSyRecipeMaps.PUMPING_RECIPES); - this.recipeMapWorkable = new MultiblockRecipeLogic(this, true); + + this.recipeMapWorkable = new LargePumpRecipeLogic(this); } public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { return new MetaTileEntityLargeFluidPump(this.metaTileEntityId); } + @Override + public boolean isMultiblockPartWeatherResistant(@Nonnull IMultiblockPart part) { + return true; + } + + @Override + public boolean getIsWeatherOrTerrainResistant() { + return true; + } + + @Override + public boolean allowsExtendedFacing() { + return false; + } + + protected @NotNull BlockPattern createStructurePattern() { return FactoryBlockPattern.start(RIGHT, FRONT, UP) + .aisle(" ", " P", " ") .aisle(" ", " P", " ") .aisle("FCCCC ", "CCCCC P", "FCECC ") - .aisle("CCSGC ", "OPPPPPP", "FCECC ") + .aisle("CCSGC ", "OPPPPPP", "CCECC ") .aisle("FCCC ", "CCCCC ", "FCEC ") .where(' ', any()) .where('S', selfPredicate()) @@ -53,9 +74,10 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { .where('G', states(getGearboxState())) .where('F', frames(Materials.Steel)) .where('C', states(getCasingState()) - .or(abilities(MultiblockAbility.IMPORT_ITEMS))) + .or(abilities(MultiblockAbility.IMPORT_ITEMS).setMaxGlobalLimited(1)) + .or(autoAbilities(true, false))) .where('E', states(getCasingState()) - .or(abilities(MultiblockAbility.INPUT_ENERGY))) + .or(abilities(MultiblockAbility.INPUT_ENERGY)).setMinGlobalLimited(1).setMaxGlobalLimited(2)) .where('O', abilities(MultiblockAbility.EXPORT_FLUIDS)) .build(); } @@ -74,6 +96,8 @@ protected static IBlockState getGearboxState() { } public void addInformation(ItemStack stack, @Nullable World player, @NotNull List tooltip, boolean advanced) { + tooltip.add(I18n.format("gregtech.machine.large_fluid_pump.tooltip.1")); + tooltip.add(I18n.format("gregtech.machine.large_fluid_pump.tooltip.2")); super.addInformation(stack, player, tooltip, advanced); tooltip.add(TooltipHelper.RAINBOW_SLOW + I18n.format("gregtech.machine.perfect_oc", new Object[0])); } @@ -82,4 +106,46 @@ public void addInformation(ItemStack stack, @Nullable World player, @NotNull Lis protected ICubeRenderer getFrontOverlay() { return SusyTextures.OCEANIC_DRILL_OVERLAY; } + + /** + * A custom recipeLogic class, for adding our check for biomes + * This can be moved out to a stand-alone class. + * But generally speaking if you do not plan to re-use this, making it an inner class should be fine. + * CEu itself has many such cases. + */ + public static class LargePumpRecipeLogic extends MultiblockRecipeLogic { + + public LargePumpRecipeLogic(RecipeMapMultiblockController tileEntity) { + super(tileEntity, true); + } + + + /** + * Overriding this to add our own custom checks + * Don't forget super calls + */ + @Override + public boolean checkRecipe(@NotNull Recipe recipe) { + return checkHeightRequirement() && checkBiomeRequirement(recipe) && super.checkRecipe(recipe); + } + + public boolean checkHeightRequirement() { + return getMetaTileEntity().getPos().getY() == 64; + } + /** + * This is a method for biome checking + */ + public boolean checkBiomeRequirement(@NotNull Recipe recipe) { + if (!recipe.hasProperty(BiomeProperty.getInstance())) return true; + BlockPos tempPos = getMetaTileEntity().getPos(); + return recipe.getProperty(BiomeProperty.getInstance(), BiomeProperty.BiomePropertyList.EMPTY_LIST) + .checkBiome(getMetaTileEntity().getWorld().getBiome(getMetaTileEntity().getPos())); + } + + @Override + public int getParallelLimit() { + return 256; + } + } + } diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index 909a59bd1..15fbcd4de 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -256,6 +256,9 @@ gregtech.machine.primitive_mud_pump.name=Primitive Mud Pump gregtech.machine.primitive_mud_pump.tooltip=Works only in River biomes between Y=64 and Y=80 gregtech.machine.basic_steam_turbine.name=Large Steam Turbine gregtech.machine.basic_gas_turbine.name=Large Gas Turbine +gregtech.machine.large_fluid_pump.name=Large Fluid Pump +gregtech.machine.large_fluid_pump.tooltip.1=This would definitely affect the local trout population. +gregtech.machine.large_fluid_pump.tooltip.2=Only works when the controller is at Y=64 gregtech.machine.ocean_pumper.name=Ocean Pumper gregtech.machine.ocean_pumper.tooltip=Works only in Ocean biomes between Y=70 and Y=75 gregtech.machine.advanced_arc_furnace.name=Advanced Arc Furnace From 2829c1b1739efea0470b9e0d2c86d308f75b7dc5 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Mon, 21 Oct 2024 17:13:05 +0700 Subject: [PATCH 07/18] Update SuSyRecipeMaps.java --- src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java b/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java index f46ebd147..0186bab53 100644 --- a/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java +++ b/src/main/java/supersymmetry/api/recipes/SuSyRecipeMaps.java @@ -300,7 +300,7 @@ public class SuSyRecipeMaps { .setSound(GTSoundEvents.BATH); public static final RecipeMap PUMPING_RECIPES = new RecipeMap<>("large_fluid_pump", 1, 0, 0, 1, new BiomeRecipeBuilder(), false) - .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, ProgressWidget.MoveType.VERTICAL) + .setProgressBar(GuiTextures.PROGRESS_BAR_GAS_COLLECTOR, ProgressWidget.MoveType.HORIZONTAL) .setSound(GTSoundEvents.MINER); public static final RecipeMap DRONE_PAD = new RecipeMap<>("drone_pad", 4, 9, 0, 0, new DronePadRecipeBuilder(), false); From 222190f9f57b561ea5d189f5564d77a563a08c18 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Mon, 21 Oct 2024 19:09:29 +0700 Subject: [PATCH 08/18] Update MetaTileEntityLargeFluidPump.java --- .../multi/electric/MetaTileEntityLargeFluidPump.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index 79e460bcc..5515613f6 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -10,6 +10,7 @@ import gregtech.api.pattern.FactoryBlockPattern; import gregtech.api.recipes.Recipe; import gregtech.api.unification.material.Materials; +import gregtech.api.util.RelativeDirection; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.texture.Textures; import gregtech.client.utils.TooltipHelper; @@ -33,6 +34,7 @@ import java.util.List; import static gregtech.api.util.RelativeDirection.*; +import static net.minecraft.util.EnumFacing.*; public class MetaTileEntityLargeFluidPump extends RecipeMapMultiblockController { public MetaTileEntityLargeFluidPump(ResourceLocation metaTileEntityId) { @@ -62,7 +64,7 @@ public boolean allowsExtendedFacing() { protected @NotNull BlockPattern createStructurePattern() { - return FactoryBlockPattern.start(RIGHT, FRONT, UP) + return FactoryBlockPattern.start(RIGHT, FRONT, RelativeDirection.UP) .aisle(" ", " P", " ") .aisle(" ", " P", " ") .aisle("FCCCC ", "CCCCC P", "FCECC ") @@ -138,8 +140,9 @@ public boolean checkHeightRequirement() { public boolean checkBiomeRequirement(@NotNull Recipe recipe) { if (!recipe.hasProperty(BiomeProperty.getInstance())) return true; BlockPos tempPos = getMetaTileEntity().getPos(); + tempPos.offset(getMetaTileEntity().getFrontFacing().rotateYCCW(), 2); return recipe.getProperty(BiomeProperty.getInstance(), BiomeProperty.BiomePropertyList.EMPTY_LIST) - .checkBiome(getMetaTileEntity().getWorld().getBiome(getMetaTileEntity().getPos())); + .checkBiome(getMetaTileEntity().getWorld().getBiome(tempPos)); } @Override From 0a5bd07e7b42e6401db4ef943748f1f117afc851 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Mon, 21 Oct 2024 20:12:34 +0700 Subject: [PATCH 09/18] Update en_us.lang --- src/main/resources/assets/susy/lang/en_us.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index 15fbcd4de..a276ba5e1 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -258,7 +258,7 @@ gregtech.machine.basic_steam_turbine.name=Large Steam Turbine gregtech.machine.basic_gas_turbine.name=Large Gas Turbine gregtech.machine.large_fluid_pump.name=Large Fluid Pump gregtech.machine.large_fluid_pump.tooltip.1=This would definitely affect the local trout population. -gregtech.machine.large_fluid_pump.tooltip.2=Only works when the controller is at Y=64 +gregtech.machine.large_fluid_pump.tooltip.2=Only works when the controller is at Y=64 and the bottom Steel Pipe Casing is located in the right biome. gregtech.machine.ocean_pumper.name=Ocean Pumper gregtech.machine.ocean_pumper.tooltip=Works only in Ocean biomes between Y=70 and Y=75 gregtech.machine.advanced_arc_furnace.name=Advanced Arc Furnace From 007d466e9ea985613824f7b9503e552744151215 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Mon, 21 Oct 2024 20:42:54 +0700 Subject: [PATCH 10/18] Update MetaTileEntityLargeFluidPump.java --- .../multi/electric/MetaTileEntityLargeFluidPump.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index 5515613f6..a43510c60 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -34,7 +34,6 @@ import java.util.List; import static gregtech.api.util.RelativeDirection.*; -import static net.minecraft.util.EnumFacing.*; public class MetaTileEntityLargeFluidPump extends RecipeMapMultiblockController { public MetaTileEntityLargeFluidPump(ResourceLocation metaTileEntityId) { @@ -139,8 +138,7 @@ public boolean checkHeightRequirement() { */ public boolean checkBiomeRequirement(@NotNull Recipe recipe) { if (!recipe.hasProperty(BiomeProperty.getInstance())) return true; - BlockPos tempPos = getMetaTileEntity().getPos(); - tempPos.offset(getMetaTileEntity().getFrontFacing().rotateYCCW(), 2); + BlockPos tempPos = getMetaTileEntity().getPos().offset(getMetaTileEntity().getFrontFacing().rotateYCCW(), 2); return recipe.getProperty(BiomeProperty.getInstance(), BiomeProperty.BiomePropertyList.EMPTY_LIST) .checkBiome(getMetaTileEntity().getWorld().getBiome(tempPos)); } From aa3de3a6313409b33dc5a974110f7d4381969675 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Mon, 21 Oct 2024 21:02:05 +0700 Subject: [PATCH 11/18] Update MetaTileEntityLargeFluidPump.java --- .../multi/electric/MetaTileEntityLargeFluidPump.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index a43510c60..13b0fe493 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -5,6 +5,7 @@ import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.metatileentity.multiblock.IMultiblockPart; import gregtech.api.metatileentity.multiblock.MultiblockAbility; +import gregtech.api.metatileentity.multiblock.MultiblockControllerBase; import gregtech.api.metatileentity.multiblock.RecipeMapMultiblockController; import gregtech.api.pattern.BlockPattern; import gregtech.api.pattern.FactoryBlockPattern; @@ -21,6 +22,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -138,7 +140,13 @@ public boolean checkHeightRequirement() { */ public boolean checkBiomeRequirement(@NotNull Recipe recipe) { if (!recipe.hasProperty(BiomeProperty.getInstance())) return true; - BlockPos tempPos = getMetaTileEntity().getPos().offset(getMetaTileEntity().getFrontFacing().rotateYCCW(), 2); + EnumFacing rightSide = RelativeDirection.RIGHT + .getRelativeFacing( + getMetaTileEntity().getFrontFacing(), + ((MultiblockControllerBase) getMetaTileEntity()).getUpwardsFacing(), + ((MultiblockControllerBase) getMetaTileEntity()).isFlipped() + ); + BlockPos tempPos = getMetaTileEntity().getPos().offset(rightSide, 2); return recipe.getProperty(BiomeProperty.getInstance(), BiomeProperty.BiomePropertyList.EMPTY_LIST) .checkBiome(getMetaTileEntity().getWorld().getBiome(tempPos)); } From 473239de7392799aae84e24477b4f19c61160cf7 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Tue, 22 Oct 2024 08:18:19 +0700 Subject: [PATCH 12/18] sample --- .../multi/electric/MetaTileEntityLargeFluidPump.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index 13b0fe493..212a62fc4 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -146,7 +146,7 @@ public boolean checkBiomeRequirement(@NotNull Recipe recipe) { ((MultiblockControllerBase) getMetaTileEntity()).getUpwardsFacing(), ((MultiblockControllerBase) getMetaTileEntity()).isFlipped() ); - BlockPos tempPos = getMetaTileEntity().getPos().offset(rightSide, 2); + BlockPos tempPos = getMetaTileEntity().getPos().offset(rightSide, 4); return recipe.getProperty(BiomeProperty.getInstance(), BiomeProperty.BiomePropertyList.EMPTY_LIST) .checkBiome(getMetaTileEntity().getWorld().getBiome(tempPos)); } From 618c421c0a986db9a47b9b727113e21fe565ba32 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Tue, 22 Oct 2024 09:06:39 +0700 Subject: [PATCH 13/18] sample --- .../multi/electric/MetaTileEntityLargeFluidPump.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index 212a62fc4..8c0c4f9a8 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -140,13 +140,19 @@ public boolean checkHeightRequirement() { */ public boolean checkBiomeRequirement(@NotNull Recipe recipe) { if (!recipe.hasProperty(BiomeProperty.getInstance())) return true; - EnumFacing rightSide = RelativeDirection.RIGHT + EnumFacing leftSide = RelativeDirection.LEFT .getRelativeFacing( getMetaTileEntity().getFrontFacing(), ((MultiblockControllerBase) getMetaTileEntity()).getUpwardsFacing(), ((MultiblockControllerBase) getMetaTileEntity()).isFlipped() ); - BlockPos tempPos = getMetaTileEntity().getPos().offset(rightSide, 4); + EnumFacing backSide = RelativeDirection.BACK + .getRelativeFacing( + getMetaTileEntity().getFrontFacing(), + ((MultiblockControllerBase) getMetaTileEntity()).getUpwardsFacing(), + ((MultiblockControllerBase) getMetaTileEntity()).isFlipped() + ); + BlockPos tempPos = getMetaTileEntity().getPos().offset(leftSide, 4).offset(backSide); return recipe.getProperty(BiomeProperty.getInstance(), BiomeProperty.BiomePropertyList.EMPTY_LIST) .checkBiome(getMetaTileEntity().getWorld().getBiome(tempPos)); } From c6f1a502d788ae3f1050119b67ca5756de877e36 Mon Sep 17 00:00:00 2001 From: MCTian-mi <35869948+MCTian-mi@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:03:02 +0800 Subject: [PATCH 14/18] use `biomeName` field directly since forge makes the method client-only (thanks to @CaliforniaDemise) --- .../supersymmetry/api/recipes/properties/BiomeProperty.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/supersymmetry/api/recipes/properties/BiomeProperty.java b/src/main/java/supersymmetry/api/recipes/properties/BiomeProperty.java index fb973f3fc..ea3895893 100644 --- a/src/main/java/supersymmetry/api/recipes/properties/BiomeProperty.java +++ b/src/main/java/supersymmetry/api/recipes/properties/BiomeProperty.java @@ -30,7 +30,7 @@ public static BiomeProperty getInstance() { private static String getBiomesForRecipe(List value) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < value.size(); i++) { - builder.append(value.get(i).getBiomeName()); + builder.append(value.get(i).biomeName); if (i != value.size() - 1) builder.append(", "); } From 35060c257cfbe4fe6c6c38405007069dd892cf95 Mon Sep 17 00:00:00 2001 From: MCTian-mi <35869948+MCTian-mi@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:09:21 +0800 Subject: [PATCH 15/18] formatting --- .../SuSyMetaTileEntities.java | 1 + .../MetaTileEntityLargeFluidPump.java | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java index 2fa522e27..7a6026a60 100644 --- a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java +++ b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java @@ -261,6 +261,7 @@ public static void init() { FLARE_STACK = registerMetaTileEntity(17007, new MetaTileEntityFlareStack(susyId("flare_stack"))); FROTH_FLOTATION_TANK = registerMetaTileEntity(17008, new MetaTileEntityFrothFlotationTank(susyId("froth_flotation_tank"))); MULTI_STAGE_FLASH_DISTILLER = registerMetaTileEntity(17009, new MetaTileEntityMultiStageFlashDistiller(susyId("multi_stage_flash_distiller"))); + OCEAN_PUMPER = registerMetaTileEntity(17011, new MetaTileEntityOceanPumper(susyId("ocean_pumper"))); HIGH_TEMPERATURE_DISTILLATION_TOWER = registerMetaTileEntity(17012, new MetaTileEntityHighTemperatureDistillationTower(susyId("high_temperature_distillation_tower"))); ROTARY_KILN = registerMetaTileEntity(17013, new MetaTileEntityRotaryKiln(susyId("rotary_kiln"))); diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index 8c0c4f9a8..3675dcd5d 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -35,15 +35,17 @@ import javax.annotation.Nullable; import java.util.List; -import static gregtech.api.util.RelativeDirection.*; +import static gregtech.api.util.RelativeDirection.FRONT; +import static gregtech.api.util.RelativeDirection.RIGHT; public class MetaTileEntityLargeFluidPump extends RecipeMapMultiblockController { + public MetaTileEntityLargeFluidPump(ResourceLocation metaTileEntityId) { super(metaTileEntityId, SuSyRecipeMaps.PUMPING_RECIPES); - this.recipeMapWorkable = new LargePumpRecipeLogic(this); } + @Override public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) { return new MetaTileEntityLargeFluidPump(this.metaTileEntityId); } @@ -63,8 +65,9 @@ public boolean allowsExtendedFacing() { return false; } - - protected @NotNull BlockPattern createStructurePattern() { + @NotNull + @Override + protected BlockPattern createStructurePattern() { return FactoryBlockPattern.start(RIGHT, FRONT, RelativeDirection.UP) .aisle(" ", " P", " ") .aisle(" ", " P", " ") @@ -84,6 +87,8 @@ public boolean allowsExtendedFacing() { .where('O', abilities(MultiblockAbility.EXPORT_FLUIDS)) .build(); } + + @Override public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { return Textures.SOLID_STEEL_CASING; } @@ -91,13 +96,16 @@ public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { protected static IBlockState getCasingState() { return MetaBlocks.METAL_CASING.getState(MetalCasingType.STEEL_SOLID); } + protected static IBlockState getPipeCasingState() { return MetaBlocks.BOILER_CASING.getState(BoilerCasingType.STEEL_PIPE); } + protected static IBlockState getGearboxState() { return MetaBlocks.TURBINE_CASING.getState(TurbineCasingType.STEEL_GEARBOX); } + @Override public void addInformation(ItemStack stack, @Nullable World player, @NotNull List tooltip, boolean advanced) { tooltip.add(I18n.format("gregtech.machine.large_fluid_pump.tooltip.1")); tooltip.add(I18n.format("gregtech.machine.large_fluid_pump.tooltip.2")); @@ -106,6 +114,7 @@ public void addInformation(ItemStack stack, @Nullable World player, @NotNull Lis } @Nonnull + @Override protected ICubeRenderer getFrontOverlay() { return SusyTextures.OCEANIC_DRILL_OVERLAY; } @@ -122,7 +131,6 @@ public LargePumpRecipeLogic(RecipeMapMultiblockController tileEntity) { super(tileEntity, true); } - /** * Overriding this to add our own custom checks * Don't forget super calls @@ -135,6 +143,7 @@ public boolean checkRecipe(@NotNull Recipe recipe) { public boolean checkHeightRequirement() { return getMetaTileEntity().getPos().getY() == 64; } + /** * This is a method for biome checking */ From c14a66ae4acba55260ac382a3055e2b36d4cc67d Mon Sep 17 00:00:00 2001 From: trainvoi Date: Wed, 23 Oct 2024 08:55:44 +0700 Subject: [PATCH 16/18] Update en_us.lang --- src/main/resources/assets/susy/lang/en_us.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index a276ba5e1..45315d1be 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -712,6 +712,7 @@ recipemap.gravity_separator=Gravity Separation recipemap.spinning.name=Textile Spinning recipemap.large_steam_turbine.name=Large Steam Turbine recipemap.primitive_smelter.name=Primitive Smelting +recipemap.large_fluid_pump.name=Large Fluid Pump gregtech.multiblock.primitive_mud_pump.description=The Primitive Mud Pump is a Steam Era multiblock that collects mud once per second, but only if it is in a river biome, and when the controller is between Y = 64 and Y = 80 (Inclusive). It can use a Pump, ULV, or LV Output Hatch. gregtech.multiblock.ocean_pumper.description=The Ocean Pumper is an electrically powered multiblock that collects a base amount of 8,000 L Seawater per second (at MV), but only if it is in an ocean biome, and when the controller is between Y = 70 and Y = 75 (Inclusive). It needs an output hatch, a maintenance hatch, and an energy input hatch. From ef057139d83e5c4e61c4de021d3d2aa4659aa107 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Wed, 23 Oct 2024 09:29:12 +0700 Subject: [PATCH 17/18] commit --- .../MetaTileEntityLargeFluidPump.java | 27 +++++++++++++++++++ .../resources/assets/susy/lang/en_us.lang | 2 ++ 2 files changed, 29 insertions(+) diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index 3675dcd5d..5b1695491 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -1,5 +1,6 @@ package supersymmetry.common.metatileentities.multi.electric; +import gregtech.api.GTValues; import gregtech.api.capability.impl.MultiblockRecipeLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; @@ -11,6 +12,7 @@ import gregtech.api.pattern.FactoryBlockPattern; import gregtech.api.recipes.Recipe; import gregtech.api.unification.material.Materials; +import gregtech.api.util.GTUtility; import gregtech.api.util.RelativeDirection; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.texture.Textures; @@ -25,6 +27,10 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.Style; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import org.jetbrains.annotations.NotNull; import supersymmetry.api.recipes.SuSyRecipeMaps; @@ -112,6 +118,27 @@ public void addInformation(ItemStack stack, @Nullable World player, @NotNull Lis super.addInformation(stack, player, tooltip, advanced); tooltip.add(TooltipHelper.RAINBOW_SLOW + I18n.format("gregtech.machine.perfect_oc", new Object[0])); } + @Override + protected void addDisplayText(List textList) { + super.addDisplayText(textList); + EnumFacing leftSide = RelativeDirection.LEFT + .getRelativeFacing( + getFrontFacing(), + getUpwardsFacing(), + isFlipped() + ); + EnumFacing backSide = RelativeDirection.BACK + .getRelativeFacing( + getFrontFacing(), + getUpwardsFacing(), + isFlipped() + ); + BlockPos tempPos = this.getPos().offset(leftSide, 4).offset(backSide); + int yLevel = getPos().getY(); + String biome = getWorld().getBiome(tempPos).biomeName; + textList.add(new TextComponentTranslation("susy.large_fluid_pump.y_level", yLevel).setStyle(new Style().setColor(TextFormatting.YELLOW))); + textList.add(new TextComponentTranslation("susy.large_fluid_pump.biome", biome).setStyle(new Style().setColor(TextFormatting.YELLOW))); + } @Nonnull @Override diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index 45315d1be..3ea4a2b36 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -802,6 +802,8 @@ susy.ocean_pumper.full=Tanks are Full! susy.ocean_pumper.drainrate=Current Pumping Rate: %s susy.wrongbiome=Machine can not work in this biome! susy.weather_resistance=§2Will not explode from water, lava, fire or rain. +susy.large_fluid_pump.y_level=Current Controller Y level: Y= +susy.large_fluid_pump.biome=Current bottom Pipe Casing biome: # Latex Logs gregtech.block_group_members.latex_logs.name=Rubber Log From 2d306b39c60068cb20b9912149847ddcf8242250 Mon Sep 17 00:00:00 2001 From: trainvoi Date: Wed, 23 Oct 2024 10:02:29 +0700 Subject: [PATCH 18/18] commit --- .../multi/electric/MetaTileEntityLargeFluidPump.java | 4 +--- src/main/resources/assets/susy/lang/en_us.lang | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java index 5b1695491..d791afdb3 100644 --- a/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java +++ b/src/main/java/supersymmetry/common/metatileentities/multi/electric/MetaTileEntityLargeFluidPump.java @@ -1,6 +1,5 @@ package supersymmetry.common.metatileentities.multi.electric; -import gregtech.api.GTValues; import gregtech.api.capability.impl.MultiblockRecipeLogic; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; @@ -12,7 +11,6 @@ import gregtech.api.pattern.FactoryBlockPattern; import gregtech.api.recipes.Recipe; import gregtech.api.unification.material.Materials; -import gregtech.api.util.GTUtility; import gregtech.api.util.RelativeDirection; import gregtech.client.renderer.ICubeRenderer; import gregtech.client.renderer.texture.Textures; @@ -133,7 +131,7 @@ protected void addDisplayText(List textList) { getUpwardsFacing(), isFlipped() ); - BlockPos tempPos = this.getPos().offset(leftSide, 4).offset(backSide); + BlockPos tempPos = getPos().offset(leftSide, 4).offset(backSide); int yLevel = getPos().getY(); String biome = getWorld().getBiome(tempPos).biomeName; textList.add(new TextComponentTranslation("susy.large_fluid_pump.y_level", yLevel).setStyle(new Style().setColor(TextFormatting.YELLOW))); diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index 3ea4a2b36..f6b7ed481 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -802,8 +802,8 @@ susy.ocean_pumper.full=Tanks are Full! susy.ocean_pumper.drainrate=Current Pumping Rate: %s susy.wrongbiome=Machine can not work in this biome! susy.weather_resistance=§2Will not explode from water, lava, fire or rain. -susy.large_fluid_pump.y_level=Current Controller Y level: Y= -susy.large_fluid_pump.biome=Current bottom Pipe Casing biome: +susy.large_fluid_pump.y_level=Current Controller Y level: Y=%s +susy.large_fluid_pump.biome=Current bottom Pipe Casing biome: %s # Latex Logs gregtech.block_group_members.latex_logs.name=Rubber Log