From 5bbd43bd9fadf95cb811328c012ca5e5de1c9a5d Mon Sep 17 00:00:00 2001 From: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Date: Sat, 7 Mar 2020 18:37:54 +0100 Subject: Fixed NEI Handler for small ores + useage of fastfloor/ceil + Loading plugin reorder + version increase Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Former-commit-id: bc9ac90b654f67f20640b202df7f51434cd4d45a --- .../com/github/bartimaeusnek/ASM/BWCorePlugin.java | 4 +- .../client/gui/GT_GUIContainer_RadioHatch.java | 5 ++- .../tileentities/multis/GT_TileEntity_BioVat.java | 6 +-- .../multis/GT_TileEntity_CrackingDistillTower.java | 7 ++-- .../tileentities/multis/GT_TileEntity_THTR.java | 5 ++- .../mega/GT_TileEntity_MegaDistillTower.java | 5 ++- .../tiered/GT_MetaTileEntity_RadioHatch.java | 9 +++-- .../bartworks/neiHandler/BW_NEI_OreHandler.java | 22 +++++++---- .../bartimaeusnek/bartworks/util/MathUtils.java | 45 ++++++++++++++++++++++ .../planets/ross128ba/WorldProviderRoss128Ba.java | 5 ++- 10 files changed, 86 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java (limited to 'src') diff --git a/src/main/java/com/github/bartimaeusnek/ASM/BWCorePlugin.java b/src/main/java/com/github/bartimaeusnek/ASM/BWCorePlugin.java index 3d8811142d..bbaff54ba1 100644 --- a/src/main/java/com/github/bartimaeusnek/ASM/BWCorePlugin.java +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCorePlugin.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 bartimaeusnek + * Copyright (c) 2018-2020 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 @@ -31,7 +31,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Map; -@IFMLLoadingPlugin.SortingIndex(999999999)//Load as late as possible (after fastcraft/OptiFine). +@IFMLLoadingPlugin.SortingIndex(Integer.MAX_VALUE)//Load as late as possible (after fastcraft/OptiFine). @IFMLLoadingPlugin.MCVersion("1.7.10") @IFMLLoadingPlugin.TransformerExclusions("com.github.bartimaeusnek.ASM") @IFMLLoadingPlugin.Name(BWCorePlugin.BWCORE_PLUGIN_NAME) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java index 9bd331c59c..58e4cc0c12 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 bartimaeusnek + * Copyright (c) 2018-2020 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 @@ -26,6 +26,7 @@ import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_RadioHatch; +import com.github.bartimaeusnek.bartworks.util.MathUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; @@ -60,7 +61,7 @@ public class GT_GUIContainer_RadioHatch extends GT_GUIContainerMetaTile_Machine this.drawTexturedModalRect(124, 18, 124, 18, 16, 48); } GL11.glColor3f(1f, 1f, 1f); - this.drawTexturedModalRect(124, 18, 176, 0, 16, 48 - (int) Math.ceil(48 * (rem / maxT))); + this.drawTexturedModalRect(124, 18, 176, 0, 16, 48 - (int) MathUtils.ceil(48 * (rem / maxT))); this.drawTexturedModalRect(65, 13, 192, 0, (48 * (((GT_Container_RadioHatch) this.mContainer).sv)) / (GT_GUIContainer_RadioHatch.maxSv), 16); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java index d3d8d5f6ab..5623735b19 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 bartimaeusnek + * Copyright (c) 2018-2020 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 @@ -143,8 +143,8 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { } private int calcMod(double x) { - int ret = (int) Math.ceil(ConfigHandler.bioVatMaxParallelBonus*(-(((2D*x/(double)this.getOutputCapacity())-1D)*(2D*x/(double)this.getOutputCapacity()-1D))+1D)); - return ret <= 0 ? 1 : Math.min(ret, 100);//(int) Math.ceil((-0.00000025D * x * (x - this.getOutputCapacity()))); + int ret = (int) MathUtils.ceil(ConfigHandler.bioVatMaxParallelBonus*(-(((2D*x/(double)this.getOutputCapacity())-1D)*(2D*x/(double)this.getOutputCapacity()-1D))+1D)); + return ret <= 0 ? 1 : Math.min(ret, 100);//(int) MathUtils.ceil((-0.00000025D * x * (x - this.getOutputCapacity()))); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java index 1f96a207e3..5b26664943 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 bartimaeusnek + * Copyright (c) 2018-2020 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 @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis; import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.MathUtils; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -68,9 +69,9 @@ public class GT_TileEntity_CrackingDistillTower extends GT_MetaTileEntity_Distil FluidStack[] nuoutputs = new FluidStack[recipeDistill.mFluidOutputs.length]; for (int i = 0; i < nuoutputs.length; i++) { nuoutputs[i] = recipeDistill.mFluidOutputs[i]; - nuoutputs[i].amount = (int) (Math.floor(recipeDistill.mFluidOutputs[i].amount * ratio)); + nuoutputs[i].amount = (int) (MathUtils.floor(recipeDistill.mFluidOutputs[i].amount * ratio)); } - BWRecipes.DynamicGTRecipe combined = new BWRecipes.DynamicGTRecipe(true, null, recipeDistill.mOutputs, null, recipeDistill.mChances, recipeCracking.mFluidInputs, nuoutputs, (int) (Math.floor(recipeDistill.mDuration * ratio)) + recipeCracking.mDuration, Math.max((int) (Math.floor(recipeDistill.mEUt * ratio)), recipeCracking.mEUt), 0); + BWRecipes.DynamicGTRecipe combined = new BWRecipes.DynamicGTRecipe(true, null, recipeDistill.mOutputs, null, recipeDistill.mChances, recipeCracking.mFluidInputs, nuoutputs, (int) (MathUtils.floor(recipeDistill.mDuration * ratio)) + recipeCracking.mDuration, Math.max((int) (MathUtils.floor(recipeDistill.mEUt * ratio)), recipeCracking.mEUt), 0); if (combined.isRecipeInputEqual(true, array)) { this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java index 87e1089e1f..0d449ecddc 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 bartimaeusnek + * Copyright (c) 2018-2020 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 @@ -26,6 +26,7 @@ import com.github.bartimaeusnek.bartworks.common.items.SimpleSubItemClass; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.bartworks.util.MathUtils; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; @@ -138,7 +139,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { if (!(this.HeliumSupply >= GT_TileEntity_THTR.HELIUM_NEEDED && this.BISOPeletSupply + this.TRISOPeletSupply >= 100000)) return false; - int toReduce = new XSTR().nextInt((int)Math.floor(((double)this.BISOPeletSupply + (double)this.TRISOPeletSupply) / 200D)); + int toReduce = new XSTR().nextInt((int) MathUtils.floor(((double)this.BISOPeletSupply + (double)this.TRISOPeletSupply) / 200D)); this.savedBISO = BISOPeletSupply; this.savedTRISO = TRISOPeletSupply; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java index 127c38d0c4..4e81813ca1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaDistillTower.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 bartimaeusnek + * Copyright (c) 2018-2020 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 @@ -25,6 +25,7 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.bartworks.util.MathUtils; import com.google.common.collect.ArrayListMultimap; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; @@ -141,7 +142,7 @@ public class GT_TileEntity_MegaDistillTower extends GT_MetaTileEntity_Distillati if (super.addOutputToMachineList(aTileEntity, aBaseCasingIndex)) { if (aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Output) { int layer = aTileEntity.getYCoord() - controllerY; - layer = (int) Math.ceil(((double)layer) /5D)-1; + layer = (int) MathUtils.ceil(((double)layer) /5D)-1; LAYERMAP.put(layer,(GT_MetaTileEntity_Hatch_Output) aTileEntity.getMetaTileEntity()); } return true; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java index eadf67de7a..205dab5a9a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 bartimaeusnek + * Copyright (c) 2018-2020 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 @@ -29,6 +29,7 @@ import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_RadioHatch; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_RadioHatch; import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.bartworks.util.MathUtils; import com.github.bartimaeusnek.crossmod.GTpp.loader.RadioHatchCompat; import cpw.mods.fml.common.Loader; import gregtech.api.enums.ItemList; @@ -82,14 +83,14 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { else if (x == 61) ret = 4500; else if (x <= 100) - ret = (long) Math.ceil((8000D * Math.tanh(-x / 20D) + 8000D) * 1000D); + ret = (long) MathUtils.ceil((8000D * Math.tanh(-x / 20D) + 8000D) * 1000D); else - ret = (long) Math.ceil(((8000D * Math.tanh(-x / 65D) + 8000D))); + ret = (long) MathUtils.ceil(((8000D * Math.tanh(-x / 65D) + 8000D))); return ret;//*20; } public int getSievert() { - return this.sievert - (int) Math.ceil((float) this.sievert / 100f * (float) this.coverage); + return this.sievert - (int) MathUtils.ceil((float) this.sievert / 100f * (float) this.coverage); } public short[] getColorForGUI() { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java index 902bf6681c..677a9af5f7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 bartimaeusnek + * Copyright (c) 2018-2020 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 @@ -96,15 +96,23 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { public void drawExtras(int recipe) { if ((recipe < this.arecipes.size()) && (this.arecipes.get(recipe) instanceof CachedOreRecipe) ) { CachedOreRecipe cachedOreRecipe = (CachedOreRecipe) this.arecipes.get(recipe); - if (cachedOreRecipe == null || cachedOreRecipe.getOtherStacks() == null || - cachedOreRecipe.getOtherStacks().get(0) == null || cachedOreRecipe.getOtherStacks().get(1) == null - || cachedOreRecipe.getOtherStacks().get(2) == null || cachedOreRecipe.getOtherStacks().get(3) == null || - cachedOreRecipe.getOtherStacks().get(0).item == null || cachedOreRecipe.getOtherStacks().get(1).item == null - || cachedOreRecipe.getOtherStacks().get(2).item == null || cachedOreRecipe.getOtherStacks().get(3).item == null - ) + + if (cachedOreRecipe == null || cachedOreRecipe.getOtherStacks() == null || cachedOreRecipe.getOtherStacks().size() == 0) return; + + if (!cachedOreRecipe.small) { + if (cachedOreRecipe.getOtherStacks().get(0) == null || cachedOreRecipe.getOtherStacks().get(0).item == null + || cachedOreRecipe.getOtherStacks().get(1) == null + || cachedOreRecipe.getOtherStacks().get(2) == null || cachedOreRecipe.getOtherStacks().get(3) == null || cachedOreRecipe.getOtherStacks().get(1).item == null + || cachedOreRecipe.getOtherStacks().get(2).item == null || cachedOreRecipe.getOtherStacks().get(3).item == null + ) + return; + } else if (cachedOreRecipe.getOtherStacks().get(0) == null || cachedOreRecipe.getOtherStacks().get(0).item == null) + return; + if (cachedOreRecipe.worldGen != null) GuiDraw.drawString(ChatColorHelper.BOLD + "DIM: " + ChatColorHelper.RESET + cachedOreRecipe.worldGen.getDimName(), 0, 40, 0, false); + GuiDraw.drawString(ChatColorHelper.BOLD + "Primary:", 0, 50, 0, false); GuiDraw.drawString(cachedOreRecipe.getOtherStacks().get(0).item.getDisplayName(), 0, 60, 0, false); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java new file mode 100644 index 0000000000..dfb95c921d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/MathUtils.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2018-2020 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; + +/* + * Faster implementations for Math stuff + */ +public class MathUtils { + + public static double floor(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) + return x; + int xi = (int)x; + return x < xi ? xi - 1 : xi; + } + + public static double ceil(double x) { + if (Double.isInfinite(x) || Double.isNaN(x)) + return x; + int xi = (int)x; + return x > xi ? xi + 1 : xi; + } + + +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/WorldProviderRoss128Ba.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/WorldProviderRoss128Ba.java index f445290136..8ecb971452 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/WorldProviderRoss128Ba.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/WorldProviderRoss128Ba.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2019 bartimaeusnek + * Copyright (c) 2018-2020 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 @@ -22,6 +22,7 @@ package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128ba; +import com.github.bartimaeusnek.bartworks.util.MathUtils; import com.github.bartimaeusnek.crossmod.galacticraft.planets.AbstractWorldProviderSpace; import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; @@ -43,7 +44,7 @@ public class WorldProviderRoss128Ba extends AbstractWorldProviderSpace { @Override public long getDayLength() { - return (long) Math.floor(24000f*9.9f/100f); + return (long) MathUtils.floor(24000f*9.9f/100f); } @Override public boolean hasSunset() { -- cgit