From 99324328548ac88afd70450f8310fcb68885fb62 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 12 Nov 2015 21:36:20 +0100 Subject: [PATCH] This is.. wow. I'm... wow. /cc AtomSponge --- .../blocks/BlockContainerBase.java | 15 ++++++------- .../blocks/BlockGrinder.java | 4 ++-- .../blocks/BlockInputter.java | 5 +++-- .../blocks/BlockTreasureChest.java | 21 +++++++++---------- .../blocks/render/RenderSmileyCloud.java | 4 +--- .../event/EntityLivingEvent.java | 3 +-- .../event/LivingDropEvent.java | 14 ++++++------- .../items/ItemGrowthRing.java | 3 +-- .../items/ItemHairyBall.java | 10 ++++----- .../tile/TileEntityFeeder.java | 12 +++++------ .../tile/TileEntityFishingNet.java | 7 ++----- .../tile/TileEntityGreenhouseGlass.java | 4 +--- .../tile/TileEntityGrinder.java | 3 +-- .../tile/TileEntityHeatCollector.java | 6 ++---- 14 files changed, 45 insertions(+), 66 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockContainerBase.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockContainerBase.java index ba9713482..201a37f63 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockContainerBase.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockContainerBase.java @@ -21,8 +21,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import java.util.Random; - public abstract class BlockContainerBase extends BlockContainer{ public BlockContainerBase(Material mat){ @@ -44,20 +42,19 @@ public abstract class BlockContainerBase extends BlockContainer{ } public void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, int x, int y, int z){ - Random rand = new Random(); ItemStack stack = tile.getStackInSlot(i); if(stack != null && stack.stackSize > 0){ - float dX = rand.nextFloat()*0.8F+0.1F; - float dY = rand.nextFloat()*0.8F+0.1F; - float dZ = rand.nextFloat()*0.8F+0.1F; + float dX = world.rand.nextFloat()*0.8F+0.1F; + float dY = world.rand.nextFloat()*0.8F+0.1F; + float dZ = world.rand.nextFloat()*0.8F+0.1F; EntityItem entityItem = new EntityItem(world, x+dX, y+dY, z+dZ, stack.copy()); if(stack.hasTagCompound()){ entityItem.getEntityItem().setTagCompound((NBTTagCompound)stack.getTagCompound().copy()); } float factor = 0.05F; - entityItem.motionX = rand.nextGaussian()*factor; - entityItem.motionY = rand.nextGaussian()*factor+0.2F; - entityItem.motionZ = rand.nextGaussian()*factor; + entityItem.motionX = world.rand.nextGaussian()*factor; + entityItem.motionY = world.rand.nextGaussian()*factor+0.2F; + entityItem.motionZ = world.rand.nextGaussian()*factor; world.spawnEntityInWorld(entityItem); } tile.setInventorySlotContents(i, null); diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockGrinder.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockGrinder.java index 169942c4e..4775690c0 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockGrinder.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockGrinder.java @@ -78,8 +78,8 @@ public class BlockGrinder extends BlockContainerBase implements IActAddItemOrBlo if(meta == 1){ for(int i = 0; i < 5; i++){ - double xRand = new Random().nextDouble()/0.75D-0.5D; - double zRand = new Random().nextDouble()/0.75D-0.5D; + double xRand = rand.nextDouble()/0.75D-0.5D; + double zRand = rand.nextDouble()/0.75D-0.5D; world.spawnParticle("crit", (double)x+0.4F, (double)y+0.8F, (double)z+0.4F, xRand, 0.5D, zRand); } world.spawnParticle(ClientProxy.bulletForMyValentine ? "heart" : "smoke", (double)x+0.5F, (double)y+1.0F, (double)z+0.5F, 0.0D, 0.0D, 0.0D); diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockInputter.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockInputter.java index 55a718ec0..12a2e1306 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockInputter.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockInputter.java @@ -104,6 +104,8 @@ public class BlockInputter extends BlockContainerBase implements IActAddItemOrBl private long lastSysTime; private int toPick; + private final Random rand = new Random(); + public TheItemBlock(Block block){ super(block); this.setHasSubtypes(false); @@ -128,12 +130,11 @@ public class BlockInputter extends BlockContainerBase implements IActAddItemOrBl @Override public String getItemStackDisplayName(ItemStack stack){ - Random rand = new Random(); long sysTime = System.currentTimeMillis(); if(this.lastSysTime+5000 < sysTime){ this.lastSysTime = sysTime; - this.toPick = rand.nextInt(NAME_FLAVOUR_AMOUNTS)+1; + this.toPick = this.rand.nextInt(NAME_FLAVOUR_AMOUNTS)+1; } return StringUtil.localize(this.getUnlocalizedName()+".name")+" ("+StringUtil.localize("tile."+ModUtil.MOD_ID_LOWER+".blockInputter.add."+this.toPick+".name")+")"; diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/BlockTreasureChest.java b/src/main/java/ellpeck/actuallyadditions/blocks/BlockTreasureChest.java index 8bdd8e58e..44965b0b6 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/BlockTreasureChest.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/BlockTreasureChest.java @@ -103,7 +103,7 @@ public class BlockTreasureChest extends Block implements IActAddItemOrBlock{ @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9){ if(!world.isRemote){ - world.playSoundAtEntity(player, "random.chestopen", 0.2F, new Random().nextFloat()*0.1F+0.9F); + world.playSoundAtEntity(player, "random.chestopen", 0.2F, world.rand.nextFloat()*0.1F+0.9F); this.dropItems(world, x, y, z); player.addStat(TheAchievements.OPEN_TREASURE_CHEST.ach, 1); world.setBlockToAir(x, y, z); @@ -154,23 +154,22 @@ public class BlockTreasureChest extends Block implements IActAddItemOrBlock{ } private void dropItems(World world, int x, int y, int z){ - Random rand = new Random(); - for(int i = 0; i < MathHelper.getRandomIntegerInRange(rand, 3, 6); i++){ - TreasureChestHandler.Return theReturn = (TreasureChestHandler.Return)WeightedRandom.getRandomItem(rand, TreasureChestHandler.returns); + for(int i = 0; i < MathHelper.getRandomIntegerInRange(world.rand, 3, 6); i++){ + TreasureChestHandler.Return theReturn = (TreasureChestHandler.Return)WeightedRandom.getRandomItem(world.rand, TreasureChestHandler.returns); ItemStack itemStack = theReturn.returnItem.copy(); - itemStack.stackSize = MathHelper.getRandomIntegerInRange(rand, theReturn.minAmount, theReturn.maxAmount); + itemStack.stackSize = MathHelper.getRandomIntegerInRange(world.rand, theReturn.minAmount, theReturn.maxAmount); - float dX = rand.nextFloat()*0.8F+0.1F; - float dY = rand.nextFloat()*0.8F+0.1F; - float dZ = rand.nextFloat()*0.8F+0.1F; + float dX = world.rand.nextFloat()*0.8F+0.1F; + float dY = world.rand.nextFloat()*0.8F+0.1F; + float dZ = world.rand.nextFloat()*0.8F+0.1F; EntityItem entityItem = new EntityItem(world, x+dX, y+dY, z+dZ, itemStack.copy()); if(itemStack.hasTagCompound()){ entityItem.getEntityItem().setTagCompound((NBTTagCompound)itemStack.getTagCompound().copy()); } float factor = 0.05F; - entityItem.motionX = rand.nextGaussian()*factor; - entityItem.motionY = rand.nextGaussian()*factor+0.2F; - entityItem.motionZ = rand.nextGaussian()*factor; + entityItem.motionX = world.rand.nextGaussian()*factor; + entityItem.motionY = world.rand.nextGaussian()*factor+0.2F; + entityItem.motionZ = world.rand.nextGaussian()*factor; world.spawnEntityInWorld(entityItem); itemStack.stackSize = 0; } diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/render/RenderSmileyCloud.java b/src/main/java/ellpeck/actuallyadditions/blocks/render/RenderSmileyCloud.java index 491bf456b..ec1c51c0d 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/render/RenderSmileyCloud.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/render/RenderSmileyCloud.java @@ -24,8 +24,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -import java.util.Random; - public class RenderSmileyCloud extends RenderTileEntity{ private static final ResourceLocation resLocValentine = new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/blocks/models/modelPinkFluffyUnicloud.png"); @@ -44,7 +42,7 @@ public class RenderSmileyCloud extends RenderTileEntity{ GL11.glPushMatrix(); { if(theCloud.flyHeight == 0){ - theCloud.flyHeight = new Random().nextInt(30)+30; + theCloud.flyHeight = tile.getWorldObj().rand.nextInt(30)+30; } int bobHeight = theCloud.flyHeight; long theTime = Minecraft.getSystemTime(); diff --git a/src/main/java/ellpeck/actuallyadditions/event/EntityLivingEvent.java b/src/main/java/ellpeck/actuallyadditions/event/EntityLivingEvent.java index 29e5d1b52..965aa81c5 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/EntityLivingEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/EntityLivingEvent.java @@ -21,7 +21,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; -import java.util.Random; import java.util.UUID; public class EntityLivingEvent{ @@ -32,7 +31,7 @@ public class EntityLivingEvent{ if(event.entityLiving != null && event.entityLiving.worldObj != null && !event.entityLiving.worldObj.isRemote){ if((event.entityLiving instanceof EntityOcelot && ((EntityOcelot)event.entityLiving).isTamed()) || (event.entityLiving instanceof EntityPlayer && event.entityLiving.getUniqueID().equals(/*KittyVanCat*/ UUID.fromString("681d4e20-10ef-40c9-a0a5-ba2f1995ef44")))){ if(ConfigBoolValues.DO_CAT_DROPS.isEnabled()){ - if(new Random().nextInt(ConfigIntValues.CAT_DROP_CHANCE.getValue())+1 == 1){ + if(event.entityLiving.worldObj.rand.nextInt(ConfigIntValues.CAT_DROP_CHANCE.getValue())+1 == 1){ EntityItem item = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX+0.5, event.entityLiving.posY+0.5, event.entityLiving.posZ+0.5, new ItemStack(InitItems.itemHairyBall)); event.entityLiving.worldObj.spawnEntityInWorld(item); } diff --git a/src/main/java/ellpeck/actuallyadditions/event/LivingDropEvent.java b/src/main/java/ellpeck/actuallyadditions/event/LivingDropEvent.java index dacd62cf1..6e900b22b 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/LivingDropEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/LivingDropEvent.java @@ -23,8 +23,6 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.living.LivingDropsEvent; -import java.util.Random; - public class LivingDropEvent{ @SubscribeEvent @@ -34,23 +32,23 @@ public class LivingDropEvent{ for(int i = 0; i < TheSpecialDrops.values().length; i++){ TheSpecialDrops theDrop = TheSpecialDrops.values()[i]; if(theDrop.canDrop && theDrop.dropFrom.isAssignableFrom(event.entityLiving.getClass())){ - if(new Random().nextInt(100)+1 <= theDrop.chance){ - event.entityLiving.entityDropItem(new ItemStack(InitItems.itemSpecialDrop, new Random().nextInt(theDrop.maxAmount)+1, theDrop.ordinal()), 0); + if(event.entityLiving.worldObj.rand.nextInt(100)+1 <= theDrop.chance){ + event.entityLiving.entityDropItem(new ItemStack(InitItems.itemSpecialDrop, event.entityLiving.worldObj.rand.nextInt(theDrop.maxAmount)+1, theDrop.ordinal()), 0); } } } //Drop Cobwebs from Spiders if(ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.entityLiving instanceof EntitySpider){ - if(new Random().nextInt(ConfigIntValues.SPIDER_DROP_CHANCE.getValue()) <= 0){ - event.entityLiving.entityDropItem(new ItemStack(Blocks.web, new Random().nextInt(2)+1), 0); + if(event.entityLiving.worldObj.rand.nextInt(ConfigIntValues.SPIDER_DROP_CHANCE.getValue()) <= 0){ + event.entityLiving.entityDropItem(new ItemStack(Blocks.web, event.entityLiving.worldObj.rand.nextInt(2)+1), 0); } } //Drop Wings from Bats if(ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.entityLiving instanceof EntityBat){ - if(new Random().nextInt(ConfigIntValues.BAT_DROP_CHANCE.getValue()) <= 0){ - event.entityLiving.entityDropItem(new ItemStack(InitItems.itemMisc, new Random().nextInt(2)+1, TheMiscItems.BAT_WING.ordinal()), 0); + if(event.entityLiving.worldObj.rand.nextInt(ConfigIntValues.BAT_DROP_CHANCE.getValue()) <= 0){ + event.entityLiving.entityDropItem(new ItemStack(InitItems.itemMisc, event.entityLiving.worldObj.rand.nextInt(2)+1, TheMiscItems.BAT_WING.ordinal()), 0); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemGrowthRing.java b/src/main/java/ellpeck/actuallyadditions/items/ItemGrowthRing.java index a938715a6..331115bfd 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemGrowthRing.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemGrowthRing.java @@ -30,7 +30,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; import java.util.ArrayList; -import java.util.Random; public class ItemGrowthRing extends ItemEnergy{ @@ -74,7 +73,7 @@ public class ItemGrowthRing extends ItemEnergy{ //Fertilizing the Blocks if(!blocks.isEmpty()){ for(int i = 0; i < ConfigIntValues.GROWTH_RING_GROWTH_PER_CYCLE.getValue(); i++){ - WorldPos pos = blocks.get(new Random().nextInt(blocks.size())); + WorldPos pos = blocks.get(world.rand.nextInt(blocks.size())); int metaBefore = pos.getMetadata(); pos.getBlock().updateTick(world, pos.getX(), pos.getY(), pos.getZ(), world.rand); diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemHairyBall.java b/src/main/java/ellpeck/actuallyadditions/items/ItemHairyBall.java index 31a0a3dda..e2f848976 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemHairyBall.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemHairyBall.java @@ -25,27 +25,25 @@ import net.minecraft.util.IIcon; import net.minecraft.util.WeightedRandom; import net.minecraft.world.World; -import java.util.Random; - public class ItemHairyBall extends Item implements IActAddItemOrBlock{ @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player){ if(!world.isRemote){ - ItemStack returnItem = this.getRandomReturnItem(); + ItemStack returnItem = this.getRandomReturnItem(world); if(!player.inventory.addItemStackToInventory(returnItem)){ EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem); entityItem.delayBeforeCanPickup = 0; player.worldObj.spawnEntityInWorld(entityItem); } stack.stackSize--; - world.playSoundAtEntity(player, "random.pop", 0.2F, new Random().nextFloat()*0.1F+0.9F); + world.playSoundAtEntity(player, "random.pop", 0.2F, world.rand.nextFloat()*0.1F+0.9F); } return stack; } - public ItemStack getRandomReturnItem(){ - return ((HairyBallHandler.Return)WeightedRandom.getRandomItem(new Random(), HairyBallHandler.returns)).returnItem.copy(); + public ItemStack getRandomReturnItem(World world){ + return ((HairyBallHandler.Return)WeightedRandom.getRandomItem(world.rand, HairyBallHandler.returns)).returnItem.copy(); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java index ad9a015b7..3aba24803 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java @@ -19,7 +19,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import java.util.List; -import java.util.Random; public class TileEntityFeeder extends TileEntityInventoryBase{ @@ -45,7 +44,7 @@ public class TileEntityFeeder extends TileEntityInventoryBase{ if(this.currentTimer >= ConfigIntValues.FEEDER_TIME.getValue()){ this.currentTimer = 0; if(this.slots[0] != null){ - EntityAnimal randomAnimal = animals.get(new Random().nextInt(this.currentAnimalAmount)); + EntityAnimal randomAnimal = animals.get(worldObj.rand.nextInt(this.currentAnimalAmount)); if(!randomAnimal.isInLove() && randomAnimal.getGrowingAge() == 0 && randomAnimal.isBreedingItem(this.slots[0])){ this.feedAnimal(randomAnimal); @@ -84,12 +83,11 @@ public class TileEntityFeeder extends TileEntityInventoryBase{ public void feedAnimal(EntityAnimal animal){ animal.func_146082_f(null); - Random rand = new Random(); for(int i = 0; i < 7; i++){ - double d = rand.nextGaussian()*0.02D; - double d1 = rand.nextGaussian()*0.02D; - double d2 = rand.nextGaussian()*0.02D; - worldObj.spawnParticle("heart", (animal.posX+(double)(rand.nextFloat()*animal.width*2.0F))-animal.width, animal.posY+0.5D+(double)(rand.nextFloat()*animal.height), (animal.posZ+(double)(rand.nextFloat()*animal.width*2.0F))-animal.width, d, d1, d2); + double d = animal.worldObj.rand.nextGaussian()*0.02D; + double d1 = animal.worldObj.rand.nextGaussian()*0.02D; + double d2 = animal.worldObj.rand.nextGaussian()*0.02D; + worldObj.spawnParticle("heart", (animal.posX+(double)(animal.worldObj.rand.nextFloat()*animal.width*2.0F))-animal.width, animal.posY+0.5D+(double)(animal.worldObj.rand.nextFloat()*animal.height), (animal.posZ+(double)(animal.worldObj.rand.nextFloat()*animal.width*2.0F))-animal.width, d, d1, d2); } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java index 304d89adf..9e37c526b 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java @@ -21,8 +21,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.FishingHooks; import net.minecraftforge.common.util.ForgeDirection; -import java.util.Random; - public class TileEntityFishingNet extends TileEntityBase{ public int timeUntilNextDrop; @@ -42,11 +40,10 @@ public class TileEntityFishingNet extends TileEntityBase{ if(!worldObj.isRemote){ if(!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)){ if(worldObj.getBlock(xCoord, yCoord-1, zCoord).getMaterial() == Material.water){ - Random rand = new Random(); if(this.timeUntilNextDrop > 0){ this.timeUntilNextDrop--; if(timeUntilNextDrop <= 0){ - ItemStack fishable = FishingHooks.getRandomFishable(rand, this.worldObj.rand.nextFloat()); + ItemStack fishable = FishingHooks.getRandomFishable(worldObj.rand, this.worldObj.rand.nextFloat()); TileEntity tile = worldObj.getTileEntity(xCoord, yCoord+1, zCoord); if(tile != null && tile instanceof IInventory){ this.insertIntoInventory((IInventory)tile, fishable); @@ -59,7 +56,7 @@ public class TileEntityFishingNet extends TileEntityBase{ } } else{ - this.timeUntilNextDrop = ConfigIntValues.FISHER_TIME.getValue()+rand.nextInt(ConfigIntValues.FISHER_TIME.getValue()/2); + this.timeUntilNextDrop = ConfigIntValues.FISHER_TIME.getValue()+worldObj.rand.nextInt(ConfigIntValues.FISHER_TIME.getValue()/2); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java index d2b16df00..c0f54e31f 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java @@ -18,8 +18,6 @@ import net.minecraft.block.IGrowable; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.IPlantable; -import java.util.Random; - public class TileEntityGreenhouseGlass extends TileEntityBase{ private int timeUntilNextFert; @@ -42,7 +40,7 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{ } } else{ - this.timeUntilNextFert = ConfigIntValues.GLASS_TIME_NEEDED.getValue()+new Random().nextInt(ConfigIntValues.GLASS_TIME_NEEDED.getValue()); + this.timeUntilNextFert = ConfigIntValues.GLASS_TIME_NEEDED.getValue()+this.worldObj.rand.nextInt(ConfigIntValues.GLASS_TIME_NEEDED.getValue()); } } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java index f2b0599ac..b4b7dc0e1 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java @@ -22,7 +22,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; -import java.util.Random; public class TileEntityGrinder extends TileEntityInventoryBase implements IEnergyReceiver{ @@ -178,7 +177,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg if(outputTwos != null){ ItemStack outputTwo = outputTwos.get(0); if(outputTwo != null){ - int rand = new Random().nextInt(100)+1; + int rand = this.worldObj.rand.nextInt(100)+1; if(rand <= CrusherRecipeRegistry.getOutputTwoChance(this.slots[theInput])){ if(this.slots[theSecondOutput] == null){ this.slots[theSecondOutput] = outputTwo.copy(); diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java index bf797b11e..38417b6b5 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java @@ -21,7 +21,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; -import java.util.Random; public class TileEntityHeatCollector extends TileEntityBase implements IEnergyProvider{ @@ -46,9 +45,8 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr this.storage.receiveEnergy(ConfigIntValues.HEAT_COLLECTOR_ENERGY_PRODUCED.getValue(), false); this.markDirty(); - Random rand = new Random(); - if(rand.nextInt(ConfigIntValues.HEAT_COLLECTOR_LAVA_CHANCE.getValue()) == 0){ - int randomSide = blocksAround.get(rand.nextInt(blocksAround.size())); + if(worldObj.rand.nextInt(ConfigIntValues.HEAT_COLLECTOR_LAVA_CHANCE.getValue()) == 0){ + int randomSide = blocksAround.get(worldObj.rand.nextInt(blocksAround.size())); WorldUtil.breakBlockAtSide(WorldUtil.getDirectionBySidesInOrder(randomSide), worldObj, xCoord, yCoord, zCoord); } }