net.minecraft.world.storage.loot.LootTableList Java Examples

The following examples show how to use net.minecraft.world.storage.loot.LootTableList. 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: MetaTileEntityFisher.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void update() {
    super.update();
    ItemStack baitStack = importItems.getStackInSlot(0);
    if (!getWorld().isRemote && energyContainer.getEnergyStored() >= energyAmountPerFish && getTimer() % fishingTicks == 0L && !baitStack.isEmpty()) {
        WorldServer world = (WorldServer) this.getWorld();
        int waterCount = 0;
        int edgeSize = (int) Math.sqrt(WATER_CHECK_SIZE);
        for (int x = 0; x < edgeSize; x++){
            for (int z = 0; z < edgeSize; z++){
                BlockPos waterCheckPos = getPos().down().add(x - edgeSize / 2, 0, z - edgeSize / 2);
                if (world.getBlockState(waterCheckPos).getBlock() instanceof BlockLiquid &&
                    world.getBlockState(waterCheckPos).getMaterial() == Material.WATER) {
                    waterCount++;
                }
            }
        }
        if (waterCount == WATER_CHECK_SIZE) {
            LootTable table = world.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING);
            NonNullList<ItemStack> itemStacks = NonNullList.create();
            itemStacks.addAll(table.generateLootForPools(world.rand, new LootContext.Builder(world).build()));
            if(addItemsToItemHandler(exportItems, true, itemStacks)) {
                addItemsToItemHandler(exportItems, false, itemStacks);
                energyContainer.removeEnergy(energyAmountPerFish);
                baitStack.shrink(1);
            }
        }
    }
    if(!getWorld().isRemote && getTimer() % 5 == 0) {
        pushItemsIntoNearbyHandlers(getFrontFacing());
    }
}
 
Example #2
Source File: MageTowerGenerator.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void addLootToChest(World world, IBlockState block, BlockPos placementPos) {
	if (block.getBlock() == Blocks.CHEST) {
		TileEntity tileentity = world.getTileEntity(placementPos);

		if (tileentity instanceof TileEntityChest) {
			((TileEntityChest) tileentity).setLootTable(LootTableList.CHESTS_END_CITY_TREASURE, world.rand.nextLong());
		}
	}
}
 
Example #3
Source File: MonolithGenerator.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void placeChest(World world, BlockPos placementPos) {
	setBlockAndNotifyAdequately(world, placementPos, Blocks.CHEST.getDefaultState());
	TileEntity tileentity = world.getTileEntity(placementPos);
	if (tileentity instanceof TileEntityChest) {
		((TileEntityChest) tileentity).setLootTable(LootTableList.CHESTS_END_CITY_TREASURE, world.rand.nextLong());
	}
}
 
Example #4
Source File: BastionsLairGenerator.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void addLootToChest() {
	if (block == null) {
		return;
	}
	if (block.getBlock() == Blocks.CHEST) {
		TileEntity tileentity = world.getTileEntity(origin.add(x, y, z));
		if (tileentity instanceof TileEntityChest) {
			((TileEntityChest) tileentity).setLootTable(LootTableList.CHESTS_END_CITY_TREASURE, world.rand.nextLong());
		}
	}
}
 
Example #5
Source File: BackpacksContent.java    From WearableBackpacks with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onRegisterItems(RegistryEvent.Register<Item> event) {
	if (BACKPACK != null) {
		event.getRegistry().register(
			BACKPACK.setRegistryName(WearableBackpacks.MOD_ID, "backpack"));
		
		BackpackRegistry.registerEntity("minecraft:zombie",        RenderOptions.DEFAULT);
		BackpackRegistry.registerEntity("minecraft:skeleton",      RenderOptions.DEFAULT);
		BackpackRegistry.registerEntity("minecraft:zombie_pigman", RenderOptions.DEFAULT);
		
		String backpack  = BACKPACK.getRegistryName().toString();
		String idDefault = WearableBackpacks.MOD_ID + ":default";
		String idColored = WearableBackpacks.MOD_ID + ":colored";
		String lootTable = ItemBackpack.LOOT_TABLE.toString();
		
		BackpackRegistry.registerBackpack("minecraft:zombie",        idDefault, backpack,   800, lootTable, null);
		BackpackRegistry.registerBackpack("minecraft:zombie",        idColored, backpack,  8000, lootTable, ColorRange.DEFAULT);
		BackpackRegistry.registerBackpack("minecraft:skeleton",      idDefault, backpack,  1200, lootTable, null);
		BackpackRegistry.registerBackpack("minecraft:skeleton",      idColored, backpack, 12000, lootTable, ColorRange.DEFAULT);
		BackpackRegistry.registerBackpack("minecraft:zombie_pigman", idColored, backpack,  1000, lootTable, ColorRange.DEFAULT);
		
		// TODO: Register all loot tables mentioned in config file?
		LootTableList.register(ItemBackpack.LOOT_TABLE);
	}
	
	// BackpackRegistry.registerBackpackEntity(EntityEnderman.class, ENDER_BACKPACK, 1.0 / 80);
}
 
Example #6
Source File: EntityTofuSlime.java    From TofuCraftReload with MIT License 4 votes vote down vote up
@Nullable
@Override
protected ResourceLocation getLootTable()
{
    return this.getSlimeSize() == 1 ? TofuLootTables.tofuslime : LootTableList.EMPTY;
}
 
Example #7
Source File: EntitySamuraiIllager.java    From Sakura_mod with MIT License 4 votes vote down vote up
protected ResourceLocation getLootTable() {
    return LootTableList.ENTITIES_VINDICATION_ILLAGER;
}
 
Example #8
Source File: EntityExplodingChicken.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Nullable
protected ResourceLocation getLootTable()
{
    return LootTableList.ENTITIES_CHICKEN;
}
 
Example #9
Source File: DungeonLootLoader.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void init() {
    GTLog.logger.info("Registering dungeon loot...");
    ChestGenHooks.init();
    if (ConfigHolder.increaseDungeonLoot) {
        ChestGenHooks.addRolls(LootTableList.CHESTS_SPAWN_BONUS_CHEST, 2, 4);
        ChestGenHooks.addRolls(LootTableList.CHESTS_SIMPLE_DUNGEON, 1, 3);
        ChestGenHooks.addRolls(LootTableList.CHESTS_DESERT_PYRAMID, 2, 4);
        ChestGenHooks.addRolls(LootTableList.CHESTS_JUNGLE_TEMPLE, 4, 8);
        ChestGenHooks.addRolls(LootTableList.CHESTS_JUNGLE_TEMPLE_DISPENSER, 0, 2);
        ChestGenHooks.addRolls(LootTableList.CHESTS_ABANDONED_MINESHAFT, 1, 3);
        ChestGenHooks.addRolls(LootTableList.CHESTS_VILLAGE_BLACKSMITH, 2, 6);
        ChestGenHooks.addRolls(LootTableList.CHESTS_STRONGHOLD_CROSSING, 2, 4);
        ChestGenHooks.addRolls(LootTableList.CHESTS_STRONGHOLD_CORRIDOR, 2, 4);
        ChestGenHooks.addRolls(LootTableList.CHESTS_STRONGHOLD_LIBRARY, 4, 8);
    }

    ChestGenHooks.addItem(LootTableList.CHESTS_SPAWN_BONUS_CHEST, MetaItems.BOTTLE_PURPLE_DRINK.getStackForm(), 8, 16, 2);

    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, MetaItems.BOTTLE_PURPLE_DRINK.getStackForm(), 8, 16, 40);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.ingot, Materials.Silver, 1), 1, 6, 30);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.ingot, Materials.Lead, 1), 1, 6, 7);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.ingot, Materials.Steel, 1), 1, 6, 15);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.ingot, Materials.Bronze, 1), 1, 6, 15);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.ingot, Materials.Manganese, 1), 1, 6, 15);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.ingot, Materials.DamascusSteel, 1), 1, 6, 5);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.gem, Materials.Vinteum, 1), 2, 5, 3);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.gem, Materials.Emerald, 1), 1, 6, 5);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.gem, Materials.Ruby, 1), 1, 6, 5);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.gem, Materials.Sapphire, 1), 1, 6, 5);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.gem, Materials.GreenSapphire, 1), 1, 6, 5);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.gem, Materials.Olivine, 1), 1, 6, 5);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.gem, Materials.GarnetRed, 1), 1, 6, 10);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.gem, Materials.GarnetYellow, 1), 1, 6, 10);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.dust, Materials.Aluminium, 1), 1, 6, 10);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.dust, Materials.Neodymium, 1), 1, 6, 10);
    ChestGenHooks.addItem(LootTableList.CHESTS_SIMPLE_DUNGEON, OreDictUnifier.get(OrePrefix.dust, Materials.Chrome, 1), 1, 3, 10);

    ChestGenHooks.addItem(LootTableList.CHESTS_DESERT_PYRAMID, OreDictUnifier.get(OrePrefix.ingot, Materials.Silver, 1), 4, 16, 6);
    ChestGenHooks.addItem(LootTableList.CHESTS_DESERT_PYRAMID, OreDictUnifier.get(OrePrefix.ingot, Materials.Platinum, 1), 2, 8, 3);
    ChestGenHooks.addItem(LootTableList.CHESTS_DESERT_PYRAMID, OreDictUnifier.get(OrePrefix.gem, Materials.Ruby, 1), 2, 8, 1);
    ChestGenHooks.addItem(LootTableList.CHESTS_DESERT_PYRAMID, OreDictUnifier.get(OrePrefix.gem, Materials.Sapphire, 1), 2, 8, 3);
    ChestGenHooks.addItem(LootTableList.CHESTS_DESERT_PYRAMID, OreDictUnifier.get(OrePrefix.gem, Materials.GreenSapphire, 1), 2, 8, 4);
    ChestGenHooks.addItem(LootTableList.CHESTS_DESERT_PYRAMID, OreDictUnifier.get(OrePrefix.gem, Materials.Olivine, 1), 2, 8, 4);
    ChestGenHooks.addItem(LootTableList.CHESTS_DESERT_PYRAMID, OreDictUnifier.get(OrePrefix.gem, Materials.GarnetRed, 1), 2, 8, 3);
    ChestGenHooks.addItem(LootTableList.CHESTS_DESERT_PYRAMID, OreDictUnifier.get(OrePrefix.gem, Materials.GarnetYellow, 1), 2, 8, 3);

    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE, MetaItems.COIN_GOLD_ANCIENT.getStackForm(), 16, 64, 5);
    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE, MetaItems.ZPM.getChargedStack(Long.MAX_VALUE), 1, 1, 1);
    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE, OreDictUnifier.get(OrePrefix.ingot, Materials.Bronze, 1), 4, 16, 12);
    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE, OreDictUnifier.get(OrePrefix.gem, Materials.Ruby, 1), 2, 8, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE, OreDictUnifier.get(OrePrefix.gem, Materials.Sapphire, 1), 2, 8, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE, OreDictUnifier.get(OrePrefix.gem, Materials.GreenSapphire, 1), 2, 8, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE, OreDictUnifier.get(OrePrefix.gem, Materials.Olivine, 1), 2, 8, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE, OreDictUnifier.get(OrePrefix.gem, Materials.GarnetRed, 1), 2, 8, 4);
    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE, OreDictUnifier.get(OrePrefix.gem, Materials.GarnetYellow, 1), 2, 8, 4);

    ChestGenHooks.addItem(LootTableList.CHESTS_JUNGLE_TEMPLE_DISPENSER, new ItemStack(Items.FIRE_CHARGE, 1), 2, 7, 17);

    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.ingot, Materials.Silver, 1), 1, 4, 6);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.ingot, Materials.Lead, 1), 1, 4, 3);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.ingot, Materials.Steel, 1), 1, 4, 6);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.ingot, Materials.Bronze, 1), 1, 4, 6);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.gem, Materials.Sapphire, 1), 1, 4, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.gem, Materials.GreenSapphire, 1), 1, 4, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.gem, Materials.Olivine, 1), 1, 4, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.gem, Materials.GarnetRed, 1), 1, 4, 4);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.gem, Materials.GarnetYellow, 1), 1, 4, 4);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.gem, Materials.Ruby, 1), 1, 4, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.gem, Materials.Emerald, 1), 1, 4, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.toolHeadPickaxe, Materials.DamascusSteel, 1), 1, 4, 1);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.toolHeadShovel, Materials.DamascusSteel, 1), 1, 4, 1);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.toolHeadPickaxe, Materials.Vinteum, 1), 1, 2, 2);
    ChestGenHooks.addItem(LootTableList.CHESTS_ABANDONED_MINESHAFT, OreDictUnifier.get(OrePrefix.toolHeadShovel, Materials.Vinteum, 1), 1, 2, 2);

    ChestGenHooks.addItem(LootTableList.CHESTS_VILLAGE_BLACKSMITH, OreDictUnifier.get(OrePrefix.dust, Materials.Chrome, 1), 1, 4, 3);
    ChestGenHooks.addItem(LootTableList.CHESTS_VILLAGE_BLACKSMITH, OreDictUnifier.get(OrePrefix.dust, Materials.Neodymium, 1), 2, 8, 3);
    ChestGenHooks.addItem(LootTableList.CHESTS_VILLAGE_BLACKSMITH, OreDictUnifier.get(OrePrefix.ingot, Materials.Manganese, 1), 2, 8, 6);
    ChestGenHooks.addItem(LootTableList.CHESTS_VILLAGE_BLACKSMITH, OreDictUnifier.get(OrePrefix.ingot, Materials.Steel, 1), 4, 12, 6);
    ChestGenHooks.addItem(LootTableList.CHESTS_VILLAGE_BLACKSMITH, OreDictUnifier.get(OrePrefix.ingot, Materials.Bronze, 1), 4, 12, 6);
    ChestGenHooks.addItem(LootTableList.CHESTS_VILLAGE_BLACKSMITH, OreDictUnifier.get(OrePrefix.ingot, Materials.Brass, 1), 4, 12, 6);
    ChestGenHooks.addItem(LootTableList.CHESTS_VILLAGE_BLACKSMITH, OreDictUnifier.get(OrePrefix.ingot, Materials.DamascusSteel, 1), 4, 12, 3);
    ChestGenHooks.addItem(LootTableList.CHESTS_VILLAGE_BLACKSMITH, OreDictUnifier.get(OrePrefix.gem, Materials.Vinteum, 1), 3, 10, 2);

    ChestGenHooks.addItem(LootTableList.CHESTS_STRONGHOLD_CORRIDOR, OreDictUnifier.get(OrePrefix.toolHeadSword, Materials.DamascusSteel, 1), 1, 4, 4);
    ChestGenHooks.addItem(LootTableList.CHESTS_STRONGHOLD_CORRIDOR, OreDictUnifier.get(OrePrefix.toolHeadAxe, Materials.DamascusSteel, 1), 1, 4, 4);
    ChestGenHooks.addItem(LootTableList.CHESTS_STRONGHOLD_CORRIDOR, OreDictUnifier.get(OrePrefix.toolHeadPickaxe, Materials.Vinteum, 1), 1, 2, 3);
    ChestGenHooks.addItem(LootTableList.CHESTS_STRONGHOLD_CORRIDOR, OreDictUnifier.get(OrePrefix.toolHeadShovel, Materials.Vinteum, 1), 1, 2, 3);
}
 
Example #10
Source File: EntityVampireBat.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
protected ResourceLocation getLootTable() {
	return LootTableList.ENTITIES_BAT;
}
 
Example #11
Source File: EntityMonolithEye.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
protected ResourceLocation getLootTable() {
	return LootTableList.ENTITIES_GUARDIAN;
}
 
Example #12
Source File: EntityHelper.java    From Moo-Fluids with GNU General Public License v3.0 4 votes vote down vote up
public static void registerEntityLootTable(final String entityName) {
  LootTableList.register(getLootTable(entityName));
}