net.minecraft.util.WeightedRandomChestContent Java Examples

The following examples show how to use net.minecraft.util.WeightedRandomChestContent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BeetrootSeeds.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
public BeetrootSeeds() {
	super(ModBlocks.beetroot, Blocks.farmland);
	setTextureName("beetroot_seeds");
	setUnlocalizedName(Utils.getUnlocalisedName("beetroot_seeds"));
	setCreativeTab(EtFuturum.enableBeetroot ? EtFuturum.creativeTab : null);

	if (EtFuturum.enableBeetroot) {
		ChestGenHooks.addItem(ChestGenHooks.MINESHAFT_CORRIDOR, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.PYRAMID_DESERT_CHEST, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.PYRAMID_JUNGLE_CHEST, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CORRIDOR, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_LIBRARY, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.STRONGHOLD_CROSSING, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
		ChestGenHooks.addItem(ChestGenHooks.DUNGEON_CHEST, new WeightedRandomChestContent(new ItemStack(this), 1, 2, 5));
	}
}
 
Example #2
Source File: ChestLootDumper.java    From NEI-Integration with MIT License 6 votes vote down vote up
@Override
public Iterable<String[]> dump(int mode) {
    List<String[]> list = new LinkedList<String[]>();
    
    Map<String, ChestGenHooks> lootTables = ReflectionHelper.getPrivateValue(ChestGenHooks.class, null, "chestInfo");
    List<String> names = new ArrayList<String>();
    names.addAll(lootTables.keySet());
    Collections.sort(names);
    
    for (String name : names) {
        List<WeightedRandomChestContent> contents = ReflectionHelper.getPrivateValue(ChestGenHooks.class, lootTables.get(name), "contents");
        
        for (WeightedRandomChestContent w : contents) {
            String displayName;
            try {
                displayName = w.theItemId.getDisplayName();
            } catch (Exception ex) {
                displayName = "-";
            }
            list.add(new String[] { name, w.theItemId.toString(), displayName, Item.itemRegistry.getNameForObject(w.theItemId.getItem()), String.valueOf(w.itemWeight) });
        }
    }
    
    return list;
}
 
Example #3
Source File: GardenContainers.java    From GardenCollection with MIT License 5 votes vote down vote up
@Mod.EventHandler
public void init (FMLInitializationEvent event) {
    proxy.registerRenderers();
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());

    for (int j = 0; j < config.getPatternLocationCount(); j++)
        ChestGenHooks.addItem(config.getPatternLocation(j), new WeightedRandomChestContent(items.potteryPatternDirty, 0, 1, 1, config.getPatternLocationRarity(j)));

    VillagerTradeHandler.instance().load();
}
 
Example #4
Source File: DungeonChestGenerator.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
public static void generateLoot() {
    if (!ConfigHandler.thorHammerResearch) {
        ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(IC2ItemRegistry.taintedThorHammer), 0, 1, ConfigHandler.chanceTaintedMjolnir));
    }
    if (!ConfigHandler.oneRingSpawn) {
        ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(IC2ItemRegistry.emtBauble, 1, 2), 0, 1, ConfigHandler.chanceOneRing));
    }
}
 
Example #5
Source File: PneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void load(FMLInitializationEvent event){
    NetworkHandler.init();

    if(Config.enableDungeonLoot) {
        ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.stopWorm), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.stopWorm), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.stopWorm), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_DESERT_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.stopWorm), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.stopWorm), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_LIBRARY).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.stopWorm), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CORRIDOR).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.stopWorm), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CROSSING).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.stopWorm), 1, 4, 10));

        ChestGenHooks.getInfo(ChestGenHooks.VILLAGE_BLACKSMITH).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.nukeVirus), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.nukeVirus), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.nukeVirus), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_DESERT_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.nukeVirus), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.nukeVirus), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_LIBRARY).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.nukeVirus), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CORRIDOR).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.nukeVirus), 1, 4, 10));
        ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CROSSING).addItem(new WeightedRandomChestContent(new ItemStack(Itemss.nukeVirus), 1, 4, 10));
    }

    proxy.init();
    ThirdPartyManager.instance().init();
}
 
Example #6
Source File: StructureMasterTower.java    From Artifacts with MIT License 4 votes vote down vote up
private static void basement(World world, int i, int j, int k, Random rand) {
	boolean noair = false;
	int y = -1;
	do {
		noair = false;
		for(int x = 1; x <= 12; x++) {
			for(int z = 0; z <= 12; z++) {
				//5,y,4
				int d = (x-6)*(x-6)+(z-7)*(z-7);
				if(d <= 26) {
					if(!world.getBlock(i+x, j+y, z+k).isOpaqueCube() || world.getBlock(i+x, j+y, z+k) == Blocks.leaves) {
						noair=true;
						world.setBlock(i+x, j+y, z+k, Blocks.stonebrick, StructureGenHelper.stoneBrickMeta(rand), 2);
					}
				}
			}
		}
		y--;
	} while(noair && (j+y) >= 0);
	if(y >= -7 && world.rand.nextInt(4) != 0) {
		y = -8;
	}
	if(y < -7) {
		y++;
		int yy = 3;
		for(; yy <= 5; yy++) {
			for(int x = 3; x <= 8; x++) {
				for(int z = 4; z <= 8; z++) {
					world.setBlockToAir(i+x, j+y+yy, k+z);
				}
			}
		}
		world.setBlock(i+5, j+y+5, k+6, Blocks.mob_spawner, 0, 2);
		TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getTileEntity(i+5, j+y+5, k+6);

		if (tileentitymobspawner != null)
           {
               tileentitymobspawner.func_145881_a/*getSpawnerLogic*/().setEntityName("ClayGolem");
               NBTTagCompound nbt = new NBTTagCompound();
               tileentitymobspawner.writeToNBT(nbt);
               nbt.setShort("MinSpawnDelay",(short)100);
               nbt.setShort("MaxSpawnDelay",(short)600);
               tileentitymobspawner.readFromNBT(nbt);
           }
		world.setBlock(i+5, j+y+4, k+6, StructureGenHelper.randomBlock(rand, new Block[]{Blocks.chest, Blocks.chest, Blocks.chest, Blocks.chest, Blocks.air}), 2, 2);
   		TileEntity te = world.getTileEntity(i+5, j+y+4, k+6);
   		if(te != null && te instanceof TileEntityChest) {
   			TileEntityChest tec = (TileEntityChest)te;
   			ChestGenHooks info = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST);
               WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), tec, info.getCount(rand));
   		}
   		
   		world.setBlock(i+5, j+y+3, k+6, Blocks.stonebrick, StructureGenHelper.stoneBrickMeta(rand), 2);
		for(yy=3;yy*-1>y-3;yy++) {
			world.setBlock(i+9, j+y+yy, k+6, Blocks.ladder, 2, 2);
		}
		//world.setBlock(i+9, j+y+yy-1, k+6, Blocks.ladder, 2, 2);
		world.setBlock(i+9, j+y+yy, k+6, Blocks.trapdoor, 1, 2);
	}
}
 
Example #7
Source File: StructureJourneymanTower.java    From Artifacts with MIT License 4 votes vote down vote up
private static void basement(World world, int i, int j, int k, Random rand) {
	boolean noair = false;
	int y = -1;
	do {
		noair = false;
		for(int x = 1; x <= 9; x++) {
			for(int z = 0; z <= 8; z++) {
				//5,y,4
				int d = (x-5)*(x-5)+(z-4)*(z-4);
				if(d <= 17) {
					if(!world.getBlock(i+x, j+y, z+k).isOpaqueCube() || world.getBlock(i+x, j+y, z+k) == Blocks.leaves) {
						noair=true;
						world.setBlock(i+x, j+y, z+k, StructureGenHelper.cobbleOrMossy(rand), 0, 2);
					}
				}
			}
		}
		y--;
	} while(noair && (j+y) >= 0);
	if(y >= -7 && world.rand.nextBoolean()) {
		y = -8;
	}
	if(y < -7) {
		y++;
		int yy = 3;
		for(; yy <= 5; yy++) {
			for(int x = 3; x <= 7; x++) {
				for(int z = 2; z <= 6; z++) {
					world.setBlockToAir(i+x, j+y+yy, k+z);
				}
			}
		}
		world.setBlock(i+5, j+y+5, k+4, Blocks.mob_spawner, 0, 2);
		TileEntityMobSpawner tileentitymobspawner = (TileEntityMobSpawner)world.getTileEntity(i+5, j+y+5, k+4);

           if (tileentitymobspawner != null)
           {
               tileentitymobspawner.func_145881_a/*getSpawnerLogic*/().setEntityName("ClayGolem");
               NBTTagCompound nbt = new NBTTagCompound();
               tileentitymobspawner.writeToNBT(nbt);
               nbt.setShort("MinSpawnDelay",(short)100);
               nbt.setShort("MaxSpawnDelay",(short)600);
               tileentitymobspawner.readFromNBT(nbt);
           }
           
           world.setBlock(i+5, j+y+4, k+4, StructureGenHelper.randomBlock(rand, new Block[]{Blocks.chest, Blocks.chest, Blocks.air}), 2, 2);
   		TileEntity te = world.getTileEntity(i+5, j+y+4, k+4);
   		if(te != null && te instanceof TileEntityChest) {
   			TileEntityChest tec = (TileEntityChest)te;
   			ChestGenHooks info = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST);
               WeightedRandomChestContent.generateChestContents(rand, info.getItems(rand), tec, info.getCount(rand));
   		}
   		
   		world.setBlock(i+5, j+y+3, k+4, StructureGenHelper.cobbleOrMossy(rand), 0, 2);
           
		for(yy=3;yy*-1>y;yy++) {
			world.setBlock(i+7, j+y+yy, k+6, Blocks.ladder, 2, 2);
		}
		world.setBlock(i+7, j+y+yy, k+6, Blocks.ladder, 2, 2);
		world.setBlock(i+7, j+y+yy+1, k+6, Blocks.trapdoor, 2, 2);
	}
}