public void generateGoldPile(World world, Random rand, BlockPos position) { int height = 1 + new Random().nextInt(7); int chance = rand.nextInt(100); if (chance < 20) { world.setBlockState(position, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[new Random().nextInt(3)]), 3); if (world.getBlockState(position).getBlock() instanceof BlockChest) { TileEntity tileentity1 = world.getTileEntity(position); if (tileentity1 instanceof TileEntityChest && !((TileEntityChest) tileentity1).isInvalid()) { ((TileEntityChest) tileentity1).setLootTable(WorldGenIceDragonCave.ICEDRAGON_CHEST, new Random().nextLong()); } } } else { world.setBlockState(position, ModBlocks.silverPile.getDefaultState().withProperty(BlockGoldPile.LAYERS, height), 3); } }
world.setBlockState(pos, Blocks.CHEST.correctFacing(world, pos, Blocks.CHEST.getDefaultState()), 2); TileEntity tile = world.getTileEntity(pos);
@Override public void breakBlock(World world, @Nonnull BlockPos pos, @Nonnull IBlockState state) { TileEntity tile = world.getTileEntity(pos); if(tile instanceof ISonarInventoryTile){ List<ItemStack> stacks = ((ISonarInventoryTile) tile).inv().getDrops(); for (ItemStack itemstack : stacks){ if (!itemstack.isEmpty()){ InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack); } } } super.breakBlock(world, pos, state); }
@Override public boolean generate(World world, Random rand, BlockPos pos) { if(!aircheck(world, rand, pos)) return false; for (int xx = - radius; xx <= radius; xx++) { for (int zz = - radius; zz <= radius; zz++) { for (int yy = 0; yy < height; yy++) { double dSqDome = Math.pow(xx, 2.0D) + Math.pow(zz, 2.0D) + Math.pow(yy, 2.0D); if (yy == 0 && rand.nextBoolean() && Math.round(Math.sqrt(dSqDome)) == 5) world.setBlockState(pos.add(xx, -1, zz), DUNG, 2); if (Math.round(Math.sqrt(dSqDome)) < 5) world.setBlockState(pos.add(xx, yy, zz), DUNG, 2); } if (rand.nextInt(5) == 0) world.setBlockState(pos.add(xx, 0, zz), DUNG, 2); } } world.setBlockState(pos, Blocks.CHEST.getStateFromMeta(0), 2); TileEntityChest chest = (TileEntityChest) world.getTileEntity(pos); if (chest != null) LootUtil.generateLoot(chest, rand, CHEST_LOOT, 8, 14); world.setBlockState(pos.add(-1, 1, 1), ModBlocks.DUNG_SPAWNER_BOT_FLY.getDefaultState(), 2); world.setBlockState(pos.add(1, 1, 1), ModBlocks.DUNG_SPAWNER_FLY.getDefaultState(), 2); world.setBlockState(pos.add(1, 1, -1), ModBlocks.DUNG_SPAWNER_BOT_FLY.getDefaultState(), 2); world.setBlockState(pos.add(-1, 1, -1), ModBlocks.DUNG_SPAWNER_FLY.getDefaultState(), 2); world.setBlockState(pos.add(0, height, 0), ModBlocks.DUNG_SPAWNER_FLY.getDefaultState(), 2); return true; }
@Override public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) { super.harvestBlock(worldIn, player, pos, state, te, stack); worldIn.setBlockToAir(pos); if(te instanceof TileCustomChest) te.invalidate(); }
public void placeSpawner(World world, Random rand, int x, int y, int z) { world.setBlockState(new BlockPos(x + 1, y, z), Blocks.WEB.getDefaultState(), 2); world.setBlockState(new BlockPos(x - 1, y, z), Blocks.WEB.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y, z - 1), Blocks.WEB.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y, z + 1), Blocks.WEB.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y + 1, z), Blocks.WEB.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y, z), ModBlocks.TARANTULA_SPAWNER.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y - 1, z), Blocks.CHEST.getStateFromMeta(0), 2); TileEntityChest chest = (TileEntityChest) world.getTileEntity(new BlockPos(x, y - 1, z)); if (chest != null) LootUtil.generateLoot(chest, rand, chestLoot, 3, 10); }
public void generateGoldPile(World world, Random rand, BlockPos position) { int height = 1 + new Random().nextInt(7); int chance = rand.nextInt(100); if (chance < 20) { world.setBlockState(position, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[new Random().nextInt(3)]), 3); if (world.getBlockState(position).getBlock() instanceof BlockChest) { TileEntity tileentity1 = world.getTileEntity(position); if (tileentity1 instanceof TileEntityChest && !((TileEntityChest) tileentity1).isInvalid()) { ((TileEntityChest) tileentity1).setLootTable(WorldGenFireDragonCave.FIREDRAGON_CHEST, new Random().nextLong()); } } } else { world.setBlockState(position, ModBlocks.goldPile.getDefaultState().withProperty(BlockGoldPile.LAYERS, height), 3); } }
worldIn.setBlockState(blockpos2, Blocks.CHEST.correctFacing(worldIn, blockpos2, Blocks.CHEST.getDefaultState()), 2); TileEntity tileentity1 = worldIn.getTileEntity(blockpos2);
public static void setGoldPile(World world, BlockPos pos) { int chance = new Random().nextInt(99) + 1; if (world.getBlockState(pos).getBlock() instanceof BlockChest) { return; } if (chance < 60) { boolean generateGold = IceAndFire.CONFIG.dragonDenGoldAmount > 1 ? new Random().nextInt(IceAndFire.CONFIG.dragonDenGoldAmount) == 0 : true; world.setBlockState(pos, generateGold ? ModBlocks.goldPile.getDefaultState().withProperty(BlockGoldPile.LAYERS, 1 + new Random().nextInt(7)) : Blocks.AIR.getDefaultState(), 3); } else if (chance > 60 && chance < 62) { world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[new Random().nextInt(3)]), 3); if (world.getBlockState(pos).getBlock() instanceof BlockChest) { TileEntity tileentity1 = world.getTileEntity(pos); if (tileentity1 instanceof TileEntityChest && !((TileEntityChest) tileentity1).isInvalid()) { ((TileEntityChest) tileentity1).setLootTable(FIREDRAGON_CHEST, new Random().nextLong()); } } } }
worldIn.setBlockState(blockpos2, Blocks.CHEST.correctFacing(worldIn, blockpos2, Blocks.CHEST.getDefaultState()), 2); TileEntity tileentity1 = worldIn.getTileEntity(blockpos2);
public static void setGoldPile(World world, BlockPos pos) { int chance = new Random().nextInt(99) + 1; if (world.getBlockState(pos).getBlock() instanceof BlockChest) { return; } if (chance < 60) { boolean generateGold = IceAndFire.CONFIG.dragonDenGoldAmount > 1 ? new Random().nextInt(IceAndFire.CONFIG.dragonDenGoldAmount) == 0 : true; world.setBlockState(pos, generateGold ? ModBlocks.silverPile.getDefaultState().withProperty(BlockGoldPile.LAYERS, 1 + new Random().nextInt(7)) : Blocks.AIR.getDefaultState(), 3); } else if (chance > 60 && chance < 62) { world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[new Random().nextInt(3)]), 3); if (world.getBlockState(pos).getBlock() instanceof BlockChest) { TileEntity tileentity1 = world.getTileEntity(pos); if (tileentity1 instanceof TileEntityChest && !((TileEntityChest) tileentity1).isInvalid()) { ((TileEntityChest) tileentity1).setLootTable(ICEDRAGON_CHEST, new Random().nextLong()); } } } }
private void placeChest(World world, BlockPos pos, EnumFacing facing, Random rand) { world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, facing), 2); TileEntityChest chest = (TileEntityChest) world.getTileEntity(pos); if (chest != null) LootUtil.generateLoot(chest, rand, chestLoot, 3, 10); }
public static void generateGold(World worldIn, BlockPos blockpos, BlockPos origin, int radius, Random rand) { IBlockState gold = rand.nextBoolean() ? ModBlocks.goldPile.getDefaultState() : ModBlocks.silverPile.getDefaultState(); if (worldIn.getBlockState(blockpos.down()).isSideSolid(worldIn, blockpos.down(), EnumFacing.UP)) { worldIn.setBlockState(blockpos, gold.withProperty(BlockGoldPile.LAYERS, 8), 3); worldIn.setBlockState(MyrmexHive.getGroundedPos(worldIn, blockpos.north()), gold.withProperty(BlockGoldPile.LAYERS, 1 + new Random().nextInt(7)), 3); worldIn.setBlockState(MyrmexHive.getGroundedPos(worldIn, blockpos.south()), gold.withProperty(BlockGoldPile.LAYERS, 1 + new Random().nextInt(7)), 3); worldIn.setBlockState(MyrmexHive.getGroundedPos(worldIn, blockpos.west()), gold.withProperty(BlockGoldPile.LAYERS, 1 + new Random().nextInt(7)), 3); worldIn.setBlockState(MyrmexHive.getGroundedPos(worldIn, blockpos.east()), gold.withProperty(BlockGoldPile.LAYERS, 1 + new Random().nextInt(7)), 3); if (rand.nextInt(3) == 0) { worldIn.setBlockState(blockpos.up(), Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[new Random().nextInt(3)]), 3); if (worldIn.getBlockState(blockpos.up()).getBlock() instanceof BlockChest) { TileEntity tileentity1 = worldIn.getTileEntity(blockpos.up()); if (tileentity1 instanceof TileEntityChest && !((TileEntityChest) tileentity1).isInvalid()) { ((TileEntityChest) tileentity1).setLootTable(MYRMEX_GOLD_CHEST, rand.nextLong()); } } } } }
world.setBlockState(treasurePos, Blocks.CHEST.getDefaultState()); TileEntityChest chest = (TileEntityChest) world.getTileEntity(treasurePos);
break; case "chest": IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.WEST); world.setBlockState(dataPos, chestState);
world.setBlockState(pos.down(7), Blocks.CHEST.getDefaultState(), 2); TileEntityChest chest = (TileEntityChest) world.getTileEntity(pos.down(7)); if (chest != null)
worldIn.setBlockState(blockpos.up().west(), ModBlocks.goldPile.getDefaultState().withProperty(BlockGoldPile.LAYERS, 1 + new Random().nextInt(7)), 3); worldIn.setBlockState(blockpos.up().east(), ModBlocks.goldPile.getDefaultState().withProperty(BlockGoldPile.LAYERS, 1 + new Random().nextInt(7)), 3); worldIn.setBlockState(blockpos.up(2), Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, EnumFacing.HORIZONTALS[new Random().nextInt(3)]), 3); if (worldIn.getBlockState(blockpos.up(2)).getBlock() instanceof BlockChest) { TileEntity tileentity1 = worldIn.getTileEntity(blockpos.up(2));
world.setBlockState(new BlockPos(x, y + 2, z), ModBlocks.JUMPING_SPIDER_SPAWNER.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y, z), Blocks.CHEST.getDefaultState(), 2); TileEntityChest chest1 = (TileEntityChest) world.getTileEntity(new BlockPos(x, y, z)); if (chest1 != null) world.setBlockState(new BlockPos(x - 4, y + 11, z + moveyChest), Blocks.CHEST.getDefaultState(), 2); world.setBlockState(new BlockPos(x + 4, y + 11, z + moveyChest), Blocks.CHEST.getDefaultState(), 2); world.setBlockState(new BlockPos(x - 4, y + 12, z + moveyChest), log, 2); world.setBlockState(new BlockPos(x + 4, y + 12, z + moveyChest), log, 2);
player.getServerWorld().setBlockState(message.pos.up(chestHeight), Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, player.getHorizontalFacing()));
switch (type) { case "GeneticistChest": world.setBlockState(pos, Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, rotate(this.coordBaseMode, this.mirror == Mirror.LEFT_RIGHT ? true : false))); ((TileEntityChest) world.getTileEntity(pos)).setLootTable(Loot.GENETICIST_HOUSE_CHEST, random.nextLong()); dataBlocksClone.remove(pos);