Search in sources :

Example 6 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project NetherEx by LogicTechCorp.

the class WorldGenWallStructure method generate.

@Override
public boolean generate(World world, Random rand, BlockPos pos) {
    rand = world.getChunkFromBlockCoords(pos).getRandomWithSeed(world.getSeed());
    Mirror[] mirrors = Mirror.values();
    Rotation[] rotations = Rotation.values();
    Mirror mirror = mirrors[rand.nextInt(mirrors.length)];
    Rotation rotation = rotations[rand.nextInt(rotations.length)];
    MinecraftServer server = world.getMinecraftServer();
    TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
    Template template = manager.getTemplate(server, WeightedUtil.getRandomStructure(rand, variants));
    PlacementSettings placementSettings = new PlacementSettings().setMirror(mirror).setRotation(rotation).setReplacedBlock(Blocks.AIR).setRandom(rand);
    BlockPos structureSize = Template.transformedBlockPos(placementSettings, template.getSize());
    BlockPos newPos = new BlockPos(pos.getX() - structureSize.getX() / 2, 96, pos.getZ() - structureSize.getZ() / 2);
    BlockPos spawnPos = WorldGenUtil.getSuitableWallPos(world, newPos, structureSize, 0.8F);
    if (!spawnPos.equals(BlockPos.ORIGIN)) {
        WorldGenUtil.generateStructure(world, spawnPos, rand, template, placementSettings, lootTables, spawnerMobs);
        return true;
    }
    return false;
}
Also used : TemplateManager(net.minecraft.world.gen.structure.template.TemplateManager) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings) Mirror(net.minecraft.util.Mirror) Rotation(net.minecraft.util.Rotation) MinecraftServer(net.minecraft.server.MinecraftServer) Template(net.minecraft.world.gen.structure.template.Template)

Example 7 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project NetherEx by LogicTechCorp.

the class WorldGenCeilingStructure method generate.

@Override
public boolean generate(World world, Random rand, BlockPos pos) {
    rand = world.getChunkFromBlockCoords(pos).getRandomWithSeed(world.getSeed());
    Mirror[] mirrors = Mirror.values();
    Rotation[] rotations = Rotation.values();
    Mirror mirror = mirrors[rand.nextInt(mirrors.length)];
    Rotation rotation = rotations[rand.nextInt(rotations.length)];
    MinecraftServer server = world.getMinecraftServer();
    TemplateManager manager = world.getSaveHandler().getStructureTemplateManager();
    Template template = manager.getTemplate(server, WeightedUtil.getRandomStructure(rand, variants));
    PlacementSettings placementSettings = new PlacementSettings().setMirror(mirror).setRotation(rotation).setReplacedBlock(Blocks.STRUCTURE_VOID).setRandom(rand);
    BlockPos structureSize = Template.transformedBlockPos(placementSettings, template.getSize());
    BlockPos newPos = new BlockPos(pos.getX() - structureSize.getX() / 2, 48, pos.getZ() - structureSize.getZ() / 2);
    BlockPos spawnPos = WorldGenUtil.getSuitableCeilingPos(world, newPos, structureSize);
    if (!spawnPos.equals(BlockPos.ORIGIN)) {
        WorldGenUtil.generateStructure(world, spawnPos, rand, template, placementSettings, lootTables, spawnerMobs);
        return true;
    }
    return false;
}
Also used : TemplateManager(net.minecraft.world.gen.structure.template.TemplateManager) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings) Mirror(net.minecraft.util.Mirror) Rotation(net.minecraft.util.Rotation) MinecraftServer(net.minecraft.server.MinecraftServer) Template(net.minecraft.world.gen.structure.template.Template)

Example 8 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project Pearcel-Mod by MiningMark48.

the class StructureGenPearcel3 method generateStructure.

public static void generateStructure(WorldServer world, BlockPos pos, Random random) {
    MinecraftServer server = world.getMinecraftServer();
    Template template = world.getStructureTemplateManager().getTemplate(server, STRUCTURE);
    PlacementSettings settings = new PlacementSettings();
    settings.setRotation(Rotation.NONE);
    template.addBlocksToWorld(world, pos, settings);
    Map<BlockPos, String> dataBlocks = template.getDataBlocks(pos, settings);
    for (Map.Entry<BlockPos, String> entry : dataBlocks.entrySet()) {
        String[] tokens = entry.getValue().split(" ");
        if (tokens.length == 0)
            return;
        BlockPos dataPos = entry.getKey();
        String s = tokens[0].toLowerCase();
        if (s.equals("lootchest2")) {
            String chestOrientation = tokens[1];
            EnumFacing chestFacing = settings.getRotation().rotate(EnumFacing.byName(chestOrientation));
            IBlockState chestState = Blocks.CHEST.getDefaultState().withProperty(BlockChest.FACING, chestFacing);
            world.setBlockState(dataPos, chestState);
            TileEntity tile = world.getTileEntity(dataPos);
            if (tile != null && tile instanceof TileEntityLockableLoot)
                ((TileEntityLockableLoot) tile).setLootTable(LOOT2, random.nextLong());
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings) MinecraftServer(net.minecraft.server.MinecraftServer) Template(net.minecraft.world.gen.structure.template.Template) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityLockableLoot(net.minecraft.tileentity.TileEntityLockableLoot) BlockPos(net.minecraft.util.math.BlockPos) Map(java.util.Map)

Example 9 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project ArsMagica2 by Mithion.

the class DimensionUtilities method doDimensionTransfer.

public static void doDimensionTransfer(EntityLivingBase entity, int dimension) {
    if (entity instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        new AMTeleporter(player.mcServer.worldServerForDimension(dimension)).teleport(entity);
    } else {
        entity.worldObj.theProfiler.startSection("changeDimension");
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        int j = entity.dimension;
        WorldServer worldserver = minecraftserver.worldServerForDimension(j);
        WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimension);
        entity.dimension = dimension;
        entity.worldObj.removeEntity(entity);
        entity.isDead = false;
        entity.worldObj.theProfiler.startSection("reposition");
        minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new AMTeleporter(worldserver1));
        entity.worldObj.theProfiler.endStartSection("reloading");
        Entity e = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);
        if (e != null) {
            e.copyDataFrom(entity, true);
            worldserver1.spawnEntityInWorld(e);
        }
        entity.isDead = true;
        entity.worldObj.theProfiler.endSection();
        worldserver.resetUpdateEntityTick();
        worldserver1.resetUpdateEntityTick();
        entity.worldObj.theProfiler.endSection();
    }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 10 with MinecraftServer

use of net.minecraft.server.MinecraftServer in project NewHorizonsCoreMod by GTNewHorizons.

the class CustomDropsCommand method canCommandSenderUseCommand.

@Override
public boolean canCommandSenderUseCommand(ICommandSender pCommandSender) {
    if (pCommandSender instanceof EntityPlayerMP) {
        EntityPlayerMP tEP = (EntityPlayerMP) pCommandSender;
        boolean tPlayerOpped = MinecraftServer.getServer().getConfigurationManager().func_152596_g(tEP.getGameProfile());
        // && tIncreative;
        return tPlayerOpped;
    } else if (pCommandSender instanceof MinecraftServer)
        return true;
    else
        return false;
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MinecraftServer(net.minecraft.server.MinecraftServer)

Aggregations

MinecraftServer (net.minecraft.server.MinecraftServer)32 BlockPos (net.minecraft.util.math.BlockPos)13 Template (net.minecraft.world.gen.structure.template.Template)9 PlacementSettings (net.minecraft.world.gen.structure.template.PlacementSettings)8 World (net.minecraft.world.World)6 TemplateManager (net.minecraft.world.gen.structure.template.TemplateManager)6 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 Mirror (net.minecraft.util.Mirror)5 Rotation (net.minecraft.util.Rotation)5 WorldServer (net.minecraft.world.WorldServer)5 RCConfig (ivorius.reccomplex.RCConfig)4 RCExpect (ivorius.reccomplex.commands.parameters.RCExpect)4 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)4 ServerTranslations (ivorius.reccomplex.utils.ServerTranslations)4 List (java.util.List)4 Nullable (javax.annotation.Nullable)4 IBlockState (net.minecraft.block.state.IBlockState)4 CommandBase (net.minecraft.command.CommandBase)4 CommandException (net.minecraft.command.CommandException)4 ICommandSender (net.minecraft.command.ICommandSender)4