Java源码示例:net.minecraftforge.common.ChestGenHooks

示例1
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
@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
private String mapGenLocation (String location) {
    if (location.equals("mineshaftCorridor"))
        return ChestGenHooks.MINESHAFT_CORRIDOR;
    if (location.equals("pyramidDesertChest"))
        return ChestGenHooks.PYRAMID_DESERT_CHEST;
    if (location.equals("pyramidJungleChest"))
        return ChestGenHooks.PYRAMID_JUNGLE_CHEST;
    if (location.equals("strongholdCorridor"))
        return ChestGenHooks.STRONGHOLD_CORRIDOR;
    if (location.equals("strongholdLibrary"))
        return ChestGenHooks.STRONGHOLD_LIBRARY;
    if (location.equals("strongholdCrossing"))
        return ChestGenHooks.STRONGHOLD_CROSSING;
    if (location.equals("villageBlacksmith"))
        return ChestGenHooks.VILLAGE_BLACKSMITH;
    if (location.equals("dungeonChest"))
        return ChestGenHooks.DUNGEON_CHEST;

    return null;
}
 
示例4
@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();
}
 
示例5
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));
    }
}
 
示例6
@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();
}
 
示例7
@Override
protected ItemStack[] generateChestContent(Random random, IInventory newInventory)
   {
       ItemStack[] a = ChestGenHooks.generateStacks(random, theItemId, theMinimumChanceToGenerateItem, theMaximumChanceToGenerateItem);
       for(int i=a.length-1; i>=0; --i) {
       	a[i] = ArtifactsAPI.artifacts.applyRandomEffects(a[i]);
       }
       return a;
   }
 
示例8
@Override
public void setTreasureGeneration(String treasureString, ArtifactType type, int rarity) {
	//if(type == ArtifactType.TOOL)
	//	ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifact.instance.itemID, 0, 1, 1, rarity));
	switch(type) {
		case TOOL:
			ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifact.instance, 0, 1, 1, rarity));
			break;
		case ARMOR_CLOTH:
			ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.hcloth, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.ccloth, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.lcloth, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.bcloth, 0, 1, 1, rarity));
	        break;
		case ARMOR_CHAIN:
			ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.hchain, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.cchain, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.lchain, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.bchain, 0, 1, 1, rarity));
	        break;
		case ARMOR_IRON:
			ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.hiron, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.ciron, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.liron, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.biron, 0, 1, 1, rarity));
	        break;
		case ARMOR_GOLD:
			ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.hgold, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.cgold, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.lgold, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.bgold, 0, 1, 1, rarity));
	        break;
		case ARMOR_DIAMOND:
			ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.hdiamond, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.cdiamond, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.ldiamond, 0, 1, 1, rarity));
	        ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifactArmor.bdiamond, 0, 1, 1, rarity));
	        break;
	}
}
 
示例9
public static Map<String, ChestGenHooks> getChestLoot() {
	return getPrivateStaticObject(ChestGenHooks.class, "chestInfo");
}
 
示例10
public static Map<String, ChestGenHooks> getChestLoot() {
	return getPrivateStaticObject(ChestGenHooks.class, "chestInfo");
}
 
示例11
@Override
public void setTreasureGeneration(String treasureString, int rarity) {
	ChestGenHooks.getInfo(treasureString).addItem(new WeightedRandomArtifact(ItemArtifact.instance, 0, 1, 1, rarity));
}
 
示例12
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);
	}
}
 
示例13
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);
	}
}