类net.minecraft.util.WeightedRandomChestContent源码实例Demo

下面列出了怎么用net.minecraft.util.WeightedRandomChestContent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Et-Futurum   文件: BeetrootSeeds.java
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));
	}
}
 
源代码2 项目: NEI-Integration   文件: ChestLootDumper.java
@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;
}
 
源代码3 项目: GardenCollection   文件: GardenContainers.java
@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();
}
 
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));
    }
}
 
源代码5 项目: PneumaticCraft   文件: PneumaticCraft.java
@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();
}
 
源代码6 项目: Artifacts   文件: StructureMasterTower.java
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);
	}
}
 
源代码7 项目: Artifacts   文件: StructureJourneymanTower.java
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);
	}
}
 
 类所在包
 同包方法