Search in sources :

Example 51 with WorldServer

use of net.minecraft.world.WorldServer in project Pearcel-Mod by MiningMark48.

the class TileEntityPearcelBeacon method update.

@Override
public void update() {
    Random rand = new Random();
    World world = getWorld();
    BlockPos pos = getPos();
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    int range = ConfigurationHandler.pearcelBeaconRange;
    float damage = ConfigurationHandler.pearcelBeaconDamage;
    if (!world.isBlockPowered(pos)) {
        isActive = true;
        int num = rand.nextInt(2);
        switch(num) {
            default:
                break;
            case 0:
                world.spawnParticle(EnumParticleTypes.SPELL_MOB, x + 0.5, y + 1.875, z + 0.5, 4.47368D, 1.0D, 0.0D);
                break;
        }
        List<EntityPlayer> players = world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        List<EntityCreature> mobs = world.getEntitiesWithinAABB(EntityCreature.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range));
        for (EntityPlayer e : players) {
            e.addPotionEffect(new PotionEffect(MobEffects.SPEED, 200, 0, true, false));
            e.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, 200, 0, true, false));
            e.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 200, 0, true, false));
            e.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 200, 0, true, false));
        }
        for (EntityCreature e : mobs) {
            if (e.isCreatureType(EnumCreatureType.MONSTER, false)) {
                int num2 = rand.nextInt(10);
                if (num2 == 0) {
                    if (fakePlayer == null) {
                        if (!world.isRemote) {
                            fakePlayer = FakePlayerFactory.get((WorldServer) world, new GameProfile(UUID.randomUUID(), ModBlocks.pearcel_beacon.getLocalizedName()));
                        }
                    }
                    if (e.getMaxHealth() >= 100) {
                        e.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer), damage * 15);
                    } else {
                        e.attackEntityFrom(DamageSource.causePlayerDamage(fakePlayer), damage);
                    }
                }
                world.spawnParticle(EnumParticleTypes.SPELL_MOB, e.posX, e.posY + 0.5, e.posZ, 1.0D, 0.0D, 0.0D);
            }
        }
    } else {
        isActive = false;
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PotionEffect(net.minecraft.potion.PotionEffect) WorldServer(net.minecraft.world.WorldServer) World(net.minecraft.world.World) Random(java.util.Random) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) EntityCreature(net.minecraft.entity.EntityCreature)

Example 52 with WorldServer

use of net.minecraft.world.WorldServer in project Pearcel-Mod by MiningMark48.

the class StructureGenPearcel1 method generate.

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (!(world instanceof WorldServer))
        return;
    if (!ConfigurationHandler.enableStructure1) {
        return;
    }
    WorldServer serverworld = (WorldServer) world;
    int x = chunkX * 16 + random.nextInt(16);
    int z = chunkZ * 16 + random.nextInt(16);
    BlockPos xzPos = new BlockPos(x, 1, z);
    Biome biome = world.getBiomeForCoordsBody(xzPos);
    if (biome == Biomes.PLAINS || biome == Biomes.DESERT || biome == Biomes.EXTREME_HILLS || biome == Biomes.BEACH || biome == Biomes.FOREST || biome == Biomes.FOREST_HILLS || biome == Biomes.ICE_PLAINS) {
        if (random.nextInt(ConfigurationHandler.structureRarity2) == 0) {
            //Rarity
            BlockPos pos = new BlockPos(x, WorldTools.findEmptySpot(world, x, z), z);
            generateStructure(serverworld, pos, random);
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos)

Example 53 with WorldServer

use of net.minecraft.world.WorldServer in project Pearcel-Mod by MiningMark48.

the class StructureGenPearcel3 method generate.

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    if (!(world instanceof WorldServer))
        return;
    if (!ConfigurationHandler.enableStructure3) {
        return;
    }
    WorldServer serverworld = (WorldServer) world;
    int x = chunkX * 16 + random.nextInt(16);
    int z = chunkZ * 16 + random.nextInt(16);
    BlockPos xzPos = new BlockPos(x, 1, z);
    Biome biome = world.getBiomeForCoordsBody(xzPos);
    if (biome == Biomes.PLAINS || biome == Biomes.DESERT || biome == Biomes.EXTREME_HILLS || biome == Biomes.FOREST || biome == Biomes.FOREST_HILLS) {
        if (random.nextInt(ConfigurationHandler.structureRarity1) == 2) {
            //Rarity
            BlockPos pos = new BlockPos(x, WorldTools.findEmptySpot(world, x, z) + 1, z);
            generateStructure(serverworld, pos, random);
        }
    }
}
Also used : Biome(net.minecraft.world.biome.Biome) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos)

Example 54 with WorldServer

use of net.minecraft.world.WorldServer in project RFToolsDimensions by McJty.

the class DimensionTickEvent method serverTick.

private void serverTick(World entityWorld, boolean doEffects) {
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(entityWorld);
    if (!dimensionManager.getDimensions().isEmpty()) {
        DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(entityWorld);
        for (Map.Entry<Integer, DimensionDescriptor> entry : dimensionManager.getDimensions().entrySet()) {
            Integer id = entry.getKey();
            // If there is an activity probe we only drain power if the dimension is loaded (a player is there or a chunkloader)
            DimensionInformation information = dimensionManager.getDimensionInformation(id);
            if (!information.isCheater()) {
                WorldServer world = DimensionManager.getWorld(id);
                // Power handling.
                if ((world != null && world.getChunkProvider().getLoadedChunkCount() > 0) || information.getProbeCounter() == 0) {
                    handlePower(doEffects, dimensionStorage, entry, id, information);
                }
                // Special effect handling.
                if (world != null && !world.playerEntities.isEmpty()) {
                    handleRandomEffects(world, information);
                }
            }
        }
        dimensionStorage.save(entityWorld);
    }
}
Also used : DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) WorldServer(net.minecraft.world.WorldServer)

Example 55 with WorldServer

use of net.minecraft.world.WorldServer in project ConvenientAdditions by Necr0.

the class ItemEnderPlate method onPlayerInventoryTick.

@Override
public void onPlayerInventoryTick(ItemStack item, SlotNotation slot, EntityPlayer player) {
    if (player.getEntityWorld().isRemote || !slot.isCommonActive())
        return;
    WorldServer world = (WorldServer) player.getEntityWorld();
    if (isActive(item)) {
        for (int x = 0; x < 3; x++) {
            for (int y = 0; y < 3; y++) {
                for (int z = 0; z < 3; z++) {
                    BlockPos player_pos = player.getPosition();
                    BlockPos pos = new BlockPos(x - 1 + player_pos.getX(), y - 2 + player_pos.getY(), z - 1 + player_pos.getZ());
                    IBlockState state = world.getBlockState(pos);
                    Block b = state.getBlock();
                    if (b.isAir(state, world, pos) && b != ModBlocks.phantomPlatformBlock) {
                        world.setBlockState(pos, ModBlocks.phantomPlatformBlock.getDefaultState().withProperty(BlockPhantomPlatform.DESPAWN, true), 3 + 4);
                        world.scheduleBlockUpdate(pos, ModBlocks.phantomPlatformBlock, 1, 0);
                    }
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

WorldServer (net.minecraft.world.WorldServer)67 BlockPos (net.minecraft.util.math.BlockPos)24 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 IBlockState (net.minecraft.block.state.IBlockState)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)11 Entity (net.minecraft.entity.Entity)8 TileEntity (net.minecraft.tileentity.TileEntity)8 World (net.minecraft.world.World)8 StructureBoundingBox (net.minecraft.world.gen.structure.StructureBoundingBox)8 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)7 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)7 Nullable (javax.annotation.Nullable)6 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)5 Structure (ivorius.reccomplex.world.gen.feature.structure.Structure)5 StructureSpawnContext (ivorius.reccomplex.world.gen.feature.structure.context.StructureSpawnContext)5 Collectors (java.util.stream.Collectors)5 Block (net.minecraft.block.Block)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 Chunk (net.minecraft.world.chunk.Chunk)4 ChunkProviderServer (net.minecraft.world.gen.ChunkProviderServer)4