Added config option for chests content
This commit is contained in:
parent
a1026d7384
commit
a3f0914be3
2 changed files with 52 additions and 48 deletions
|
|
@ -1,66 +1,34 @@
|
|||
package mysticruins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class ChestFiller {
|
||||
public static List<ItemStack> rares = new ArrayList();
|
||||
public static List<ItemStack> valuables = new ArrayList();
|
||||
|
||||
public static void fillWithRares(TileEntity tile) {
|
||||
if (tile instanceof IInventory) {
|
||||
IInventory chest = (IInventory) tile;
|
||||
Random rand = new Random();
|
||||
int num;
|
||||
for (int slot = 0; slot < chest.getSizeInventory(); slot++) {
|
||||
num = rand.nextInt(16);
|
||||
if (num == 1) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.enderPearl, 4, 0));
|
||||
}
|
||||
if (num == 2) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.diamond, 1, 0));
|
||||
}
|
||||
if (num == 3) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.emerald, 1, 0));
|
||||
}
|
||||
if (num == 4) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.appleGold, 1, 0));
|
||||
}
|
||||
if (num == 5) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.ingotGold, 1, 0));
|
||||
}
|
||||
if (num == 6) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.ingotIron, 1, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
fill(tile, rares, 2.5D);
|
||||
}
|
||||
|
||||
public static void fillWithValuables(TileEntity tile) {
|
||||
fill(tile, valuables, 5D);
|
||||
}
|
||||
|
||||
private static void fill(TileEntity tile, List<ItemStack> stacks, double factor) {
|
||||
if (tile instanceof IInventory) {
|
||||
IInventory chest = (IInventory) tile;
|
||||
Random rand = new Random();
|
||||
int num;
|
||||
for (int slot = 0; slot < chest.getSizeInventory(); slot++) {
|
||||
num = rand.nextInt(32);
|
||||
if (num == 1) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.pickaxeIron, 1, 0));
|
||||
}
|
||||
if (num == 2) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.axeIron, 1, 0));
|
||||
}
|
||||
if (num == 3) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.swordIron, 1, 0));
|
||||
}
|
||||
if (num == 4) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.shovelIron, 1, 0));
|
||||
}
|
||||
if (num == 5) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.ingotGold, 1, 0));
|
||||
}
|
||||
if (num == 6) {
|
||||
chest.setInventorySlotContents(slot, new ItemStack(Item.ingotIron, 1, 0));
|
||||
num = rand.nextInt((int) (stacks.size() * factor));
|
||||
if (num < stacks.size()) {
|
||||
chest.setInventorySlotContents(slot, stacks.get(num));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue