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;
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
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);
}
}
}
}
}
}
Aggregations