2014-01-13 05:55:42 +01:00
|
|
|
package mekanism.api;
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
import mekanism.common.util.StackUtils;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
|
|
|
public class ChanceOutput
|
|
|
|
{
|
|
|
|
private static Random rand = new Random();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-13 05:55:42 +01:00
|
|
|
public ItemStack primaryOutput;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-13 05:55:42 +01:00
|
|
|
public ItemStack secondaryOutput;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-13 05:55:42 +01:00
|
|
|
public double secondaryChance;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-13 05:55:42 +01:00
|
|
|
public ChanceOutput(ItemStack primary, ItemStack secondary, double chance)
|
|
|
|
{
|
|
|
|
primaryOutput = primary;
|
|
|
|
secondaryOutput = secondary;
|
|
|
|
secondaryChance = chance;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-13 05:55:42 +01:00
|
|
|
public ChanceOutput(ItemStack primary)
|
|
|
|
{
|
|
|
|
primaryOutput = primary;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-13 05:55:42 +01:00
|
|
|
public boolean checkSecondary()
|
|
|
|
{
|
2014-01-14 04:27:47 +01:00
|
|
|
return rand.nextDouble() <= secondaryChance;
|
2014-01-13 05:55:42 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-13 05:55:42 +01:00
|
|
|
public boolean hasPrimary()
|
|
|
|
{
|
|
|
|
return primaryOutput != null;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-13 05:55:42 +01:00
|
|
|
public boolean hasSecondary()
|
|
|
|
{
|
|
|
|
return secondaryOutput != null;
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-13 05:55:42 +01:00
|
|
|
public ChanceOutput copy()
|
|
|
|
{
|
|
|
|
return new ChanceOutput(StackUtils.copy(primaryOutput), StackUtils.copy(secondaryOutput), secondaryChance);
|
|
|
|
}
|
|
|
|
}
|