Search in sources :

Example 11 with RfToolsDimensionManager

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

the class RealizedDimensionTab method onItemRightClick.

@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if ((!world.isRemote) && player.isSneaking()) {
        NBTTagCompound tagCompound = stack.getTagCompound();
        Logging.message(player, tagCompound.getString("descriptionString"));
        int id = tagCompound.getInteger("id");
        if (id != 0) {
            RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
            DimensionInformation information = dimensionManager.getDimensionInformation(id);
            if (information != null) {
                information.dump(player);
            }
        }
    }
    return stack;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 12 with RfToolsDimensionManager

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

the class DimensionMonitorItem method addInformation.

@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    int id = player.worldObj.provider.dimensionId;
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.worldObj);
    DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
    if (dimensionInformation == null) {
        list.add("Not an RFTools dimension!");
    } else {
        if (System.currentTimeMillis() - lastTime > 500) {
            lastTime = System.currentTimeMillis();
            RFToolsMessages.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
        }
        String name = dimensionInformation.getName();
        DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
        int power = storage != null ? storage.getEnergyLevel(id) : 0;
        list.add(EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
        list.add(EnumChatFormatting.YELLOW + "Power: " + power + " RF");
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) PacketGetDimensionEnergy(mcjty.rftools.dimension.network.PacketGetDimensionEnergy)

Example 13 with RfToolsDimensionManager

use of mcjty.rftools.dimension.RfToolsDimensionManager 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 14 with RfToolsDimensionManager

use of mcjty.rftools.dimension.RfToolsDimensionManager 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 15 with RfToolsDimensionManager

use of mcjty.rftools.dimension.RfToolsDimensionManager 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)

Aggregations

RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)43 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)29 World (net.minecraft.world.World)27 ChatComponentText (net.minecraft.util.ChatComponentText)16 DimensionStorage (mcjty.rftools.dimension.DimensionStorage)11 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)9 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 DimensionDescriptor (mcjty.rftools.dimension.description.DimensionDescriptor)5 ItemStack (net.minecraft.item.ItemStack)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 File (java.io.File)3 Coordinate (mcjty.lib.varia.Coordinate)3 EffectType (mcjty.rftools.dimension.world.types.EffectType)3 IOException (java.io.IOException)2 Map (java.util.Map)2 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)2 GlobalCoordinate (mcjty.lib.varia.GlobalCoordinate)2 TeleportDestinations (mcjty.rftools.blocks.teleporter.TeleportDestinations)2 IMob (net.minecraft.entity.monster.IMob)2 IAnimals (net.minecraft.entity.passive.IAnimals)2