diff options
8 files changed, 279 insertions, 34 deletions
diff --git a/.classpath b/.classpath index 6e2dc0efb1..1486df3c06 100644 --- a/.classpath +++ b/.classpath @@ -17,6 +17,5 @@ <classpathentry kind="lib" path="libs/forestry_1.7.10-4.1.1.46-deobf.jar"/> <classpathentry kind="lib" path="libs/Psychedelicraft-1.5.2.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/VillageWipe"/> - <classpathentry kind="lib" path="libs/LibShapeDraw-1.3.2-dev.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/src/Java/miscutil/core/block/base/BlockBaseModular.java b/src/Java/miscutil/core/block/base/BlockBaseModular.java index 2276702c67..377ab833e7 100644 --- a/src/Java/miscutil/core/block/base/BlockBaseModular.java +++ b/src/Java/miscutil/core/block/base/BlockBaseModular.java @@ -26,7 +26,7 @@ public class BlockBaseModular extends BasicBlock{ this.thisBlock = blockType; this.thisBlockMaterial = blockMaterial; this.setBlockName(getLocalizedName()); - LanguageRegistry.addName(this, getLocalizedName()); + LanguageRegistry.addName(this, unlocalizedName); //setOreDict(unlocalizedName, blockType); if (thisBlock == BlockTypes.STANDARD){ GameRegistry.registerBlock(this, ItemBlockGtBlock.class, blockType.getTexture()+unlocalizedName); diff --git a/src/Java/miscutil/core/item/base/dusts/BaseItemDust.java b/src/Java/miscutil/core/item/base/dusts/BaseItemDust.java index 1dee49bfa4..49fb1ac13d 100644 --- a/src/Java/miscutil/core/item/base/dusts/BaseItemDust.java +++ b/src/Java/miscutil/core/item/base/dusts/BaseItemDust.java @@ -6,6 +6,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; import java.util.List; @@ -39,7 +40,6 @@ public class BaseItemDust extends Item{ this.setTextureName(CORE.MODID + ":" + "dust");} else{ this.setTextureName(CORE.MODID + ":" + "dust"+pileSize);} - this.setMaxStackSize(64); this.setCreativeTab(tabMisc); this.colour = colour; this.mTier = tier; @@ -94,14 +94,17 @@ public class BaseItemDust extends Item{ @Override public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - if (pileType != null && materialName != null && pileType != "" && materialName != "" && !pileType.equals("") && !materialName.equals("")){ - if (this.pileType == "dust"){ - list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); + //if (pileType != null && materialName != null && pileType != "" && materialName != "" && !pileType.equals("") && !materialName.equals("")){ + if (getUnlocalizedName().contains("DustTiny")){ + list.add(EnumChatFormatting.GRAY+"A tiny pile of " + materialName + " dust."); } - else{ - list.add(EnumChatFormatting.GRAY+"A "+this.pileType.toLowerCase()+" pile of " + materialName + " dust."); + else if (getUnlocalizedName().contains("DustSmall")){ + list.add(EnumChatFormatting.GRAY+"A small pile of " + materialName + " dust."); } - } + else { + list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); + } + //} super.addInformation(stack, aPlayer, list, bool); } @@ -151,11 +154,11 @@ public class BaseItemDust extends Item{ } else { if (outputStacks[0] != null){ - Utils.LOG_INFO("Getting output dusts for mixer recipe. Checking ENUM, got: "+outputStacks[0].toString()); + Utils.LOG_WARNING("Getting output dusts for mixer recipe. Checking ENUM, got: "+outputStacks[0].toString()); tempOutput = outputStacks[0]; } else { - Utils.LOG_INFO("Getting output dusts for mixer recipe. Enum check failed, failback item is: "+temp); + Utils.LOG_WARNING("Getting output dusts for mixer recipe. Enum check failed, failback item is: "+temp); tempOutput = UtilsItems.getItemStackOfAmountFromOreDict(temp, 1); } } @@ -178,14 +181,32 @@ public class BaseItemDust extends Item{ null, null, null); } else { - Utils.LOG_WARNING("Generating a shapeless Dust recipe for "+materialName); + Utils.LOG_INFO("Generating a Dust recipe for "+materialName+" in the mixer."); - GT_Values.RA.addMixerRecipe( + /*GT_Values.RA.addMixerRecipe( inputStacks[0], inputStacks[1], inputStacks[2], inputStacks[3], null, null, tempOutput, + 8*mTier*20, 8*mTier*2);*/ + int i = 0; + for (ItemStack is : inputStacks){ + i++; + if (is != null){ + Utils.LOG_INFO("Found "+is.getDisplayName()+" as an input for mixer recipe."); + } + else { + Utils.LOG_INFO("Input "+i+" was null."); + } + } + + GT_Values.RA.addMixerRecipe( + GT_Utility.copyAmount(inputStacks[0].stackSize, new Object[]{inputStacks[0]}), GT_Utility.copyAmount(inputStacks[1].stackSize, new Object[]{inputStacks[1]}), + GT_Utility.copyAmount(inputStacks[2].stackSize, new Object[]{inputStacks[2]}), GT_Utility.copyAmount(inputStacks[3].stackSize, new Object[]{inputStacks[3]}), + null, null, + tempOutput, 8*mTier*20, 8*mTier*2); + } } diff --git a/src/Java/miscutil/core/item/base/itemblock/ItemBlockGtBlock.java b/src/Java/miscutil/core/item/base/itemblock/ItemBlockGtBlock.java index 0bd051928e..79364cb079 100644 --- a/src/Java/miscutil/core/item/base/itemblock/ItemBlockGtBlock.java +++ b/src/Java/miscutil/core/item/base/itemblock/ItemBlockGtBlock.java @@ -12,7 +12,7 @@ public class ItemBlockGtBlock extends ItemBlock{ public ItemBlockGtBlock(Block block) { super(block); this.blockColour = block.getBlockColor(); - GT_OreDictUnificator.registerOre("block"+block.getUnlocalizedName().replace("tile.block", "").replace("tile.", "").replace("of", "").replace("Block", "").replace("-", "").replace("_", "").replace(" ", ""), UtilsItems.getSimpleStack(this)); + GT_OreDictUnificator.registerOre("block"+block.getUnlocalizedName().replace("tile.block", "").replace("tile.", "").replace("of", "").replace("Of", "").replace("Block", "").replace("-", "").replace("_", "").replace(" ", ""), UtilsItems.getSimpleStack(this)); } public int getRenderColor(int aMeta) { diff --git a/src/Java/miscutil/core/item/general/RF2EU_Battery.java b/src/Java/miscutil/core/item/general/RF2EU_Battery.java index a6888b4dcc..ae03ea5a06 100644 --- a/src/Java/miscutil/core/item/general/RF2EU_Battery.java +++ b/src/Java/miscutil/core/item/general/RF2EU_Battery.java @@ -17,6 +17,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import cofh.api.energy.ItemEnergyContainer; @@ -110,7 +111,7 @@ public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, @Override public String getItemStackDisplayName(ItemStack p_77653_1_) { - return ("Universally chargeable battery"); + return ("Universally Chargeable Battery"); } @Override @@ -149,13 +150,13 @@ public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, @Override public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - list.add("IC2/EU Information"); - list.add("Tier: ["+getTier(thisStack)+"]"+" Current Power: ["+(long) getCharge(stack)+"/EU]"); - list.add("Transfer Limit: ["+getTransferLimit(thisStack)+"Eu/t]"+" Burn Time: ["+getBurnTime(stack)/20+"s]"); + list.add(EnumChatFormatting.YELLOW+"IC2/EU Information"+EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY+"Tier: ["+EnumChatFormatting.YELLOW+getTier(thisStack)+EnumChatFormatting.GRAY+"] Current Power: ["+EnumChatFormatting.YELLOW+(long) getCharge(stack)+EnumChatFormatting.GRAY+"/EU]"); + list.add(EnumChatFormatting.GRAY+"Transfer Limit: ["+EnumChatFormatting.YELLOW+getTransferLimit(thisStack)+ EnumChatFormatting.GRAY +"Eu/t]" +"Burn Time: ["+EnumChatFormatting.YELLOW+getBurnTime(stack)/20+EnumChatFormatting.GRAY+"s]"); list.add(""); - list.add("RF Information"); - list.add("Extraction Rate: [" + this.maxExtract + "Rf/t]" + " Insert Rate: [" + this.maxReceive+"Rf/t]"); - list.add("Current Charge: ["+getEnergyStored(stack) + "Rf / " + getMaxEnergyStored(stack)+"Rf] "+MathUtils.findPercentage(getEnergyStored(stack), getMaxEnergyStored(stack))+"%"); + list.add(EnumChatFormatting.RED+"RF Information"); + list.add(EnumChatFormatting.GRAY+"Extraction Rate: [" +EnumChatFormatting.RED+ this.maxExtract + EnumChatFormatting.GRAY + "Rf/t]" + " Insert Rate: [" +EnumChatFormatting.RED+ this.maxReceive+EnumChatFormatting.GRAY+"Rf/t]"); + list.add(EnumChatFormatting.GRAY+"Current Charge: ["+EnumChatFormatting.RED+getEnergyStored(stack) + EnumChatFormatting.GRAY + "Rf / " + getMaxEnergyStored(stack)+"Rf] "+EnumChatFormatting.RED+MathUtils.findPercentage(getEnergyStored(stack), getMaxEnergyStored(stack))+EnumChatFormatting.GRAY+"%"); super.addInformation(stack, aPlayer, list, bool); } @@ -205,6 +206,10 @@ public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, public double discharge(ItemStack stack, double amount, int tier, boolean ignoreTransferLimit, boolean externally, boolean simulate) { if ((stack.stackTagCompound == null) || (!stack.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } return 0; } int energy = stack.stackTagCompound.getInteger("Energy"); @@ -248,8 +253,12 @@ public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, @Override public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - if (container.stackTagCompound == null) { - container.stackTagCompound = new NBTTagCompound(); + if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } + return 0; } int energy = container.stackTagCompound.getInteger("Energy"); int energyReceived = Math.min(this.capacity - energy, Math.min(this.maxReceive, maxReceive)); @@ -268,6 +277,10 @@ public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } return 0; } int energy = container.stackTagCompound.getInteger("Energy"); @@ -286,6 +299,10 @@ public class RF2EU_Battery extends ItemEnergyContainer implements IElectricItem, public int getEnergyStored(ItemStack container) { if ((container.stackTagCompound == null) || (!container.stackTagCompound.hasKey("Energy"))) { + double euCharge = getCharge(UtilsItems.getSimpleStack(this)); + if (euCharge != 0 && euCharge >= 1){ + return (int) (MathUtils.decimalRoundingToWholes(euCharge*rfPerEU)); + } return 0; } int energy = container.stackTagCompound.getInteger("Energy"); diff --git a/src/Java/miscutil/core/util/debug/UtilsRendering.java b/src/Java/miscutil/core/util/debug/UtilsRendering.java index d57d92b6ff..89967e1a6a 100644 --- a/src/Java/miscutil/core/util/debug/UtilsRendering.java +++ b/src/Java/miscutil/core/util/debug/UtilsRendering.java @@ -2,9 +2,6 @@ package miscutil.core.util.debug; import javax.vecmath.Point3d; -import libshapedraw.LibShapeDraw; -import libshapedraw.primitive.ReadonlyColor; -import libshapedraw.shape.WireframeCuboid; import miscutil.core.util.Utils; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -29,7 +26,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class UtilsRendering { static Tessellator drawBlock = Tessellator.instance; - public static void drawBlockInWorld(final int x, final int y, final int z, final ReadonlyColor colours){ + /*public static void drawBlockInWorld(final int x, final int y, final int z, final ReadonlyColor colours){ Thread t = new Thread() { @Override public void run() { @@ -51,7 +48,7 @@ public class UtilsRendering { } }; t.start(); - } + }*/ public static void renderStuff (int x, int y, int z){ Utils.LOG_INFO("Doing Some Debug Rendering."); diff --git a/src/Java/miscutil/core/util/math/MathUtils.java b/src/Java/miscutil/core/util/math/MathUtils.java new file mode 100644 index 0000000000..bc3cb2843c --- /dev/null +++ b/src/Java/miscutil/core/util/math/MathUtils.java @@ -0,0 +1,213 @@ +package miscutil.core.util.math; + +import java.util.Map; +import java.util.Random; + +import miscutil.core.util.Utils; + +public class MathUtils { + + /** + * Returns a psuedo-random number between min and max, inclusive. + * The difference between min and max can be at most + * Integer.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Integer between min and max, inclusive. + * @see java.util.Random#nextInt(int) + */ + public static int randInt(int min, int max) { + + // Usually this can be a field rather than a method variable + Random rand = new Random(); + + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + int randomNum = rand.nextInt((max - min) + 1) + min; + + return randomNum; + } + + + /** + * Returns a psuedo-random number between min and max, inclusive. + * The difference between min and max can be at most + * Long.MAX_VALUE - 1. + * + * @param min Minimim value + * @param max Maximim value. Must be greater than min. + * @return Long between min and max, inclusive. + * @see java.util.Random#nextLong(long) + */ + public static long randLong(long min, long max) { + // Usually this can be a field rather than a method variable + Random rand = new Random(); + + // nextInt is normally exclusive of the top value, + // so add 1 to make it inclusive + long randomNum = MathUtils.nextLong(rand,(max - min) + 1) + min; + + return randomNum; + } + private static long nextLong(Random rng, long n) { + // error checking and 2^x checking removed for simplicity. + long bits, val; + do { + bits = (rng.nextLong() << 1) >>> 1; + val = bits % n; + } while (bits-val+(n-1) < 0L); + return val; + } + + + /** + * Returns a percentage. + * The returned number is the % of X in Y. + * Supports Doubles. + * + * @param current Current value. + * @param max Maximim value. Must be greater than min. + * @return double between min and max, inclusive. + */ + public static double findPercentage(double current, double max){ + double c = ((double) current / max) * 100; + double roundOff = Math.round(c * 100.00) / 100.00; + return roundOff; + } + + + //Smooth Rounding Function + /** + * Returns a double. + * The returned number is d rounded to the nearest d.01. + * Supports Doubles. + * + * @param current Current value. + * @return double Rounded value. + */ + public static double decimalRounding(double d) { + return Math.round(d * 2) / 2.0; + } + + + //Smooth Rounding Function (Nearest 5) + /** + * Returns a double. + * The returned number is d rounded to the nearest d.5. + * Supports Doubles. + * + * @param current Current value. + * @return double Rounded value. + */ + public static double decimalRoundingToWholes(double d) { + return 5*(Math.round(d/5)); + } + + + /** + * Returns a boolean. + * The returned boolean is wether or not X evenly fits in to Y. + * Supports ints. + * + * @param x Value A. + * @param y Value B. Must be greater than min. + * @return boolean Whether or not it divides evenly. + */ + public static boolean divideXintoY(int x, int y){ + if ((x % y) == 0) + { + return true; + } + return false; + } + + + /** + * Returns a boolean. + * The returned boolean is based on the odd/eveness of the input. + * Supports ints. + * + * @param x Value A. + * @return boolean Whether or not it divides evenly. + */ + public static boolean isNumberEven(int x){ + if ((x % 2) == 0) + { + return true; + } + return false; + } + + + + /** + * Returns an int. + * The returned number is the value on i + 273.15F. + * Supports ints. + * + * @param i Temp in Celcius. + * @return int The celcius temp returned as Kelvin, rounded to the readest whole. + */ + public static float celsiusToKelvin(int i){ + double f = i + 273.15F; + return (int)decimalRoundingToWholes(f); + } + + + /** + * Returns a hexInteger. + * The returned number is the hex value of the input. + * Supports ints. + * + * @param input Current value. + * @return hexInteger. + */ + public static int getHexNumberFromInt(int input){ + String result = Integer.toHexString(input); + int resultINT = Integer.getInteger(result); + return resultINT; + } + + + /** + * Returns a hexInteger. + * The returned value is between min and max. + * Supports ints. + * + * @param min Minimum value. + * @param max Maximium value. Must be greater than min. + * @return hexInteger between min and max, inclusive. + */ + public static int generateRandomHexValue(int min, int max){ + int result = getHexNumberFromInt(randInt(min, max)); + return result; + } + + + /** + * Returns a random hex value. + * The returned value is between 000000-ffffff. + * + * @return hexInteger between min and max, inclusive. + */ + public static int generateSingularRandomHexValue(){ + String temp; + int randomInt = randInt(1, 5); + final Map<Integer, String> colours = Utils.hexColourGeneratorRandom(5); + + if (colours.get(randomInt) != null && colours.size() > 0){ + temp = colours.get(randomInt); + } + else { + temp = "0F0F0F"; + } + + Utils.LOG_WARNING("Operating with "+temp); + temp = Utils.appenedHexNotationToString(String.valueOf(temp)); + Utils.LOG_WARNING("Made "+temp+" - Hopefully it's not a mess."); + Utils.LOG_WARNING("It will decode into "+Integer.decode(temp)+"."); + return Integer.decode(temp); + } + +} diff --git a/src/Java/miscutil/core/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java b/src/Java/miscutil/core/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java index e0b1c8c078..165a8e15a0 100644 --- a/src/Java/miscutil/core/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java +++ b/src/Java/miscutil/core/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityIndustrialSinter.java @@ -13,11 +13,9 @@ import gregtech.api.util.GT_Utility; import java.util.ArrayList; -import libshapedraw.primitive.Color; import miscutil.core.block.ModBlocks; import miscutil.core.lib.CORE; import miscutil.core.util.Utils; -import miscutil.core.util.debug.UtilsRendering; import miscutil.core.xmod.gregtech.api.gui.GUI_MultiMachine; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; @@ -137,7 +135,7 @@ extends GT_MetaTileEntity_MultiBlockBase { Utils.LOG_INFO("Found Air at: "+(controllerX+i)+" "+(controllerY+k)+" "+(controllerZ+k)); //if (aBaseMetaTileEntity.getWorld().isRemote){ //asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, (controllerX+i), (controllerY+k), (controllerZ+k)); - UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.YELLOW_GREEN); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.YELLOW_GREEN); //} tAirCount++; } @@ -149,7 +147,7 @@ extends GT_MetaTileEntity_MultiBlockBase { //return false; } for (byte i = 2; i < 6; i = (byte) (i + 1)) { - UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY), (controllerZ), Color.LIME_GREEN); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY), (controllerZ), Color.LIME_GREEN); IGregTechTileEntity tTileEntity; if ((null != (tTileEntity = getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2))) && (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing()) && (tTileEntity.getMetaTileEntity() != null) && @@ -165,9 +163,9 @@ extends GT_MetaTileEntity_MultiBlockBase { for (byte j = -1; j < 2; j = (byte) (j + 1)) { if ((i != 0) || (j != 0)) { for (byte k = 0; k < 5; k = (byte) (k + 1)) { - UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.ORANGE); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.ORANGE); if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) { - UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.TOMATO); + //UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k), Color.TOMATO); if (getBaseMetaTileEntity().getBlock(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingBlock() && getBaseMetaTileEntity().getMetaID(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)) == getCasingMeta()) { } else if (!addToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))) && (!addEnergyInputToMachineList(getBaseMetaTileEntity().getIGregTechTileEntity(tX + (tSide == 5 ? k : tSide == 4 ? -k : i), tY + j, tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) { |