diff options
Diffstat (limited to 'src/Java')
6 files changed, 429 insertions, 87 deletions
diff --git a/src/Java/gregtech/api/util/FishPondFakeRecipe.java b/src/Java/gregtech/api/util/FishPondFakeRecipe.java new file mode 100644 index 0000000000..5aef1bcd8a --- /dev/null +++ b/src/Java/gregtech/api/util/FishPondFakeRecipe.java @@ -0,0 +1,75 @@ +package gregtech.api.util; + +import java.util.ArrayList; + +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.array.AutoMap; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomFishable; +import net.minecraftforge.common.FishingHooks; +import net.minecraftforge.fluids.FluidStack; + +public class FishPondFakeRecipe { + + public static ArrayList<WeightedRandomFishable> fish = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> junk = new ArrayList<WeightedRandomFishable>(); + public static ArrayList<WeightedRandomFishable> treasure = new ArrayList<WeightedRandomFishable>(); + + @SuppressWarnings("unchecked") + public static boolean generateFishPondRecipes() { + + try { + fish = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "fish").get(null); + junk = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "junk").get(null); + treasure = (ArrayList<WeightedRandomFishable>) ReflectionUtils.getField(FishingHooks.class, "treasure").get(null); + } + catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) { + Logger.INFO("Error generating Fish Pond Recipes. [1]"); + e.printStackTrace(); + } + + AutoMap<ArrayList<WeightedRandomFishable>> mega = new AutoMap<ArrayList<WeightedRandomFishable>>(); + mega.put(fish); + mega.put(junk); + mega.put(treasure); + + int mType = 14; + for (ArrayList<WeightedRandomFishable> f : mega.values()) { + for (int e=0;e<f.size();e++) { + if (f.get(e) != null) { + WeightedRandomFishable u = f.get(e); + try { + ItemStack t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b").get(u); + addNewFishPondLoot(mType, new ItemStack[]{t}, new int[] {10000}); + } + catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e1) { + Logger.INFO("Error generating Fish Pond Recipes. [2]"); + e1.printStackTrace(); + } + } + } + mType++; + } + + return true; + } + + public static void addNewFishPondLoot(int circuit, ItemStack[] outputItems, int[] chances) { + GT_Recipe x = new GT_Recipe( + true, + new ItemStack[]{CI.getNumberedCircuit(circuit)}, + outputItems, + null, + chances, + new FluidStack[]{null}, + new FluidStack[]{null}, + 100, //1 Tick + 0, //No Eu produced + 0 //Magic Number + ); + Recipe_GT.Gregtech_Recipe_Map.sFishPondRecipes.addRecipe(x); + } + +} diff --git a/src/Java/gregtech/api/util/Recipe_GT.java b/src/Java/gregtech/api/util/Recipe_GT.java index 351814f386..342add5b63 100644 --- a/src/Java/gregtech/api/util/Recipe_GT.java +++ b/src/Java/gregtech/api/util/Recipe_GT.java @@ -281,6 +281,8 @@ public class Recipe_GT extends GT_Recipe{ //Component Assembler public static final GT_Recipe_Map sComponentAssemblerRecipes = new GT_Recipe_Map_Assembler(new HashSet<GT_Recipe>(300), "gt.recipe.componentassembler", "Component Assembler", null, RES_PATH_GUI + "basicmachines/Assembler", 6, 1, 1, 0, 1, E, 1, E, true, true); + public static final GT_Recipe_Map sFishPondRecipes = new GT_Recipe_Map(new HashSet<GT_Recipe>(3), "gt.recipe.fishpond", "Zhuhai - Fishing Port", null, RES_PATH_GUI + "basicmachines/PotionBrewer", 0, 1, 0, 0, 1, E, 1, E, true, true); + /** diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java index 7a9be5788c..37f7f2cb16 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks3.java @@ -21,21 +21,21 @@ extends GregtechMetaCasingBlocksAbstract { TAE.registerTextures(new GT_CopiedBlockTexture(this, 6, i)); } GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".0.name", "Aquatic Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Hastelloy-N Sealant Block"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Hastelloy-X Structural Block"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Incoloy-DS Fluid Containment Block"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Wash Plant Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Industrial Sieve Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Large Sieve Grate"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Vanadium Redox Power Cell"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Sub-Station External Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Cyclotron Coil"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Cyclotron Outer Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Thermal Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Autocrafter Frame"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cutting Factory Frame"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Tesla Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Casing "); //Tree Farmer Textures + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".1.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".2.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".3.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".4.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".5.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Placeholder");; + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Placeholder"); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Placeholder"); GregtechItemList.Casing_FishPond.set(new ItemStack(this, 1, 0)); //GregtechItemList.Casing_Refinery_External.set(new ItemStack(this, 1, 1)); //GregtechItemList.Casing_Refinery_Structural.set(new ItemStack(this, 1, 2)); @@ -56,6 +56,6 @@ extends GregtechMetaCasingBlocksAbstract { @Override public IIcon getIcon(final int aSide, final int aMeta) { - return CasingTextureHandler2.getIcon(aSide, aMeta); + return CasingTextureHandler3.getIcon(aSide, aMeta); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java index 4e9d2c7e51..1bd59724fb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler3.java @@ -9,60 +9,59 @@ public class CasingTextureHandler3 { if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { //Centrifuge - case 0: - return TexturesGtBlock.TEXTURE_METAL_PANEL_B.getIcon(); + case 0: + return TexturesGtBlock.TEXTURE_METAL_PANEL_B.getIcon(); //Coke Oven Frame case 1: - return TexturesGtBlock.Casing_Material_HastelloyX.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Coke Oven Casing Tier 1 case 2: - return TexturesGtBlock.Casing_Material_HastelloyN.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Coke Oven Casing Tier 2 case 3: - return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Material Press Casings case 4: - return TexturesGtBlock.Casing_Material_Grisium.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Sifter Structural case 5: - return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Sifter Sieve case 6: - return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon(); - + return TexturesGtBlock._PlaceHolder.getIcon(); //Vanadium Radox Battery case 7: - return TexturesGtBlock.Overlay_Machine_Cyber_B.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Power Sub-Station Casing case 8: - return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Cyclotron Coil case 9: - return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Cyclotron External Casing case 10: - return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Multitank Exterior Casing case 11: - return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Reactor Casing I case 12: - return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); //Reactor Casing II case 13: if (aSide <2) { - return TexturesGtBlock.TEXTURE_TECH_A.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); } else { - return TexturesGtBlock.TEXTURE_TECH_B.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); } case 14: - return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); case 15: - return TexturesGtBlock.Casing_Machine_Farm_Manager.getIcon(); //Tree Farmer Textures + return TexturesGtBlock._PlaceHolder.getIcon(); //Tree Farmer Textures default: - return TexturesGtBlock.Overlay_UU_Matter.getIcon(); + return TexturesGtBlock._PlaceHolder.getIcon(); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java index 7d11e1f525..e83b17dbac 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -1,18 +1,35 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import gregtech.api.enums.GT_Values; +import static gtPlusPlus.core.util.array.ArrayUtils.removeNulls; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.ArrayUtils; + import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.FishPondFakeRecipe; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.XSTR; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.array.AutoMap; import gtPlusPlus.core.util.fluid.FluidUtils; +import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.gui.GUI_MultiMachine; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import ic2.core.init.BlocksItems; @@ -21,6 +38,7 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.WeightedRandomFishable; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; @@ -44,20 +62,22 @@ extends GregtechMeta_MultiBlockBase { @Override public String[] getDescription() { return new String[]{ - "Controller Block for the Industrial Ore Washing Plant", - "80% faster than using single block machines of the same voltage", - "Processes one item per voltage tier", - "Size: 7x3x5 [WxHxL] (open)", + "Controller Block for the Fishing Pond", + "Size: 9x3x9 [WxHxL] (open)", "X X", "X X", "XXXXX", + "Put a numbered circuit into the input bus.", + "Circuit 14 for Fish", + "Circuit 15 for Junk", + "Circuit 16 for Treasure", "Controller (front centered)", - "1x Input Bus (Any casing)", "1x Output Bus (Any casing)", + "1x Input Bus (Any casing)", + "1x Input Hatch (Any casing)", "1x Maintenance Hatch (Any casing)", "1x Energy Hatch (Any casing)", CORE.GT_Tooltip - }; } @@ -76,7 +96,7 @@ extends GregtechMeta_MultiBlockBase { @Override public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return GT_Recipe.GT_Recipe_Map.sOreWasherRecipes; + return Recipe_GT.Gregtech_Recipe_Map.sFishPondRecipes; } @Override @@ -86,10 +106,19 @@ extends GregtechMeta_MultiBlockBase { @Override public boolean checkRecipe(final ItemStack aStack) { - if (checkForWater()) { - return checkRecipeGeneric((1*Utils.calculateVoltageTier(this.getMaxInputVoltage())), 100, 80); + if (!hasGenerateRecipes) { + Logger.WARNING("Generating Recipes."); + generateRecipes(); + } + if (hasGenerateRecipes && checkForWater()) { + Logger.WARNING("Trying to run recipe."); + ArrayList<ItemStack> tItems = getStoredInputs(); + ArrayList<FluidStack> tFluids = getStoredFluids(); + ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); + FluidStack[] tFluidInputs = tFluids.toArray(new FluidStack[tFluids.size()]); + return checkRecipeGeneric(tItemInputs, tFluidInputs, 1, 100, 80, 100); } - return false; + return true; } @Override @@ -97,7 +126,6 @@ extends GregtechMeta_MultiBlockBase { //Get Facing direction int mDirectionX = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int mCurrentDirectionX; int mCurrentDirectionZ; int mOffsetX_Lower = 0; @@ -105,28 +133,19 @@ extends GregtechMeta_MultiBlockBase { int mOffsetZ_Lower = 0; int mOffsetZ_Upper = 0; - - Logger.WARNING("mDirectionX "+(mDirectionX)); if (mDirectionX == 0){ mCurrentDirectionX = 2; mCurrentDirectionZ = 3; - mOffsetX_Lower = -2; - mOffsetX_Upper = 2; - mOffsetZ_Lower = -3; - mOffsetZ_Upper = 3; - Logger.WARNING("Controler is facing Z direction."); } else { mCurrentDirectionX = 3; mCurrentDirectionZ = 2; - mOffsetX_Lower = -3; - mOffsetX_Upper = 3; - mOffsetZ_Lower = -2; - mOffsetZ_Upper = 2; - Logger.WARNING("Controler is facing X direction."); } - //if (aBaseMetaTileEntity.fac) + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; final int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * mCurrentDirectionX; final int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * mCurrentDirectionZ; @@ -151,16 +170,21 @@ extends GregtechMeta_MultiBlockBase { if ((i != mOffsetX_Lower && j != mOffsetZ_Lower && i != mOffsetX_Upper && j != mOffsetZ_Upper) && (h == 0 || h == 1)){ if (tBlock == Blocks.air){ - Logger.WARNING("Found Air"); + Logger.INFO("Found Air"); } else if (tBlock == Blocks.water){ - Logger.WARNING("Found Water"); + Logger.INFO("Found Water"); } } else { - Logger.WARNING("[x] Did not form - Found: "+tBlock.getLocalizedName() + " | "+tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(), aBaseMetaTileEntity.getXCoord()+ i, aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord() + j)); - Logger.WARNING("[x] Did not form - Found: "+(aBaseMetaTileEntity.getXCoord()+xDir + i) +" | "+ aBaseMetaTileEntity.getYCoord()+" | "+ (aBaseMetaTileEntity.getZCoord()+zDir + j)); - return false; + if (tBlock.getLocalizedName().contains("gt.blockmachines") || tBlock == Blocks.water || tBlock == Blocks.flowing_water || tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { + + } + else { + Logger.INFO("[x] Did not form - Found: "+tBlock.getLocalizedName() + " | "+tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(), aBaseMetaTileEntity.getXCoord()+ i, aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord() + j) + " | Special Meta: "+(tTileEntity == null ? "0" : tTileEntity.getMetaTileID())); + Logger.INFO("[x] Did not form - Found: "+(aBaseMetaTileEntity.getXCoord()+xDir + i) +" | "+ aBaseMetaTileEntity.getYCoord()+" | "+ (aBaseMetaTileEntity.getZCoord()+zDir + j)); + return false; + } } } @@ -170,13 +194,13 @@ extends GregtechMeta_MultiBlockBase { } } } - if ((tAmount >= 8)){ - Logger.WARNING("Made structure."); + if ((tAmount >= 64)){ + Logger.INFO("Made structure."); } else { - Logger.WARNING("Did not make structure."); + Logger.INFO("Did not make structure."); } - return (tAmount >= 8); + return (tAmount >= 64); } @Override @@ -218,8 +242,7 @@ extends GregtechMeta_MultiBlockBase { || (this.addInputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addOutputToMachineList(tTileEntity, this.getCasingTextureIndex())) || (this.addMufflerToMachineList(tTileEntity, this.getCasingTextureIndex())) - || (this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex())) - || (this.addDynamoToMachineList(tTileEntity, this.getCasingTextureIndex()))); + || (this.addEnergyInputToMachineList(tTileEntity, this.getCasingTextureIndex()))); } public boolean checkForWater() { @@ -234,22 +257,19 @@ extends GregtechMeta_MultiBlockBase { int mOffsetZ_Lower = 0; int mOffsetZ_Upper = 0; + if (mDirectionX == 0){ mCurrentDirectionX = 2; mCurrentDirectionZ = 3; - mOffsetX_Lower = -2; - mOffsetX_Upper = 2; - mOffsetZ_Lower = -3; - mOffsetZ_Upper = 3; } else { mCurrentDirectionX = 3; mCurrentDirectionZ = 2; - mOffsetX_Lower = -3; - mOffsetX_Upper = 3; - mOffsetZ_Lower = -2; - mOffsetZ_Upper = 2; } + mOffsetX_Lower = -4; + mOffsetX_Upper = 4; + mOffsetZ_Lower = -4; + mOffsetZ_Upper = 4; //if (aBaseMetaTileEntity.fac) @@ -286,22 +306,266 @@ extends GregtechMeta_MultiBlockBase { } if (tBlock == Blocks.water) { ++tAmount; - //Utils.LOG_WARNING("Found Water"); + //Logger.INFO("Found Water"); } else if (tBlock == BlocksItems.getFluidBlock(InternalName.fluidDistilledWater)) { ++tAmount; ++tAmount; - //Utils.LOG_WARNING("Found Distilled Water"); + //Logger.INFO("Found Distilled Water"); } } } } - if ((tAmount >= 45)){ + if ((tAmount >= 80)){ Logger.WARNING("Filled structure."); } else { Logger.WARNING("Did not fill structure."); } - return (tAmount >= 45); + return (tAmount >= 80); + } + + private static AutoMap<AutoMap> categories = new AutoMap<AutoMap>(); + private static AutoMap<WeightedRandomFishable> categoryFish = new AutoMap<WeightedRandomFishable>(); + private static AutoMap<WeightedRandomFishable> categoryJunk = new AutoMap<WeightedRandomFishable>(); + private static AutoMap<WeightedRandomFishable> categoryLoot = new AutoMap<WeightedRandomFishable>(); + private static boolean hasGenerateRecipes = false; + private int mMode = 14; + private int mMax = 8; + + private boolean generateRecipes() { + if (!hasGenerateRecipes) { + categories.put(categoryFish); + categories.put(categoryJunk); + categories.put(categoryLoot); + for (WeightedRandomFishable h : FishPondFakeRecipe.fish) { + categoryFish.put(h); + } + for (WeightedRandomFishable h : FishPondFakeRecipe.junk) { + categoryJunk.put(h); + } + for (WeightedRandomFishable h : FishPondFakeRecipe.treasure) { + categoryLoot.put(h); + } + hasGenerateRecipes = true; + return true; + } + else { + return true; + } + } + + private int getCircuit(ItemStack[] t) { + for (ItemStack j : t) { + if (j.getItem() == CI.getNumberedCircuit(0).getItem()) { + //Fish + if (j.getItemDamage() == 14) { + mMax = 8; + this.mMode = 14; + break; + } + //Junk + else if (j.getItemDamage() == 15) { + this.mMode = 15; + mMax = 4; + break; + } + //Loot + else if (j.getItemDamage() == 16) { + this.mMode = 16; + mMax = 4; + break; + } + else { + this.mMode = 0; + mMax = 0; + break; + } + } + else { + this.mMode = 0; + mMax = 0; + break; + } + } + return this.mMode; + } + + //reflection map + private static Map<WeightedRandomFishable, ItemStack> reflectiveFishMap = new HashMap<WeightedRandomFishable, ItemStack>(); + private ItemStack reflectiveFish(WeightedRandomFishable y) { + if (reflectiveFishMap.containsKey(y)) { + return reflectiveFishMap.get(y); + } + ItemStack t; + try { + t = (ItemStack) ReflectionUtils.getField(WeightedRandomFishable.class, "field_150711_b").get(y); + ItemStack k = ItemUtils.getSimpleStack(t, 1); + reflectiveFishMap.put(y, k); + return t; + } + catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {} + return null; + } + + private ItemStack[] generateLoot(int mode) { + ItemStack[] mFishOutput = new ItemStack[this.mMax]; + if (this.mMode == 14) { + for (int k=0;k<this.mMax;k++) { + if (mFishOutput[k] == null) + for (WeightedRandomFishable g : categoryFish.values()) { + if (MathUtils.randInt(0, 75) <= 2) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } + else if (this.mMode == 15) { + for (int k=0;k<this.mMax;k++) { + if (mFishOutput[k] == null) + for (WeightedRandomFishable g : categoryJunk.values()) { + if (MathUtils.randInt(0, 100) <= 1) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } + else if (this.mMode == 16) { + for (int k=0;k<this.mMax;k++) { + if (mFishOutput[k] == null) + for (WeightedRandomFishable g : categoryLoot.values()) { + if (MathUtils.randInt(0, 1000) <= 2) { + ItemStack t = reflectiveFish(g); + if (t != null) { + mFishOutput[k] = ItemUtils.getSimpleStack(t, 1); + } + } + } + } + } + else { + mFishOutput = null; + } + return mFishOutput; + } + + @Override + public boolean checkRecipeGeneric( + ItemStack[] aItemInputs, FluidStack[] aFluidInputs, + int aMaxParallelRecipes, int aEUPercent, + int aSpeedBonusPercent, int aOutputChanceRoll) { + + + + // Based on the Processing Array. A bit overkill, but very flexible. + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + int parallelRecipes = 1; + getCircuit(aItemInputs); + + /*GT_Recipe tRecipe = this.getRecipeMap().findRecipe( + getBaseMetaTileEntity(), mLastRecipe, false, + gregtech.api.enums.GT_Values.V[tTier], aFluidInputs, aItemInputs);*/ + + ItemStack[] mFishOutput = generateLoot(this.mMode); + Logger.WARNING("Mode: "+this.mMode+" | Is loot valid? "+(mFishOutput != null)); + + int jslot = 0; + for (ItemStack x : mFishOutput) { + if (x != null) { + Logger.INFO("Slot "+jslot+" in mFishOutput contains "+x.stackSize+"x "+x.getDisplayName()+"."); + } + else { + Logger.WARNING("Slot "+jslot+" in mFishOutput was null."); + } + jslot++; + } + + // EU discount + float tRecipeEUt = (32 * aEUPercent) / 100.0f; + float tTotalEUt = 0.0f; + + // Reset outputs and progress stats + this.mEUt = 0; + this.mMaxProgresstime = 0; + this.mOutputItems = new ItemStack[]{}; + this.mOutputFluids = new FluidStack[]{}; + + tTotalEUt = 16; + Logger.WARNING("Recipe Step. [1]"); + + if (parallelRecipes == 0) { + Logger.WARNING("Recipe Step. [-1]"); + return false; + } + + // Convert speed bonus to duration multiplier + // e.g. 100% speed bonus = 200% speed = 100%/200% = 50% recipe duration. + float tTimeFactor = 100.0f / (100.0f + 0); + + float modeMulti = 1; + modeMulti = (this.mMode == 14 ? 5 : (this.mMode == 15 ? 1 : 20)); + this.mMaxProgresstime = (int)((60*modeMulti) * tTimeFactor); + + this.mEUt = (int)Math.ceil(tTotalEUt); + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + Logger.WARNING("Recipe Step. [2]"); + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mEUt * (1 << tTier - 1) * (1 << tTier - 1)); + this.mMaxProgresstime = (this.mMaxProgresstime / (1 << tTier - 1)); + } else { + while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { + this.mEUt *= 4; + this.mMaxProgresstime /= 2; + } + } + + if (this.mEUt > 0) { + this.mEUt = (-this.mEUt); + } + + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + + Logger.WARNING("Recipe Step. [3]"); + // Collect output item types + ItemStack[] tOutputItems = mFishOutput; + + + int rslot = 0; + tOutputItems = removeNulls(mFishOutput); + + for (ItemStack x : tOutputItems) { + if (x != null) { + Logger.INFO("rSlot "+rslot+" in mFishOutput contains "+x.stackSize+"x "+x.getDisplayName()+"."); + } + else { + Logger.INFO("rSlot "+rslot+" in mFishOutput was null."); + } + rslot++; + } + + // Commit outputs + for (ItemStack n : tOutputItems) { + this.addOutput(n); + } + + //this.mOutputItems = tOutputItems; + //updateSlots(); + + // Play sounds (GT++ addition - GT multiblocks play no sounds) + startProcess(); + + return true; } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFishPond.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFishPond.java index 0d3d00833f..93f8f7460a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFishPond.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialFishPond.java @@ -1,8 +1,9 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; +import gregtech.api.util.FishPondFakeRecipe; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialWashPlant; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.GregtechMetaTileEntity_IndustrialFishingPond; public class GregtechIndustrialFishPond { @@ -10,14 +11,15 @@ public class GregtechIndustrialFishPond { if (gtPlusPlus.core.lib.LoadedMods.Gregtech) { Logger.INFO("Gregtech5u Content | Registering Industrial Fishing Pond Multiblock."); //if (CORE.ConfigSwitches.enableMultiblock_IndustrialWashPlant) { - run1(); + FishPondFakeRecipe.generateFishPondRecipes(); + run1(); //} } } private static void run1() { - GregtechItemList.Industrial_FishingPond.set(new GregtechMetaTileEntity_IndustrialWashPlant(829, + GregtechItemList.Industrial_FishingPond.set(new GregtechMetaTileEntity_IndustrialFishingPond(829, "industrial.fishpond.controller.tier.single", "Zhuhai - Fishing Port").getStackForm(1L)); } |