aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/pers/gwyog/gtneioreplugin/util/GT6OreSmallHelper.java
blob: 873f049856d106d760a48ebdb07f49d39079ec49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package pers.gwyog.gtneioreplugin.util;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import gregapi.block.IBlockPlacable;
import gregapi.block.prefixblock.PrefixBlock;
import gregapi.data.CS;
import gregapi.data.OP;
import gregapi.oredict.OreDictMaterial;
import gregapi.worldgen.WorldgenObject;
import gregapi.worldgen.Worldgen_GT_Ore_SmallPieces;
import gregapi.worldgen.Worldgenerator;
import net.minecraft.item.ItemStack;
import pers.gwyog.gtneioreplugin.GTNEIOrePlugin;

public class GT6OreSmallHelper {
    public static List<ItemStack> oreSmallList = new ArrayList<ItemStack>();
    public static HashMap<String, OreSmallWrapper> mapOreSmallWrapper = new HashMap<String, OreSmallWrapper>();
    public static HashMap<String, Short> mapOreDropUnlocalizedNameToOreMeta = new HashMap<String, Short>();
    public static HashMap<Short, List<ItemStack>> mapOreMetaToOreDrops = new HashMap<Short, List<ItemStack>>();    
    public static Set<PrefixBlock> setOreSmallBasicTypes = new HashSet<PrefixBlock>();
    
    public GT6OreSmallHelper() {
        ItemStack stack;
        OreDictMaterial material;
        PrefixBlock oreSmall = CS.BlocksGT.oreSmall;
        short meta;
        for (WorldgenObject worldGen : Worldgenerator.sWorldgenList)
            if (worldGen.mWorldGenName.startsWith("ore.small.") && worldGen instanceof Worldgen_GT_Ore_SmallPieces) {
                Worldgen_GT_Ore_SmallPieces worldGenSmallPieces = (Worldgen_GT_Ore_SmallPieces)worldGen;
                meta = worldGenSmallPieces.mMeta;
                material = oreSmall.getMetaMaterial(meta);
                mapOreSmallWrapper.put(worldGen.mWorldGenName, new OreSmallWrapper(worldGenSmallPieces));
                if (!mapOreMetaToOreDrops.keySet().contains(meta)) {
                    List<ItemStack> stackList = new ArrayList<ItemStack>();
                    stack = OP.gemExquisite.mat(material, OP.gem.mat(material, 1L), 1L); 
                    if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);}
                    stack = OP.gemFlawless.mat(material, OP.gem.mat(material, 1L), 1L);
                    if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);}
                    stack = OP.gem.mat(material, 1L);
                    if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);}
                    stack = OP.gemFlawed.mat(material, OP.crushed.mat(material, 1L), 1L);
                    if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);}
                    stack = OP.crushed.mat(material, 1L);
                    if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);}
                    stack = OP.gemChipped.mat(material, OP.dustImpure.mat(material, 1L), 1L);
                    if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);}
                    stack = OP.dustImpure.mat(material, OP.dust.mat(material, 1L), 1L);
                    if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);}
                    stack = OP.gemLegendary.mat(material, 1L);
                    if (stack != null && !mapOreDropUnlocalizedNameToOreMeta.keySet().contains(stack.getUnlocalizedName())) {mapOreDropUnlocalizedNameToOreMeta.put(stack.getUnlocalizedName(), meta);stackList.add(stack);}
                    oreSmallList.add(new ItemStack(oreSmall, 1, meta));
                    mapOreMetaToOreDrops.put(meta, stackList);
                }
                Set<IBlockPlacable> setSmallOreBasicTypesTemp = new HashSet<IBlockPlacable>(CS.BlocksGT.stoneToSmallOres.values());
                for (IBlockPlacable block: setSmallOreBasicTypesTemp)
                    if (block instanceof PrefixBlock)
                        setOreSmallBasicTypes.add((PrefixBlock)block);       
            }
    }
    
    public class OreSmallWrapper {
        public String oreGenName;
        public short oreMeta;
        public String worldGenHeightRange;
        public String amountPerChunk;
        public boolean genOverworld = false;
        public boolean genNether = false;
        public boolean genEnd = false;
        
        public OreSmallWrapper(Worldgen_GT_Ore_SmallPieces worldGen) {
            this.oreGenName = worldGen.mWorldGenName;
            this.oreMeta = worldGen.mMeta;
            this.worldGenHeightRange = worldGen.mMinY + "-" + worldGen.mMaxY;
            this.amountPerChunk = worldGen.mAmount/2 + "-" + (worldGen.mAmount/2 + (worldGen.mAmount+1)/2);
            this.genOverworld = worldGen.mOverworld;
            this.genNether = worldGen.mNether;
            this.genEnd = worldGen.mEnd;
        }
    }
    
}