From ff9f58d39a282aee81cc9ae72e7463e470dc596b Mon Sep 17 00:00:00 2001 From: Technus Date: Sun, 1 Oct 2017 15:19:28 +0200 Subject: Optimize imports, optimize random number generation, make turbines loose 0.75 or normal durability in loose fitting mode. --- src/main/java/gregtech/common/blocks/GT_Block_Machines.java | 13 ++++++------- .../java/gregtech/common/blocks/GT_Block_Reinforced.java | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/main/java/gregtech/common/blocks') diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java index 4608f0a7a5..1c24ce4dac 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -12,7 +12,6 @@ import gregtech.api.items.GT_Generic_Block; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.BaseTileEntity; -import gregtech.api.objects.XSTR; import gregtech.api.util.GT_BaseCrop; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; @@ -41,7 +40,8 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; import java.util.List; -import java.util.Random; + +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; public class GT_Block_Machines extends GT_Generic_Block @@ -336,18 +336,17 @@ public class GT_Block_Machines TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity instanceof IGregTechTileEntity)) { IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; - Random tRandom = new XSTR(); mTemporaryTileEntity.set(tGregTechTileEntity); for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) { ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); if ((tItem != null) && (tItem.stackSize > 0) && (tGregTechTileEntity.isValidSlot(i))) { - EntityItem tItemEntity = new EntityItem(aWorld, aX + tRandom.nextFloat() * 0.8F + 0.1F, aY + tRandom.nextFloat() * 0.8F + 0.1F, aZ + tRandom.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); + EntityItem tItemEntity = new EntityItem(aWorld, aX + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, aY + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, aZ + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); if (tItem.hasTagCompound()) { tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); } - tItemEntity.motionX = (tRandom.nextGaussian() * 0.0500000007450581D); - tItemEntity.motionY = (tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D); - tItemEntity.motionZ = (tRandom.nextGaussian() * 0.0500000007450581D); + tItemEntity.motionX = (XSTR_INSTANCE.nextGaussian() * 0.0500000007450581D); + tItemEntity.motionY = (XSTR_INSTANCE.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D); + tItemEntity.motionZ = (XSTR_INSTANCE.nextGaussian() * 0.0500000007450581D); aWorld.spawnEntityInWorld(tItemEntity); tItem.stackSize = 0; tGregTechTileEntity.setInventorySlotContents(i, null); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java index 18aed61b9f..5c74052ff0 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java @@ -35,6 +35,8 @@ import net.minecraft.world.World; import java.util.List; import java.util.Random; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + public class GT_Block_Reinforced extends GT_Generic_Block { public GT_Block_Reinforced(String aName) { @@ -202,9 +204,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int par5, float chance, int par7) { if (par5 == 4) { - Random ran = new Random(); - - this.dropBlockAsItem(aWorld, aX, aY, aZ, new ItemStack(Items.coal, ran.nextInt(2) + 1, 1)); + this.dropBlockAsItem(aWorld, aX, aY, aZ, new ItemStack(Items.coal, XSTR_INSTANCE.nextInt(2) + 1, 1)); } else { super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, par5, chance, par7); } -- cgit