Search in sources :

Example 21 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class GenericWorldGenerator method generate.

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
    RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(world);
    if (manager.getDimensionDescriptor(world.provider.getDimension()) == null) {
        // Not an RFTools dimension
        return;
    }
    DimensionInformation information = manager.getDimensionInformation(world.provider.getDimension());
    IBlockState baseBlock = information.getBaseBlockForTerrain();
    if (information.hasFeatureType(FeatureType.FEATURE_OREGEN)) {
        for (IBlockState block : information.getExtraOregen()) {
            addOreSpawn(block, baseBlock, world, random, chunkX * 16, chunkZ * 16, 7, 10, 12, 2, 60);
        }
    }
    Block dimensionalShardBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation("rftools", "dimensional_shard_ore"));
    addOreSpawn(dimensionalShardBlock.getDefaultState(), Blocks.STONE.getDefaultState(), world, random, chunkX * 16, chunkZ * 16, WorldgenConfiguration.oreMinimumVeinSize, WorldgenConfiguration.oreMaximumVeinSize, WorldgenConfiguration.oreMaximumVeinCount, WorldgenConfiguration.oreMinimumHeight, WorldgenConfiguration.oreMaximumHeight);
    if (information.isPatreonBitSet(PatreonType.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(WorldgenConfiguration.dungeonChance) == 1) {
            generateDimletDungeon(random, chunkX, chunkZ, world);
        }
    }
    if ((Math.abs(chunkX) >= 2 || Math.abs(chunkZ) >= 2) && information.isPatreonBitSet(PatreonType.PATREON_COLOREDPRISMS)) {
        if (random.nextInt(10) == 1) {
            generatePrism(chunkX, chunkZ, world);
        }
    }
    if ((Math.abs(chunkX) >= 1 || Math.abs(chunkZ) >= 1) && information.isPatreonBitSet(PatreonType.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(WorldgenConfiguration.volcanoChance) == 1) {
            generateVolcano(random, chunkX, chunkZ, world);
        }
    }
    if (information.getTerrainType() == TerrainType.TERRAIN_LOSTCITIES) {
        generateLootSpawners(random, chunkX, chunkZ, world);
        generateVines(random, chunkX, chunkZ, world);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ResourceLocation(net.minecraft.util.ResourceLocation) BaseBlock(mcjty.lib.container.BaseBlock) Block(net.minecraft.block.Block) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 22 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class EssencePainterTileEntity method setName.

private void setName(String name) {
    ItemStack realizedTab = inventoryHelper.getStackInSlot(EssencePainterContainer.SLOT_TAB);
    if (realizedTab != null) {
        NBTTagCompound tagCompound = realizedTab.getTagCompound();
        if (tagCompound == null) {
            tagCompound = new NBTTagCompound();
            realizedTab.setTagCompound(tagCompound);
        }
        tagCompound.setString("name", name);
        if (tagCompound.hasKey("id")) {
            Integer id = tagCompound.getInteger("id");
            RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(getWorld());
            DimensionInformation information = dimensionManager.getDimensionInformation(id);
            if (information != null) {
                information.setName(name);
                dimensionManager.save(getWorld());
            }
        }
        markDirty();
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 23 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class ActivityProbeBlock method breakBlock.

@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    super.breakBlock(world, pos, state);
    if (!world.isRemote) {
        RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
        DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.getDimension());
        if (information != null) {
            information.removeProbe();
        }
        dimensionManager.save(world);
    }
}
Also used : DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)

Example 24 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class CmdListDimensions method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    WorldServer[] worlds = DimensionManager.getWorlds();
    for (WorldServer world : worlds) {
        int id = world.provider.getDimension();
        String dimName = world.provider.getDimensionType().getName();
        ITextComponent component = new TextComponentString("    Loaded: id:" + id + ", " + dimName);
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
    }
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(sender.getEntityWorld());
    DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(sender.getEntityWorld());
    for (Map.Entry<Integer, DimensionDescriptor> me : dimensionManager.getDimensions().entrySet()) {
        int id = me.getKey();
        DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
        String dimName = dimensionInformation.getName();
        int energy = dimensionStorage.getEnergyLevel(id);
        String ownerName = dimensionInformation.getOwnerName();
        if (ownerName != null && !ownerName.isEmpty()) {
            ITextComponent component = new TextComponentString("    RfTools: id:" + id + ", " + dimName + " (power " + energy + ") (owner " + ownerName + ")");
            if (sender instanceof EntityPlayer) {
                ((EntityPlayer) sender).sendStatusMessage(component, false);
            } else {
                sender.sendMessage(component);
            }
        } else {
            ITextComponent component = new TextComponentString("    RfTools: id:" + id + ", " + dimName + " (power " + energy + ")");
            if (sender instanceof EntityPlayer) {
                ((EntityPlayer) sender).sendStatusMessage(component, false);
            } else {
                sender.sendMessage(component);
            }
        }
    }
}
Also used : ITextComponent(net.minecraft.util.text.ITextComponent) WorldServer(net.minecraft.world.WorldServer) TextComponentString(net.minecraft.util.text.TextComponentString) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) TextComponentString(net.minecraft.util.text.TextComponentString) DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) DimensionDescriptor(mcjty.rftoolsdim.dimensions.description.DimensionDescriptor) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Map(java.util.Map) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation)

Example 25 with DimensionInformation

use of mcjty.rftoolsdim.dimensions.DimensionInformation in project RFToolsDimensions by McJty.

the class CmdSetPower method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 2) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    int rf = fetchInt(sender, args, 1, PowerConfiguration.MAX_DIMENSION_POWER);
    World world = sender.getEntityWorld();
    int dim = world.provider.getDimension();
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information == null) {
        ITextComponent component = new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!");
        if (sender instanceof EntityPlayer) {
            ((EntityPlayer) sender).sendStatusMessage(component, false);
        } else {
            sender.sendMessage(component);
        }
        return;
    }
    DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
    storage.setEnergyLevel(dim, rf);
    storage.save(world);
}
Also used : DimensionStorage(mcjty.rftoolsdim.dimensions.DimensionStorage) ITextComponent(net.minecraft.util.text.ITextComponent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) DimensionInformation(mcjty.rftoolsdim.dimensions.DimensionInformation) RfToolsDimensionManager(mcjty.rftoolsdim.dimensions.RfToolsDimensionManager) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

DimensionInformation (mcjty.rftoolsdim.dimensions.DimensionInformation)34 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)21 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)12 DimensionStorage (mcjty.rftoolsdim.dimensions.DimensionStorage)11 World (net.minecraft.world.World)10 ItemStack (net.minecraft.item.ItemStack)8 DimensionDescriptor (mcjty.rftoolsdim.dimensions.description.DimensionDescriptor)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 ITextComponent (net.minecraft.util.text.ITextComponent)5 TextComponentString (net.minecraft.util.text.TextComponentString)5 IOException (java.io.IOException)4 GenericWorldProvider (mcjty.rftoolsdim.dimensions.world.GenericWorldProvider)4 PacketGetDimensionEnergy (mcjty.rftoolsdim.network.PacketGetDimensionEnergy)4 IBlockState (net.minecraft.block.state.IBlockState)4 PacketBuffer (net.minecraft.network.PacketBuffer)4 ActionResult (net.minecraft.util.ActionResult)4 EnumActionResult (net.minecraft.util.EnumActionResult)4 WorldProvider (net.minecraft.world.WorldProvider)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 Map (java.util.Map)3