diff --git a/dependencies.gradle b/dependencies.gradle index 21ec7b37..6a921755 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -109,7 +109,7 @@ dependencies { //compileOnly "micdoodle8.mods:GalacticraftCore:1.7-3.0.12.504:Dev" //compileOnly "micdoodle8.mods:MicdoodleCore:1.7-3.0.12.504:Dev" //compileOnly "minechem:Minechem:1.7.10-6.0.407:dev" - //compileOnly "minetweaker:MineTweaker3:1.7.10-3.0.10:dev-full" + compile "minetweaker:MineTweaker3:1.7.10-3.0.10:dev-full" //compileOnly "mods.railcraft:Railcraft_1.7.10:9.12.3.0:dev" //compileOnly "mrtjp:ForgeRelocation:0.0.1.4:dev" //compileOnly "mrtjp:MrTJPCore:1.1.0.34:dev" diff --git a/src/main/java/org/altadoon/gt6x/Gt6xMod.java b/src/main/java/org/altadoon/gt6x/Gt6xMod.java index 040ad4df..d1fb8f25 100644 --- a/src/main/java/org/altadoon/gt6x/Gt6xMod.java +++ b/src/main/java/org/altadoon/gt6x/Gt6xMod.java @@ -1,12 +1,13 @@ package org.altadoon.gt6x; +import cpw.mods.fml.common.event.FMLInitializationEvent; import gregapi.data.CS; import org.altadoon.gt6x.common.*; -import org.altadoon.gt6x.common.items.ItemMaterialDisplay; import org.altadoon.gt6x.common.items.MultiItemsX; import org.altadoon.gt6x.features.GT6XFeature; import org.altadoon.gt6x.features.basicchem.BasicChemistry; import org.altadoon.gt6x.features.ceramics.Ceramics; +import org.altadoon.gt6x.features.worldgen.WorldGen; import org.altadoon.gt6x.features.oil.OilProcessing; import org.altadoon.gt6x.features.pgm.PgmProcessing; import org.altadoon.gt6x.features.metallurgy.Metallurgy; @@ -28,6 +29,7 @@ public final class Gt6xMod extends gregapi.api.Abstract_Mod { public static final String MOD_NAME = "GRADLETOKEN_MODNAME"; public static final String VERSION = "GRADLETOKEN_VERSION"; public static final String GROUPNAME = "GRADLETOKEN_GROUPNAME"; + public static Gt6xMod instance; public static gregapi.code.ModData MOD_DATA = new gregapi.code.ModData(MOD_ID, MOD_NAME); @cpw.mods.fml.common.SidedProxy(modId = MOD_ID, clientSide = "gregapi.api.example.Example_Proxy_Client", serverSide = "gregapi.api.example.Example_Proxy_Server") @@ -57,7 +59,8 @@ public final class Gt6xMod extends gregapi.api.Abstract_Mod { OilProcessing.class, PgmProcessing.class, RefractoryMetals.class, - VerticalMixers.class + VerticalMixers.class, + WorldGen.class }; private final ArrayList enabledFeatures; @@ -66,7 +69,23 @@ public Gt6xMod() { this.modConfig = new Config(allFeatures); this.enabledFeatures = modConfig.getEnabledFeatures(); - + // try to use shady reflection code to detect feature classes + // sometimes work sometimes dosent +// try{ +// Field field = ClassLoader.class.getDeclaredField("classes"); +// field.setAccessible(true); +// Collection> clzs = (Collection>) field.get(this.getClass().getClassLoader()); +// for(var claz:clzs){ +// if(claz.getName().contains("org.altadoon.gt6x.features.")){ +// System.out.println(claz.getName()); +// if(claz.getSuperclass().equals(GT6XFeature.class)){ +// allFeatures.add((Class) claz); +// } +// } +// } +// } catch (Exception ignored){ +// ignored.printStackTrace(); +// } final Gt6xMod copy = this; GT.mBeforePreInit.add(copy::prePreInit); GT.mAfterPreInit.add(copy::postPreInit); @@ -80,14 +99,13 @@ public void onModPreInit2(cpw.mods.fml.common.event.FMLPreInitializationEvent aE MTx.touch(); RMx.init(); MultiItemsX.instance = new MultiItemsX(MOD_ID, "gt6x.multiitems"); - for (GT6XFeature feature : enabledFeatures) { feature.preInit(); } } @Override - public void onModInit2(cpw.mods.fml.common.event.FMLInitializationEvent aEvent) { + public void onModInit2(FMLInitializationEvent aEvent) { for (GT6XFeature feature : enabledFeatures) { feature.init(); } diff --git a/src/main/java/org/altadoon/gt6x/ProxyClient.java b/src/main/java/org/altadoon/gt6x/ProxyClient.java index dcf6768b..8f781068 100644 --- a/src/main/java/org/altadoon/gt6x/ProxyClient.java +++ b/src/main/java/org/altadoon/gt6x/ProxyClient.java @@ -1,13 +1,6 @@ package org.altadoon.gt6x; -import gregapi.api.Abstract_Proxy; - -/** - * @author Max Mustermann - * - * An example implementation for a Clientside Proxy using my System. - */ -public final class ProxyClient extends Abstract_Proxy { +public class ProxyClient extends ProxyServer { // Insert your Clientside-only implementation of Stuff here } \ No newline at end of file diff --git a/src/main/java/org/altadoon/gt6x/ProxyServer.java b/src/main/java/org/altadoon/gt6x/ProxyServer.java index 7cf5ba30..fb2d36d1 100644 --- a/src/main/java/org/altadoon/gt6x/ProxyServer.java +++ b/src/main/java/org/altadoon/gt6x/ProxyServer.java @@ -1,13 +1,21 @@ package org.altadoon.gt6x; +import cpw.mods.fml.common.IWorldGenerator; import gregapi.api.Abstract_Proxy; +import gregapi.data.CS; +import gregapi.worldgen.WorldgenObject; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import java.util.Random; -/** - * @author Max Mustermann - * - * An example implementation for a Serverside Proxy using my System. - */ -public final class ProxyServer extends Abstract_Proxy { + +public class ProxyServer extends Abstract_Proxy implements IWorldGenerator { + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { +// if(world.provider.dimensionId == CS.DIM_OVERWORLD){ +// new WorldgenObject().generate(world,world.getChunkFromChunkCoords(chunkX,chunkZ),) +// } + } // Insert your Serverside-only implementation of Stuff here } \ No newline at end of file diff --git a/src/main/java/org/altadoon/gt6x/common/RMx.java b/src/main/java/org/altadoon/gt6x/common/RMx.java index 7712e6e4..200fda46 100644 --- a/src/main/java/org/altadoon/gt6x/common/RMx.java +++ b/src/main/java/org/altadoon/gt6x/common/RMx.java @@ -1,12 +1,14 @@ package org.altadoon.gt6x.common; import gregapi.recipes.Recipe.RecipeMap; +import org.altadoon.gt6x.features.metallurgy.utils.EAFSmeltingRecipe; import static gregapi.data.CS.RES_PATH_GUI; /** Common recipe maps */ public class RMx { public static RecipeMap sintering = null; + public static RecipeMap electric_arc_furnace = EAFSmeltingRecipe.FakeRecipes; public static void init() { sintering = new RecipeMap(null, "gt6x.recipe.sintering", "Sintering", null, 0, 1, RES_PATH_GUI+"machines/Sintering", 6, 1, 1, 0, 0, 0, 1, 1, "", 1, "", true, true, true, true, false, true, true); diff --git a/src/main/java/org/altadoon/gt6x/common/recipe/RB.java b/src/main/java/org/altadoon/gt6x/common/recipe/RB.java new file mode 100644 index 00000000..678daff4 --- /dev/null +++ b/src/main/java/org/altadoon/gt6x/common/recipe/RB.java @@ -0,0 +1,101 @@ +package org.altadoon.gt6x.common.recipe; + +import gregapi.data.RM; +import gregapi.recipes.Recipe; + +public class RB { + public static final RB DidYouKnow=new RB(RM.DidYouKnow) + , Autocrafter=new RB(RM.Autocrafter) + , DistillationTower=new RB(RM.DistillationTower) + , CryoDistillationTower=new RB(RM.CryoDistillationTower) + , SteamCracking=new RB(RM.SteamCracking) + , CatalyticCracking=new RB(RM.CatalyticCracking) + , Fermenter=new RB(RM.Fermenter) + , Distillery=new RB(RM.Distillery) + , Drying=new RB(RM.Drying) + , Coagulator=new RB(RM.Coagulator) + , CrystallisationCrucible=new RB(RM.CrystallisationCrucible) + , Mixer=new RB(RM.Mixer) + , HeatMixer=new RB(RM.HeatMixer) + , BurnMixer=new RB(RM.BurnMixer) + , CryoMixer=new RB(RM.CryoMixer) + , CokeOven=new RB(RM.CokeOven) + , Roasting=new RB(RM.Roasting) + , Bath=new RB(RM.Bath) + , Sluice=new RB(RM.Sluice) + , MagneticSeparator=new RB(RM.MagneticSeparator) + , Sifting=new RB(RM.Sifting) + , Calciner=new RB(RM.Calciner) + , ImplosionCompressor=new RB(RM.ImplosionCompressor) + , Compressor=new RB(RM.Compressor) + , Injector=new RB(RM.Injector) + , Loom=new RB(RM.Loom) + , Laminator=new RB(RM.Laminator) + , Autoclave=new RB(RM.Autoclave) + , Freezer=new RB(RM.Freezer) + , Polarizer=new RB(RM.Polarizer) + , Lightning=new RB(RM.Lightning) + , Slicer=new RB(RM.Slicer) + , Lathe=new RB(RM.Lathe) + , Debarker=new RB(RM.Debarker) + , Press=new RB(RM.Press) + , Squeezer=new RB(RM.Squeezer) + , Juicer=new RB(RM.Juicer) + , Furnace=new RB(RM.Furnace) + , Microwave=new RB(RM.Microwave) + , Cooking=new RB(RM.Cooking) + , BumbleQueens=new RB(RM.BumbleQueens) + , Bumblelyzer=new RB(RM.Bumblelyzer) + , Trees=new RB(RM.Trees) + , Plantalyzer=new RB(RM.Plantalyzer) + , Wiremill=new RB(RM.Wiremill) + , ClusterMill=new RB(RM.ClusterMill) + , RollingMill=new RB(RM.RollingMill) + , RollBender=new RB(RM.RollBender) + , RollFormer=new RB(RM.RollFormer) + , LaserEngraver=new RB(RM.LaserEngraver) + , Welder=new RB(RM.Welder) + , Anvil=new RB(RM.Anvil) + , AnvilBendSmall=new RB(RM.AnvilBendSmall) + , AnvilBendBig=new RB(RM.AnvilBendBig) + , Centrifuge=new RB(RM.Centrifuge) + , Electrolyzer=new RB(RM.Electrolyzer) + , ToolHeads=new RB(RM.ToolHeads) + , Sharpening=new RB(RM.Sharpening) + , CrucibleAlloying=new RB(RM.CrucibleAlloying) + , CrucibleSmelting=new RB(RM.CrucibleSmelting) + , Cutter=new RB(RM.Cutter) + , Smelter=new RB(RM.Smelter) + , Mortar=new RB(RM.Mortar) + , Shredder=new RB(RM.Shredder) + , Crusher=new RB(RM.Crusher) + , Extruder=new RB(RM.Extruder) + , Hammer=new RB(RM.Hammer) + , Chisel=new RB(RM.Chisel) + , Nanofab=new RB(RM.Nanofab) + , Printer=new RB(RM.Printer) + , ScannerVisuals=new RB(RM.ScannerVisuals) + , ScannerMolecular=new RB(RM.ScannerMolecular) + , Massfab=new RB(RM.Massfab) + , Replicator=new RB(RM.Replicator) + , Fusion=new RB(RM.Fusion) + , Canner=new RB(RM.Canner) + , Boxinator=new RB(RM.Boxinator) + , Unboxinator=new RB(RM.Unboxinator) + , Generifier=new RB(RM.Generifier) + , BedrockOreList=new RB(RM.BedrockOreList) + , ByProductList=new RB(RM.ByProductList) + , BlastFurnace=new RB(RM.BlastFurnace) + , VacuumFreezer=new RB(RM.VacuumFreezer) + , Assembler=new RB(RM.Assembler) + , CNC=new RB(RM.CNC); + + public final Recipe.RecipeMap MAP; + RB(Recipe.RecipeMap aRecipeMap){ + MAP = aRecipeMap; + } + + public RecipeBuilder builder(){ + return new RecipeBuilder(MAP); + } +} diff --git a/src/main/java/org/altadoon/gt6x/common/recipe/RecipeBuilder.java b/src/main/java/org/altadoon/gt6x/common/recipe/RecipeBuilder.java new file mode 100644 index 00000000..0eb633bc --- /dev/null +++ b/src/main/java/org/altadoon/gt6x/common/recipe/RecipeBuilder.java @@ -0,0 +1,455 @@ +package org.altadoon.gt6x.common.recipe; + +import gregapi.data.FL; +import gregapi.oredict.OreDictManager; +import gregapi.oredict.OreDictMaterial; +import gregapi.oredict.OreDictPrefix; +import gregapi.recipes.Recipe; +import gregapi.util.ST; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import org.altadoon.gt6x.common.utils.OD_Utils; + +import java.util.ArrayList; +import java.util.List; + +import static gregapi.data.CS.*; + +/** + * + */ +public class RecipeBuilder { + + List builderList = new ArrayList<>(); + + public static RecipeBuilder create(Recipe.RecipeMap recipeMap){ + return new RecipeBuilder(recipeMap); + } + public RecipeBuilder(Recipe.RecipeMap aRecipeMap) { + RecipeBuilderInternal builder = new RecipeBuilderInternal(aRecipeMap); + builderList.add(builder); + } + + /** + * @param aStacks an OreDictionary List of Items + * Warning: Outputs do not inTake OreDictionary + */ + public RecipeBuilder item(List aStacks, boolean isInput, int aChance){ + if(aStacks.isEmpty()) return this; + List aList = new ArrayList<>(); + for(var s:aStacks) { + builderList.forEach(builder -> { + if (isInput) aList.add(new RecipeBuilderInternal(builder).input(s)); + if (!isInput && aChance > -1) aList.add(new RecipeBuilderInternal(builder).output(s)); + if (!isInput && aChance < 0) aList.add(new RecipeBuilderInternal(builder).chancedOutput(s,aChance)); + }); + } + builderList.clear(); + builderList.addAll(aList); + return this; + } + + public RecipeBuilder item(List aStacks, boolean isInput){ + return item(aStacks,isInput,-1); + } + + public RecipeBuilder item(String aOreDictionary,int aAmount, boolean isInput, int aChances){ + return item(OD_Utils.getOres(aOreDictionary,aAmount,false),isInput,aChances); + } + + public RecipeBuilder item(OreDictPrefix aPrefix, OreDictMaterial aMaterial, int aAmount, boolean isInput,boolean aOreDict,int aChance){ + if(aOreDict) return item(OD_Utils.getOres(aPrefix,aMaterial,aAmount,false),isInput,aChance); + return item(aPrefix.mat(aMaterial,aAmount),isInput,aChance); + } + + /** + * @param aStacks an OreDictionary List of Items + */ + public RecipeBuilder input(List aStacks){ + return item(aStacks,true); + } + + /** + * @param aStacks gets the first OreDictionary List of Items + */ + public RecipeBuilder output(List aStacks){ + return item(aStacks.get(0),false,-1); + } + + public RecipeBuilder item(ItemStack aStack,boolean isInput,int aChance){ + builderList.forEach(builder->builder.item(aStack,isInput,aChance)); + return this; + } + public RecipeBuilder item(ItemStack aStack,boolean isInput){ + return item(aStack,isInput,-1); + } + + public RecipeBuilder item(Item aItem, boolean isInput) { + return item(aItem, W, isInput); + } + + public RecipeBuilder item(Item aItem, short aMeta, boolean isInput) { + return item(aItem, 1, aMeta, isInput); + } + + public RecipeBuilder input(Item aItem, short aMeta) { + return input(aItem, 1, aMeta); + } + + public RecipeBuilder input(Item aItem, int aSize, short aMeta) { + return item(aItem, aSize, aMeta, true); + } + + public RecipeBuilder output(Item aItem, short aMeta) { + return output(aItem, 1, aMeta); + } + + public RecipeBuilder output(Item aItem, int aSize, short aMeta) { + return item(aItem, aSize, aMeta, false); + } + + public RecipeBuilder item(Item aItem, int aSize, short aMeta, boolean isInput){ + return item(ST.make(aItem,aSize,aMeta),isInput); + } + + public RecipeBuilder input(ItemStack aStack){ + return item(aStack,true); + } + + public RecipeBuilder output(ItemStack aStack){ + return item(aStack,false); + } + + public RecipeBuilder input(OreDictPrefix aPrefix, OreDictMaterial aMaterial) { + return input(aPrefix, aMaterial, 1); + } + + public RecipeBuilder input(OreDictPrefix aPrefix, OreDictMaterial aMaterial, int aAmount){ + return item(aPrefix,aMaterial,aAmount,true,true,-1); + } + + //TODO: fixone item sometimes randomally get stackSize of 1 while rest are correct + public RecipeBuilder output(OreDictPrefix aPrefix, OreDictMaterial aMaterial) { + return output(aPrefix, aMaterial, 1); + } + + //TODO: fixone item sometimes randomally get stackSize of 1 while rest are correct + public RecipeBuilder output(OreDictPrefix aPrefix, OreDictMaterial aMaterial, int aAmount){ + return item(aPrefix,aMaterial,aAmount,false,false,-1); + } + + public RecipeBuilder input(OreDictPrefix aPrefix, OreDictMaterial aMaterial, boolean aUseOreDict) { + return input(aPrefix, aMaterial, 1, aUseOreDict); + } + + public RecipeBuilder input(OreDictPrefix aPrefix, OreDictMaterial aMaterial, int aAmount, boolean aUseOreDict){ + return item(aPrefix,aMaterial,aAmount,true,aUseOreDict,-1); + } + + public RecipeBuilder input(String aOreDictionary) { + return input(aOreDictionary, 1); + } + + public RecipeBuilder input(String aOreDictionary, int aAmount){ + return item(aOreDictionary,aAmount,true,-1); + } + + /** + * @param aOreDictionary gets the first item of the ore dictionary + */ + public RecipeBuilder output(String aOreDictionary) { + return output(aOreDictionary, 1); + } + + /** + * @param aOreDictionary gets the first item of the ore dictionary + */ + public RecipeBuilder output(String aOreDictionary, int aAmount){ + return output(ST.amount(aAmount,OreDictManager.getOres(aOreDictionary,false).get(0))); + } + + + public RecipeBuilder chancedOutput(ItemStack aStack, int aChances){ + return item(aStack,false,aChances); + } + + public RecipeBuilder chancedOutput(OreDictPrefix aPrefix,OreDictMaterial aMaterial, int aChances) { + return chancedOutput(aPrefix, aMaterial, 1, aChances); + } + + public RecipeBuilder chancedOutput(OreDictPrefix aPrefix, OreDictMaterial aMaterial, int aAmount, int aChances){ + return chancedOutput(aPrefix.mat(aMaterial,aAmount),aChances); + } + + public RecipeBuilder notConsumed(OreDictPrefix aPrefix,OreDictMaterial aMaterial){ + return input(aPrefix,aMaterial,0,false); + } + + @Deprecated + // FIXME: OreDicts dont work in not consumption + public RecipeBuilder notConsumed(String aOreDict){ + return input(aOreDict,0); + } + + public RecipeBuilder notConsumed(Item aItem){ + return notConsumed(aItem,W); + } + + public RecipeBuilder notConsumed(Item aItem,short aMeta){ + return input(ST.make(aItem,0,aMeta)); + } + + public RecipeBuilder notConsumed(ItemStack aStack){ + return input(ST.amount(0,aStack)); + } + + @Deprecated() + public RecipeBuilder notConsumed(List aStacks){ + aStacks.forEach(itemStack -> itemStack.stackSize=0); + return input(aStacks); + } + + public RecipeBuilder fluid(boolean aInput,FluidStack... aFluidStack){ + builderList.forEach(builder -> builder.fluid(aInput,aFluidStack)); + return this; + } + + public RecipeBuilder inputFluid(FluidStack... aFluidStack){ + return fluid(true,aFluidStack); + } + + public RecipeBuilder outputFluid(FluidStack... aFluidStack){ + return fluid(true,aFluidStack); + } + + public RecipeBuilder inputFluid(Fluid aFluid, int aAmount){ + return fluid(true, FL.make(aFluid,aAmount)); + } + + public RecipeBuilder outputFluid(Fluid aFluid, int aAmount){ + return fluid(false, FL.make(aFluid,aAmount)); + } + + public RecipeBuilder circuit(int aCircuit){ + builderList.forEach(builder -> builder.circuit(aCircuit)); + return this; + } + + public RecipeBuilder fake(){ + builderList.forEach(RecipeBuilderInternal::fake); + return this; + } + + public RecipeBuilder eut(int aEUt) { + builderList.forEach(builder -> builder.eut(aEUt)); + return this; + } + + public RecipeBuilder duration(int aDuration) { + builderList.forEach(builder -> builder.duration(aDuration)); + return this; + } + + /** + * Warning: We check for collision which basically removes oreDict Possibilities from outputs + * this is necessary because outputs cannot be different! + */ + public void build() { + builderList.forEach(RecipeBuilderInternal::optimizedBuild); + } + + final class RecipeBuilderInternal { + Recipe.RecipeMap recipeMap; + ItemStack[] mInputs,mOutputs; + FluidStack[] mFluidInputs, mFluidOutputs; + + long[] mChances, mMaxChances; + /** An Item that needs to be inside the Special Slot, like for example the Copy Slot inside the Printer. This is only useful for Fake Recipes in NEI, since findRecipe() and containsInput() don't give a shit about this Field. Lists are also possible. */ + Object mSpecialItems = null; + /** Use this to just disable a specific Recipe, but the Configuration enables that already for every single Recipe. */ + public boolean mEnabled = T; + /** If this Recipe is hidden from NEI */ + public boolean mHidden = F; + /** If this Recipe is Fake and therefore doesn't get found by the findRecipe Function (It is still in the HashMaps, so that containsInput does return T on those fake Inputs) */ + public boolean mFakeRecipe = F; + /** If this Recipe can be stored inside a Machine in order to make Recipe searching more Efficient by trying the previously used Recipe first. In case you have a Recipe Map overriding things and returning one time use Recipes, you have to set this to F. */ + public boolean mCanBeBuffered = T; + /** If this Recipe needs the Output Slots to be completely empty. Needed in case you have randomised Outputs */ + public boolean mNeedsEmptyOutput = F; + + long mDuration, mEUt, mSpecialValue; + + public RecipeBuilderInternal(Recipe.RecipeMap recipeMap){ + this.recipeMap = recipeMap; mDuration=100; mEUt = 0; + mInputs = new ItemStack[recipeMap.mInputItemsCount]; + mOutputs = new ItemStack[recipeMap.mOutputItemsCount]; + mFluidInputs = new FluidStack[recipeMap.mInputFluidCount]; + mFluidOutputs = new FluidStack[recipeMap.mOutputFluidCount]; + mChances = new long[mOutputs.length]; + } + + public RecipeBuilderInternal(RecipeBuilderInternal aCopy){ + recipeMap=aCopy.recipeMap; + mDuration=aCopy.mDuration; + mChances=aCopy.mChances; + mMaxChances=aCopy.mMaxChances; + mEUt=aCopy.mEUt; + mInputs=aCopy.mInputs.clone(); + mOutputs= aCopy.mOutputs.clone(); + mFluidInputs=aCopy.mFluidInputs.clone(); + mFluidOutputs= aCopy.mFluidOutputs.clone(); + mSpecialItems=aCopy.mSpecialItems; + mSpecialValue=aCopy.mSpecialValue; + mFakeRecipe=aCopy.mFakeRecipe; + mEnabled=aCopy.mEnabled; + mHidden=aCopy.mHidden; + mCanBeBuffered=aCopy.mCanBeBuffered; + mNeedsEmptyOutput=aCopy.mNeedsEmptyOutput; + } + + public RecipeBuilderInternal eut(int aEUt){ + mEUt=aEUt; + return this; + } + + public RecipeBuilderInternal duration(int aDuration){ + mDuration=aDuration; + return this; + } + + /* INPUTS */ + + /** + * puts items one by one, first item goes on next availble index, dose nothing if it excedes maximum numbers of items allowed + */ + public RecipeBuilderInternal input(ItemStack... aItemStack){ + return item(true,aItemStack); + } + + public RecipeBuilderInternal output(ItemStack... aItemStack){ + return item(false,aItemStack); + } + + public RecipeBuilderInternal input(OreDictPrefix aPrefix, OreDictMaterial aMaterial, int aAmount){ + return item(aPrefix,aMaterial,aAmount,true); + } + + public RecipeBuilderInternal output(OreDictPrefix aPrefix, OreDictMaterial aMaterial, int aAmount){ + return item(aPrefix,aMaterial,aAmount,false); + } + + public RecipeBuilderInternal item(boolean aInput, ItemStack... aItemStack){ + for (int i = 0; i < aItemStack.length; i++) { + if(aInput) + for (int j = 0; j < mInputs.length; j++) { + if(mInputs[j]==null) { + mInputs[j] = aItemStack[i]; + break; + } + } + else { + for (int j = 0; j < mOutputs.length; j++) { + if(mOutputs[j]==null) { + mOutputs[j] = aItemStack[i]; + break; + } + } + } + } + return this; + } + + public RecipeBuilderInternal item(ItemStack aStack, boolean aInput ,int aChance){ + if(!aInput){ + for (int j = 0; j < mOutputs.length; j++) { + if(mOutputs[j]==null) { + mOutputs[j] = aStack; + mChances[j]=aChance; + break; + } + } + return this; + } + return item(aInput,aStack); + } + + public RecipeBuilderInternal item(ItemStack aStack, boolean aInput){ + return item(aStack,aInput,-1); + } + + public RecipeBuilderInternal item(OreDictPrefix aPrefix,OreDictMaterial aMaterial,int aAmount, boolean isInput){ + return item(aPrefix.mat(aMaterial,aAmount),isInput); + } + + public RecipeBuilderInternal item(OreDictPrefix aPrefix,OreDictMaterial aMaterial,int aAmount, boolean isInput,int aChance){ + return item(aPrefix.mat(aMaterial,aAmount),isInput,aChance); + } + + public RecipeBuilderInternal chancedOutput(ItemStack aStack, int aChance){ + return item(aStack,false,aChance); + } + + + + public RecipeBuilderInternal fluid(boolean aInput, FluidStack... aFluidStack){ + for (int i = 0; i < aFluidStack.length; i++) { + if(aInput) + for (int j = 0; j < mFluidInputs.length; j++) { + if(mFluidInputs[j]==null) { + mFluidInputs[j] = aFluidStack[i]; + break; + } + } + else { + for (int j = 0; j < mFluidOutputs.length; j++) { + if(mFluidOutputs[j]==null) { + mFluidOutputs[j] = aFluidStack[i]; + break; + } + } + } + } + return this; + } + + public RecipeBuilderInternal inputFluid(FluidStack... aFluidStacks){ + return fluid(true,aFluidStacks); + } + + public RecipeBuilderInternal outputFluid(FluidStack... aFluidStacks){ + return fluid(false,aFluidStacks); + } + + public RecipeBuilderInternal circuit(int aCircuit){ + input(ST.tag(aCircuit)); + return this; + } + + public RecipeBuilderInternal fake(){ + mFakeRecipe=true; + return this; + } + + public RecipeBuilderInternal hide(){ + mHidden=true; + return this; + } + + /* BUILD BLOCK */ + public void build(boolean aOptimize, boolean aUnification){ + var ret = new Recipe(aOptimize,aUnification,mInputs,mOutputs,mSpecialItems,mChances,mFluidInputs,mFluidOutputs,mDuration,mEUt,mSpecialValue); + recipeMap.addRecipe(ret,true,mFakeRecipe,mHidden,true); + } + + public void build(){ + build(false,false); + } + + public void optimizedBuild(){ + build(true,true); + } + } + +} diff --git a/src/main/java/org/altadoon/gt6x/common/utils/OD_Utils.java b/src/main/java/org/altadoon/gt6x/common/utils/OD_Utils.java new file mode 100644 index 00000000..10f9076d --- /dev/null +++ b/src/main/java/org/altadoon/gt6x/common/utils/OD_Utils.java @@ -0,0 +1,49 @@ +package org.altadoon.gt6x.common.utils; + +import gregapi.code.ArrayListNoNulls; +import gregapi.oredict.OreDictMaterial; +import gregapi.oredict.OreDictMaterialStack; +import gregapi.oredict.OreDictPrefix; +import gregapi.util.ST; +import gregapi.util.UT; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.List; + +import static gregapi.data.CS.*; +import static gregapi.data.CS.F; + +public class OD_Utils { + /* + just a reWrite of OreDictManager.getOres that also handles amounts + */ + public static List getOres(OreDictPrefix aPrefix, OreDictMaterial aMaterial, int aAmount,boolean aTransformWildcardBlocksTo16) { + return getOres(aPrefix.mNameInternal + aMaterial.mNameInternal, aAmount, aTransformWildcardBlocksTo16); + } + /** @return a Copy of the OreDictionary.getOres() List */ + public static List getOres(OreDictPrefix aPrefix, OreDictMaterialStack aMaterial, int aAmount, boolean aTransformWildcardBlocksTo16) { + return getOres(aPrefix.mNameInternal + aMaterial.mMaterial.mNameInternal, aAmount, aTransformWildcardBlocksTo16); + } + + /** @return a Copy of the OreDictionary.getOres() List */ + public static List getOres(Object aOreName,int aAmount, boolean aTransformWildcardBlocksTo16) { + String aName = aOreName==null?"":aOreName.toString(); + List rList = new ArrayListNoNulls<>(), tList; + if (UT.Code.stringValid(aName)) { + if (aTransformWildcardBlocksTo16) { + tList = OreDictionary.getOres(aName, F); + for (ItemStack tStack : tList) { + if (ST.meta_(tStack) == W && ST.block(tStack) != NB) { + for (int i = 0; i < 16; i++) rList.add(ST.make(tStack.getItem(), aAmount, i)); + } else { + rList.add(tStack); + } + } + } else { + rList.addAll(OreDictionary.getOres(aName, F)); + } + } + return rList; + } +} diff --git a/src/main/java/org/altadoon/gt6x/features/GT6XFeature.java b/src/main/java/org/altadoon/gt6x/features/GT6XFeature.java index 425476be..2cc392db 100644 --- a/src/main/java/org/altadoon/gt6x/features/GT6XFeature.java +++ b/src/main/java/org/altadoon/gt6x/features/GT6XFeature.java @@ -3,7 +3,7 @@ import org.altadoon.gt6x.common.Config; public abstract class GT6XFeature { - public abstract String name(); + public String name() {return this.getClass().getName();} public abstract void configure(Config config); public void beforePreInit() {} public abstract void preInit(); diff --git a/src/main/java/org/altadoon/gt6x/features/worldgen/WorldGen.java b/src/main/java/org/altadoon/gt6x/features/worldgen/WorldGen.java new file mode 100644 index 00000000..0c94a6c5 --- /dev/null +++ b/src/main/java/org/altadoon/gt6x/features/worldgen/WorldGen.java @@ -0,0 +1,48 @@ +package org.altadoon.gt6x.features.worldgen; + +import gregapi.data.MD; +import micdoodle8.mods.galacticraft.core.blocks.GCBlocks; +import net.minecraft.init.Blocks; +import org.altadoon.gt6x.common.Config; +import org.altadoon.gt6x.features.GT6XFeature; + +import static gregapi.data.CS.*; + +public class WorldGen extends GT6XFeature { + public static boolean enableMeteorite = true; + + @Override + public void configure(Config config) { + enableMeteorite = config.cfg.get("meotorite","enable", enableMeteorite).getBoolean(); + } + + @Override + public void preInit() { + + } + + @Override + public void init() { + if(enableMeteorite){ + new WorldgenMeteor("meotorite.1" , T, GEN_OVERWORLD, GEN_GT, GEN_PFAA, GEN_TFC,GEN_PLANETS); + if(MD.GC.mLoaded){ + new WorldgenMeteor("meotorite.2", BlocksGT.GraniteBlack, GCBlocks.blockMoon, T, GEN_MOON); + new WorldgenMeteor("meotorite.3", BlocksGT.GraniteBlack, T, GEN_MARS); + new WorldgenMeteor("meotorite.4", BlocksGT.GraniteBlack, GCBlocks.blockMoon, T, GEN_ASTEROIDS); + } + + if(MD.TF.mLoaded){ + new WorldgenMeteor("meotorite.5", BlocksGT.GraniteBlack, BlocksGT.Granite, T, GEN_TWILIGHT); + } + + if(MD.ATUM.mLoaded){ + new WorldgenMeteor("meotorite.6", BlocksGT.GraniteBlack, Blocks.sandstone, T, GEN_ATUM); + } + } + } + + @Override + public void postInit() { + + } +} diff --git a/src/main/java/org/altadoon/gt6x/features/worldgen/WorldgenMeteor.java b/src/main/java/org/altadoon/gt6x/features/worldgen/WorldgenMeteor.java new file mode 100644 index 00000000..ea5e98e5 --- /dev/null +++ b/src/main/java/org/altadoon/gt6x/features/worldgen/WorldgenMeteor.java @@ -0,0 +1,124 @@ +package org.altadoon.gt6x.features.worldgen; + +import appeng.api.AEApi; +import gregapi.data.MD; +import gregapi.data.MT; +import gregapi.data.OP; +import gregapi.util.WD; +import gregapi.worldgen.WorldgenObject; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraft.world.chunk.Chunk; + +import java.util.List; +import java.util.Random; +import java.util.Set; + +import static gregapi.data.CS.*; + +public class WorldgenMeteor extends WorldgenObject { + Block baseBlock = BlocksGT.GraniteBlack; + Block crustBlock = BlocksGT.GraniteBlack; + + @SafeVarargs + public WorldgenMeteor(String aName, boolean aDefault, List... aLists) { + super(aName, aDefault, aLists); + if (MD.AE.mLoaded) { + crustBlock = AEApi.instance().definitions().blocks().skyStone().maybeBlock().or(BlocksGT.GraniteBlack); + if (crustBlock == BlocksGT.GraniteBlack) + System.out.println("> ERROR, AE is present but SkyStone is not accessible."); + } + } + + @SafeVarargs + public WorldgenMeteor(String aName, Block aMainBlock, boolean aDefault, List... aLists) { + this(aName, aDefault, aLists); + baseBlock = aMainBlock; +// crustBlock = baseBlock; + } + + @SafeVarargs + public WorldgenMeteor(String aName, Block aMainBlock, Block aCrust, boolean aDefault, List... aLists) { + this(aName, aMainBlock, aDefault, aLists); + crustBlock = aCrust; + } + + @Override + public boolean generate(World aWorld, Chunk aChunk, int aDimType, int aMinX, int aMinZ, int aMaxX, int aMaxZ, Random aRandom, BiomeGenBase[][] aBiomes, Set aBiomeNames) { + if (aRandom.nextInt(50) == 0 || ((aDimType == DIM_MOON || aDimType == DIM_MARS || aDimType == DIM_ASTEROIDS || aDimType == DIM_PLANETS) && aRandom.nextInt(10) == 0)) { + int radius = 3 + aRandom.nextInt(7); + int centerX = aMinX + aRandom.nextInt(15); + int centerZ = aMinZ + aRandom.nextInt(15); + int centerY = aWorld.getChunkFromBlockCoords(centerX, centerZ).getHeightValue(centerX & 15, centerZ & 15); + // prevent floating in water + while (WD.anywater(aWorld, centerX, centerY - 1, centerZ)) { + centerY--; + if (centerY == 0) break; + } + + centerY = centerY - radius - aRandom.nextInt(50); // let's burry the metorite under the ground slightly + if (centerY < 5) centerY = radius; // prevent from spawing under the bedrock + // make an Impact creator if the asteroid is above ground + int radius2 = radius + 5 + aRandom.nextInt(5); + int creatorY = centerY + radius2 - radius + aRandom.nextInt(3); + if (centerY > WD.waterLevel(aWorld) && aWorld.canBlockSeeTheSky(centerX, centerY + radius2, centerZ)) + for (int i = -radius2; i <= radius2; i++) { + for (int j = -radius2; j <= radius2; j++) { + for (int k = -radius2; k < radius2; k++) { + var x = centerX + i; + var y = creatorY + j; + var z = centerZ + k; + var dis = ((x - centerX) * (x - centerX) + (y - creatorY) * (y - creatorY) + (z - centerZ) * (z - centerZ)); + if (dis <= radius2 * radius2) { + if (!WD.anywater(aWorld, x, y, z)) { + WD.set(aWorld, x, y, z, Blocks.air, 0, 0); + } else if (aBiomeNames.contains(BiomeGenBase.ocean.biomeName) || WD.anywater(aWorld, centerX, centerY, centerZ)) { + WD.set(aWorld, x, y, z, BlocksGT.Ocean, 0, 0); + } + } + } + } + } + + for (int i = -radius; i <= radius; i++) { + for (int j = -radius; j <= radius; j++) { + for (int k = -radius; k < radius; k++) { + var x = centerX + i; + var y = centerY + j; + var z = centerZ + k; + var dis = ((x - centerX) * (x - centerX) + (y - centerY) * (y - centerY) + (z - centerZ) * (z - centerZ)); + if (dis <= radius * radius) { + // it's in sphere + if (WD.bedrock(aWorld, x, y, z)) continue; // dont replace bedrock duh + boolean edge = false; + for (byte l = 0; l < 6; l++) if (!WD.obstructed(aWorld, x, y, z, l)) edge = true; + if (edge) WD.set(aWorld, x, y, z, crustBlock, 0, 0); + else WD.set(aWorld, x, y, z, baseBlock, 0, 0, T); + if (aRandom.nextInt(4) == 0) WD.setSmallOre(aWorld, x, y, z, MT.MeteoricIron); + else if (aRandom.nextInt(5) == 0) WD.setSmallOre(aWorld, x, y, z, MT.Ni); + else if (aRandom.nextInt(8) == 0) WD.setOre(aWorld, x, y, z, MT.MeteoricIron); + else if (aRandom.nextInt(20) == 0) WD.setOre(aWorld, x, y, z, MT.Ir); + + if ((x == centerX) && (y == centerY) && (z == centerZ)) { + // center for spawning loots and what not + if ((radius > 2)) // default core is lava! + WD.set(aWorld, x, y, z, Blocks.lava, W, 2); + if ((radius > 2) && aRandom.nextInt(2) == 0) + WD.set(aWorld, x, y, z, OP.blockPlate.mat(MT.MeteoricIron, 1)); + if ((radius > 2) && aRandom.nextInt(3) == 0) + WD.set(aWorld, x, y, z, OP.blockPlate.mat(MT.DamascusSteel, 1)); + if ((radius > 2) && aRandom.nextInt(5) == 0) + WD.set(aWorld, x, y, z, OP.blockPlate.mat(MT.DuraniumAlloy, 1)); + + } + } + } + } + } + return T; + } + return F; + } +}