package mcjty.rftoolsdim.dimensions.dimlets.types;

import mcjty.lib.varia.Logging;
import mcjty.rftoolsdim.dimensions.DimensionInformation;
import mcjty.rftoolsdim.dimensions.dimlets.DimletKey;
import mcjty.rftoolsdim.dimensions.types.PatreonType;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import org.apache.commons.lang3.tuple.Pair;

import java.util.List;
import java.util.Random;

public class PatreonDimletType implements IDimletType {

    @Override
    public String getName() {
        return "Patreon";
    }

    @Override
    public String getOpcode() {
        return "P";
    }

    @Override
    public String getTextureName() {
        return "patreonDimlet";
    }

    @Override
    public void setupFromConfig(Configuration cfg) {
    }

    @Override
    public boolean isModifier() {
        return false;
    }

    @Override
    public boolean isModifiedBy(DimletType type) {
        return false;
    }

    @Override
    public float getModifierCreateCostFactor(DimletType modifierType, DimletKey key) {
        return 1.0f;
    }

    @Override
    public float getModifierMaintainCostFactor(DimletType modifierType, DimletKey key) {
        return 1.0f;
    }

    @Override
    public float getModifierTickCostFactor(DimletType modifierType, DimletKey key) {
        return 1.0f;
    }

    @Override
    public boolean isInjectable(DimletKey key) {
        switch(key.getId()) {
        case "McJty":
        case "SickHippie":
        case "Nissenfeld":
        case "DarkCorvuz":
        case "TomWolf":
        case "Kenney":
            return true;
        default:
            Logging.logError("Unknown Patreon dimlet ID " + key.getId(), new RuntimeException());
            //$FALL-THROUGH$
        case "Lockesly":
        case "Puppeteer":
        case "Rouven":
        case "FireBall":
            return false;
        }
    }

    @Override
    public void inject(DimletKey key, DimensionInformation dimensionInformation) {
        switch(key.getId()) {
        case "McJty":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_FIREWORKS);
            break;
        case "SickHippie":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_SICKMOON);
            dimensionInformation.setPatreonBit(PatreonType.PATREON_SICKSUN);
            break;
        case "Nissenfeld":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_RABBITMOON);
            dimensionInformation.setPatreonBit(PatreonType.PATREON_RABBITSUN);
            break;
        case "Lockesly":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_PINKPILLARS);
            break;
        case "Puppeteer":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_PUPPETEER);
            break;
        case "Rouven":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_LAYEREDMETA);
            break;
        case "FireBall":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_COLOREDPRISMS);
            break;
        case "DarkCorvuz":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_DARKCORVUS);
            break;
        case "TomWolf":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_TOMWOLF);
            break;
        case "Kenney":
            dimensionInformation.setPatreonBit(PatreonType.PATREON_KENNEY);
            break;
        default:
            Logging.logError("Unknown Patreon dimlet ID " + key.getId(), new RuntimeException());
        }
    }

    @Override
    public void constructDimension(List<Pair<DimletKey, List<DimletKey>>> dimlets, Random random, DimensionInformation dimensionInformation) {
        dimlets = DimensionInformation.extractType(DimletType.DIMLET_PATREON, dimlets);
        if (dimlets.isEmpty()) {
            return;
        }

        for (Pair<DimletKey, List<DimletKey>> dimlet : dimlets) {
            inject(dimlet.getKey(), dimensionInformation);
        }
    }

    @Override
    public String[] getInformation() {
        return new String[] { "Patreon dimlets are in honor of a player and add purely cosmetic features to dimensions" };
    }

    @Override
    public DimletKey attemptDimletCrafting(ItemStack stackController, ItemStack stackMemory, ItemStack stackEnergy, ItemStack stackEssence) {
        return null;
    }
}

@@ -3727,18 +3727,55 @@
     
+ for (Pair%3CDimletKey, List%3CDimletKey%3E%3E
  dimlet
-s =
+ :
  Dim
@@ -3843,136 +3843,8 @@
 ets)
-;%0A        if (dimlets.isEmpty()) %7B%0A            return;%0A        %7D%0A%0A        for (Pair%3CDimletKey, List%3CDimletKey%3E%3E dimlet : dimlets
 ) %7B%0A

Remove an unnecessary test