Remove Util.RANDOM

This commit is contained in:
Ellpeck 2016-11-02 19:36:32 +01:00
parent 1b8169e7bc
commit 7524ee52fd
29 changed files with 100 additions and 96 deletions

View file

@ -180,8 +180,8 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
if(this.lastSysTime+3000 < sysTime){
this.lastSysTime = sysTime;
this.toPick1 = Util.RANDOM.nextInt(NAME_FLAVOR_AMOUNTS_1)+1;
this.toPick2 = Util.RANDOM.nextInt(NAME_FLAVOR_AMOUNTS_2)+1;
this.toPick1 = player.worldObj.rand.nextInt(NAME_FLAVOR_AMOUNTS_1)+1;
this.toPick2 = player.worldObj.rand.nextInt(NAME_FLAVOR_AMOUNTS_2)+1;
}
String base = "tile."+ModUtil.MOD_ID+"."+((BlockAtomicReconstructor)this.block).getBaseName()+".info.";

View file

@ -34,6 +34,8 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.Random;
public class BlockInputter extends BlockContainerBase{
public static final int NAME_FLAVOR_AMOUNTS = 15;
@ -94,6 +96,7 @@ public class BlockInputter extends BlockContainerBase{
private long lastSysTime;
private int toPick;
private final Random rand = new Random();
public TheItemBlock(Block block){
super(block);
@ -119,7 +122,7 @@ public class BlockInputter extends BlockContainerBase{
if(this.lastSysTime+5000 < sysTime){
this.lastSysTime = sysTime;
this.toPick = Util.RANDOM.nextInt(NAME_FLAVOR_AMOUNTS)+1;
this.toPick = this.rand.nextInt(NAME_FLAVOR_AMOUNTS)+1;
}
return StringUtil.localize(this.getUnlocalizedName()+".name")+" ("+StringUtil.localize("tile."+ModUtil.MOD_ID+".blockInputter.add."+this.toPick+".name")+")";

View file

@ -62,12 +62,12 @@ public class BlockSmileyCloud extends BlockContainerBase{
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand){
if(Util.RANDOM.nextInt(30) == 0){
if(world.rand.nextInt(30) == 0){
for(int i = 0; i < 2; i++){
double d = Util.RANDOM.nextGaussian()*0.02D;
double d1 = Util.RANDOM.nextGaussian()*0.02D;
double d2 = Util.RANDOM.nextGaussian()*0.02D;
world.spawnParticle(EnumParticleTypes.HEART, pos.getX()+Util.RANDOM.nextFloat(), pos.getY()+0.65+Util.RANDOM.nextFloat(), pos.getZ()+Util.RANDOM.nextFloat(), d, d1, d2);
double d = world.rand.nextGaussian()*0.02D;
double d1 = world.rand.nextGaussian()*0.02D;
double d2 = world.rand.nextGaussian()*0.02D;
world.spawnParticle(EnumParticleTypes.HEART, pos.getX()+world.rand.nextFloat(), pos.getY()+0.65+world.rand.nextFloat(), pos.getZ()+world.rand.nextFloat(), d, d1, d2);
}
}
}

View file

@ -68,7 +68,7 @@ public class BlockTreasureChest extends BlockBase{
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
if(!world.isRemote){
world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, Util.RANDOM.nextFloat()*0.1F+0.9F);
world.playSound(null, pos, SoundEvents.BLOCK_CHEST_OPEN, SoundCategory.BLOCKS, 0.2F, world.rand.nextFloat()*0.1F+0.9F);
this.dropItems(world, pos);
world.setBlockToAir(pos);
@ -101,19 +101,19 @@ public class BlockTreasureChest extends BlockBase{
}
private void dropItems(World world, BlockPos pos){
for(int i = 0; i < MathHelper.getRandomIntegerInRange(Util.RANDOM, 3, 6); i++){
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(Util.RANDOM, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
for(int i = 0; i < MathHelper.getRandomIntegerInRange(world.rand, 3, 6); i++){
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(world.rand, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
ItemStack itemStack = theReturn.returnItem.copy();
itemStack.stackSize = MathHelper.getRandomIntegerInRange(Util.RANDOM, theReturn.minAmount, theReturn.maxAmount);
itemStack.stackSize = MathHelper.getRandomIntegerInRange(world.rand, theReturn.minAmount, theReturn.maxAmount);
float dX = Util.RANDOM.nextFloat()*0.8F+0.1F;
float dY = Util.RANDOM.nextFloat()*0.8F+0.1F;
float dZ = Util.RANDOM.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, pos.getX()+dX, pos.getY()+dY, pos.getZ()+dZ, itemStack.copy());
float factor = 0.05F;
entityItem.motionX = Util.RANDOM.nextGaussian()*factor;
entityItem.motionY = Util.RANDOM.nextGaussian()*factor+0.2F;
entityItem.motionZ = Util.RANDOM.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;
}

View file

@ -99,14 +99,14 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
public void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, BlockPos pos){
ItemStack stack = tile.getStackInSlot(i);
if(stack != null && stack.stackSize > 0){
float dX = Util.RANDOM.nextFloat()*0.8F+0.1F;
float dY = Util.RANDOM.nextFloat()*0.8F+0.1F;
float dZ = Util.RANDOM.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, pos.getX()+dX, pos.getY()+dY, pos.getZ()+dZ, stack.copy());
float factor = 0.05F;
entityItem.motionX = Util.RANDOM.nextGaussian()*factor;
entityItem.motionY = Util.RANDOM.nextGaussian()*factor+0.2F;
entityItem.motionZ = Util.RANDOM.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);
}
}
@ -277,7 +277,7 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
data.removeTag(key);
}
ItemStack stack = new ItemStack(this.getItemDropped(state, Util.RANDOM, fortune), 1, this.damageDropped(state));
ItemStack stack = new ItemStack(this.getItemDropped(state, tile.getWorld().rand, fortune), 1, this.damageDropped(state));
if(!data.hasNoTags()){
stack.setTagCompound(new NBTTagCompound());
stack.getTagCompound().setTag("Data", data);

View file

@ -326,8 +326,8 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
@Override
public void initGui(){
int flavor = 1;
if(Util.RANDOM.nextFloat() <= 0.1){
flavor = MathHelper.getRandomIntegerInRange(Util.RANDOM, 2, 6);
if(this.mc.theWorld.rand.nextFloat() <= 0.1){
flavor = MathHelper.getRandomIntegerInRange(this.mc.theWorld.rand, 2, 6);
}
this.bookletName = "info."+ModUtil.MOD_ID+".booklet.manualName.1."+flavor;

View file

@ -98,7 +98,7 @@ public class EntityWorm extends Entity{
Block plantBlock = plantState.getBlock();
if((plantBlock instanceof IGrowable || plantBlock instanceof IPlantable) && !(plantBlock instanceof BlockGrass)){
plantBlock.updateTick(this.worldObj, plant, plantState, Util.RANDOM);
plantBlock.updateTick(this.worldObj, plant, plantState, this.worldObj.rand);
IBlockState newState = this.worldObj.getBlockState(plant);
if(newState.getBlock().getMetaFromState(newState) != plantBlock.getMetaFromState(plantState)){

View file

@ -85,8 +85,8 @@ public class CommonEvents{
if(event.getEntityLiving().worldObj != null && !event.getEntityLiving().worldObj.isRemote && event.getSource().getEntity() instanceof EntityPlayer){
//Drop Cobwebs from Spiders
if(ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.getEntityLiving() instanceof EntitySpider){
if(Util.RANDOM.nextInt(20) <= event.getLootingLevel()*2){
event.getEntityLiving().entityDropItem(new ItemStack(Blocks.WEB, Util.RANDOM.nextInt(2+event.getLootingLevel())+1), 0);
if(event.getEntityLiving().worldObj.rand.nextInt(20) <= event.getLootingLevel()*2){
event.getEntityLiving().entityDropItem(new ItemStack(Blocks.WEB, event.getEntityLiving().worldObj.rand.nextInt(2+event.getLootingLevel())+1), 0);
}
}
}

View file

@ -69,12 +69,12 @@ public class ItemGrowthRing extends ItemEnergy{
if(!blocks.isEmpty()){
for(int i = 0; i < 45; i++){
if(this.getEnergyStored(stack) >= energyUse){
BlockPos pos = blocks.get(Util.RANDOM.nextInt(blocks.size()));
BlockPos pos = blocks.get(world.rand.nextInt(blocks.size()));
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
int metaBefore = block.getMetaFromState(state);
block.updateTick(world, pos, world.getBlockState(pos), Util.RANDOM);
block.updateTick(world, pos, world.getBlockState(pos), world.rand);
//Show Particles if Metadata changed
IBlockState newState = world.getBlockState(pos);

View file

@ -26,6 +26,7 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.Random;
import java.util.UUID;
public class ItemHairyBall extends ItemBase{
@ -43,7 +44,7 @@ public class ItemHairyBall extends ItemBase{
if(event.getEntityLiving().worldObj != null && !event.getEntityLiving().worldObj.isRemote){
if((event.getEntityLiving() instanceof EntityOcelot && ((EntityOcelot)event.getEntityLiving()).isTamed()) || (event.getEntityLiving() instanceof EntityPlayer && event.getEntityLiving().getUniqueID().equals(/*KittyVanCat*/ UUID.fromString("681d4e20-10ef-40c9-a0a5-ba2f1995ef44")))){
if(ConfigBoolValues.DO_CAT_DROPS.isEnabled()){
if(Util.RANDOM.nextInt(5000)+1 == 1){
if(event.getEntityLiving().worldObj.rand.nextInt(5000)+1 == 1){
EntityItem item = new EntityItem(event.getEntityLiving().worldObj, event.getEntityLiving().posX+0.5, event.getEntityLiving().posY+0.5, event.getEntityLiving().posZ+0.5, new ItemStack(InitItems.itemHairyBall));
event.getEntityLiving().worldObj.spawnEntityInWorld(item);
}
@ -56,7 +57,7 @@ public class ItemHairyBall extends ItemBase{
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){
if(!world.isRemote){
ItemStack returnItem = this.getRandomReturnItem();
ItemStack returnItem = this.getRandomReturnItem(world.rand);
if(!player.inventory.addItemStackToInventory(returnItem)){
EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem);
entityItem.setPickupDelay(0);
@ -64,13 +65,13 @@ public class ItemHairyBall extends ItemBase{
}
stack.stackSize--;
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, Util.RANDOM.nextFloat()*0.1F+0.9F);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, world.rand.nextFloat()*0.1F+0.9F);
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
public ItemStack getRandomReturnItem(){
return WeightedRandom.getRandomItem(Util.RANDOM, ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS).returnItem.copy();
public ItemStack getRandomReturnItem(Random rand){
return WeightedRandom.getRandomItem(rand, ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS).returnItem.copy();
}

View file

@ -133,7 +133,7 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi
for(EntityLivingBase entity : entities){
if(entity.isPotionActive(potion)){
//Sometimes make the effect switch to someone else
if(Util.RANDOM.nextInt(100) <= 0){
if(tile.getWorld().rand.nextInt(100) <= 0){
entity.removePotionEffect(potion);
break;
}

View file

@ -42,8 +42,8 @@ public class ItemSolidifiedExperience extends ItemBase{
if(event.getEntityLiving().worldObj != null && !event.getEntityLiving().worldObj.isRemote && event.getSource().getEntity() instanceof EntityPlayer){
//Drop Solidified XP
if(event.getEntityLiving() instanceof EntityCreature){
if(Util.RANDOM.nextInt(10) <= event.getLootingLevel()*2){
event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemSolidifiedExperience, Util.RANDOM.nextInt(2+event.getLootingLevel())+1), 0);
if(event.getEntityLiving().worldObj.rand.nextInt(10) <= event.getLootingLevel()*2){
event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemSolidifiedExperience, event.getEntityLiving().worldObj.rand.nextInt(2+event.getLootingLevel())+1), 0);
}
}
}

View file

@ -110,8 +110,8 @@ public class ItemWingsOfTheBats extends ItemBase{
if(event.getEntityLiving().worldObj != null && !event.getEntityLiving().worldObj.isRemote && event.getSource().getEntity() instanceof EntityPlayer){
//Drop Wings from Bats
if(ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat){
if(Util.RANDOM.nextInt(15) <= event.getLootingLevel()*2){
event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemMisc, Util.RANDOM.nextInt(2+event.getLootingLevel())+1, TheMiscItems.BAT_WING.ordinal()), 0);
if(event.getEntityLiving().worldObj.rand.nextInt(15) <= event.getLootingLevel()*2){
event.getEntityLiving().entityDropItem(new ItemStack(InitItems.itemMisc, event.getEntityLiving().worldObj.rand.nextInt(2+event.getLootingLevel())+1, TheMiscItems.BAT_WING.ordinal()), 0);
}
}
}

View file

@ -28,9 +28,11 @@ import net.minecraft.util.math.BlockPos;
import java.util.ArrayList;
import java.util.Map;
import java.util.Random;
public class LensColor extends Lens{
private final Random rand = new Random();
public static final int ENERGY_USE = 200;
//Thanks to xdjackiexd for this, as I couldn't be bothered
@ -99,7 +101,7 @@ public class LensColor extends Lens{
@Override
public float[] getColor(){
float[] colors = POSSIBLE_COLORS[Util.RANDOM.nextInt(POSSIBLE_COLORS.length)];
float[] colors = POSSIBLE_COLORS[this.rand.nextInt(POSSIBLE_COLORS.length)];
return new float[]{colors[0]/255F, colors[1]/255F, colors[2]/255F};
}

View file

@ -42,11 +42,11 @@ public class LensDisruption extends Lens{
ItemStack newStack;
do{
if(Util.RANDOM.nextBoolean()){
newStack = new ItemStack(Item.REGISTRY.getRandomObject(Util.RANDOM));
if(tile.getWorldObject().rand.nextBoolean()){
newStack = new ItemStack(Item.REGISTRY.getRandomObject(tile.getWorldObject().rand));
}
else{
newStack = new ItemStack(Block.REGISTRY.getRandomObject(Util.RANDOM));
newStack = new ItemStack(Block.REGISTRY.getRandomObject(tile.getWorldObject().rand));
}
}
while(newStack == null || newStack.getItem() == null);

View file

@ -31,7 +31,7 @@ public class DamageSources extends DamageSource{
@Override
public ITextComponent getDeathMessage(EntityLivingBase entity){
String locTag = "death."+ModUtil.MOD_ID+"."+this.damageType+"."+(Util.RANDOM.nextInt(this.messageCount)+1);
String locTag = "death."+ModUtil.MOD_ID+"."+this.damageType+"."+(entity.worldObj.rand.nextInt(this.messageCount)+1);
return new TextComponentTranslation(locTag, entity.getName());
}
}

View file

@ -90,7 +90,7 @@ public class TileEntityBreaker extends TileEntityInventoryBase{
List<ItemStack> drops = blockToBreak.getDrops(this.worldObj, coordsBlock, stateToBreak, 0);
float chance = ForgeEventFactory.fireBlockHarvesting(drops, this.worldObj, coordsBlock, this.worldObj.getBlockState(coordsBlock), 0, 1, false, null);
if(Util.RANDOM.nextFloat() <= chance){
if(this.worldObj.rand.nextFloat() <= chance){
if(WorldUtil.addToInventory(this, drops, false, true)){
if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){
this.worldObj.playEvent(2001, coordsBlock, Block.getStateId(stateToBreak));

View file

@ -90,7 +90,7 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem
List<ItemStack> drops = blockToBreak.getDrops(this.worldObj, coordsBlock, this.worldObj.getBlockState(coordsBlock), 0);
float chance = ForgeEventFactory.fireBlockHarvesting(drops, this.worldObj, coordsBlock, this.worldObj.getBlockState(coordsBlock), 0, 1, false, null);
if(Util.RANDOM.nextFloat() <= chance){
if(this.worldObj.rand.nextFloat() <= chance){
if(WorldUtil.addToInventory(this, drops, false, true)){
if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){
this.worldObj.playEvent(2001, coordsBlock, Block.getStateId(this.worldObj.getBlockState(coordsBlock)));

View file

@ -75,7 +75,7 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
if(this.currentTimer >= TIME){
this.currentTimer = 0;
if(this.slots[0] != null){
EntityAnimal randomAnimal = animals.get(Util.RANDOM.nextInt(this.currentAnimalAmount));
EntityAnimal randomAnimal = animals.get(this.worldObj.rand.nextInt(this.currentAnimalAmount));
if(!randomAnimal.isInLove() && randomAnimal.getGrowingAge() == 0 && (randomAnimal.isBreedingItem(this.slots[0]) || this.canHorseBeFed(randomAnimal))){
this.feedAnimal(randomAnimal);
@ -130,10 +130,10 @@ public class TileEntityFeeder extends TileEntityInventoryBase{
public void feedAnimal(EntityAnimal animal){
animal.setInLove(null);
for(int i = 0; i < 7; i++){
double d = Util.RANDOM.nextGaussian()*0.02D;
double d1 = Util.RANDOM.nextGaussian()*0.02D;
double d2 = Util.RANDOM.nextGaussian()*0.02D;
this.worldObj.spawnParticle(EnumParticleTypes.HEART, (animal.posX+(double)(Util.RANDOM.nextFloat()*animal.width*2.0F))-animal.width, animal.posY+0.5D+(double)(Util.RANDOM.nextFloat()*animal.height), (animal.posZ+(double)(Util.RANDOM.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;
this.worldObj.spawnParticle(EnumParticleTypes.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);
}
}

View file

@ -33,29 +33,29 @@ public class TileEntityFireworkBox extends TileEntityBase implements ICustomEner
super("fireworkBox");
}
public static void spawnFireworks(World world, double x, double y, double z){
public void spawnFireworks(World world, double x, double y, double z){
int range = 4;
int amount = Util.RANDOM.nextInt(5)+1;
int amount = world.rand.nextInt(5)+1;
for(int i = 0; i < amount; i++){
ItemStack firework = makeFirework();
ItemStack firework = this.makeFirework();
double newX = x+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
double newZ = z+MathHelper.getRandomDoubleInRange(Util.RANDOM, 0, range*2)-range;
double newX = x+MathHelper.getRandomDoubleInRange(this.worldObj.rand, 0, range*2)-range;
double newZ = z+MathHelper.getRandomDoubleInRange(this.worldObj.rand, 0, range*2)-range;
EntityFireworkRocket rocket = new EntityFireworkRocket(world, newX, y+0.5, newZ, firework);
world.spawnEntityInWorld(rocket);
}
}
private static ItemStack makeFirework(){
private ItemStack makeFirework(){
NBTTagList list = new NBTTagList();
int chargesAmount = Util.RANDOM.nextInt(2)+1;
int chargesAmount = this.worldObj.rand.nextInt(2)+1;
for(int i = 0; i < chargesAmount; i++){
list.appendTag(makeFireworkCharge());
list.appendTag(this.makeFireworkCharge());
}
NBTTagCompound compound1 = new NBTTagCompound();
compound1.setTag("Explosions", list);
compound1.setByte("Flight", (byte)(Util.RANDOM.nextInt(3)+1));
compound1.setByte("Flight", (byte)(this.worldObj.rand.nextInt(3)+1));
NBTTagCompound compound = new NBTTagCompound();
compound.setTag("Fireworks", compound1);
@ -66,11 +66,11 @@ public class TileEntityFireworkBox extends TileEntityBase implements ICustomEner
return firework;
}
private static NBTTagCompound makeFireworkCharge(){
private NBTTagCompound makeFireworkCharge(){
NBTTagCompound compound = new NBTTagCompound();
if(Util.RANDOM.nextFloat() >= 0.65F){
if(Util.RANDOM.nextFloat() >= 0.5F){
if(this.worldObj.rand.nextFloat() >= 0.65F){
if(this.worldObj.rand.nextFloat() >= 0.5F){
compound.setBoolean("Flicker", true);
}
else{
@ -78,13 +78,13 @@ public class TileEntityFireworkBox extends TileEntityBase implements ICustomEner
}
}
int[] colors = new int[MathHelper.getRandomIntegerInRange(Util.RANDOM, 1, 6)];
int[] colors = new int[MathHelper.getRandomIntegerInRange(this.worldObj.rand, 1, 6)];
for(int i = 0; i < colors.length; i++){
colors[i] = ItemDye.DYE_COLORS[Util.RANDOM.nextInt(ItemDye.DYE_COLORS.length)];
colors[i] = ItemDye.DYE_COLORS[this.worldObj.rand.nextInt(ItemDye.DYE_COLORS.length)];
}
compound.setIntArray("Colors", colors);
compound.setByte("Type", (byte)Util.RANDOM.nextInt(5));
compound.setByte("Type", (byte)this.worldObj.rand.nextInt(5));
return compound;
}
@ -126,7 +126,7 @@ public class TileEntityFireworkBox extends TileEntityBase implements ICustomEner
private void doWork(){
if(this.storage.getEnergyStored() >= USE_PER_SHOT){
spawnFireworks(this.worldObj, this.pos.getX(), this.pos.getY(), this.pos.getZ());
this.spawnFireworks(this.worldObj, this.pos.getX(), this.pos.getY(), this.pos.getZ());
this.storage.extractEnergy(USE_PER_SHOT, false);
}

View file

@ -59,7 +59,7 @@ public class TileEntityFishingNet extends TileEntityBase{
this.timeUntilNextDrop--;
if(this.timeUntilNextDrop <= 0){
LootContext.Builder builder = new LootContext.Builder((WorldServer)this.worldObj);
List<ItemStack> fishables = this.worldObj.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(Util.RANDOM, builder.build());
List<ItemStack> fishables = this.worldObj.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(this.worldObj.rand, builder.build());
for(ItemStack fishable : fishables){
ItemStack leftover = this.storeInContainer(fishable);
if(leftover != null){
@ -72,7 +72,7 @@ public class TileEntityFishingNet extends TileEntityBase{
}
else{
int time = 15000;
this.timeUntilNextDrop = time+Util.RANDOM.nextInt(time/2);
this.timeUntilNextDrop = time+this.worldObj.rand.nextInt(time/2);
}
}
}

View file

@ -56,7 +56,7 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
IBlockState state = this.worldObj.getBlockState(blockToFert);
Block block = state.getBlock();
int metaBefore = block.getMetaFromState(state);
block.updateTick(this.worldObj, blockToFert, this.worldObj.getBlockState(blockToFert), Util.RANDOM);
block.updateTick(this.worldObj, blockToFert, this.worldObj.getBlockState(blockToFert), this.worldObj.rand);
IBlockState newState = this.worldObj.getBlockState(blockToFert);
if(newState.getBlock().getMetaFromState(newState) != metaBefore){
@ -67,7 +67,7 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{
}
else{
int time = 100;
this.timeUntilNextFert = time+Util.RANDOM.nextInt(time);
this.timeUntilNextFert = time+this.worldObj.rand.nextInt(time);
}
}
}

View file

@ -226,7 +226,7 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements ICusto
if(outputTwo.getItemDamage() == Util.WILDCARD){
outputTwo.setItemDamage(0);
}
int rand = Util.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();

View file

@ -64,8 +64,8 @@ public class TileEntityHeatCollector extends TileEntityBase implements ISharingE
this.storage.receiveEnergy(ENERGY_PRODUCE, false);
this.markDirty();
if(Util.RANDOM.nextInt(10000) == 0){
int randomSide = blocksAround.get(Util.RANDOM.nextInt(blocksAround.size()));
if(this.worldObj.rand.nextInt(10000) == 0){
int randomSide = blocksAround.get(this.worldObj.rand.nextInt(blocksAround.size()));
this.worldObj.setBlockToAir(this.pos.offset(WorldUtil.getDirectionBySidesInOrder(randomSide)));
}
}

View file

@ -96,7 +96,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
@SideOnly(Side.CLIENT)
public void renderParticles(){
if(Util.RANDOM.nextInt(ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 16 : 8) == 0){
if(this.worldObj.rand.nextInt(ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 16 : 8) == 0){
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(player != null){
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
@ -108,7 +108,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
if(network != null){
for(IConnectionPair aPair : network.connections){
if(!aPair.doesSuppressRender() && aPair.contains(this.pos) && this.pos.equals(aPair.getPositions()[0])){
AssetUtil.renderParticlesFromAToB(aPair.getPositions()[0].getX(), aPair.getPositions()[0].getY(), aPair.getPositions()[0].getZ(), aPair.getPositions()[1].getX(), aPair.getPositions()[1].getY(), aPair.getPositions()[1].getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, this.type == LaserType.ITEM ? COLOR_ITEM : (this.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR), 1F);
AssetUtil.renderParticlesFromAToB(aPair.getPositions()[0].getX(), aPair.getPositions()[0].getY(), aPair.getPositions()[0].getZ(), aPair.getPositions()[1].getX(), aPair.getPositions()[1].getY(), aPair.getPositions()[1].getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : this.worldObj.rand.nextInt(3)+1, 0.8F, this.type == LaserType.ITEM ? COLOR_ITEM : (this.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR), 1F);
}
}
}

View file

@ -107,7 +107,7 @@ public class TileEntityMiner extends TileEntityInventoryBase implements ICustomE
List<ItemStack> drops = block.getDrops(this.worldObj, pos, this.worldObj.getBlockState(pos), 0);
float chance = ForgeEventFactory.fireBlockHarvesting(drops, this.worldObj, pos, this.worldObj.getBlockState(pos), 0, 1, false, null);
if(Util.RANDOM.nextFloat() <= chance){
if(this.worldObj.rand.nextFloat() <= chance){
if(WorldUtil.addToInventory(this, drops, false, true)){
if(!ConfigBoolValues.LESS_BLOCK_BREAKING_EFFECTS.isEnabled()){
this.worldObj.playEvent(2001, pos, Block.getStateId(this.worldObj.getBlockState(pos)));

View file

@ -161,15 +161,15 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
@SideOnly(Side.CLIENT)
public void renderParticles(){
if(Util.RANDOM.nextInt(2) == 0){
double d1 = (double)((float)this.boundPosition.getY()+Util.RANDOM.nextFloat());
int i1 = Util.RANDOM.nextInt(2)*2-1;
int j1 = Util.RANDOM.nextInt(2)*2-1;
double d4 = ((double)Util.RANDOM.nextFloat()-0.5D)*0.125D;
if(this.worldObj.rand.nextInt(2) == 0){
double d1 = (double)((float)this.boundPosition.getY()+this.worldObj.rand.nextFloat());
int i1 = this.worldObj.rand.nextInt(2)*2-1;
int j1 = this.worldObj.rand.nextInt(2)*2-1;
double d4 = ((double)this.worldObj.rand.nextFloat()-0.5D)*0.125D;
double d2 = (double)this.boundPosition.getZ()+0.5D+0.25D*(double)j1;
double d5 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)j1);
double d5 = (double)(this.worldObj.rand.nextFloat()*1.0F*(float)j1);
double d0 = (double)this.boundPosition.getX()+0.5D+0.25D*(double)i1;
double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1);
double d3 = (double)(this.worldObj.rand.nextFloat()*1.0F*(float)i1);
this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5);
}

View file

@ -141,15 +141,15 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
@SideOnly(Side.CLIENT)
public void renderParticles(){
if(Util.RANDOM.nextInt(2) == 0){
double d1 = (double)((float)this.boundPosition.getY()+Util.RANDOM.nextFloat());
int i1 = Util.RANDOM.nextInt(2)*2-1;
int j1 = Util.RANDOM.nextInt(2)*2-1;
double d4 = ((double)Util.RANDOM.nextFloat()-0.5D)*0.125D;
if(this.worldObj.rand.nextInt(2) == 0){
double d1 = (double)((float)this.boundPosition.getY()+this.worldObj.rand.nextFloat());
int i1 = this.worldObj.rand.nextInt(2)*2-1;
int j1 = this.worldObj.rand.nextInt(2)*2-1;
double d4 = ((double)this.worldObj.rand.nextFloat()-0.5D)*0.125D;
double d2 = (double)this.boundPosition.getZ()+0.5D+0.25D*(double)j1;
double d5 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)j1);
double d5 = (double)(this.worldObj.rand.nextFloat()*1.0F*(float)j1);
double d0 = (double)this.boundPosition.getX()+0.5D+0.25D*(double)i1;
double d3 = (double)(Util.RANDOM.nextFloat()*1.0F*(float)i1);
double d3 = (double)(this.worldObj.rand.nextFloat()*1.0F*(float)i1);
this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, d0, d1, d2, d3, d4, d5);
}

View file

@ -17,11 +17,9 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.oredict.OreDictionary;
import java.util.Locale;
import java.util.Random;
public final class Util{
public static final Random RANDOM = new Random();
public static final int WILDCARD = OreDictionary.WILDCARD_VALUE;
public static final int BUCKET = Fluid.BUCKET_VOLUME;