Search in sources :

Example 11 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class GenericWorldGenerator method generateSpawnPlatform.

private void generateSpawnPlatform(World world) {
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.dimensionId);
    int midx = 8;
    int midz = 8;
    int starty;
    if (information.getTerrainType() == TerrainType.TERRAIN_SOLID) {
        starty = 64;
    } else {
        starty = WorldGenerationTools.findSuitableEmptySpot(world, midx, midz);
    }
    if (starty == -1) {
        // No suitable spot. We will carve something out.
        starty = 64;
    } else {
        // Go one up
        starty++;
    }
    boolean shelter = information.isShelter();
    if (information.getTerrainType() == TerrainType.TERRAIN_LIQUID) {
        shelter = true;
    }
    int bounds = 3;
    if (shelter) {
        bounds = 4;
    }
    for (int x = -bounds; x <= bounds; x++) {
        for (int z = -bounds; z <= bounds; z++) {
            if (x == 0 && z == 0) {
                world.setBlock(x + midx, starty, z + midz, TeleporterSetup.matterReceiverBlock, 0, 2);
                MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) world.getTileEntity(x + midx, starty, z + midz);
                matterReceiverTileEntity.modifyEnergyStored(TeleportConfiguration.RECEIVER_MAXENERGY);
                matterReceiverTileEntity.setName(information.getName());
                matterReceiverTileEntity.markDirty();
            } else if (x == 0 && (z == 2 || z == -2)) {
                world.setBlock(x + midx, starty, z + midz, Blocks.glowstone, 0, 3);
            } else {
                world.setBlock(x + midx, starty, z + midz, Blocks.stained_hardened_clay, 3, 2);
            }
            for (int y = 1; y <= 3; y++) {
                world.setBlockToAir(x + midx, starty + y, z + midz);
            }
            // Check the top layer. If it is something other then air we will replace it with clay as well.
            if (!world.isAirBlock(x + midx, starty + 4, z + midz)) {
                world.setBlock(x + midx, starty + 4, z + midz, Blocks.stained_hardened_clay, 3, 2);
            }
        }
    }
    if (shelter) {
        for (int y = 1; y <= 3; y++) {
            for (int x = -bounds; x <= bounds; x++) {
                for (int z = -bounds; z <= bounds; z++) {
                    if (x == -bounds || x == bounds || z == -bounds || z == bounds) {
                        if (z == 0 && y >= 2 && y <= 3 || x == 0 && y >= 2 && y <= 3 && z == bounds) {
                            world.setBlock(x + midx, starty + y, z + midz, Blocks.glass_pane, 0, 2);
                        } else if (x == 0 && y == 1 && z == -bounds) {
                            world.setBlock(x + midx, starty + y, z + midz, Blocks.iron_door, 1, 2);
                        } else if (x == 0 && y == 2 && z == -bounds) {
                            world.setBlock(x + midx, starty + y, z + midz, Blocks.iron_door, 8, 2);
                        } else {
                            world.setBlock(x + midx, starty + y, z + midz, Blocks.stained_hardened_clay, 9, 2);
                        }
                    }
                }
            }
        }
        for (int x = -bounds; x <= bounds; x++) {
            for (int z = -bounds; z <= bounds; z++) {
                world.setBlock(x + midx, starty + 4, z + midz, Blocks.stained_hardened_clay, 9, 2);
            }
        }
        world.setBlock(midx - 1, starty + 2, midz - bounds - 1, Blocks.stone_button, 4, 2);
        world.setBlock(midx + 1, starty + 2, midz - bounds + 1, Blocks.stone_button, 3, 2);
        world.setBlock(midx + 1, starty, midz - bounds - 1, Blocks.stained_hardened_clay, 3, 2);
        world.setBlock(midx, starty, midz - bounds - 1, Blocks.stained_hardened_clay, 3, 2);
        world.setBlock(midx - 1, starty, midz - bounds - 1, Blocks.stained_hardened_clay, 3, 2);
        world.setBlock(midx + 1, starty, midz - bounds - 2, Blocks.stained_hardened_clay, 3, 2);
        world.setBlock(midx, starty, midz - bounds - 2, Blocks.stained_hardened_clay, 3, 2);
        world.setBlock(midx - 1, starty, midz - bounds - 2, Blocks.stained_hardened_clay, 3, 2);
    }
    createReceiver(world, dimensionManager, information, midx, midz, starty);
}
Also used : DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 12 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class GenericWorldGenerator method generateBigSpawnPlatform.

private void generateBigSpawnPlatform(World world, int chunkX, int chunkZ, int[][] platform) {
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.dimensionId);
    int midx = 8;
    int midz = 8;
    int starty = WorldGenerationTools.findSuitableEmptySpot(world, midx, midz);
    if (starty == -1) {
        // No suitable spot. We will carve something out.
        starty = 64;
    } else {
        // Go one up
        starty++;
    }
    if (isReceiverPresent(world, midx, midz, starty - 1, platform)) {
        starty--;
    }
    int r = platform.length;
    int sx = -r / 2;
    int sz = -r / 2;
    for (int x = sx; x < sx + r; x++) {
        int cx = (x + midx) >> 4;
        if (chunkX == cx) {
            for (int z = sz; z < sz + r; z++) {
                int cz = (z + midz) >> 4;
                if (chunkZ == cz) {
                    int color = platform[r - x - r / 2 - 1][z + r / 2];
                    if (color == -2) {
                        world.setBlock(x + midx, starty, z + midz, TeleporterSetup.matterReceiverBlock, 0, 2);
                        MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) world.getTileEntity(x + midx, starty, z + midz);
                        matterReceiverTileEntity.modifyEnergyStored(TeleportConfiguration.RECEIVER_MAXENERGY);
                        matterReceiverTileEntity.setName(information.getName());
                        matterReceiverTileEntity.markDirty();
                    } else if (color != -1) {
                        world.setBlock(x + midx, starty, z + midz, Blocks.stained_hardened_clay, color, 2);
                    } else {
                        world.setBlockToAir(x + midx, starty, z + midz);
                    }
                    for (int y = 1; y <= 3; y++) {
                        world.setBlockToAir(x + midx, starty + y, z + midz);
                    }
                }
            }
        }
    }
    if (chunkX == 0 && chunkZ == 0) {
        createReceiver(world, dimensionManager, information, midx, midz, starty);
    }
}
Also used : DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 13 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class GenericWorldGenerator method generate.

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
    RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(world);
    if (manager.getDimensionDescriptor(world.provider.dimensionId) == null) {
        // Not an RFTools dimension
        return;
    }
    DimensionInformation information = manager.getDimensionInformation(world.provider.dimensionId);
    BlockMeta baseBlock = information.getBaseBlockForTerrain();
    if (information.hasFeatureType(FeatureType.FEATURE_OREGEN)) {
        for (BlockMeta block : information.getExtraOregen()) {
            addOreSpawn(block.getBlock(), block.getMeta(), baseBlock.getBlock(), world, random, chunkX * 16, chunkZ * 16, 7, 10, 12, 2, 60);
        }
    }
    addOreSpawn(DimletSetup.dimensionalShardBlock, (byte) 0, Blocks.stone, world, random, chunkX * 16, chunkZ * 16, 5, 8, 3, 2, 40);
    if (information.isPatreonBitSet(Patreons.PATREON_PUPPETEER) && Math.abs(chunkX) <= 1 && Math.abs(chunkZ) <= 1) {
        generateBigSpawnPlatform(world, chunkX, chunkZ, puppeteerSpawnPlatform);
    } else if (chunkX == 0 && chunkZ == 0) {
        generateSpawnPlatform(world);
    } else if ((Math.abs(chunkX) > 6 || Math.abs(chunkZ) > 6) && !information.hasFeatureType(FeatureType.FEATURE_NODIMLETBUILDINGS)) {
        // Not too close to starting platform we possibly generate dungeons.
        if (random.nextInt(DimletConfiguration.dungeonChance) == 1) {
            generateDimletDungeon(random, chunkX, chunkZ, world);
        }
    }
    if ((Math.abs(chunkX) >= 2 || Math.abs(chunkZ) >= 2) && information.isPatreonBitSet(Patreons.PATREON_COLOREDPRISMS)) {
        if (random.nextInt(10) == 1) {
            generatePrism(chunkX, chunkZ, world);
        }
    }
    if ((Math.abs(chunkX) >= 1 || Math.abs(chunkZ) >= 1) && information.isPatreonBitSet(Patreons.PATREON_PINKPILLARS)) {
        if (random.nextInt(2) == 1) {
            generatePillar(random, chunkX, chunkZ, world);
        }
    }
    if ((Math.abs(chunkX) >= 3 || Math.abs(chunkZ) >= 3) && information.hasFeatureType(FeatureType.FEATURE_VOLCANOES)) {
        if (random.nextInt(DimletConfiguration.volcanoChance) == 1) {
            generateVolcano(random, chunkX, chunkZ, world);
        }
    }
}
Also used : DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 14 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class GenericWorldChunkManager method getModdedBiomeGenerators.

@Override
public GenLayer[] getModdedBiomeGenerators(WorldType worldType, long seed, GenLayer[] original) {
    if (dimensionInformation == null) {
        dimensionInformation = hackyDimensionInformation;
    }
    GenLayer[] layer = super.getModdedBiomeGenerators(worldType, seed, original);
    GenLayer rflayer = null;
    ControllerType type;
    DimensionInformation di = dimensionInformation;
    if (di == null) {
        di = hackyDimensionInformation;
    }
    type = di.getControllerType();
    switch(type) {
        case CONTROLLER_DEFAULT:
        case CONTROLLER_SINGLE:
            // Cannot happen
            break;
        case CONTROLLER_CHECKERBOARD:
            rflayer = new GenLayerCheckerboard(this, seed, layer[0]);
            break;
        case CONTROLLER_COLD:
        case CONTROLLER_WARM:
        case CONTROLLER_MEDIUM:
        case CONTROLLER_DRY:
        case CONTROLLER_WET:
        case CONTROLLER_FIELDS:
        case CONTROLLER_MOUNTAINS:
        case CONTROLLER_MAGICAL:
        case CONTROLLER_FOREST:
        case CONTROLLER_FILTERED:
            rflayer = new GenLayerFiltered(this, seed, layer[0], type);
            break;
    }
    GenLayerVoronoiZoom zoomLayer = new GenLayerVoronoiZoom(10L, rflayer);
    try {
        zoomLayer.initWorldGenSeed(seed);
    } catch (Exception e) {
        if (!workaroundErrorReported) {
            Logging.logError("Error in RFTools getModdedBiomeGenerators possibly caused by another biome changing mod");
            workaroundErrorReported = true;
            e.printStackTrace();
        }
    }
    return new GenLayer[] { rflayer, zoomLayer, rflayer };
}
Also used : GenLayerVoronoiZoom(net.minecraft.world.gen.layer.GenLayerVoronoiZoom) GenLayer(net.minecraft.world.gen.layer.GenLayer) ControllerType(mcjty.rftools.dimension.world.types.ControllerType) DimensionInformation(mcjty.rftools.dimension.DimensionInformation)

Example 15 with DimensionInformation

use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.

the class CmdSetOwner method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension and player parameters are missing!"));
        return;
    } else if (args.length > 3) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    String playerName = fetchString(sender, args, 2, null);
    World world = sender.getEntityWorld();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    if (dimensionManager.getDimensionDescriptor(dim) == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    for (Object o : MinecraftServer.getServer().getConfigurationManager().playerEntityList) {
        EntityPlayerMP entityPlayerMP = (EntityPlayerMP) o;
        if (playerName.equals(entityPlayerMP.getDisplayName())) {
            DimensionInformation information = dimensionManager.getDimensionInformation(dim);
            information.setOwner(playerName, entityPlayerMP.getGameProfile().getId());
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Owner of dimension changed!"));
            dimensionManager.save(world);
            return;
        }
    }
    sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Could not find player!"));
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Aggregations

DimensionInformation (mcjty.rftools.dimension.DimensionInformation)35 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)29 World (net.minecraft.world.World)19 ChatComponentText (net.minecraft.util.ChatComponentText)13 DimensionStorage (mcjty.rftools.dimension.DimensionStorage)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)8 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)5 IOException (java.io.IOException)4 DimensionDescriptor (mcjty.rftools.dimension.description.DimensionDescriptor)4 ItemStack (net.minecraft.item.ItemStack)4 File (java.io.File)3 EffectType (mcjty.rftools.dimension.world.types.EffectType)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 Map (java.util.Map)2 Coordinate (mcjty.lib.varia.Coordinate)2 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)2 PacketGetDimensionEnergy (mcjty.rftools.dimension.network.PacketGetDimensionEnergy)2 IMob (net.minecraft.entity.monster.IMob)2