diff options
Diffstat (limited to 'src/main/java')
18 files changed, 965 insertions, 62 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java new file mode 100644 index 0000000000..76612ad404 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java @@ -0,0 +1,33 @@ +/* + * 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.API; + +public interface INoiseGen { + + double getNoise(int x, int z); + double[][] getNoiseForRegion(int xStart, int zStart, int xEnd, int zEnd); + void setOctaves(int octaves); + void setFrequency(double freq); + void setSeed(long seed); + void setAmplitude(double amplitude); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index bc7bfe2bed..ba65d2198a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -41,7 +41,6 @@ import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.Circ import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitPartLoader; import com.github.bartimaeusnek.bartworks.system.material.ThreadedLoader; import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; -import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.DownTierLoader; import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; import com.github.bartimaeusnek.bartworks.util.BWRecipes; @@ -61,7 +60,6 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.SubTag; -import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.*; import net.minecraft.creativetab.CreativeTabs; @@ -74,6 +72,7 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import java.util.ArrayList; import java.io.IOException; import java.lang.reflect.Field; @@ -183,18 +182,20 @@ public final class MainMod { } @Mod.EventHandler public void onServerStarted(FMLServerStartedEvent event) { - MainMod.runOnPlayerJoined(ConfigHandler.classicMode); + MainMod.runOnPlayerJoined(ConfigHandler.classicMode, ConfigHandler.disableExtraGassesForEBF); } - public static void runOnPlayerJoined(boolean classicMode){ + public static void runOnPlayerJoined(boolean classicMode, boolean extraGasRecipes){ OreDictHandler.adaptCacheForWorld(); removeIC2Recipes(); MainMod.addElectricImplosionCompressorRecipes(); MainMod.unificationEnforcer(); - ArrayListMultimap tochange = MainMod.getRecipesToChange(NOBLE_GAS,ANAEROBE_GAS); - HashSet noGas = MainMod.getNoGasItems(tochange); - MainMod.editRecipes(tochange,noGas); + if (!extraGasRecipes) { + ArrayListMultimap<SubTag, GT_Recipe> toChange = MainMod.getRecipesToChange(NOBLE_GAS, ANAEROBE_GAS); + HashSet<ItemStack> noGas = MainMod.getNoGasItems(toChange); + MainMod.editRecipes(toChange, noGas); + } new CircuitImprintLoader().run(); if (classicMode) @@ -389,7 +390,12 @@ public final class MainMod { } for (ItemStack is : noGas) if (GT_Utility.areStacksEqual(is, recipe.mOutputs[0])) { - toAdd.add(new BWRecipes.DynamicGTRecipe(false, recipe.mInputs, recipe.mOutputs, recipe.mSpecialItems, recipe.mChances, null, recipe.mFluidOutputs, (int) ((double) recipe.mDuration / 200D * (200D + (double) mat.getProtons())), recipe.mEUt, recipe.mSpecialValue)); + ArrayList<ItemStack> inputs = new ArrayList<>(recipe.mInputs.length); + for (ItemStack stack : recipe.mInputs) + if (!GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(11),stack)) + inputs.add(stack); + inputs.add(GT_Utility.getIntegratedCircuit(0)); + toAdd.add(new BWRecipes.DynamicGTRecipe(false, inputs.toArray(new ItemStack[0]), recipe.mOutputs, recipe.mSpecialItems, recipe.mChances, null, recipe.mFluidOutputs, (int) ((double) recipe.mDuration / 200D * (200D + ((double) mat.getProtons()*2.5D))), recipe.mEUt, recipe.mSpecialValue)); break; } } @@ -397,6 +403,25 @@ public final class MainMod { } GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.removeAll(base.get(GasTag)); } + HashSet<GT_Recipe> duplicates = new HashSet<GT_Recipe>(); + for (GT_Recipe recipe : toAdd){ + for (GT_Recipe recipe2 : toAdd){ + if (recipe.mEUt != recipe2.mEUt || recipe.mDuration != recipe2.mDuration || recipe.mSpecialValue != recipe2.mSpecialValue || recipe == recipe2 || recipe.mInputs.length != recipe2.mInputs.length || recipe.mFluidInputs.length != recipe2.mFluidInputs.length) + continue; + boolean isSame = true; + for (int i = 0; i < recipe.mInputs.length; i++) { + if (!GT_Utility.areStacksEqual(recipe.mInputs[i],recipe2.mInputs[i])) + isSame = false; + } + for (int i = 0; i < recipe.mFluidInputs.length; i++) { + if (!GT_Utility.areFluidsEqual(recipe.mFluidInputs[i],recipe2.mFluidInputs[i])) + isSame = false; + } + if (isSame) + duplicates.add(recipe2); + } + } + toAdd.removeAll(duplicates); for (GT_Recipe recipe : toAdd) GT_Recipe.GT_Recipe_Map.sBlastRecipes.add(recipe); } 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 10fe70816f..b5d5d8b972 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 @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.common.configs; import com.github.bartimaeusnek.ASM.BWCoreTransformer; +import gregtech.api.enums.GT_Values; import net.minecraftforge.common.config.Configuration; import java.util.Arrays; @@ -44,6 +45,7 @@ public class ConfigHandler { public static int ross128bRuinChance = 512; public static int creativeScannerID; public static int bioVatMaxParallelBonus = 1000; + public static int cutoffTier = 5; public static long energyPerCell = 1000000L; @@ -51,6 +53,8 @@ public class ConfigHandler { public static boolean BioLab = true; public static boolean Ross128Enabled = true; + public static boolean disableExtraGassesForEBF; + public static boolean disableMagicalForest; public static boolean DEHPDirectSteam; public static boolean teslastaff; public static boolean classicMode; @@ -74,6 +78,9 @@ public class ConfigHandler { ConfigHandler.teslastaff = ConfigHandler.c.get("System", "Enable Teslastaff", false, "Enables the Teslastaff, an Item used to destroy Electric Armors").getBoolean(false); ConfigHandler.newStuff = !ConfigHandler.c.get("System", "Disable non-original-GT-stuff", false, "This switch disables my new content, that is not part of the GT2 compat").getBoolean(false); ConfigHandler.BioLab = !ConfigHandler.c.get("System", "Disable BioLab", false, "This switch disables the BioLab, BioVat etc. If you use GT5.08 or equivalent, this needs to be turned off!").getBoolean(false); + ConfigHandler.cutoffTier = ConfigHandler.c.get("System", "Tier to nerf circuits", 5, "This switch sets the lowest unnerfed Circuit Recipe Tier. -1 to disable it completely.").getInt(5); + ConfigHandler.cutoffTier = (ConfigHandler.cutoffTier == -1 ? GT_Values.VN.length : ConfigHandler.cutoffTier); + ConfigHandler.disableExtraGassesForEBF = ConfigHandler.c.get("System", "Disable Extra Gases for EBF", false, "This switch disables extra gas recipes for the EBF, i.e. Xenon instead of Nitrogen").getBoolean(false); ConfigHandler.mbWaterperSec = ConfigHandler.c.get("Singleblocks", "mL Water per Sec for the StirlingPump", 150).getInt(150); @@ -100,6 +107,8 @@ public class ConfigHandler { ConfigHandler.ross128bRuinChance = ConfigHandler.c.get("CrossMod Interactions", "Ruin Chance - Ross128b", 512, "Higher Values mean lesser Ruins.").getInt(512); ConfigHandler.Ross128Enabled = ConfigHandler.c.get("CrossMod Interactions", "Galacticraft - Activate Ross128 System", true, "If the Ross128 System should be activated").getBoolean(true); ConfigHandler.landerType = ConfigHandler.c.get("CrossMod Interactions", "LanderType", 3, "1 = Moon Lander, 2 = Landing Balloons, 3 = Asteroid Lander").getInt(3); + ConfigHandler.disableMagicalForest = ConfigHandler.c.get("CrossMod Interactions", "Disable Magical Forest - Ross128b", false, "True disables the magical Forest Biome on Ross for more performance during World generation.").getBoolean(false); + ConfigHandler.setUpComments(); if (ConfigHandler.c.hasChanged()) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java index 5a85445f39..d6b1293cbf 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java @@ -791,7 +791,7 @@ public class RecipeLoader implements Runnable { Materials.SolderingAlloy.getMolten(1440) }, ItemRegistry.cal.copy(), - 240000, + 24000, BW_Util.getMachineVoltageFromTier(6) ); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java index a9b37065e4..149db03d5b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java @@ -30,7 +30,7 @@ import net.minecraft.world.IBlockAccess; public class ServerJoinedPackage extends GT_Packet { - private boolean config; + private byte config; ServerJoinedPackage() { super(true); @@ -38,7 +38,8 @@ public class ServerJoinedPackage extends GT_Packet { public ServerJoinedPackage(Object obj) { super(false); - this.config = ConfigHandler.classicMode; + this.config =(byte) (ConfigHandler.classicMode && ConfigHandler.disableExtraGassesForEBF ? 3 : ConfigHandler.classicMode ? 2 : ConfigHandler.disableExtraGassesForEBF ? 1 : 0); + } @Override @@ -48,17 +49,19 @@ public class ServerJoinedPackage extends GT_Packet { @Override public byte[] encode() { - return new byte[]{(byte) (this.config ? 1 : 0)}; + return new byte[]{this.config}; } @Override public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) { - this.config = byteArrayDataInput.readBoolean(); + this.config = byteArrayDataInput.readByte(); return this; } @Override public void process(IBlockAccess iBlockAccess) { - MainMod.runOnPlayerJoined(this.config); + boolean gas = (this.config & 1) != 0; + boolean classic = (this.config & 0b10) != 0; + MainMod.runOnPlayerJoined(classic,gas); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java index 3fe6337b7d..45db6ce632 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java @@ -79,10 +79,9 @@ public class BW_MetaGeneratedOreTE extends TileEntity implements ITexturedTileEn return rList; } - public Packet getDescriptionPacket() { + public void sendPacket(){ if (!this.worldObj.isRemote) BW_Network_instance.sendPacketToAllPlayersInRange(this.worldObj, new OrePacket(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), this.xCoord, this.zCoord); - return null; } @Override 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 f09c5f7442..47e676e082 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 @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.system.material; import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; +import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; @@ -165,11 +166,27 @@ public class BW_MetaGenerated_Ores extends BW_TileEntityContainer { @Override public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block p_149695_5_) { - aWorld.getTileEntity(aX, aY, aZ).getDescriptionPacket(); + if ((!aWorld.isRemote || this.checkForAir(aWorld,aX,aY,aZ)) && aWorld.getTileEntity(aX, aY, aZ) instanceof BW_MetaGeneratedOreTE) + ((BW_MetaGeneratedOreTE)aWorld.getTileEntity(aX, aY, aZ)).sendPacket(); } @Override public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int tileX, int tileY, int tileZ) { - aWorld.getTileEntity(aX, aY, aZ).getDescriptionPacket(); + if ((FMLCommonHandler.instance().getEffectiveSide().isServer() || this.checkForAir(aWorld,aX,aY,aZ)) && aWorld.getTileEntity(aX, aY, aZ) instanceof BW_MetaGeneratedOreTE) + ((BW_MetaGeneratedOreTE)aWorld.getTileEntity(aX, aY, aZ)).sendPacket(); + } + + private boolean checkForAir(IBlockAccess aWorld, int aX, int aY, int aZ){ + for (int x = -1; x <= 1; x++) { + for (int y = -1; y <= 1; y++) { + for (int z = -1; z <= 1; z++) { + if (x == 0 && y == 0 && z == 0) + continue; + if (aWorld.getBlock(aX+x,aY+y,aZ+z).isAir(aWorld,aX+x,aY+y,aZ+z)) + return true; + } + } + } + return false; } -} +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java index 7f6cbe008e..005f89cc88 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -22,6 +22,7 @@ package com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_Util; @@ -89,12 +90,12 @@ public class CircuitImprintLoader implements Runnable { GT_Recipe newRecipe = CircuitImprintLoader.reBuildRecipe(circuitRecipe); if (newRecipe != null) BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).addRecipe(newRecipe); - if (circuitRecipe.mEUt > BW_Util.getTierVoltage(5)) { + if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) { toRem.add(circuitRecipe); toAdd.add(CircuitImprintLoader.makeMoreExpensive(circuitRecipe)); } } else { - if (circuitRecipe.mEUt > BW_Util.getTierVoltage(5)) { + if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) { toRem.add(circuitRecipe); } } @@ -193,26 +194,26 @@ public class CircuitImprintLoader implements Runnable { 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite,1), 'X', BW_Meta_Items.getNEWCIRCUITS().getStack(3)}); } - for (ItemStack stack : CircuitImprintLoader.bwCircuitTagMap.values()){ - NBTTagCompound tag = CircuitImprintLoader.getTagFromStack(stack); - CircuitData data = CircuitImprintLoader.bwCircuitTagMap.inverse().get(stack); - GT_Recipe slicingRecipe = new BWRecipes.DynamicGTRecipe(true,new ItemStack[]{stack,ItemList.Shape_Slicer_Flat.get(0)},new ItemStack[]{BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1)},null,null,null,null,300, Math.toIntExact(data.getaVoltage()),data.getaSpecial()); - GT_Recipe.GT_Recipe_Map.sSlicerRecipes.add(slicingRecipe); - GameRegistry.addRecipe(new BWRecipes.BWNBTDependantCraftingRecipe(BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,0,1), - " X ", - "GPG", - " X ", - 'P', BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1), - 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite,1), - 'X', BW_Meta_Items.getNEWCIRCUITS().getStack(3))); - GT_ModHandler.addCraftingRecipe(BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,0,1),GT_ModHandler.RecipeBits.KEEPNBT | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS ,new Object[]{ - " X ", - "GPG", - " X ", - 'P', BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1), - 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite,1), - 'X', BW_Meta_Items.getNEWCIRCUITS().getStack(3) - }); - } +// for (ItemStack stack : CircuitImprintLoader.bwCircuitTagMap.values()){ +// NBTTagCompound tag = CircuitImprintLoader.getTagFromStack(stack); +// CircuitData data = CircuitImprintLoader.bwCircuitTagMap.inverse().get(stack); +// GT_Recipe slicingRecipe = new BWRecipes.DynamicGTRecipe(true,new ItemStack[]{stack,ItemList.Shape_Slicer_Flat.get(0)},new ItemStack[]{BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1)},null,null,null,null,300, Math.toIntExact(data.getaVoltage()),data.getaSpecial()); +// GT_Recipe.GT_Recipe_Map.sSlicerRecipes.add(slicingRecipe); +// GameRegistry.addRecipe(new BWRecipes.BWNBTDependantCraftingRecipe(BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,0,1), +// " X ", +// "GPG", +// " X ", +// 'P', BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1), +// 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite,1), +// 'X', BW_Meta_Items.getNEWCIRCUITS().getStack(3))); +// GT_ModHandler.addCraftingRecipe(BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,0,1),GT_ModHandler.RecipeBits.KEEPNBT | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS ,new Object[]{ +// " X ", +// "GPG", +// " X ", +// 'P', BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1), +// 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite,1), +// 'X', BW_Meta_Items.getNEWCIRCUITS().getStack(3) +// }); +// } } }
\ No newline at end of file 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 64822f25fe..cc4841cad7 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 @@ -282,9 +282,10 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { @Override public boolean contains(SubTag subTag) { - for (Pair<ISubTagContainer, Integer> p : this.contents) - if (p.getKey().contains(subTag)) - return true; + if (!subTag.equals(WerkstoffLoader.NOBLE_GAS) && !subTag.equals(WerkstoffLoader.ANAEROBE_GAS)) + for (Pair<ISubTagContainer, Integer> p : this.contents) + if (p.getKey().contains(subTag)) + return true; return this.subtags.contains(subTag); } @@ -444,6 +445,10 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { return this; } + public boolean hasCells() { + return (this.toGenerate & 0b10000) != 0; + } + public boolean hasMolten() { return (this.toGenerate & 0b1000000) != 0; } 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 2b19c6a4c4..e8ae5f64ae 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 @@ -78,8 +78,8 @@ public class WerkstoffLoader implements Runnable { public static final SubTag NOBLE_GAS = SubTag.getNewSubTag("NobleGas"); public static final SubTag ANAEROBE_GAS = SubTag.getNewSubTag("AnaerobeGas"); public static final SubTag ANAEROBE_SMELTING = SubTag.getNewSubTag("AnaerobeSmelting"); - public static OrePrefixes cellMolten; + static { for (OrePrefixes prefix : OrePrefixes.values()){ if (prefix.toString().equals("cellMolten")) @@ -636,7 +636,29 @@ public class WerkstoffLoader implements Runnable { //No Byproducts //No Ingredients ); - + public static final Werkstoff BArTiMaEuSNeK = new Werkstoff( + new short[]{0x00,0xff,0x00}, + "BArTiMaEuSNeK", + "Are you serious?", + new Werkstoff.Stats().setMeltingPoint(9001).setCentrifuge(true).setBlastFurnace(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems().addMetalItems().addMolten(), + 43, + TextureSet.SET_DIAMOND, + Arrays.asList( + Materials.Boron, + Materials.Titanium, + Materials.Europium + ), + new Pair<>(Materials.Boron,1), + new Pair<>(Materials.Argon,1), + new Pair<>(Materials.Titanium,1), + new Pair<>(Materials.Magic,1), + new Pair<>(Materials.Europium,1), + new Pair<>(Materials.Sulfur,1), + new Pair<>(WerkstoffLoader.Neon,1), + new Pair<>(Materials.Potassium,1) + ); public static HashMap<OrePrefixes, BW_MetaGenerated_Items> items = new HashMap<>(); public static HashMap<Werkstoff, Fluid> fluids = new HashMap<>(); @@ -644,6 +666,17 @@ public class WerkstoffLoader implements Runnable { public static Block BWOres; public boolean registered; + public static Werkstoff getWerkstoff(String Name){ + try{ + Field f = WerkstoffLoader.class.getField(Name); + if (f != null) + return (Werkstoff) f.get(null); + } catch (IllegalAccessException | NoSuchFieldException | ClassCastException e) { + e.printStackTrace(); + } + return Werkstoff.default_null_Werkstoff; + } + public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { return WerkstoffLoader.getCorrespondingItemStack(orePrefixes, werkstoff, 1); } @@ -723,21 +756,21 @@ public class WerkstoffLoader implements Runnable { } private void addSubTags() { - - WerkstoffLoader.Krypton.add(WerkstoffLoader.NOBLE_GAS); - WerkstoffLoader.Xenon.add(WerkstoffLoader.NOBLE_GAS); - WerkstoffLoader.Neon.add(WerkstoffLoader.NOBLE_GAS); Materials.Helium.add(WerkstoffLoader.NOBLE_GAS); - + WerkstoffLoader.Neon.add(WerkstoffLoader.NOBLE_GAS); Materials.Argon.add(WerkstoffLoader.NOBLE_GAS); - + WerkstoffLoader.Krypton.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Xenon.add(WerkstoffLoader.NOBLE_GAS,WerkstoffLoader.ANAEROBE_GAS); + Materials.Radon.add(WerkstoffLoader.NOBLE_GAS); WerkstoffLoader.Oganesson.add(WerkstoffLoader.NOBLE_GAS,WerkstoffLoader.ANAEROBE_GAS); - Materials.Radon.add(WerkstoffLoader.NOBLE_GAS,WerkstoffLoader.ANAEROBE_GAS); Materials.Nitrogen.add(WerkstoffLoader.ANAEROBE_GAS); WerkstoffLoader.Calcium.add(WerkstoffLoader.ANAEROBE_SMELTING); + //Calcium Smelting block + Materials.Calcium.mBlastFurnaceRequired=true; + for (Werkstoff W : Werkstoff.werkstoffHashMap.values()) { for (Pair<ISubTagContainer, Integer> pair : W.getContents().getValue().toArray(new Pair[0])) { @@ -980,6 +1013,8 @@ public class WerkstoffLoader implements Runnable { cells += container.getValue(); } } else { + if (((Materials) container.getKey()).getDust(container.getValue()) == null ) + continue; if (!tracker.containsKey(container.getKey())) { stOutputs.add(((Materials) container.getKey()).getDust(container.getValue())); tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); @@ -989,9 +1024,25 @@ public class WerkstoffLoader implements Runnable { } } } else if (container.getKey() instanceof Werkstoff) { - if (((Werkstoff) container.getKey()).getTexSet() == TextureSet.SET_FLUID) { - //not yet implemented no fluids from me... + if (((Werkstoff) container.getKey()).getStats().isGas() || ((Werkstoff) container.getKey()).getGenerationFeatures().hasCells()) { + FluidStack tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Werkstoff) container.getKey()).get(cell, container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add(((Werkstoff) container.getKey()).get(cell, tracker.get(container.getKey()).getKey() + container.getValue())); + stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); + } + cells += container.getValue(); + } } else { + if (!((Werkstoff) container.getKey()).getGenerationFeatures().hasDusts()) + continue; if (!tracker.containsKey(container.getKey())) { stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue())); tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java new file mode 100644 index 0000000000..7b62f34e2c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java @@ -0,0 +1,237 @@ +/* + * 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.util.NoiseUtil; + +import com.github.bartimaeusnek.bartworks.API.INoiseGen; +import gregtech.api.objects.XSTR; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.Random; + +public class BartsNoise implements INoiseGen { + public void setUsePhase(boolean usePhase) { + this.usePhase = usePhase; + } + + public void setRandom(Random random) { + this.random = random; + } + + boolean usePhase; + int octaves; + double frequency; + double amplitude; + long seed; + Random random; + + public enum NoiseColor{ + Red(-1),Pink(-0.5),White(0),Blue(0.5),Violet(1); + NoiseColor(double num) { + this.ampl=num; + } + double ampl; + public BartsNoise getColoredNoise(){ + BartsNoise noise = new BartsNoise(); + noise.setAmplitude(this.ampl); + return noise; + } + } + + public static double clamp(double input, double lowerBound, double upperBound){ + return Math.min(Math.max(input, lowerBound),upperBound); + } + public static double wrap(double input, double bound){ + return (((input % bound)+bound) % bound); + } + + public BartsNoise(int octaves, double frequency, double amplitude, long seed) { + this.octaves = octaves; + this.frequency = frequency; + this.amplitude = amplitude; + this.seed = seed; + this.random = new XSTR(seed); + } + + public BartsNoise() { + this.seed = new XSTR().nextLong(); + this.random = new XSTR(this.seed); + this.octaves = 1; + this.frequency = this.random.nextGaussian(); + this.amplitude = this.random.nextGaussian(); + } + + public BartsNoise(long seed) { + this.seed = seed; + this.random = new XSTR(seed); + this.octaves = 1; + this.frequency = this.random.nextGaussian(); + this.amplitude = this.random.nextGaussian(); + } + + public BartsNoise copy(){ + return new BartsNoise(this.octaves,this.frequency,this.amplitude,this.seed); + } + public BartsNoise copy(long seed){ + return new BartsNoise(this.octaves,this.frequency,this.amplitude,seed); + } +// public static void main(String[] args) throws IOException { +// +// BartsNoise noiseGen1 = new BartsNoise(2,0.005F,1D,System.nanoTime()); +//// BartsNoise noiseGen2 = new BartsNoise(1,0.002F,-1D,System.nanoTime()); +//// BartsNoise noiseGen3 = new BartsNoise(1,0.002F,-1D,System.nanoTime()); +// +// noiseGen1.setUsePhase(false); +//// noiseGen2.setUsePhase(false); +//// noiseGen3.setUsePhase(false); +// +// +// BufferedImage image = new BufferedImage(640, 640, BufferedImage.TYPE_INT_RGB); +// +// for (int chunkX = 0; chunkX < 40; chunkX++) { +// for (int chunkZ = 0; chunkZ < 40; chunkZ++) { +// for (int x = 0; x < 16; ++x) { +// for (int z = 0; z < 16; ++z) { +// double d = noiseGen1.getNoise(x + chunkX * 16, z + chunkZ * 16) * 2D; +//// double d2 = noiseGen2.getNoise(x + chunkX * 16, z + chunkZ * 16) * 2D; +//// double d3 = (noiseGen3.getNoise(x + chunkX * 16, z + chunkZ * 16) - 0.5D); +//// d3 *= 2; +// double yDev; +//// if (d3 < 0.0D) { +//// yDev = d; +//// } else if (d3 > 1.0D) { +//// yDev = d2; +//// } else { +// yDev = d*4; +//// } +// yDev=wrap(yDev,1); +// image.setRGB(x + chunkX * 16,z + chunkZ * 16,new Color((float)(1f*yDev),(float)(1f*yDev),(float)(1f*yDev)).getRGB()); +// } +// } +// } +// } +// File file = new File("myimage.png"); +// ImageIO.write(image, "png", file); +//// BartsNoise redNoise = NoiseColor.Blue.getColoredNoise(); +//// redNoise.setOctaves(1); +//// redNoise.setFrequency(0.05F); +//// for (int i = 40; i < 50; i++) { +//// String line = ""; +//// for (int j = 0; j < 10; j++) { +//// double num = (redNoise.getNoise(i,j)-0.5D); +//// line += num+","; +//// } +//// System.out.println(line); +//// } +// } + + public double getCosNoise(double x, double y){ + double pr = x * this.frequency; + double r1 = Math.cos(pr); + if (r1 < 0) + r1 = Math.abs(r1); + double result = Math.pow(r1, this.amplitude); + double pr2 = y * this.frequency; + double r2 = Math.cos(pr2); + if (r2 < 0) + r2 = Math.abs(r2); + double result2 = Math.pow(r2, this.amplitude); + result *= result2; + if (result == Double.POSITIVE_INFINITY) + result = Double.MAX_VALUE; + if (result == Double.NEGATIVE_INFINITY) + result = Double.MIN_VALUE; + return BartsNoise.wrap(result,1D); + } + + + double getNonOctavedNoise(double x, double y){ + double phase = SimplexNoise.noise( Math.pow(x*this.frequency,this.amplitude),Math.pow(y*this.frequency,this.amplitude)); + return BartsNoise.wrap(phase,1); + + } + + public double getNeighbouringNoise(int x, int y){ + return (this.getNoiseSingle(x-1,y-1)+ + this.getNoiseSingle(x,y-1) + + this.getNoiseSingle(x-1,y) + + this.getNoiseSingle(x+1,y) + + this.getNoiseSingle(x,y+1) + + this.getNoiseSingle(x+1,y+1) + + this.getNoiseSingle(x-1,y+1)+ + this.getNoiseSingle(x+1,y-1) + )/8; + } + + public double getNoiseSingle(int x, int y){ + double result = 0; + for (double i = 1; i <= this.octaves; i++) { + result += 1d/i * this.getNonOctavedNoise(i * x, i * y); + } + return result; + } + + @Override + public double getNoise(int x, int y) { + double result = 0; + for (double i = 1; i <= this.octaves; i++) { + result += 1d/i * this.getNonOctavedNoise(i * x, y); + } + //result = (this.getNeighbouringNoise(x,y)+result)/2; + return BartsNoise.wrap(result,1D); + } + + @Override + public double[][] getNoiseForRegion(int xStart, int zStart, int xEnd, int zEnd) { +// double[][] results = new double[Math.abs(xEnd)-Math.abs(xStart)][Math.abs(zEnd)-Math.abs(zStart)]; +// for (int i = xStart; i < xEnd; i++) { +// for (int j = zStart; j < zEnd; j++) { +// results +// } +// } + return new double[0][0]; + } + + @Override + public void setAmplitude(double amplitude) { + this.amplitude = amplitude; + } + + @Override + public void setOctaves(int octaves) { + this.octaves = octaves; + } + + @Override + public void setFrequency(double freq) { + this.frequency = freq; + } + + @Override + public void setSeed(long seed) { + this.seed=seed; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java new file mode 100644 index 0000000000..e494594bd2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java @@ -0,0 +1,357 @@ +package com.github.bartimaeusnek.bartworks.util.NoiseUtil; +/* + * A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. + * + * Based on example code by Stefan Gustavson (stegu@itn.liu.se). + * Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). + * Better rank ordering method by Stefan Gustavson in 2012. + * + * This could be speeded up even further, but it's useful as it is. + * + * Version 2012-03-09 + * + * This code was placed in the public domain by its original author, + * Stefan Gustavson. You may use it as you see fit, but + * attribution is appreciated. + * + */ + +public class SimplexNoise { // Simplex noise in 2D, 3D and 4D + private static Grad grad3[] = {new Grad(1,1,0),new Grad(-1,1,0),new Grad(1,-1,0),new Grad(-1,-1,0), + new Grad(1,0,1),new Grad(-1,0,1),new Grad(1,0,-1),new Grad(-1,0,-1), + new Grad(0,1,1),new Grad(0,-1,1),new Grad(0,1,-1),new Grad(0,-1,-1)}; + + private static Grad grad4[]= {new Grad(0,1,1,1),new Grad(0,1,1,-1),new Grad(0,1,-1,1),new Grad(0,1,-1,-1), + new Grad(0,-1,1,1),new Grad(0,-1,1,-1),new Grad(0,-1,-1,1),new Grad(0,-1,-1,-1), + new Grad(1,0,1,1),new Grad(1,0,1,-1),new Grad(1,0,-1,1),new Grad(1,0,-1,-1), + new Grad(-1,0,1,1),new Grad(-1,0,1,-1),new Grad(-1,0,-1,1),new Grad(-1,0,-1,-1), + new Grad(1,1,0,1),new Grad(1,1,0,-1),new Grad(1,-1,0,1),new Grad(1,-1,0,-1), + new Grad(-1,1,0,1),new Grad(-1,1,0,-1),new Grad(-1,-1,0,1),new Grad(-1,-1,0,-1), + new Grad(1,1,1,0),new Grad(1,1,-1,0),new Grad(1,-1,1,0),new Grad(1,-1,-1,0), + new Grad(-1,1,1,0),new Grad(-1,1,-1,0),new Grad(-1,-1,1,0),new Grad(-1,-1,-1,0)}; + + private static short p[] = {151,160,137,91,90,15, + 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, + 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, + 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, + 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, + 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, + 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, + 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, + 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, + 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, + 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, + 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, + 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180}; + // To remove the need for index wrapping, double the permutation table length + private static short perm[] = new short[512]; + private static short permMod12[] = new short[512]; + static { + for(int i=0; i<512; i++) + { + perm[i]=p[i & 255]; + permMod12[i] = (short)(perm[i] % 12); + } + } + + // Skewing and unskewing factors for 2, 3, and 4 dimensions + private static final double F2 = 0.5*(Math.sqrt(3.0)-1.0); + private static final double G2 = (3.0-Math.sqrt(3.0))/6.0; + private static final double F3 = 1.0/3.0; + private static final double G3 = 1.0/6.0; + private static final double F4 = (Math.sqrt(5.0)-1.0)/4.0; + private static final double G4 = (5.0-Math.sqrt(5.0))/20.0; + + // This method is a *lot* faster than using (int)Math.floor(x) + private static int fastfloor(double x) { + int xi = (int)x; + return x<xi ? xi-1 : xi; + } + + private static double dot(Grad g, double x, double y) { + return g.x*x + g.y*y; } + + private static double dot(Grad g, double x, double y, double z) { + return g.x*x + g.y*y + g.z*z; } + + private static double dot(Grad g, double x, double y, double z, double w) { + return g.x*x + g.y*y + g.z*z + g.w*w; } + + + // 2D simplex noise + public static double noise(double xin, double yin) { + double n0, n1, n2; // Noise contributions from the three corners + // Skew the input space to determine which simplex cell we're in + double s = (xin+yin)*F2; // Hairy factor for 2D + int i = fastfloor(xin+s); + int j = fastfloor(yin+s); + double t = (i+j)*G2; + double X0 = i-t; // Unskew the cell origin back to (x,y) space + double Y0 = j-t; + double x0 = xin-X0; // The x,y distances from the cell origin + double y0 = yin-Y0; + // For the 2D case, the simplex shape is an equilateral triangle. + // Determine which simplex we are in. + int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords + if(x0>y0) {i1=1; j1=0;} // lower triangle, XY order: (0,0)->(1,0)->(1,1) + else {i1=0; j1=1;} // upper triangle, YX order: (0,0)->(0,1)->(1,1) + // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and + // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where + // c = (3-sqrt(3))/6 + double x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords + double y1 = y0 - j1 + G2; + double x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords + double y2 = y0 - 1.0 + 2.0 * G2; + // Work out the hashed gradient indices of the three simplex corners + int ii = i & 255; + int jj = j & 255; + int gi0 = permMod12[ii+perm[jj]]; + int gi1 = permMod12[ii+i1+perm[jj+j1]]; + int gi2 = permMod12[ii+1+perm[jj+1]]; + // Calculate the contribution from the three corners + double t0 = 0.5 - x0*x0-y0*y0; + if(t0<0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient + } + double t1 = 0.5 - x1*x1-y1*y1; + if(t1<0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad3[gi1], x1, y1); + } + double t2 = 0.5 - x2*x2-y2*y2; + if(t2<0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad3[gi2], x2, y2); + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to return values in the interval [-1,1]. + return 70.0 * (n0 + n1 + n2); + } + + + // 3D simplex noise + public static double noise(double xin, double yin, double zin) { + double n0, n1, n2, n3; // Noise contributions from the four corners + // Skew the input space to determine which simplex cell we're in + double s = (xin+yin+zin)*F3; // Very nice and simple skew factor for 3D + int i = fastfloor(xin+s); + int j = fastfloor(yin+s); + int k = fastfloor(zin+s); + double t = (i+j+k)*G3; + double X0 = i-t; // Unskew the cell origin back to (x,y,z) space + double Y0 = j-t; + double Z0 = k-t; + double x0 = xin-X0; // The x,y,z distances from the cell origin + double y0 = yin-Y0; + double z0 = zin-Z0; + // For the 3D case, the simplex shape is a slightly irregular tetrahedron. + // Determine which simplex we are in. + int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords + int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords + if(x0>=y0) { + if(y0>=z0) + { i1=1; j1=0; k1=0; i2=1; j2=1; k2=0; } // X Y Z order + else if(x0>=z0) { i1=1; j1=0; k1=0; i2=1; j2=0; k2=1; } // X Z Y order + else { i1=0; j1=0; k1=1; i2=1; j2=0; k2=1; } // Z X Y order + } + else { // x0<y0 + if(y0<z0) { i1=0; j1=0; k1=1; i2=0; j2=1; k2=1; } // Z Y X order + else if(x0<z0) { i1=0; j1=1; k1=0; i2=0; j2=1; k2=1; } // Y Z X order + else { i1=0; j1=1; k1=0; i2=1; j2=1; k2=0; } // Y X Z order + } + // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z), + // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and + // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where + // c = 1/6. + double x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords + double y1 = y0 - j1 + G3; + double z1 = z0 - k1 + G3; + double x2 = x0 - i2 + 2.0*G3; // Offsets for third corner in (x,y,z) coords + double y2 = y0 - j2 + 2.0*G3; + double z2 = z0 - k2 + 2.0*G3; + double x3 = x0 - 1.0 + 3.0*G3; // Offsets for last corner in (x,y,z) coords + double y3 = y0 - 1.0 + 3.0*G3; + double z3 = z0 - 1.0 + 3.0*G3; + // Work out the hashed gradient indices of the four simplex corners + int ii = i & 255; + int jj = j & 255; + int kk = k & 255; + int gi0 = permMod12[ii+perm[jj+perm[kk]]]; + int gi1 = permMod12[ii+i1+perm[jj+j1+perm[kk+k1]]]; + int gi2 = permMod12[ii+i2+perm[jj+j2+perm[kk+k2]]]; + int gi3 = permMod12[ii+1+perm[jj+1+perm[kk+1]]]; + // Calculate the contribution from the four corners + double t0 = 0.6 - x0*x0 - y0*y0 - z0*z0; + if(t0<0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad3[gi0], x0, y0, z0); + } + double t1 = 0.6 - x1*x1 - y1*y1 - z1*z1; + if(t1<0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad3[gi1], x1, y1, z1); + } + double t2 = 0.6 - x2*x2 - y2*y2 - z2*z2; + if(t2<0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad3[gi2], x2, y2, z2); + } + double t3 = 0.6 - x3*x3 - y3*y3 - z3*z3; + if(t3<0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad3[gi3], x3, y3, z3); + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to stay just inside [-1,1] + return 32.0*(n0 + n1 + n2 + n3); + } + + + // 4D simplex noise, better simplex rank ordering method 2012-03-09 + public static double noise(double x, double y, double z, double w) { + + double n0, n1, n2, n3, n4; // Noise contributions from the five corners + // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in + double s = (x + y + z + w) * F4; // Factor for 4D skewing + int i = fastfloor(x + s); + int j = fastfloor(y + s); + int k = fastfloor(z + s); + int l = fastfloor(w + s); + double t = (i + j + k + l) * G4; // Factor for 4D unskewing + double X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space + double Y0 = j - t; + double Z0 = k - t; + double W0 = l - t; + double x0 = x - X0; // The x,y,z,w distances from the cell origin + double y0 = y - Y0; + double z0 = z - Z0; + double w0 = w - W0; + // For the 4D case, the simplex is a 4D shape I won't even try to describe. + // To find out which of the 24 possible simplices we're in, we need to + // determine the magnitude ordering of x0, y0, z0 and w0. + // Six pair-wise comparisons are performed between each possible pair + // of the four coordinates, and the results are used to rank the numbers. + int rankx = 0; + int ranky = 0; + int rankz = 0; + int rankw = 0; + if(x0 > y0) rankx++; else ranky++; + if(x0 > z0) rankx++; else rankz++; + if(x0 > w0) rankx++; else rankw++; + if(y0 > z0) ranky++; else rankz++; + if(y0 > w0) ranky++; else rankw++; + if(z0 > w0) rankz++; else rankw++; + int i1, j1, k1, l1; // The integer offsets for the second simplex corner + int i2, j2, k2, l2; // The integer offsets for the third simplex corner + int i3, j3, k3, l3; // The integer offsets for the fourth simplex corner + // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. + // Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w + // impossible. Only the 24 indices which have non-zero entries make any sense. + // We use a thresholding to set the coordinates in turn from the largest magnitude. + // Rank 3 denotes the largest coordinate. + i1 = rankx >= 3 ? 1 : 0; + j1 = ranky >= 3 ? 1 : 0; + k1 = rankz >= 3 ? 1 : 0; + l1 = rankw >= 3 ? 1 : 0; + // Rank 2 denotes the second largest coordinate. + i2 = rankx >= 2 ? 1 : 0; + j2 = ranky >= 2 ? 1 : 0; + k2 = rankz >= 2 ? 1 : 0; + l2 = rankw >= 2 ? 1 : 0; + // Rank 1 denotes the second smallest coordinate. + i3 = rankx >= 1 ? 1 : 0; + j3 = ranky >= 1 ? 1 : 0; + k3 = rankz >= 1 ? 1 : 0; + l3 = rankw >= 1 ? 1 : 0; + // The fifth corner has all coordinate offsets = 1, so no need to compute that. + double x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords + double y1 = y0 - j1 + G4; + double z1 = z0 - k1 + G4; + double w1 = w0 - l1 + G4; + double x2 = x0 - i2 + 2.0*G4; // Offsets for third corner in (x,y,z,w) coords + double y2 = y0 - j2 + 2.0*G4; + double z2 = z0 - k2 + 2.0*G4; + double w2 = w0 - l2 + 2.0*G4; + double x3 = x0 - i3 + 3.0*G4; // Offsets for fourth corner in (x,y,z,w) coords + double y3 = y0 - j3 + 3.0*G4; + double z3 = z0 - k3 + 3.0*G4; + double w3 = w0 - l3 + 3.0*G4; + double x4 = x0 - 1.0 + 4.0*G4; // Offsets for last corner in (x,y,z,w) coords + double y4 = y0 - 1.0 + 4.0*G4; + double z4 = z0 - 1.0 + 4.0*G4; + double w4 = w0 - 1.0 + 4.0*G4; + // Work out the hashed gradient indices of the five simplex corners + int ii = i & 255; + int jj = j & 255; + int kk = k & 255; + int ll = l & 255; + int gi0 = perm[ii+perm[jj+perm[kk+perm[ll]]]] % 32; + int gi1 = perm[ii+i1+perm[jj+j1+perm[kk+k1+perm[ll+l1]]]] % 32; + int gi2 = perm[ii+i2+perm[jj+j2+perm[kk+k2+perm[ll+l2]]]] % 32; + int gi3 = perm[ii+i3+perm[jj+j3+perm[kk+k3+perm[ll+l3]]]] % 32; + int gi4 = perm[ii+1+perm[jj+1+perm[kk+1+perm[ll+1]]]] % 32; + // Calculate the contribution from the five corners + double t0 = 0.6 - x0*x0 - y0*y0 - z0*z0 - w0*w0; + if(t0<0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad4[gi0], x0, y0, z0, w0); + } + double t1 = 0.6 - x1*x1 - y1*y1 - z1*z1 - w1*w1; + if(t1<0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad4[gi1], x1, y1, z1, w1); + } + double t2 = 0.6 - x2*x2 - y2*y2 - z2*z2 - w2*w2; + if(t2<0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad4[gi2], x2, y2, z2, w2); + } + double t3 = 0.6 - x3*x3 - y3*y3 - z3*z3 - w3*w3; + if(t3<0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad4[gi3], x3, y3, z3, w3); + } + double t4 = 0.6 - x4*x4 - y4*y4 - z4*z4 - w4*w4; + if(t4<0) n4 = 0.0; + else { + t4 *= t4; + n4 = t4 * t4 * dot(grad4[gi4], x4, y4, z4, w4); + } + // Sum up and scale the result to cover the range [-1,1] + return 27.0 * (n0 + n1 + n2 + n3 + n4); + } + + // Inner class to speed upp gradient computations + // (array access is a lot slower than member access) + private static class Grad + { + double x, y, z, w; + + Grad(double x, double y, double z) + { + this.x = x; + this.y = y; + this.z = z; + } + + Grad(double x, double y, double z, double w) + { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + } +} 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 2c126759b8..cca1bf94d4 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java @@ -23,12 +23,14 @@ package com.github.bartimaeusnek.crossmod.galacticraft; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.crossmod.galacticraft.atmosphere.BWAtmosphereManager; 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.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import gregtech.api.objects.GT_UO_DimensionList; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import java.io.File; @@ -74,6 +76,7 @@ public class GalacticraftProxy { if (GalacticraftProxy.gtConf.hasChanged()) GalacticraftProxy.gtConf.save(); init_OresRoss128(); + MinecraftForge.EVENT_BUS.register(BWAtmosphereManager.INSTANCE); } public static void init(FMLInitializationEvent e) { diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java new file mode 100644 index 0000000000..0b835e382c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java @@ -0,0 +1,113 @@ +/* + * 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.crossmod.galacticraft.atmosphere; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.google.common.collect.ArrayListMultimap; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; +import micdoodle8.mods.galacticraft.api.galaxies.GalaxyRegistry; +import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas; + +import java.util.*; + +public final class BWAtmosphereManager { + + private static final Map<Integer,Integer[]> COEFFICIENT_MAP = new HashMap<>(); + + private BWAtmosphereManager() { + BWAtmosphereManager.COEFFICIENT_MAP.put(1, new Integer[]{100}); + BWAtmosphereManager.COEFFICIENT_MAP.put(2,new Integer[]{70,30}); + BWAtmosphereManager.COEFFICIENT_MAP.put(3,new Integer[]{60,25,15}); + BWAtmosphereManager.COEFFICIENT_MAP.put(4,new Integer[]{50,25,15,10}); + BWAtmosphereManager.COEFFICIENT_MAP.put(5,new Integer[]{45,25,15,10,5}); + BWAtmosphereManager.COEFFICIENT_MAP.put(6,new Integer[]{45,20,15,10,5,5}); + BWAtmosphereManager.COEFFICIENT_MAP.put(7,new Integer[]{40,20,15,10,5,5,5}); + BWAtmosphereManager.COEFFICIENT_MAP.put(8,new Integer[]{35,20,15,10,5,5,5,5}); + BWAtmosphereManager.COEFFICIENT_MAP.put(9,new Integer[]{35,15,15,10,5,5,5,5,5}); + } + + public static final BWAtmosphereManager INSTANCE = new BWAtmosphereManager(); + + private static final ArrayListMultimap<Integer, Pair<ISubTagContainer,Integer>> gasConcentration = ArrayListMultimap.create(); + + public static List<Pair<ISubTagContainer,Integer>> getGasFromWorldID(int worldID){ + return BWAtmosphereManager.gasConcentration.get(worldID); + } + + public static void removeGasFromWorld(int worldID, ISubTagContainer gas){ + HashSet toRemSet = new HashSet(); + for (Pair<ISubTagContainer,Integer> pair : BWAtmosphereManager.gasConcentration.get(worldID)){ + if (pair.getKey().equals(gas)){ + BWAtmosphereManager.gasConcentration.get(worldID).remove(pair); + return; + } + } + } + + public static void addGasToWorld(int worldID, ISubTagContainer gas, int amount){ + Pair<ISubTagContainer,Integer> toadd = new Pair<ISubTagContainer,Integer>(gas,amount); + BWAtmosphereManager.gasConcentration.put(worldID,toadd); + } + + public static void addGasToWorld(int worldID, Pair<ISubTagContainer,Integer> toPut){ + BWAtmosphereManager.gasConcentration.put(worldID,toPut); + } + + public static void addGasToWorld(int worldID, Pair<ISubTagContainer,Integer>... toPut){ + for (Pair<ISubTagContainer,Integer> toadd : toPut) + BWAtmosphereManager.gasConcentration.put(worldID,toadd); + } + + private static boolean addGCGasToWorld(int worldID, IAtmosphericGas gas, int aNumber, int aMaxNumber){ + if (gas.equals(IAtmosphericGas.CO2)) { + BWAtmosphereManager.addGasToWorld(worldID, Materials.CarbonDioxide, BWAtmosphereManager.COEFFICIENT_MAP.get(aMaxNumber)[aNumber]); + return true; + } + String name = gas.toString(); + name = name.substring(0,1)+name.substring(1).toLowerCase(Locale.US); + ISubTagContainer mat = Materials.get(name); + if (mat == Materials._NULL){ + mat = WerkstoffLoader.getWerkstoff(name); + } + if (mat == Werkstoff.default_null_Werkstoff){ + return false; + } + BWAtmosphereManager.addGasToWorld(worldID, mat, BWAtmosphereManager.COEFFICIENT_MAP.get(aMaxNumber)[aNumber]); + return true; + } + + @SubscribeEvent + public void gcAutoRegister(GalaxyRegistry.PlanetRegisterEvent event){ + CelestialBody planet = GalaxyRegistry.getRegisteredPlanets().get(event.planetName); + for (int i = 0; i < planet.atmosphere.size(); i++) { + if (!BWAtmosphereManager.addGCGasToWorld(planet.getDimensionID(),planet.atmosphere.get(i),i,planet.atmosphere.size())) + BartWorksCrossmod.LOGGER.warn("Unidentified Fluid ("+planet.atmosphere.get(i)+") in the Atmosphere of: "+planet.getLocalizedName()); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java index 08f496edda..807ad35055 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java @@ -44,6 +44,7 @@ import net.minecraft.world.gen.feature.WorldGenLakes; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; +import sun.security.krb5.Config; import java.util.List; @@ -85,6 +86,8 @@ public class ChunkProviderRoss128b extends ChunkProviderGenerate { if (Loader.isModLoaded("Thaumcraft")) { if (ThaumcraftHandler.isTaintBiome(biomeGenBase.biomeID)) this.biomesForGeneration[i] = BiomeGenBase.taiga; + else if (ConfigHandler.disableMagicalForest && ThaumcraftHandler.isMagicalForestBiome(biomeGenBase.biomeID)) + this.biomesForGeneration[i] = BiomeGenBase.birchForest; } } this.replaceBlocksForBiome(p_73154_1_, p_73154_2_, ablock, abyte, this.biomesForGeneration); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java index aa0968a95b..677bb17e39 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java @@ -22,8 +22,11 @@ package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128ba; +import com.github.bartimaeusnek.bartworks.util.NoiseUtil.BartsNoise; import gregtech.api.objects.XSTR; import micdoodle8.mods.galacticraft.api.prefab.world.gen.MapGenBaseMeta; +import micdoodle8.mods.galacticraft.core.blocks.GCBlocks; +import micdoodle8.mods.galacticraft.core.perlin.NoiseModule; import micdoodle8.mods.galacticraft.core.world.gen.BiomeGenBaseMoon; import micdoodle8.mods.galacticraft.core.world.gen.ChunkProviderMoon; import micdoodle8.mods.galacticraft.core.world.gen.MapGenCavesMoon; @@ -63,4 +66,34 @@ public class ChunkProviderRoss128ba extends ChunkProviderMoon { Chunk.generateSkylightMap(); return Chunk; } + + private int getIndex(int x, int y, int z) { + return (x * 16 + z) * 256 + y; + } + + final Block lowerBlockID = GCBlocks.blockMoon; + final BartsNoise noiseGen= new BartsNoise(2,0.008F,1D,System.nanoTime()); + final BartsNoise noiseGen2= new BartsNoise(2,0.01F,1D,System.nanoTime()); + final BartsNoise noiseGen3= new BartsNoise(2,0.002F,1D,System.nanoTime()); + + public void generateTerrain(int chunkX, int chunkZ, Block[] idArray, byte[] metaArray) { + for(int x = 0; x < 16; ++x) { + for(int z = 0; z < 16; ++z) { + double d = noiseGen.getNoise(x + chunkX * 16, z + chunkZ * 16); + double d2 = noiseGen2.getNoise(x + chunkX * 16, z + chunkZ * 16); + double d3 = noiseGen3.getCosNoise(x + chunkX * 16, z + chunkZ * 16); + + double yDev = d*4+d2*2+d3; + + for(int y = 0; y < 128; ++y) { + if ((double)y < 60.0D + yDev) { + idArray[this.getIndex(x, y, z)] = this.lowerBlockID; + int var10001 = this.getIndex(x, y, z); + metaArray[var10001] = 4; + } + } + } + } + + } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java index 121a31bf2f..359450c7f9 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java @@ -26,6 +26,7 @@ import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; import com.github.bartimaeusnek.crossmod.galacticraft.UniversalTeleportType; import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128b.WorldProviderRoss128b; +import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128ba.WorldProviderRoss128Ba; import cpw.mods.fml.common.Loader; import micdoodle8.mods.galacticraft.api.GalacticraftRegistry; import micdoodle8.mods.galacticraft.api.galaxies.*; @@ -67,14 +68,14 @@ public class Ross128SolarSystem { 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.setDimensionInfo(ConfigHandler.ross128BAID, WorldProviderRoss128Ba.class); - Ross128SolarSystem.Ross128ba.setTierRequired(Loader.isModLoaded("galaxyspace") ? 4 : 3); + Ross128SolarSystem.Ross128ba.setDimensionInfo(ConfigHandler.ross128BAID, WorldProviderRoss128Ba.class); + Ross128SolarSystem.Ross128ba.setTierRequired(Loader.isModLoaded("galaxyspace") ? Math.min(ConfigHandler.ross128btier + 1, 8) : 3); - Ross128SolarSystem.Ross128ba.setUnreachable(); + //Ross128SolarSystem.Ross128ba.setUnreachable(); - GalaxyRegistry.registerPlanet(Ross128SolarSystem.Ross128b); - GalaxyRegistry.registerMoon(Ross128SolarSystem.Ross128ba); GalaxyRegistry.registerSolarSystem(Ross128SolarSystem.Ross128System); + GalaxyRegistry.registerPlanet(Ross128SolarSystem.Ross128b); +// GalaxyRegistry.registerMoon(Ross128SolarSystem.Ross128ba); GalacticraftRegistry.registerRocketGui(WorldProviderRoss128b.class, new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/overworldRocketGui.png")); // GalacticraftRegistry.registerRocketGui(WorldProviderRoss128Ba.class, new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/moonRocketGui.png")); 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 ebede8bf4b..ef6dcde7f0 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 @@ -38,7 +38,7 @@ public class ThaumcraftHandler { private ThaumcraftHandler(){} private static Integer taintBiomeID; - + private static Integer magicalForestBiomeID; private static Class mWandInterface; static { @@ -57,6 +57,19 @@ public class ThaumcraftHandler { } } + public static boolean isMagicalForestBiome(int biomeID){ + if (ThaumcraftHandler.magicalForestBiomeID == null) { + try { + BiomeGenBase biome = (BiomeGenBase) Class.forName("thaumcraft.common.lib.world.ThaumcraftWorldGenerator").getField("biomeMagicalForest").get(null); + return biomeID == (ThaumcraftHandler.magicalForestBiomeID = biome.biomeID); + } catch (ClassCastException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + return false; + } + } + return biomeID == ThaumcraftHandler.magicalForestBiomeID; + } + public static boolean isTaintBiome(int biomeID){ if (ThaumcraftHandler.taintBiomeID == null) { try { |