diff options
Diffstat (limited to 'src/main')
16 files changed, 475 insertions, 265 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java index f35d86218f..6437ad1087 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/WerkstoffAdderRegistry.java @@ -26,8 +26,8 @@ import java.util.HashSet; public final class WerkstoffAdderRegistry implements Runnable { - static final WerkstoffAdderRegistry INSTANCE = new WerkstoffAdderRegistry(); - final HashSet<Runnable> toRun = new HashSet<>(); + private static final WerkstoffAdderRegistry INSTANCE = new WerkstoffAdderRegistry(); + private final HashSet<Runnable> toRun = new HashSet<>(); private WerkstoffAdderRegistry() { } @@ -36,12 +36,12 @@ public final class WerkstoffAdderRegistry implements Runnable { return INSTANCE; } - public static void addWerkstoffAdder(Runnable adder) { + public static final void addWerkstoffAdder(Runnable adder) { INSTANCE.toRun.add(adder); } @Override - public void run() { + public final void run() { for (Runnable r : toRun) r.run(); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index f668e85b4f..7de924d625 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -35,6 +35,7 @@ import com.github.bartimaeusnek.bartworks.common.loaders.BioLabLoader; import com.github.bartimaeusnek.bartworks.common.loaders.GTNHBlocks; import com.github.bartimaeusnek.bartworks.common.loaders.LoaderRegistry; import com.github.bartimaeusnek.bartworks.common.net.BW_Network; +import com.github.bartimaeusnek.bartworks.system.log.DebugLog; import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; import com.github.bartimaeusnek.bartworks.util.BW_Util; @@ -60,6 +61,7 @@ import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.io.IOException; import java.util.HashSet; import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor.eicMap; @@ -99,6 +101,13 @@ public final class MainMod { GTNH = true; } CHandler = new ConfigHandler(preinit); + if (ConfigHandler.debugLog) { + try { + new DebugLog(preinit); + } catch (IOException e) { + e.printStackTrace(); + } + } if (GTNH) LOGGER.info("GTNH-Detected . . . ACTIVATE HARDMODE."); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java index 6cbca9b7ad..fc546fc980 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java @@ -65,7 +65,7 @@ public class BW_TileEntityContainer extends BlockContainer implements ITileAddsI @Override public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (worldObj.isRemote) { - return true; + return false; } final TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof BW_TileEntity_HeatedWaterPump) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java index 1539ec80ac..2321c5e413 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java @@ -43,6 +43,7 @@ public class ConfigHandler { public static int megaMachinesMax = 256; public static int mbWaterperSec = 150; private static boolean ezmode = false; + public static boolean debugLog = false; public ConfigHandler(@Nonnull FMLPreInitializationEvent e) { c = new Configuration(new File(e.getModConfigurationDirectory().toString() + "/" + MainMod.MOD_ID + ".cfg")); @@ -61,7 +62,7 @@ public class ConfigHandler { ConfigHandler.IDOffset = 12600; c.get("System", "ID Offset", 12600, "ID Offset for this mod. This Mod uses " + IDU + " IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS").set(12600); } - + debugLog=c.get("System","Enable Debug Log",false,"Enables or Disables the debug log.").getBoolean(false); if (c.hasChanged()) c.save(); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java new file mode 100644 index 0000000000..ba85a38e79 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2019 bartimaeusnek + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.github.bartimaeusnek.bartworks.system.log; + +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.logging.FileHandler; +import java.util.logging.Formatter; +import java.util.logging.LogRecord; +import java.util.logging.Logger; + +public class DebugLog { + private static boolean init = false; + private static FileHandler fh; + private static Logger utilLog; + public DebugLog(FMLPreInitializationEvent event) throws IOException { + if (init) + return; + fh = new FileHandler(new File(new File(event.getModConfigurationDirectory().getParentFile(),"logs"),"BWLog.log").toString()); + utilLog = Logger.getLogger("DebugLog"); + utilLog.setUseParentHandlers(false); + utilLog.addHandler(fh); + Formatter formatter = new Formatter() { + @Override + public String format(LogRecord record) { + SimpleDateFormat logTime = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); + Calendar cal = new GregorianCalendar(); + cal.setTimeInMillis(record.getMillis()); + return "Level: " + record.getLevel() + +" at " + logTime.format(cal.getTime()) + + " " + record.getMessage() + "\n"; + } + }; + fh.setFormatter(formatter); + init = true; + } + + public static void log(String record){ + if (!init) + return; + utilLog.info(record); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java index 862de3cd98..7b7d33fa3d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java @@ -27,7 +27,6 @@ import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java index 3ade8d123d..f732932eed 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -23,13 +23,9 @@ package com.github.bartimaeusnek.bartworks.system.material; import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; -import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.MurmurHash3; import com.github.bartimaeusnek.bartworks.util.Pair; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SubTag; -import gregtech.api.enums.TextureSet; +import gregtech.api.enums.*; import gregtech.api.interfaces.IColorModulationContainer; import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.util.GT_OreDictUnificator; @@ -41,61 +37,62 @@ import java.util.*; public class Werkstoff implements IColorModulationContainer, ISubTagContainer { - public static final LinkedHashSet<Werkstoff> werkstoffHashSet = new LinkedHashSet<>(); + static final LinkedHashSet<Werkstoff> werkstoffHashSet = new LinkedHashSet<>(); public static final LinkedHashMap<Short, Werkstoff> werkstoffHashMap = new LinkedHashMap<>(); private static final HashSet<Short> idHashSet = new HashSet<>(); - public static final Werkstoff.Stats DEFAULT_NULL_STATS = new Werkstoff.Stats(); - public static final GenerationFeatures DEFAULT_NULL_GENERATION_FEATURES = new GenerationFeatures(); + private static final Werkstoff.Stats DEFAULT_NULL_STATS = new Werkstoff.Stats(); + private static final Werkstoff.GenerationFeatures DEFAULT_NULL_GENERATION_FEATURES = new Werkstoff.GenerationFeatures().disable(); public static Werkstoff default_null_Werkstoff; private final List<ISubTagContainer> mOreByProducts = new ArrayList<ISubTagContainer>(); private final LinkedHashSet<Pair<ISubTagContainer, Integer>> contents = new LinkedHashSet<>(); HashSet<SubTag> subtags = new HashSet<>(); private byte[] rgb = new byte[3]; - private String defaultName; + private final String defaultName; private String toolTip; private Fluid fluid; private Fluid gas; + private Werkstoff.Stats stats; - private Werkstoff.Types type; - private GenerationFeatures generationFeatures; - private short mID; - private TextureSet texSet; + private final Werkstoff.Types type; + private final Werkstoff.GenerationFeatures generationFeatures; + private final short mID; + private final TextureSet texSet; public static void init(){ - default_null_Werkstoff = new Werkstoff(new short[3], "_NULL", "Default null Werkstoff", DEFAULT_NULL_STATS, Werkstoff.Types.UNDEFINED, DEFAULT_NULL_GENERATION_FEATURES, -1, TextureSet.SET_NONE); + Werkstoff.default_null_Werkstoff = new Werkstoff(new short[3], "_NULL", "Default null Werkstoff", Werkstoff.DEFAULT_NULL_STATS, Werkstoff.Types.UNDEFINED, Werkstoff.DEFAULT_NULL_GENERATION_FEATURES, -1, TextureSet.SET_NONE); } - public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair<ISubTagContainer, Integer>... contents) { + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair<ISubTagContainer, Integer>... contents) { this(rgba, defaultName, Werkstoff.Types.getDefaultStatForType(type), type, generationFeatures, mID, texSet, contents); } - public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { this(rgba, defaultName, Werkstoff.Types.getDefaultStatForType(type), type, generationFeatures, mID, texSet, oreByProduct, contents); } - public Werkstoff(short[] rgba, String toolTip, String defaultName, Werkstoff.Types type, GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + public Werkstoff(short[] rgba, String toolTip, String defaultName, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { this(rgba, toolTip, defaultName, Werkstoff.Types.getDefaultStatForType(type), type, generationFeatures, mID, texSet, oreByProduct, contents); } - public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { this(rgba, defaultName, "", stats, type, generationFeatures, mID, texSet, contents); this.mOreByProducts.addAll(oreByProduct); } - public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair<ISubTagContainer, Integer>... contents) { + public Werkstoff(short[] rgba, String defaultName, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair<ISubTagContainer, Integer>... contents) { this(rgba, defaultName, "", stats, type, generationFeatures, mID, texSet, contents); } - public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, List<ISubTagContainer> oreByProduct, Pair<ISubTagContainer, Integer>... contents) { this(rgba, defaultName, toolTip, stats, type, generationFeatures, mID, texSet, contents); this.mOreByProducts.addAll(oreByProduct); } - public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair<ISubTagContainer, Integer>... contents) { + public Werkstoff(short[] rgba, String defaultName, String toolTip, Werkstoff.Stats stats, Werkstoff.Types type, Werkstoff.GenerationFeatures generationFeatures, int mID, TextureSet texSet, Pair<ISubTagContainer, Integer>... contents) { - if (idHashSet.contains((short) mID)) + if (Werkstoff.idHashSet.contains((short) mID)) throw new UnsupportedOperationException("ID (" + mID + ") is already in use!"); - idHashSet.add((short) mID); + Werkstoff.idHashSet.add((short) mID); if (type == null) type = Werkstoff.Types.UNDEFINED; @@ -138,11 +135,38 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { this.stats = stats.setMass(tmpmass); this.texSet = texSet; - werkstoffHashSet.add(this); - werkstoffHashMap.put(this.mID, this); + Werkstoff.werkstoffHashSet.add(this); + Werkstoff.werkstoffHashMap.put(this.mID, this); } + public void setTCAspects(Pair<Object,Integer>... pAspectsArr){ + this.stats.mTC_Aspects=pAspectsArr; + } + + public Pair<Object,Integer>[] getTCAspects(int ratio){ + if (this.stats.mTC_Aspects == null) { + HashSet<TC_Aspects.TC_AspectStack> tc_aspectStacks = new HashSet<>(); + HashSet<Pair<Object, Integer>> set = new HashSet<>(); + for (Pair p : this.getContents().getValue()) { + if (p.getKey() instanceof Materials) + tc_aspectStacks.addAll(((Materials) p.getKey()).mAspects); + if (p.getKey() instanceof Werkstoff) + set.addAll(Arrays.asList(((Werkstoff) p.getKey()).getTCAspects())); + } + tc_aspectStacks.forEach(tc_aspectStack -> set.add(new Pair<Object, Integer>(tc_aspectStack.mAspect.mAspect, (int) tc_aspectStack.mAmount))); + this.stats.mTC_Aspects = set.toArray(new Pair[0]); + } + Pair<Object,Integer>[] ret = this.stats.mTC_Aspects.clone(); + for (int i = 0; i < ret.length; i++) { + ret[i]=ret[i].copyWithNewValue(ret[i].getValue() * ratio); + } + return ret; + } + + public Pair<Object,Integer>[] getTCAspects(){ + return getTCAspects(1); + } public Werkstoff.Types getType() { return this.type; @@ -153,8 +177,8 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { switch (this.type) { case COMPOUND: case BIOLOGICAL: { - for (int i = 0; i < contents.toArray().length; i++) { - ret += ((Pair<ISubTagContainer, Integer>) contents.toArray()[i]).getValue(); + for (int i = 0; i < this.contents.toArray().length; i++) { + ret += ((Pair<ISubTagContainer, Integer>) this.contents.toArray()[i]).getValue(); } break; } @@ -166,31 +190,31 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { } public int getNoOfByProducts() { - return mOreByProducts.size(); + return this.mOreByProducts.size(); } public ISubTagContainer getOreByProductRaw(int aNumber){ - if (mOreByProducts.size() == 0) + if (this.mOreByProducts.size() == 0) return null; if (aNumber < 0) - aNumber = mOreByProducts.size() + aNumber; - while (aNumber >= mOreByProducts.size()) + aNumber = this.mOreByProducts.size() + aNumber; + while (aNumber >= this.mOreByProducts.size()) aNumber--; - ISubTagContainer o = mOreByProducts.get(aNumber); - if (o == null || o.equals(default_null_Werkstoff) || o.equals(Materials._NULL)) + ISubTagContainer o = this.mOreByProducts.get(aNumber); + if (o == null || o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) return this; return o; } public ItemStack getOreByProduct(int aNumber, OrePrefixes prefixes) { - if (mOreByProducts.size() == 0) + if (this.mOreByProducts.size() == 0) return null; if (aNumber < 0) - aNumber = mOreByProducts.size() + aNumber; - while (aNumber >= mOreByProducts.size()) + aNumber = this.mOreByProducts.size() + aNumber; + while (aNumber >= this.mOreByProducts.size()) aNumber--; - Object o = mOreByProducts.get(aNumber); - if (o == null||o.equals(default_null_Werkstoff) || o.equals(Materials._NULL)) + Object o = this.mOreByProducts.get(aNumber); + if (o == null||o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) return this.get(prefixes); if (o instanceof Werkstoff) return WerkstoffLoader.getCorresopndingItemStack(prefixes, (Werkstoff) o); @@ -215,7 +239,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { return this.mID; } - public GenerationFeatures getGenerationFeatures() { + public Werkstoff.GenerationFeatures getGenerationFeatures() { return this.generationFeatures; } @@ -229,28 +253,30 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { @Override public short[] getRGBA() { - return new short[]{(short) (rgb[0] + 128), (short) (rgb[1] + 128), (short) (rgb[2] + 128), 0}; + return new short[]{(short) (this.rgb[0] + 128), (short) (this.rgb[1] + 128), (short) (this.rgb[2] + 128), 0}; } @Override public boolean contains(SubTag subTag) { - for (Pair<ISubTagContainer, Integer> p : contents) + for (Pair<ISubTagContainer, Integer> p : this.contents) if (p.getKey().contains(subTag)) return true; - if (subtags.contains(subTag)) - return true; - return false; + return this.subtags.contains(subTag); } @Override public ISubTagContainer add(SubTag... subTags) { - subtags.addAll(Arrays.asList(subTags)); + this.subtags.addAll(Arrays.asList(subTags)); return this; } @Override public boolean remove(SubTag subTag) { - return subtags.remove(subTag); + return this.subtags.remove(subTag); + } + + public void getAndAddToCollection(OrePrefixes prefixes,int amount,Collection<ItemStack> stacks){ + stacks.add(this.get(prefixes,amount)); } public ItemStack get(OrePrefixes prefixes) { @@ -264,15 +290,15 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { public enum Types { MATERIAL, COMPOUND, MIXTURE, BIOLOGICAL, ELEMENT, UNDEFINED; - public static Stats getDefaultStatForType(Werkstoff.Types T) { + public static Werkstoff.Stats getDefaultStatForType(Werkstoff.Types T) { switch (T) { case COMPOUND: case BIOLOGICAL: - return new Stats().setElektrolysis(true); + return new Werkstoff.Stats().setElektrolysis(true); case MIXTURE: - return new Stats().setCentrifuge(true); + return new Werkstoff.Stats().setCentrifuge(true); default: - return new Stats(); + return new Werkstoff.Stats(); } } } @@ -286,40 +312,40 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { ore 1000 */ public byte toGenerate = 0b0001001; - public byte blacklist = 0b0000000; + public byte blacklist; - public GenerationFeatures setBlacklist(OrePrefixes p){ + public Werkstoff.GenerationFeatures setBlacklist(OrePrefixes p){ if (p == OrePrefixes.dustTiny || p == OrePrefixes.dust || p == OrePrefixes.dustSmall || p == OrePrefixes.crateGtDust){ - blacklist |= 1; + this.blacklist |= 1; }else - blacklist |= p.mMaterialGenerationBits; + this.blacklist |= p.mMaterialGenerationBits; return this; } public boolean hasDusts() { - return (toGenerate & 0b1) != 0; + return (this.toGenerate & 0b1) != 0; } public boolean hasGems() { - return (toGenerate & 0b100) != 0; + return (this.toGenerate & 0b100) != 0; } public boolean hasOres() { - return (toGenerate & 0b1000) != 0; + return (this.toGenerate & 0b1000) != 0; } - public GenerationFeatures removeGems(){ - if (hasGems()) - toGenerate = (byte) (toGenerate ^ 0b100); + public Werkstoff.GenerationFeatures removeGems(){ + if (this.hasGems()) + this.toGenerate = (byte) (this.toGenerate ^ 0b100); return this; } - public GenerationFeatures removeDusts(){ - if (hasDusts()) - toGenerate = (byte) (toGenerate ^ 0b1); + public Werkstoff.GenerationFeatures removeDusts(){ + if (this.hasDusts()) + this.toGenerate = (byte) (this.toGenerate ^ 0b1); return this; } - public GenerationFeatures removeOres(){ - if (hasOres()) - toGenerate = (byte) (toGenerate ^ 0b1000); + public Werkstoff.GenerationFeatures removeOres(){ + if (this.hasOres()) + this.toGenerate = (byte) (this.toGenerate ^ 0b1000); return this; } /* @@ -327,37 +353,37 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { * Auto add mixer Recipes 10 * Auto add Sifter Recipe 100 */ - public byte extraRecipes = 0b0; + public byte extraRecipes; - public GenerationFeatures addChemicalRecipes(){ + public Werkstoff.GenerationFeatures addChemicalRecipes(){ this.extraRecipes = (byte) (this.extraRecipes | 1); return this; } public boolean hasChemicalRecipes() { - return (extraRecipes & 1) != 0; + return (this.extraRecipes & 1) != 0; } - public GenerationFeatures addSifterRecipes(){ + public Werkstoff.GenerationFeatures addSifterRecipes(){ this.extraRecipes = (byte) (this.extraRecipes | 100); return this; } public boolean hasSifterRecipes() { - return (extraRecipes & 100) != 0; + return (this.extraRecipes & 100) != 0; } - public GenerationFeatures onlyDust() { - toGenerate = (byte) (1); + public Werkstoff.GenerationFeatures onlyDust() { + this.toGenerate = (byte) (1); return this; } - public GenerationFeatures disable() { - toGenerate = (byte) (0); + public Werkstoff.GenerationFeatures disable() { + this.toGenerate = (byte) (0); return this; } - public GenerationFeatures addGems() { - toGenerate = (byte) (toGenerate | 0x4); + public Werkstoff.GenerationFeatures addGems() { + this.toGenerate = (byte) (this.toGenerate | 0x4); return this; } @@ -372,9 +398,24 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { long neutrons; long electrons; long mass; + private Pair<Object,Integer>[] mTC_Aspects; //logic gate shit byte quality = ~0b111111; + public Stats setmTC_AspectsArray(Pair<Object, Integer>[] mTC_Aspects) { + this.mTC_Aspects = mTC_Aspects; + return this; + } + + public Stats setmTC_AspectsVarArg(Pair<Object, Integer>... mTC_Aspects) { + this.mTC_Aspects = mTC_Aspects; + return this; + } + + Pair<Object, Integer>[] getmTC_Aspects() { + return this.mTC_Aspects; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -393,88 +434,88 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { @Override public int hashCode() { - return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(49).put(quality).putInt(boilingPoint).putInt(meltingPoint).putLong(protons).putLong(neutrons).putLong(electrons).putLong(mass).array(), 0, 49, 31); + return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(49).put(this.quality).putInt(this.boilingPoint).putInt(this.meltingPoint).putLong(this.protons).putLong(this.neutrons).putLong(this.electrons).putLong(this.mass).array(), 0, 49, 31); } - public Stats setMass(long mass) { - this.mass = protons; + public Werkstoff.Stats setMass(long mass) { + this.mass = this.protons; return this; } - public Stats setProtons(long protons) { + public Werkstoff.Stats setProtons(long protons) { this.protons = protons; return this; } public boolean isSublimation() { - return (quality & 0b1) == 0b1; + return (this.quality & 0b1) == 0b1; } public Werkstoff.Stats setSublimation(boolean sublimation) { if (sublimation) - quality = (byte) (quality | 0b000001); + this.quality = (byte) (this.quality | 0b000001); else - quality = (byte) (quality & 0b111110); + this.quality = (byte) (this.quality & 0b111110); return this; } public boolean isToxic() { - return (quality >> 1 & 0b1) == 0b1; + return (this.quality >> 1 & 0b1) == 0b1; } public Werkstoff.Stats setToxic(boolean toxic) { if (toxic) - quality = (byte) (quality | 0b000010); + this.quality = (byte) (this.quality | 0b000010); else - quality = (byte) (quality & 0b111101); + this.quality = (byte) (this.quality & 0b111101); return this; } public boolean isRadioactive() { - return (quality >> 2 & 0b1) == 0b1; + return (this.quality >> 2 & 0b1) == 0b1; } public Werkstoff.Stats setRadioactive(boolean radioactive) { if (radioactive) - quality = (byte) (quality | 0b000100); + this.quality = (byte) (this.quality | 0b000100); else - quality = (byte) (quality & 0b111011); + this.quality = (byte) (this.quality & 0b111011); return this; } public boolean isBlastFurnace() { - return (quality >> 3 & 0b1) == 0b1; + return (this.quality >> 3 & 0b1) == 0b1; } public Werkstoff.Stats setBlastFurnace(boolean blastFurnace) { if (blastFurnace) - quality = (byte) (quality | 0b001000); + this.quality = (byte) (this.quality | 0b001000); else - quality = (byte) (quality & 0b110111); + this.quality = (byte) (this.quality & 0b110111); return this; } public boolean isElektrolysis() { - return (quality >> 4 & 0b1) == 0b1; + return (this.quality >> 4 & 0b1) == 0b1; } public Werkstoff.Stats setElektrolysis(boolean elektrolysis) { if (elektrolysis) - quality = (byte) (quality | 0b010000); + this.quality = (byte) (this.quality | 0b010000); else - quality = (byte) (quality & 0b101111); + this.quality = (byte) (this.quality & 0b101111); return this; } public boolean isCentrifuge() { - return (quality >> 5 & 0b1) == 0b1; + return (this.quality >> 5 & 0b1) == 0b1; } public Werkstoff.Stats setCentrifuge(boolean centrifuge) { if (centrifuge) - quality = (byte) (quality | 0b100000); + this.quality = (byte) (this.quality | 0b100000); else - quality = (byte) (quality & 0b011111); + this.quality = (byte) (this.quality & 0b011111); return this; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java index ebb7242ebd..18ea765786 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -25,10 +25,11 @@ package com.github.bartimaeusnek.bartworks.system.material; import com.github.bartimaeusnek.bartworks.API.WerkstoffAdderRegistry; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; +import com.github.bartimaeusnek.bartworks.system.log.DebugLog; import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.AdditionalRecipes; import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; -import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; @@ -40,7 +41,6 @@ import gregtech.api.enums.*; import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.objects.GT_MultiTexture; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.objects.MaterialStack; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; @@ -50,7 +50,10 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; import static gregtech.api.enums.OrePrefixes.*; @@ -103,8 +106,8 @@ public class WerkstoffLoader implements Runnable { new Werkstoff.GenerationFeatures().onlyDust().addGems(), 4, TextureSet.SET_DIAMOND, - Arrays.asList(WerkstoffLoader.Zirconium), - new Pair<ISubTagContainer, Integer>(WerkstoffLoader.Zirconium, 1), + Arrays.asList(Zirconium), + new Pair<ISubTagContainer, Integer>(Zirconium, 1), new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 2) ); public static final Werkstoff FluorBuergerit = new Werkstoff( @@ -300,8 +303,8 @@ public class WerkstoffLoader implements Runnable { new Werkstoff.GenerationFeatures().addGems(), 19, TextureSet.SET_GEM_VERTICAL, - Arrays.asList(WerkstoffLoader.Zirconium,Materials.Silicon), - new Pair<ISubTagContainer, Integer>(WerkstoffLoader.Zirconium, 1), + Arrays.asList(Zirconium,Materials.Silicon), + new Pair<ISubTagContainer, Integer>(Zirconium, 1), new Pair<ISubTagContainer, Integer>(Materials.Silicon, 1), new Pair<ISubTagContainer, Integer>(Materials.Oxygen, 4) ); @@ -443,15 +446,12 @@ public class WerkstoffLoader implements Runnable { ); - - - public static HashMap<OrePrefixes, BW_MetaGenerated_Items> items = new HashMap<>(); public static Block BWOres; - public boolean registered = false; + public boolean registered; public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { - return getCorresopndingItemStack(orePrefixes, werkstoff, 1); + return WerkstoffLoader.getCorresopndingItemStack(orePrefixes, werkstoff, 1); } public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { @@ -459,12 +459,12 @@ public class WerkstoffLoader implements Runnable { if (ret != null) return ret; if (orePrefixes == ore) - return new ItemStack(BWOres, amount, werkstoff.getmID()); - return new ItemStack(items.get(orePrefixes), amount, werkstoff.getmID()).copy(); + return new ItemStack(WerkstoffLoader.BWOres, amount, werkstoff.getmID()); + return new ItemStack(WerkstoffLoader.items.get(orePrefixes), amount, werkstoff.getmID()).copy(); } public void init() { - if (INSTANCE == null) + if (WerkstoffLoader.INSTANCE == null) MainMod.LOGGER.error("INSTANCE IS NULL THIS SHOULD NEVER HAPPEN!"); } @@ -472,30 +472,42 @@ public class WerkstoffLoader implements Runnable { MainMod.LOGGER.info("Making Meta Items for BW Materials"); long timepre = System.nanoTime(); WerkstoffAdderRegistry.getINSTANCE().run(); - addSubTags(); - addItemsForGeneration(); - runAdditionalOreDict(); + this.addSubTags(); + this.addItemsForGeneration(); + this.runAdditionalOreDict(); long timepost = System.nanoTime(); MainMod.LOGGER.info("Making Meta Items for BW Materials took " + (timepost - timepre) + "ns/" + ((timepost - timepre) / 1000000) + "ms/" + ((timepost - timepre) / 1000000000) + "s!"); } @Override public void run() { - if (!registered) { + if (!this.registered) { MainMod.LOGGER.info("Loading Processing Recipes for BW Materials"); long timepre = System.nanoTime(); ProgressManager.ProgressBar progressBar = ProgressManager.push("Register BW Materials", Werkstoff.werkstoffHashMap.size()+1); - + DebugLog.log("Loading Recipes"+(System.nanoTime()-timepre)); for (short i = 0; i < Werkstoff.werkstoffHashMap.size(); i++) { + long timepreone = System.nanoTime(); Werkstoff werkstoff = Werkstoff.werkstoffHashMap.get(i); + DebugLog.log("Werkstoff is null or id < 0 ? "+ (werkstoff==null || werkstoff.getmID() < 0) + " " + (System.nanoTime()-timepreone)); if (werkstoff == null || werkstoff.getmID() < 0) { progressBar.step(""); continue; } - addDustRecipes(werkstoff); - addGemRecipes(werkstoff); - addOreRecipes(werkstoff); - addCrushedRecipes(werkstoff); + DebugLog.log("Werkstoff: "+ werkstoff.getDefaultName() +" " +(System.nanoTime()-timepreone)); + DebugLog.log("Loading Dusts Recipes"+" " +(System.nanoTime()-timepreone)); + this.addDustRecipes(werkstoff); + DebugLog.log("Loading Gem Recipes"+" " +(System.nanoTime()-timepreone)); + this.addGemRecipes(werkstoff); + DebugLog.log("Loading Ore Recipes"+" " +(System.nanoTime()-timepreone)); + this.addOreRecipes(werkstoff); + DebugLog.log("Loading Crushed Recipes"+" " +(System.nanoTime()-timepreone)); + this.addCrushedRecipes(werkstoff); + if (Loader.isModLoaded("Thaumcraft")) { + DebugLog.log("Loading Aspects"+" " +(System.nanoTime()-timepreone)); + ThaumcraftHandler.AspectAdder.addAspectToAll(werkstoff); + } + DebugLog.log("Done"+" " +(System.nanoTime()-timepreone)); progressBar.step(werkstoff.getDefaultName()); } progressBar.step("Load Additional Recipes"); @@ -503,7 +515,7 @@ public class WerkstoffLoader implements Runnable { ProgressManager.pop(progressBar); long timepost = System.nanoTime(); MainMod.LOGGER.info("Loading Processing Recipes for BW Materials took " + (timepost - timepre) + "ns/" + ((timepost - timepre) / 1000000) + "ms/" + ((timepost - timepre) / 1000000000) + "s!"); - registered = true; + this.registered = true; } } @@ -511,13 +523,13 @@ public class WerkstoffLoader implements Runnable { for (Werkstoff W : Werkstoff.werkstoffHashMap.values()) { for (Pair<ISubTagContainer, Integer> pair : W.getContents().getValue().toArray(new Pair[0])) { - if (pair.getKey() instanceof Materials && ((Materials) pair.getKey()) == Materials.Neodymium) { + if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Neodymium) { W.add(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM); break; - } else if (pair.getKey() instanceof Materials && ((Materials) pair.getKey()) == Materials.Iron) { + } else if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Iron) { W.add(SubTag.ELECTROMAGNETIC_SEPERATION_IRON); break; - } else if (pair.getKey() instanceof Materials && ((Materials) pair.getKey()) == Materials.Gold) { + } else if (pair.getKey() instanceof Materials && pair.getKey() == Materials.Gold) { W.add(SubTag.ELECTROMAGNETIC_SEPERATION_GOLD); break; } @@ -533,7 +545,7 @@ public class WerkstoffLoader implements Runnable { int toGenerateGlobal = 0b0000000; for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { - for (OrePrefixes p : OrePrefixes.values()) + for (OrePrefixes p : values()) if ((werkstoff.getGenerationFeatures().toGenerate & p.mMaterialGenerationBits) != 0 && OreDictHandler.getItemStack(werkstoff.getDefaultName(),p,1) != null) { MainMod.LOGGER.info("Found: "+(p+werkstoff.getDefaultName().replaceAll(" ",""))+" in oreDict, disable and reroute my Items to that, also add a Tooltip."); werkstoff.getGenerationFeatures().setBlacklist(p); @@ -542,34 +554,34 @@ public class WerkstoffLoader implements Runnable { } if ((toGenerateGlobal & 0b1) != 0) { - items.put(dust, new BW_MetaGenerated_Items(dust)); - items.put(dustTiny, new BW_MetaGenerated_Items(dustTiny)); - items.put(dustSmall, new BW_MetaGenerated_Items(dustSmall)); + WerkstoffLoader.items.put(dust, new BW_MetaGenerated_Items(dust)); + WerkstoffLoader.items.put(dustTiny, new BW_MetaGenerated_Items(dustTiny)); + WerkstoffLoader.items.put(dustSmall, new BW_MetaGenerated_Items(dustSmall)); } if ((toGenerateGlobal & 0b10) != 0) { - items.put(ingot, new BW_MetaGenerated_Items(ingot)); + WerkstoffLoader.items.put(ingot, new BW_MetaGenerated_Items(ingot)); } if ((toGenerateGlobal & 0b100) != 0) { - items.put(gem, new BW_MetaGenerated_Items(gem)); - items.put(gemChipped, new BW_MetaGenerated_Items(gemChipped)); - items.put(gemExquisite, new BW_MetaGenerated_Items(gemExquisite)); - items.put(gemFlawed, new BW_MetaGenerated_Items(gemFlawed)); - items.put(gemFlawless, new BW_MetaGenerated_Items(gemFlawless)); - items.put(lens,new BW_MetaGenerated_Items(lens)); + WerkstoffLoader.items.put(gem, new BW_MetaGenerated_Items(gem)); + WerkstoffLoader.items.put(gemChipped, new BW_MetaGenerated_Items(gemChipped)); + WerkstoffLoader.items.put(gemExquisite, new BW_MetaGenerated_Items(gemExquisite)); + WerkstoffLoader.items.put(gemFlawed, new BW_MetaGenerated_Items(gemFlawed)); + WerkstoffLoader.items.put(gemFlawless, new BW_MetaGenerated_Items(gemFlawless)); + WerkstoffLoader.items.put(lens,new BW_MetaGenerated_Items(lens)); } if ((toGenerateGlobal & 0b1000) != 0) { if (FMLCommonHandler.instance().getSide().isClient()) RenderingRegistry.registerBlockHandler(BW_Renderer_Block_Ores.INSTANCE); GameRegistry.registerTileEntity(BW_MetaGeneratedOreTE.class, "bw.blockoresTE"); - BWOres = new BW_MetaGenerated_Ores(Material.rock, BW_MetaGeneratedOreTE.class, "bw.blockores"); - GameRegistry.registerBlock(BWOres, BW_MetaGeneratedOre_Item.class, "bw.blockores.01"); - - items.put(crushed, new BW_MetaGenerated_Items(crushed)); - items.put(crushedPurified, new BW_MetaGenerated_Items(crushedPurified)); - items.put(crushedCentrifuged, new BW_MetaGenerated_Items(crushedCentrifuged)); - items.put(dustPure, new BW_MetaGenerated_Items(dustPure)); - items.put(dustImpure, new BW_MetaGenerated_Items(dustImpure)); + WerkstoffLoader.BWOres = new BW_MetaGenerated_Ores(Material.rock, BW_MetaGeneratedOreTE.class, "bw.blockores"); + GameRegistry.registerBlock(WerkstoffLoader.BWOres, BW_MetaGeneratedOre_Item.class, "bw.blockores.01"); + + WerkstoffLoader.items.put(crushed, new BW_MetaGenerated_Items(crushed)); + WerkstoffLoader.items.put(crushedPurified, new BW_MetaGenerated_Items(crushedPurified)); + WerkstoffLoader.items.put(crushedCentrifuged, new BW_MetaGenerated_Items(crushedCentrifuged)); + WerkstoffLoader.items.put(dustPure, new BW_MetaGenerated_Items(dustPure)); + WerkstoffLoader.items.put(dustImpure, new BW_MetaGenerated_Items(dustImpure)); } } @@ -581,21 +593,21 @@ public class WerkstoffLoader implements Runnable { OreDictionary.registerOre("craftingLens" + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""), werkstoff.get(lens)); } - GT_OreDictUnificator.registerOre("craftingIndustrialDiamond",Zirconia.get(gemExquisite)); + GT_OreDictUnificator.registerOre("craftingIndustrialDiamond", WerkstoffLoader.Zirconia.get(gemExquisite)); } private void addGemRecipes(Werkstoff werkstoff) { if (werkstoff.getGenerationFeatures().hasGems()) { if (werkstoff.getGenerationFeatures().hasSifterRecipes() || ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0 && (werkstoff.getGenerationFeatures().toGenerate & 0b1) != 0)) { GT_Values.RA.addSifterRecipe( - getCorresopndingItemStack(crushedPurified, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(crushedPurified, werkstoff), new ItemStack[]{ - getCorresopndingItemStack(gemExquisite, werkstoff), - getCorresopndingItemStack(gemFlawless, werkstoff), - getCorresopndingItemStack(gem, werkstoff), - getCorresopndingItemStack(gemFlawed, werkstoff), - getCorresopndingItemStack(gemChipped, werkstoff), - getCorresopndingItemStack(dust, werkstoff) + WerkstoffLoader.getCorresopndingItemStack(gemExquisite, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(gemFlawless, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(gem, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(gemFlawed, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(gemChipped, werkstoff), + WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) }, new int[]{ 100, 400, 1500, 2000, 4000, 5000 @@ -621,12 +633,12 @@ public class WerkstoffLoader implements Runnable { GT_Values.RA.addForgeHammerRecipe(werkstoff.get(gemFlawed), werkstoff.get(gemChipped, 2), 64, 16); GT_Values.RA.addForgeHammerRecipe(werkstoff.get(gemChipped), werkstoff.get(dustTiny), 64, 16); - GT_Values.RA.addImplosionRecipe(werkstoff.get(gemFlawless, 3), 8, werkstoff.get(gemExquisite), GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2)); - GT_Values.RA.addImplosionRecipe(werkstoff.get(gem, 3), 8, werkstoff.get(gemFlawless), GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2)); - GT_Values.RA.addImplosionRecipe(werkstoff.get(gemFlawed, 3), 8, werkstoff.get(gem), GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2)); - GT_Values.RA.addImplosionRecipe(werkstoff.get(gemChipped, 3), 8, werkstoff.get(gemFlawed), GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 2)); + GT_Values.RA.addImplosionRecipe(werkstoff.get(gemFlawless, 3), 8, werkstoff.get(gemExquisite), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)); + GT_Values.RA.addImplosionRecipe(werkstoff.get(gem, 3), 8, werkstoff.get(gemFlawless), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)); + GT_Values.RA.addImplosionRecipe(werkstoff.get(gemFlawed, 3), 8, werkstoff.get(gem), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)); + GT_Values.RA.addImplosionRecipe(werkstoff.get(gemChipped, 3), 8, werkstoff.get(gemFlawed), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 2)); - GT_Values.RA.addImplosionRecipe(werkstoff.get(dust, 4), 24, werkstoff.get(gem, 3), GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 8)); + GT_Values.RA.addImplosionRecipe(werkstoff.get(dust, 4), 24, werkstoff.get(gem, 3), GT_OreDictUnificator.get(dustTiny, Materials.DarkAsh, 8)); if ((werkstoff.getGenerationFeatures().toGenerate & 2) != 0){ GT_Values.RA.addLatheRecipe(werkstoff.get(plate),werkstoff.get(lens),werkstoff.get(dustSmall), 1200, 120); @@ -697,12 +709,12 @@ public class WerkstoffLoader implements Runnable { } } } - ItemStack input = getCorresopndingItemStack(dust, werkstoff); + ItemStack input = WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff); input.stackSize = werkstoff.getContents().getKey(); if (werkstoff.getStats().isElektrolysis()) - GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.addRecipe(true, new ItemStack[]{input, cells > 0 ? Materials.Empty.getCells(cells) : null}, stOutputs.toArray(new ItemStack[0]), (Object) null, null, new FluidStack[]{null}, new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null}, (int) Math.max(1L, Math.abs(werkstoff.getStats().protons * werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 30, 0); + GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.addRecipe(true, new ItemStack[]{input, cells > 0 ? Materials.Empty.getCells(cells) : null}, stOutputs.toArray(new ItemStack[0]), null, null, new FluidStack[]{null}, new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null}, (int) Math.max(1L, Math.abs(werkstoff.getStats().protons * werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 30, 0); if (werkstoff.getStats().isCentrifuge()) - GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe(true, new ItemStack[]{input, cells > 0 ? Materials.Empty.getCells(cells) : null}, stOutputs.toArray(new ItemStack[0]), (Object) null, null, new FluidStack[]{null}, new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null}, (int) Math.max(1L, Math.abs(werkstoff.getStats().mass * werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 5, 0); + GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe(true, new ItemStack[]{input, cells > 0 ? Materials.Empty.getCells(cells) : null}, stOutputs.toArray(new ItemStack[0]), null, null, new FluidStack[]{null}, new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null}, (int) Math.max(1L, Math.abs(werkstoff.getStats().mass * werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 5, 0); if (werkstoff.getGenerationFeatures().hasChemicalRecipes()) { if (cells > 0) stOutputs.add(Materials.Empty.getCells(cells)); @@ -710,31 +722,31 @@ public class WerkstoffLoader implements Runnable { } } - GT_ModHandler.addCraftingRecipe(getCorresopndingItemStack(dust, werkstoff), new Object[]{ + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), new Object[]{ "TTT","TTT","TTT",'T', - getCorresopndingItemStack(dustTiny, werkstoff) + WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff) }); - GT_ModHandler.addCraftingRecipe(getCorresopndingItemStack(dust, werkstoff), new Object[]{ + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), new Object[]{ "TT ","TT ",'T', - getCorresopndingItemStack(dustSmall, werkstoff) + WerkstoffLoader.getCorresopndingItemStack(dustSmall, werkstoff) }); - GT_ModHandler.addCraftingRecipe(getCorresopndingItemStack(dustSmall, werkstoff, 4), new Object[]{ - " T ", 'T', getCorresopndingItemStack(dust, werkstoff) + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustSmall, werkstoff, 4), new Object[]{ + " T ", 'T', WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) }); - GT_ModHandler.addCraftingRecipe(getCorresopndingItemStack(dustTiny, werkstoff, 9), new Object[]{ - "T ", 'T', getCorresopndingItemStack(dust, werkstoff) + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff, 9), new Object[]{ + "T ", 'T', WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) }); if ((werkstoff.getGenerationFeatures().toGenerate & 2) != 0 && !werkstoff.getStats().isBlastFurnace()) { - GT_ModHandler.addSmeltingRecipe(getCorresopndingItemStack(dust, werkstoff), getCorresopndingItemStack(ingot, werkstoff)); - GT_ModHandler.addSmeltingRecipe(getCorresopndingItemStack(dustTiny, werkstoff), getCorresopndingItemStack(nugget, werkstoff)); + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), WerkstoffLoader.getCorresopndingItemStack(ingot, werkstoff)); + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff), WerkstoffLoader.getCorresopndingItemStack(nugget, werkstoff)); } } } private void addOreRecipes(Werkstoff werkstoff) { if ((werkstoff.getGenerationFeatures().toGenerate & 2) != 0 && !werkstoff.getStats().isBlastFurnace()) - GT_ModHandler.addSmeltingRecipe(getCorresopndingItemStack(ore, werkstoff), getCorresopndingItemStack(ingot, werkstoff)); + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(ore, werkstoff), WerkstoffLoader.getCorresopndingItemStack(ingot, werkstoff)); if ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0) { GT_Values.RA.addForgeHammerRecipe(werkstoff.get(ore), werkstoff.getGenerationFeatures().hasGems() ? werkstoff.get(gem) : werkstoff.get(crushed), 16, 10); @@ -759,8 +771,8 @@ public class WerkstoffLoader implements Runnable { GT_Values.RA.addForgeHammerRecipe(werkstoff.get(crushed), werkstoff.get(dustImpure), 10, 16); GT_ModHandler.addPulverisationRecipe(werkstoff.get(crushed), werkstoff.get(dustImpure), werkstoff.getOreByProduct(0, dust), 10, false); - GT_ModHandler.addOreWasherRecipe(werkstoff.get(crushed), 1000, werkstoff.get(crushedPurified), werkstoff.getOreByProduct(0, dustTiny), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L)); - GT_ModHandler.addThermalCentrifugeRecipe(werkstoff.get(crushed), (int) Math.min(5000L, Math.abs(werkstoff.getStats().protons * 20L)), werkstoff.get(crushedCentrifuged), werkstoff.getOreByProduct(1, dustTiny), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L)); + GT_ModHandler.addOreWasherRecipe(werkstoff.get(crushed), 1000, werkstoff.get(crushedPurified), werkstoff.getOreByProduct(0, dustTiny), GT_OreDictUnificator.get(dust, Materials.Stone, 1L)); + GT_ModHandler.addThermalCentrifugeRecipe(werkstoff.get(crushed), (int) Math.min(5000L, Math.abs(werkstoff.getStats().protons * 20L)), werkstoff.get(crushedCentrifuged), werkstoff.getOreByProduct(1, dustTiny), GT_OreDictUnificator.get(dust, Materials.Stone, 1L)); GT_Values.RA.addForgeHammerRecipe(werkstoff.get(crushedPurified), werkstoff.get(dustPure), 10, 16); GT_ModHandler.addPulverisationRecipe(werkstoff.get(crushedPurified), werkstoff.get(dustPure), werkstoff.getOreByProduct(1, dust), 10, false); @@ -779,15 +791,15 @@ public class WerkstoffLoader implements Runnable { GT_Values.RA.addAutoclaveRecipe(werkstoff.get(dustImpure), gregtech.api.util.GT_ModHandler.getDistilledWater(200L), werkstoff.get(gem), 9500, 1500, 24); } if (werkstoff.contains(SubTag.WASHING_MERCURY)) - GT_Values.RA.addChemicalBathRecipe(werkstoff.get(crushed), Materials.Mercury.getFluid(1000L), werkstoff.get(crushedPurified), werkstoff.getOreByProduct(1, dust), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L), new int[]{10000, 7000, 4000}, 800, 8); + GT_Values.RA.addChemicalBathRecipe(werkstoff.get(crushed), Materials.Mercury.getFluid(1000L), werkstoff.get(crushedPurified), werkstoff.getOreByProduct(1, dust), GT_OreDictUnificator.get(dust, Materials.Stone, 1L), new int[]{10000, 7000, 4000}, 800, 8); if (werkstoff.contains(SubTag.WASHING_SODIUMPERSULFATE)) - GT_Values.RA.addChemicalBathRecipe(werkstoff.get(crushed), Materials.SodiumPersulfate.getFluid(GT_Mod.gregtechproxy.mDisableOldChemicalRecipes ? 1000L : 100L), werkstoff.get(crushedPurified), werkstoff.getOreByProduct(1, dust), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Stone, 1L), new int[]{10000, 7000, 4000}, 800, 8); + GT_Values.RA.addChemicalBathRecipe(werkstoff.get(crushed), Materials.SodiumPersulfate.getFluid(GT_Mod.gregtechproxy.mDisableOldChemicalRecipes ? 1000L : 100L), werkstoff.get(crushedPurified), werkstoff.getOreByProduct(1, dust), GT_OreDictUnificator.get(dust, Materials.Stone, 1L), new int[]{10000, 7000, 4000}, 800, 8); if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_GOLD)) - GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Gold, 1L), GT_OreDictUnificator.get(OrePrefixes.nugget, Materials.Gold, 1L), new int[]{10000, 4000, 2000}, 400, 24); + GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(dustSmall, Materials.Gold, 1L), GT_OreDictUnificator.get(nugget, Materials.Gold, 1L), new int[]{10000, 4000, 2000}, 400, 24); else if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_IRON)) - GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Iron, 1L), GT_OreDictUnificator.get(OrePrefixes.nugget, Materials.Iron, 1L), new int[]{10000, 4000, 2000}, 400, 24); + GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(dustSmall, Materials.Iron, 1L), GT_OreDictUnificator.get(nugget, Materials.Iron, 1L), new int[]{10000, 4000, 2000}, 400, 24); else if (werkstoff.contains(SubTag.ELECTROMAGNETIC_SEPERATION_NEODYMIUM)) - GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Neodymium, 1L), GT_OreDictUnificator.get(OrePrefixes.nugget, Materials.Neodymium, 1L), new int[]{10000, 4000, 2000}, 400, 24); + GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(dustSmall, Materials.Neodymium, 1L), GT_OreDictUnificator.get(nugget, Materials.Neodymium, 1L), new int[]{10000, 4000, 2000}, 400, 24); } }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java index 4196a9eadc..acc6da7b14 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/Pair.java @@ -34,7 +34,6 @@ public class Pair<A, B> implements Map.Entry { this.pair = pair; } - public Pair(A k, B v) { this.pair[0] = k; this.pair[1] = v; @@ -71,4 +70,13 @@ public class Pair<A, B> implements Map.Entry { pair[1] = value; return (B) pair[1]; } + + public Pair<A,B> copyWithNewValue(B value){ + return new Pair<>((A)this.pair[0],value); + } + + public Pair<A,B> replaceValue(B value){ + this.setValue(value); + return this; + } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java index c3c7f7d3e6..505350d401 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java @@ -22,7 +22,7 @@ package com.github.bartimaeusnek.crossmod.galacticraft; -import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128; +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @@ -42,11 +42,11 @@ public class GalacticraftProxy { public static void preInit(FMLPreInitializationEvent e) { if (FMLCommonHandler.instance().getSide().isServer() || FMLCommonHandler.instance().getEffectiveSide().isServer()) { - serverpreInit(e); + GalacticraftProxy.serverpreInit(e); } else { - clientpreInit(e); + GalacticraftProxy.clientpreInit(e); } - commonpreInit(e); + GalacticraftProxy.commonpreInit(e); } private static void serverpreInit(FMLPreInitializationEvent e) { @@ -57,15 +57,15 @@ public class GalacticraftProxy { } private static void commonpreInit(FMLPreInitializationEvent e) { - gtConf = new Configuration(new File(new File(e.getModConfigurationDirectory(), "GregTech"), "GregTech.cfg")); - uo_dimensionList.getConfig(gtConf, "undergroundfluid"); + GalacticraftProxy.gtConf = new Configuration(new File(new File(e.getModConfigurationDirectory(), "GregTech"), "GregTech.cfg")); + GalacticraftProxy.uo_dimensionList.getConfig(GalacticraftProxy.gtConf, "undergroundfluid"); init_undergroundFluidsRoss128(); - if (gtConf.hasChanged()) - gtConf.save(); + if (GalacticraftProxy.gtConf.hasChanged()) + GalacticraftProxy.gtConf.save(); Configuration c = new Configuration(new File(e.getModConfigurationDirectory(), "bartworks.cfg")); - Ross128.ross128ID = c.get("CrossMod Interactions", "DimID - Ross128b", -64, "The Dim ID for Ross128b").getInt(-64); - Ross128.enabled = c.get("CrossMod Interactions", "Galacticraft - Activate Ross128 System", true, "If the Ross128 System should be activated").getBoolean(true); + Ross128SolarSystem.ross128ID = c.get("CrossMod Interactions", "DimID - Ross128b", -64, "The Dim ID for Ross128b").getInt(-64); + Ross128SolarSystem.enabled = c.get("CrossMod Interactions", "Galacticraft - Activate Ross128 System", true, "If the Ross128 System should be activated").getBoolean(true); if (c.hasChanged()) c.save(); @@ -74,11 +74,11 @@ public class GalacticraftProxy { public static void init(FMLInitializationEvent e) { if (FMLCommonHandler.instance().getSide().isServer() || FMLCommonHandler.instance().getEffectiveSide().isServer()) { - serverInit(e); + GalacticraftProxy.serverInit(e); } else { - clientInit(e); + GalacticraftProxy.clientInit(e); } - commonInit(e); + GalacticraftProxy.commonInit(e); } private static void serverInit(FMLInitializationEvent e) { @@ -90,7 +90,7 @@ public class GalacticraftProxy { } private static void commonInit(FMLInitializationEvent e) { - if (Ross128.enabled) - Ross128.init(); + if (Ross128SolarSystem.enabled) + Ross128SolarSystem.init(); } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_OreLayer.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_OreLayer.java index 95155b1487..4f15b27b60 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_OreLayer.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_OreLayer.java @@ -44,7 +44,7 @@ public class BW_OreLayer extends GT_Worldgen { public static final List<BW_OreLayer> sList = new ArrayList<>(); private static final boolean logOregenRoss128 = false; public static int sWeight; - public byte bwOres = 0b0000; + public byte bwOres; public int mMinY, mWeight, mDensity, mSize, mMaxY, mPrimaryMeta, mSecondaryMeta, mBetweenMeta, mSporadicMeta; public BW_OreLayer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, ISubTagContainer top, ISubTagContainer bottom, ISubTagContainer between, ISubTagContainer sprinkled) { @@ -55,42 +55,42 @@ public class BW_OreLayer extends GT_Worldgen { this.mDensity = (short) aDensity; this.mSize = (short) Math.max(1, aSize); - if (mEnabled) + if (this.mEnabled) BW_OreLayer.sWeight += this.mWeight; if (top instanceof Werkstoff) - bwOres = (byte) (bwOres | 0b1000); + this.bwOres = (byte) (this.bwOres | 0b1000); if (bottom instanceof Werkstoff) - bwOres = (byte) (bwOres | 0b0100); + this.bwOres = (byte) (this.bwOres | 0b0100); if (between instanceof Werkstoff) - bwOres = (byte) (bwOres | 0b0010); + this.bwOres = (byte) (this.bwOres | 0b0010); if (sprinkled instanceof Werkstoff) - bwOres = (byte) (bwOres | 0b0001); + this.bwOres = (byte) (this.bwOres | 0b0001); short aPrimary = top instanceof Materials ? (short) ((Materials) top).mMetaItemSubID : top instanceof Werkstoff ? - (short) ((Werkstoff) top).getmID() : + ((Werkstoff) top).getmID() : 0; short aSecondary = bottom instanceof Materials ? (short) ((Materials) bottom).mMetaItemSubID : bottom instanceof Werkstoff ? - (short) ((Werkstoff) bottom).getmID() : + ((Werkstoff) bottom).getmID() : 0; short aBetween = between instanceof Materials ? (short) ((Materials) between).mMetaItemSubID : between instanceof Werkstoff ? - (short) ((Werkstoff) between).getmID() : + ((Werkstoff) between).getmID() : 0; short aSporadic = sprinkled instanceof Materials ? (short) ((Materials) sprinkled).mMetaItemSubID : sprinkled instanceof Werkstoff ? - (short) ((Werkstoff) sprinkled).getmID() : + ((Werkstoff) sprinkled).getmID() : 0; - this.mPrimaryMeta = (short) aPrimary; - this.mSecondaryMeta = (short) aSecondary; - this.mBetweenMeta = (short) aBetween; - this.mSporadicMeta = (short) aSporadic; + this.mPrimaryMeta = aPrimary; + this.mSecondaryMeta = aSecondary; + this.mBetweenMeta = aBetween; + this.mSporadicMeta = aSporadic; } @@ -110,30 +110,30 @@ public class BW_OreLayer extends GT_Worldgen { if (this.mSecondaryMeta > 0) { for (i = tMinY - 1; i < tMinY + 2; ++i) { if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) { - setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); + this.setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false); } } } if (this.mBetweenMeta > 0 && (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { - setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); + this.setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false); } if (this.mPrimaryMeta > 0) { for (i = tMinY + 3; i < tMinY + 6; ++i) { if (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0) { - setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); + this.setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false); } } } if (this.mSporadicMeta > 0 && (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0 || aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) { - setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); + this.setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false); } } } - if (logOregenRoss128) { + if (BW_OreLayer.logOregenRoss128) { MainMod.LOGGER.info("Generated Orevein: " + this.mWorldGenName + " " + aChunkX + " " + aChunkZ); } @@ -142,7 +142,7 @@ public class BW_OreLayer extends GT_Worldgen { } public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { - if ((aMetaData == mSporadicMeta && (bwOres & 0b0001) != 0) || (aMetaData == mBetweenMeta && (bwOres & 0b0010) != 0) || (aMetaData == mPrimaryMeta && (bwOres & 0b1000) != 0) || (aMetaData == mSecondaryMeta && (bwOres & 0b0100) != 0)) { + if ((aMetaData == this.mSporadicMeta && (this.bwOres & 0b0001) != 0) || (aMetaData == this.mBetweenMeta && (this.bwOres & 0b0010) != 0) || (aMetaData == this.mPrimaryMeta && (this.bwOres & 0b1000) != 0) || (aMetaData == this.mSecondaryMeta && (this.bwOres & 0b0100) != 0)) { return BW_MetaGenerated_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, false); } return GT_TileEntity_Ores.setOreBlock(aWorld, aX, aY, aZ, aMetaData, isSmallOre, false); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WordGenerator.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WordGenerator.java index 57dc4ac57d..2571ecf8a0 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WordGenerator.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WordGenerator.java @@ -46,7 +46,7 @@ public class BW_WordGenerator implements IWorldGenerator { } public synchronized void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - new WorldGenContainer(aX * 16, aZ * 16, aWorld.provider.dimensionId, aWorld, aChunkGenerator, aChunkProvider).run(); + new BW_WordGenerator.WorldGenContainer(aX * 16, aZ * 16, aWorld.provider.dimensionId, aWorld, aChunkGenerator, aChunkProvider).run(); } public static class WorldGenContainer implements Runnable { @@ -65,7 +65,6 @@ public class BW_WordGenerator implements IWorldGenerator { this.mWorld = aWorld; this.mChunkGenerator = aChunkGenerator; this.mChunkProvider = aChunkProvider; - ; } //returns a coordinate of a center chunk of 3x3 square; the argument belongs to this square @@ -75,11 +74,11 @@ public class BW_WordGenerator implements IWorldGenerator { } public boolean surroundingChunksLoaded(int xCenter, int zCenter) { - return mWorld.checkChunksExist(xCenter - 16, 0, zCenter - 16, xCenter + 16, 0, zCenter + 16); + return this.mWorld.checkChunksExist(xCenter - 16, 0, zCenter - 16, xCenter + 16, 0, zCenter + 16); } public XSTR getRandom(int xChunk, int zChunk) { - long worldSeed = mWorld.getSeed(); + long worldSeed = this.mWorld.getSeed(); XSTR fmlRandom = new XSTR(worldSeed); long xSeed = fmlRandom.nextLong() >> 2 + 1L; long zSeed = fmlRandom.nextLong() >> 2 + 1L; @@ -89,21 +88,21 @@ public class BW_WordGenerator implements IWorldGenerator { } public void run() { - int xCenter = getVeinCenterCoordinate(mX >> 4); - int zCenter = getVeinCenterCoordinate(mZ >> 4); - Random random = getRandom(xCenter, zCenter); + int xCenter = this.getVeinCenterCoordinate(this.mX >> 4); + int zCenter = this.getVeinCenterCoordinate(this.mZ >> 4); + Random random = this.getRandom(xCenter, zCenter); xCenter <<= 4; zCenter <<= 4; ChunkCoordIntPair centerChunk = new ChunkCoordIntPair(xCenter, zCenter); - if (!mGenerated.contains(centerChunk) && surroundingChunksLoaded(xCenter, zCenter)) { - mGenerated.add(centerChunk); + if (!BW_WordGenerator.WorldGenContainer.mGenerated.contains(centerChunk) && this.surroundingChunksLoaded(xCenter, zCenter)) { + BW_WordGenerator.WorldGenContainer.mGenerated.add(centerChunk); if ((BW_OreLayer.sWeight > 0) && (BW_OreLayer.sList.size() > 0)) { boolean temp = true; int tRandomWeight; for (int i = 0; (i < 256) && (temp); i++) { tRandomWeight = random.nextInt(BW_OreLayer.sWeight); for (BW_OreLayer tWorldGen : BW_OreLayer.sList) { - tRandomWeight -= ((BW_OreLayer) tWorldGen).mWeight; + tRandomWeight -= tWorldGen.mWeight; if (tRandomWeight <= 0) { try { if (tWorldGen.executeWorldgen(this.mWorld, random, "", this.mDimensionType, xCenter, zCenter, this.mChunkGenerator, this.mChunkProvider)) { diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java index d907b7ce69..f355bb9a21 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/oregen/BW_WorldGenRoss128.java @@ -23,7 +23,7 @@ package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.oregen; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; -import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128; +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; import gregtech.api.enums.Materials; import gregtech.api.interfaces.ISubTagContainer; import net.minecraft.util.StatCollector; @@ -63,7 +63,7 @@ public class BW_WorldGenRoss128 extends BW_OreLayer { @Override public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) { - return aWorld.provider.dimensionId == Ross128.ross128ID; + return aWorld.provider.dimensionId == Ross128SolarSystem.ross128ID; } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.java index 6ed4b1bc6c..9b2b9fc75a 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128/world/worldprovider/WorldProviderRoss128b.java @@ -22,7 +22,7 @@ package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128.world.worldprovider; -import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128; +import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; @@ -129,7 +129,7 @@ public class WorldProviderRoss128b extends WorldProviderSpace implements IExitHe @Override public boolean canSpaceshipTierPass(int tier) { - return Ross128.Ross128b.getTierRequirement() <= tier; + return Ross128SolarSystem.Ross128b.getTierRequirement() <= tier; } @Override @@ -154,7 +154,7 @@ public class WorldProviderRoss128b extends WorldProviderSpace implements IExitHe @Override public CelestialBody getCelestialBody() { - return Ross128.Ross128b; + return Ross128SolarSystem.Ross128b; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java index 4caa6e02df..e7d539f969 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java @@ -34,7 +34,7 @@ import net.minecraft.util.ResourceLocation; import java.util.Arrays; -public class Ross128 { +public class Ross128SolarSystem { public static boolean enabled = true; @@ -45,33 +45,33 @@ public class Ross128 { // public static Block Ross128bBlocks; // public static BlockMetaPair Ross128bStone,Ross128bDirt,Ross128bGrass; public static int ross128ID = -64; - private Ross128() { + private Ross128SolarSystem() { } public static void init() { // Ross128bBlocks = new UniversalSpaceBlocks("Ross128bBlocks",new String[]{BartWorksCrossmod.MOD_ID+":Ross128bStone",BartWorksCrossmod.MOD_ID+":Ross128bDirt",BartWorksCrossmod.MOD_ID+":Ross128bGrass"}); - Ross128System = new SolarSystem("Ross128System", "milkyWay").setMapPosition(new Vector3(-1.0D, 1.3D, 0.0D)); - Ross128 = (Star) new Star("Ross128").setParentSolarSystem(Ross128System).setTierRequired(-1); - Ross128.setUnreachable(); - Ross128.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128.png")); - Ross128System.setMainStar(Ross128); + Ross128SolarSystem.Ross128System = new SolarSystem("Ross128System", "milkyWay").setMapPosition(new Vector3(-1.0D, 1.3D, 0.0D)); + Ross128SolarSystem.Ross128 = (Star) new Star("Ross128").setParentSolarSystem(Ross128SolarSystem.Ross128System).setTierRequired(-1); + Ross128SolarSystem.Ross128.setUnreachable(); + Ross128SolarSystem.Ross128.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128.png")); + Ross128SolarSystem.Ross128System.setMainStar(Ross128SolarSystem.Ross128); - Ross128b = new Planet("Ross128b").setParentSolarSystem(Ross128System); - Ross128b.setRingColorRGB((0x9F) / 255f, (0x8A) / 255f, (0x79) / 255f); - Ross128b.setPhaseShift(1.25F); - Ross128b.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128b.png")); - Ross128b.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(0.75F, 1.75F)); - Ross128b.setRelativeOrbitTime(0.65F); - Ross128b.atmosphere.addAll(Arrays.asList(IAtmosphericGas.OXYGEN, IAtmosphericGas.NITROGEN, IAtmosphericGas.ARGON)); - Ross128b.setDimensionInfo(ross128ID, WorldProviderRoss128b.class); - Ross128b.setTierRequired(Loader.isModLoaded("galaxyspace") ? 4 : Loader.isModLoaded("GalacticraftMars") ? 3 : -1); + Ross128SolarSystem.Ross128b = new Planet("Ross128b").setParentSolarSystem(Ross128SolarSystem.Ross128System); + Ross128SolarSystem.Ross128b.setRingColorRGB((0x9F) / 255f, (0x8A) / 255f, (0x79) / 255f); + Ross128SolarSystem.Ross128b.setPhaseShift(1.25F); + Ross128SolarSystem.Ross128b.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128b.png")); + Ross128SolarSystem.Ross128b.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(0.75F, 1.75F)); + Ross128SolarSystem.Ross128b.setRelativeOrbitTime(0.65F); + Ross128SolarSystem.Ross128b.atmosphere.addAll(Arrays.asList(IAtmosphericGas.OXYGEN, IAtmosphericGas.NITROGEN, IAtmosphericGas.ARGON)); + Ross128SolarSystem.Ross128b.setDimensionInfo(Ross128SolarSystem.ross128ID, WorldProviderRoss128b.class); + Ross128SolarSystem.Ross128b.setTierRequired(Loader.isModLoaded("galaxyspace") ? 4 : Loader.isModLoaded("GalacticraftMars") ? 3 : -1); - Ross128ba = new Moon("Ross128ba").setParentPlanet(Ross128b); - Ross128ba.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(10f, 15f)).setRelativeOrbitTime(1 / 0.01F); - Ross128ba.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128ba.png")); - Ross128ba.setUnreachable(); //for now + Ross128SolarSystem.Ross128ba = new Moon("Ross128ba").setParentPlanet(Ross128SolarSystem.Ross128b); + Ross128SolarSystem.Ross128ba.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(10f, 15f)).setRelativeOrbitTime(1 / 0.01F); + Ross128SolarSystem.Ross128ba.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128ba.png")); + Ross128SolarSystem.Ross128ba.setUnreachable(); //for now // GameRegistry.registerBlock(Ross128bBlocks,Ross128bBlocks.getUnlocalizedName()); // @@ -79,9 +79,9 @@ public class Ross128 { // Ross128bDirt=new BlockMetaPair(Ross128bBlocks, (byte) 1); // Ross128bGrass=new BlockMetaPair(Ross128bBlocks, (byte) 2); - GalaxyRegistry.registerPlanet(Ross128b); - GalaxyRegistry.registerMoon(Ross128ba); - GalaxyRegistry.registerSolarSystem(Ross128System); + GalaxyRegistry.registerPlanet(Ross128SolarSystem.Ross128b); + GalaxyRegistry.registerMoon(Ross128SolarSystem.Ross128ba); + GalaxyRegistry.registerSolarSystem(Ross128SolarSystem.Ross128System); GalacticraftRegistry.registerTeleportType(WorldProviderRoss128b.class, new UniversalTeleportType()); } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java index a3cc19b41c..c9dfe96835 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java @@ -22,23 +22,96 @@ package com.github.bartimaeusnek.crossmod.thaumcraft.util; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.log.DebugLog; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.util.Pair; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TC_Aspects; +import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + public class ThaumcraftHandler { private ThaumcraftHandler(){} - public static Integer taintBiomeID = null; + private static Integer taintBiomeID; public static boolean isTaintBiome(int biomeID){ - if (taintBiomeID == null) { + if (ThaumcraftHandler.taintBiomeID == null) { try { BiomeGenBase TaintBiome = (BiomeGenBase) Class.forName("thaumcraft.common.lib.world.ThaumcraftWorldGenerator").getField("biomeTaint").get(null); - return biomeID == (taintBiomeID = TaintBiome.biomeID); + return biomeID == (ThaumcraftHandler.taintBiomeID = TaintBiome.biomeID); } catch (ClassCastException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { e.printStackTrace(); return false; } } - return biomeID == taintBiomeID; + return biomeID == ThaumcraftHandler.taintBiomeID; + } + + public static class AspectAdder { + private static Class mAspectListClass; + private static Class mAspectClass; + private static Method registerObjectTag; + private static Method addToList; + private static Method getName; + + static { + try { + ThaumcraftHandler.AspectAdder.mAspectListClass = Class.forName("thaumcraft.api.aspects.AspectList"); + ThaumcraftHandler.AspectAdder.mAspectClass = Class.forName("thaumcraft.api.aspects.Aspect"); + ThaumcraftHandler.AspectAdder.addToList = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("add", ThaumcraftHandler.AspectAdder.mAspectClass,int.class); + ThaumcraftHandler.AspectAdder.registerObjectTag = Class.forName("thaumcraft.api.ThaumcraftApi").getMethod("registerObjectTag",ItemStack.class, ThaumcraftHandler.AspectAdder.mAspectListClass); + ThaumcraftHandler.AspectAdder.getName = mAspectClass.getMethod("getName"); + } catch (ClassNotFoundException | NoSuchMethodException e) { + e.printStackTrace(); + } + } + + public static void addAspectViaBW(ItemStack stack, Pair<Object,Integer>... aspectPair) { + if (stack == null || stack.getItem() == null || stack.getUnlocalizedName() == null) + return; + try { + Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); + for (Pair a : aspectPair) { + if (ConfigHandler.debugLog) + DebugLog.log("Stack:"+ stack.getDisplayName() + " Damage:" +stack.getItemDamage() + " aspectPair: " + getName.invoke(a.getKey()) + " / " + a.getValue()); + ThaumcraftHandler.AspectAdder.addToList.invoke(aspectList, a.getKey(), a.getValue()); + } + ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); + }catch (IllegalAccessException | InstantiationException | InvocationTargetException e){ + e.printStackTrace(); + } + } + + public static void addAspectViaGT(ItemStack stack, TC_Aspects.TC_AspectStack... tc_aspectStacks) { + try { + Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); + for (TC_Aspects.TC_AspectStack tc_aspects : tc_aspectStacks) + ThaumcraftHandler.AspectAdder.addToList.invoke(aspectList, tc_aspects.mAspect.mAspect, (int) tc_aspects.mAmount); + ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); + }catch (IllegalAccessException | InstantiationException | InvocationTargetException e){ + e.printStackTrace(); + } + } + + public static void addAspectToAll(Werkstoff werkstoff){ + for (OrePrefixes element : OrePrefixes.values()) { + if ((werkstoff.getGenerationFeatures().toGenerate & element.mMaterialGenerationBits) != 0 && (werkstoff.getGenerationFeatures().blacklist & element.mMaterialGenerationBits) == 0) { + if (element.mMaterialAmount >= 3628800L || element == OrePrefixes.ore) { + DebugLog.log("OrePrefix: "+element.name() + " mMaterialAmount: " + element.mMaterialAmount/3628800L); + ThaumcraftHandler.AspectAdder.addAspectViaBW(werkstoff.get(element), werkstoff.getTCAspects(element == OrePrefixes.ore ? 1 : (int) (element.mMaterialAmount / 3628800L))); + } + else if (element.mMaterialAmount >= 0L) { + ThaumcraftHandler.AspectAdder.addAspectViaBW(werkstoff.get(element), new Pair<Object, Integer>(TC_Aspects.PERDITIO.mAspect, 1)); + } + } + } + } + + } } |