Skip to content

Commit

Permalink
Update MetaTileEntityLargeFluidPump.java
Browse files Browse the repository at this point in the history
  • Loading branch information
trainvoi committed Oct 20, 2024
1 parent e093c33 commit f7e6768
Showing 1 changed file with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,6 +24,7 @@
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;
Expand All @@ -34,7 +36,8 @@
public class MetaTileEntityLargeFluidPump extends RecipeMapMultiblockController {
public MetaTileEntityLargeFluidPump(ResourceLocation metaTileEntityId) {
super(metaTileEntityId, SuSyRecipeMaps.PUMPING_RECIPES);
this.recipeMapWorkable = new MultiblockRecipeLogic(this, true);

this.recipeMapWorkable = new BiomeRecipeLogic(this);
}

public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
Expand All @@ -45,15 +48,16 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
return FactoryBlockPattern.start(RIGHT, FRONT, UP)
.aisle(" ", " P", " ")
.aisle("FCCCC ", "CCCCC P", "FCECC ")
.aisle("CCSGC ", "OPPPPPP", "FCECC ")
.aisle("CCSGC ", "OPPPPPP", "CCECC ")
.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)))
.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))
Expand All @@ -77,6 +81,41 @@ 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]));
}
/**
* 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 BiomeRecipeLogic extends MultiblockRecipeLogic {

public BiomeRecipeLogic(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 checkBiomeRequirement(recipe) && super.checkRecipe(recipe);
}

/**
* This is a method for biome checking
*/
public boolean checkBiomeRequirement(@NotNull Recipe recipe) {
if (!recipe.hasProperty(BiomeProperty.getInstance())) return true;
return recipe.getProperty(BiomeProperty.getInstance(), BiomeProperty.BiomePropertyList.EMPTY_LIST)
.checkBiome(getMetaTileEntity().getWorld().getBiome(getMetaTileEntity().getPos()));
}

@Override
public int getParallelLimit() {
return 256;
}
}

@Nonnull
protected ICubeRenderer getFrontOverlay() {
Expand Down

0 comments on commit f7e6768

Please sign in to comment.