From 50787529e12663685e9d0657c2e136ff4ae9ff7f Mon Sep 17 00:00:00 2001 From: Jordan Byrne Date: Sun, 4 Feb 2018 23:55:17 +1000 Subject: $ Finished the Fishing Pond. $ Made the Fishing Pond cache reflection data from WeightedRandomFishable objects. $ Fixed the Fish Pond not outputting correct stack sizes. (They were all 0) --- .../common/blocks/GregtechMetaCasingBlocks3.java | 32 +- .../blocks/textures/CasingTextureHandler3.java | 39 ++- ...egtechMetaTileEntity_IndustrialFishingPond.java | 360 ++++++++++++++++++--- 3 files changed, 347 insertions(+), 84 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common') 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 tItems = getStoredInputs(); + ArrayList 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 categories = new AutoMap(); + private static AutoMap categoryFish = new AutoMap(); + private static AutoMap categoryJunk = new AutoMap(); + private static AutoMap categoryLoot = new AutoMap(); + 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 reflectiveFishMap = new HashMap(); + 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 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 -- cgit