@author Gregorius Techneticies
| 52 | * @author Gregorius Techneticies |
| 53 | */ |
| 54 | public final class OreDictPrefix implements IOreDictListenerEvent, ITagDataContainer<OreDictPrefix>, ICondition<ITagDataContainer<?>> { |
| 55 | /** This List is sorted by the length of the Prefixes. */ |
| 56 | public static final List<OreDictPrefix> VALUES_SORTED = new ArrayListNoNulls<>(); |
| 57 | /** This is to prevent smaller Prefixes from breaking larger ones by just starting with the same few Characters the larger one starts with. */ |
| 58 | private static final List<OreDictPrefix> VALUES_SORTED_INTERNAL = new ArrayListNoNulls<>(); |
| 59 | /** The List of all Values in the order they have been added. not really sorted at all. */ |
| 60 | public static final List<OreDictPrefix> VALUES = new ArrayListNoNulls<>(); |
| 61 | /** The Map containing all Prefixes by their Name. */ |
| 62 | public static final Map<String, OreDictPrefix> sPrefixes = new HashMap<>(); |
| 63 | /** The Map containing all Prefixes by their Name. */ |
| 64 | public static final Map<String, OreDictPrefix> sParsed = new HashMap<>(); |
| 65 | |
| 66 | private final Set<TagData> mTags = new HashSetNoNulls<>(); |
| 67 | private final Set<OreDictMaterial> mItemGeneratorBlackList = new HashSetNoNulls<>(), mIgnoredRegistrations = new HashSetNoNulls<>(), mItemGeneratorForced = new HashSetNoNulls<>(); |
| 68 | private final Set<IOreDictListenerEvent> mListenersOre = new HashSetNoNulls<>(); |
| 69 | public final Set<IOreDictListenerItem> mListenersItem = new HashSetNoNulls<>(); |
| 70 | public final String mNameInternal; |
| 71 | public OreDictPrefix mTargetRegistration = this; |
| 72 | public CreativeTabs mCreativeTab = null; |
| 73 | |
| 74 | public ItemStack mContainerItem = null; |
| 75 | @SuppressWarnings("rawtypes") |
| 76 | private ICondition mCondition = ICondition.TRUE; |
| 77 | /** The Indices of the Icons inside the Texture Sets. -1 if it doesn't have a Set */ |
| 78 | public int mIconIndexBlock = -1, mIconIndexItem = -1; |
| 79 | public byte mConfigStackSize = 64, mDefaultStackSize = 64, mMinimumStackSize = 1, mState = STATE_SOLID; |
| 80 | public long mAmount = -1, mWeight = U; |
| 81 | public List<AdvancedCrafting1ToY> mShapelessManagersSingle = new ArrayListNoNulls<>(); |
| 82 | public List<AdvancedCraftingXToY> mShapelessManagers = new ArrayListNoNulls<>(); |
| 83 | public float mHeatDamage = 0.0F; |
| 84 | public String mNameLocal, mMaterialPre, mMaterialPost, mNameCategory, mNameTextureSet; |
| 85 | /** List of Prefixes which are familiar to this Prefix. Like "dust" having "dustSmall" and "dustTiny" and vice versa. Note that this per Default also contains the Prefix itself inside this Set. */ |
| 86 | public final Set<OreDictPrefix> mFamiliarPrefixes = new HashSetNoNulls<>(); |
| 87 | /** Secondary Materials of this Prefix. OreDictMaterialStacks are In Material Units */ |
| 88 | public final List<OreDictMaterialStack> mByProducts = new ArrayListNoNulls<>(); |
| 89 | /** List of ThaumCraft Aspects. */ |
| 90 | public final List<TC_AspectStack> mAspects = new ArrayListNoNulls<>(1); |
| 91 | |
| 92 | public static OreDictPrefix createPrefix(String aName) { |
| 93 | if (GAPI.mStartedInit) throw new IllegalStateException("Prefixes have to be initialised in PreInit or earlier!"); |
| 94 | String tName = aName.replaceAll(" ", "").replaceAll("-", ""); // Auto-Replace all Spaces and Minuses. |
| 95 | OreDictPrefix rPrefix = sPrefixes.get(tName); |
| 96 | return rPrefix == null ? new OreDictPrefix(tName, aName) : rPrefix; |
| 97 | } |
| 98 | |
| 99 | private OreDictPrefix(String aNameInternal, String aNameLocal) { |
| 100 | mNameInternal = aNameInternal; |
| 101 | mNameTextureSet = mNameInternal; |
| 102 | mNameCategory = mNameLocal = aNameLocal; |
| 103 | if (mNameInternal.contains("|") || mNameInternal.contains("*") || mNameInternal.contains(":") || mNameInternal.contains(".") || mNameInternal.contains("$")) throw new IllegalArgumentException("The Prefix Name contains invalid Characters!"); |
| 104 | if (mNameInternal.length() < 3) throw new IllegalArgumentException("A Prefix must have at least 3 Characters, otherwise it would break other Prefixes way to easily."); |
| 105 | VALUES.add(this); |
| 106 | if (VALUES_SORTED_INTERNAL.isEmpty()) { |
| 107 | VALUES_SORTED_INTERNAL.add(this); |
| 108 | VALUES_SORTED.add(this); |
| 109 | } else for (int i = 0, j = VALUES_SORTED_INTERNAL.size(); i < j; i++) { |
| 110 | if (mNameInternal.length() >= VALUES_SORTED_INTERNAL.get(i).mNameInternal.length()) { |
| 111 | VALUES_SORTED_INTERNAL.add(i, this); |