diff options
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r-- | src/main/java/gregtech/api/objects/MaterialStack.java | 393 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GT_Utility.java | 49 |
2 files changed, 52 insertions, 390 deletions
diff --git a/src/main/java/gregtech/api/objects/MaterialStack.java b/src/main/java/gregtech/api/objects/MaterialStack.java index 472298bf77..4392d60a07 100644 --- a/src/main/java/gregtech/api/objects/MaterialStack.java +++ b/src/main/java/gregtech/api/objects/MaterialStack.java @@ -1,6 +1,7 @@ package gregtech.api.objects; import gregtech.api.enums.Materials; +import gregtech.api.util.GT_Utility; public class MaterialStack implements Cloneable { public long mAmount; @@ -31,402 +32,16 @@ public class MaterialStack implements Cloneable { } @Override - //Done sub numbering up to 50. couldn't find a better way to do this public String toString() { String temp1 = "", temp2 = mMaterial.getToolTip(true), temp3 = "", temp4 = ""; - if (mAmount == 2) { - temp4 = "\u2082"; + if (mAmount > 1) { + temp4 = GT_Utility.toSubscript(mAmount); if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { temp1 = "("; temp3 = ")"; } } - if (mAmount == 3) { - temp4 = "\u2083"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 4) { - temp4 = "\u2084"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 5) { - temp4 = "\u2085"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 6) { - temp4 = "\u2086"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 7) { - temp4 = "\u2087"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 8) { - temp4 = "\u2088"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 9) { - temp4 = "\u2089"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 10) { - temp4 = "\u2081"+"\u2080"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 11) { - temp4 = "\u2081"+"\u2081"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 12) { - temp4 = "\u2081"+"\u2082"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 13) { - temp4 = "\u2081"+"\u2083"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 14) { - temp4 = "\u2081"+"\u2084"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 15) { - temp4 = "\u2081"+"\u2085"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 16) { - temp4 = "\u2081"+"\u2086"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 17) { - temp4 = "\u2081"+"\u2087"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 18) { - temp4 = "\u2081"+"\u2088"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 19) { - temp4 = "\u2081"+"\u2089"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 20) { - temp4 = "\u2082"+"\u2080"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 21) { - temp4 = "\u2082"+"\u2081"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 22) { - temp4 = "\u2082"+"\u2082"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 23) { - temp4 = "\u2082"+"\u2083"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 24) { - temp4 = "\u2082"+"\u2084"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 25) { - temp4 = "\u2082"+"\u2085"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 26) { - temp4 = "\u2082"+"\u2086"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 27) { - temp4 = "\u2082"+"\u2087"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 28) { - temp4 = "\u2082"+"\u2088"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 29) { - temp4 = "\u2082"+"\u2089"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 30) { - temp4 = "\u2083"+"\u2080"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 31) { - temp4 = "\u2083"+"\u2081"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 32) { - temp4 = "\u2083"+"\u2082"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 33) { - temp4 = "\u2083"+"\u2083"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 34) { - temp4 = "\u2083"+"\u2084"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 35) { - temp4 = "\u2083"+"\u2085"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 36) { - temp4 = "\u2083"+"\u2086"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 37) { - temp4 = "\u2083"+"\u2087"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 38) { - temp4 = "\u2083"+"\u2088"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 39) { - temp4 = "\u2083"+"\u2089"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 40) { - temp4 = "\u2084"+"\u2080"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 41) { - temp4 = "\u2084"+"\u2081"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 42) { - temp4 = "\u2084"+"\u2082"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 43) { - temp4 = "\u2084"+"\u2083"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 44) { - temp4 = "\u2084"+"\u2084"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 45) { - temp4 = "\u2084"+"\u2085"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 46) { - temp4 = "\u2084"+"\u2086"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 47) { - temp4 = "\u2084"+"\u2087"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 48) { - temp4 = "\u2084"+"\u2088"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 49) { - temp4 = "\u2084"+"\u2089"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - if (mAmount == 50) { - temp4 = "\u2085"+"\u2080"; - - if (mMaterial.mMaterialList.size() > 1 || isMaterialListComplex(this)) { - temp1 = "("; - temp3 = ")"; - } - } - return String.valueOf(new StringBuilder().append(temp1).append(temp2).append(temp3).append(temp4)); } @@ -444,4 +59,4 @@ public class MaterialStack implements Cloneable { public int hashCode() { return mMaterial.hashCode(); } -} +}
\ No newline at end of file diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 8b8e169ce5..17e2f3d0c4 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1,6 +1,7 @@ package gregtech.api.util; import cofh.api.transport.IItemDuct; +import com.mojang.authlib.GameProfile; import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.GregTech_API; import gregtech.api.damagesources.GT_DamageSources; @@ -56,7 +57,12 @@ import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.BlockSnapshot; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; @@ -1949,7 +1955,41 @@ public class GT_Utility { public static ItemStack getIntegratedCircuit(int config){ return ItemList.Circuit_Integrated.getWithDamage(0, config, new Object[0]); } - + + public static float getBlockHardnessAt(World aWorld, int aX, int aY, int aZ) { + return aWorld.getBlock(aX, aY, aZ).getBlockHardness(aWorld, aX, aY, aZ); + } + + public static FakePlayer getFakePlayer(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.getWorld() instanceof WorldServer) { + return FakePlayerFactory.get((WorldServer) aBaseMetaTileEntity.getWorld(), new GameProfile(null, aBaseMetaTileEntity.getOwnerName())); + } + return null; + } + + public static boolean eraseBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, boolean isSimulate) { + if (aPlayer == null) return false; + World aWorld = aPlayer.worldObj; + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(aX, aY, aZ, aWorld, aWorld.getBlock(aX, aY, aZ), aWorld.getBlockMetadata(aX, aY, aZ), aPlayer); + MinecraftForge.EVENT_BUS.post(event); + if (!event.isCanceled()) { + if (!isSimulate) return aWorld.setBlockToAir(aX, aY, aZ); + return true; + } + return false; + } + + public static boolean setBlockByFakePlayer(FakePlayer aPlayer, int aX, int aY, int aZ, Block aBlock, int aMeta, boolean isSimulate) { + if (aPlayer == null) return false; + World aWorld = aPlayer.worldObj; + BlockEvent.PlaceEvent event = ForgeEventFactory.onPlayerBlockPlace(aPlayer, new BlockSnapshot(aWorld, aX, aY, aZ, aBlock, aMeta), ForgeDirection.UNKNOWN); + if (!event.isCanceled()) { + if (!isSimulate) return aWorld.setBlock(aX, aY, aZ, aBlock, aMeta, 3); + return true; + } + return false; + } + public static class ItemNBT { public static void setNBT(ItemStack aStack, NBTTagCompound aNBT) { if (aNBT == null) { @@ -2263,4 +2303,11 @@ public class GT_Utility { } } + public static String toSubscript(long no){ + char[] chars=Long.toString(no).toCharArray(); + for(int i=0;i<chars.length;i++){ + chars[i]+=8272; + } + return new String(chars); + } } |