Search in sources :

Example 1 with RfToolsDimensionManager

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

the class DimensionEnscriberTileEntity method setName.

private void setName(String name) {
    ItemStack realizedTab = inventoryHelper.getStackInSlot(DimensionEnscriberContainer.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(worldObj);
            DimensionInformation information = dimensionManager.getDimensionInformation(id);
            if (information != null) {
                information.setName(name);
                dimensionManager.save(worldObj);
            }
        }
        markDirty();
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 2 with RfToolsDimensionManager

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

the class DimensionEnscriberTileEntity method createRealizedTab.

/**
 * Create a realized dimension tab by taking a map of ids per type and storing
 * that in the NBT of the realized dimension tab.
 */
public static ItemStack createRealizedTab(DimensionDescriptor descriptor, World world) {
    ItemStack realizedTab = new ItemStack(DimletSetup.realizedDimensionTab, 1, 0);
    NBTTagCompound tagCompound = new NBTTagCompound();
    descriptor.writeToNBT(tagCompound);
    // Check if the dimension already exists and if so set the progress to 100%.
    RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(world);
    Integer id = manager.getDimensionID(descriptor);
    if (id != null) {
        // The dimension was already created.
        tagCompound.setInteger("ticksLeft", 0);
        tagCompound.setInteger("id", id);
    }
    realizedTab.setTagCompound(tagCompound);
    return realizedTab;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 3 with RfToolsDimensionManager

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

the class ActivityProbeBlock method breakBlock.

@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
    super.breakBlock(world, x, y, z, block, meta);
    if (!world.isRemote) {
        RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
        DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.dimensionId);
        if (information != null) {
            information.removeProbe();
        }
        dimensionManager.save(world);
    }
}
Also used : DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 4 with RfToolsDimensionManager

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

the class DialingDeviceTileEntity method checkStatus.

// Server side only
private int checkStatus(Coordinate c, int dim) {
    int cost = TeleportConfiguration.rfPerCheck;
    cost = (int) (cost * (2.0f - getInfusedFactor()) / 2.0f);
    if (getEnergyStored(ForgeDirection.DOWN) < cost) {
        return DialingDeviceTileEntity.DIAL_DIALER_POWER_LOW_MASK;
    }
    consumeEnergy(cost);
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(worldObj);
    World w = dimensionManager.getWorldForDimension(dim);
    if (w == null) {
        TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
        destinations.cleanupInvalid(worldObj);
        return DialingDeviceTileEntity.DIAL_INVALID_DESTINATION_MASK;
    }
    TileEntity tileEntity = w.getTileEntity(c.getX(), c.getY(), c.getZ());
    if (!(tileEntity instanceof MatterReceiverTileEntity)) {
        TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
        destinations.cleanupInvalid(worldObj);
        return DialingDeviceTileEntity.DIAL_INVALID_DESTINATION_MASK;
    }
    if (dimensionManager.getDimensionInformation(dim) != null) {
        // This is an RFTools dimension. Check power.
        DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(w);
        int energyLevel = dimensionStorage.getEnergyLevel(dim);
        if (energyLevel < DimletConfiguration.DIMPOWER_WARN_TP) {
            return DialingDeviceTileEntity.DIAL_DIMENSION_POWER_LOW_MASK;
        }
    }
    MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) tileEntity;
    return matterReceiverTileEntity.checkStatus();
}
Also used : GenericEnergyReceiverTileEntity(mcjty.lib.entity.GenericEnergyReceiverTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) DimensionStorage(mcjty.rftools.dimension.DimensionStorage) World(net.minecraft.world.World) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 5 with RfToolsDimensionManager

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

the class CmdDelDimension method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameters is missing!"));
        return;
    } else if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    int dim = fetchInt(sender, args, 1, 0);
    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;
    }
    dimensionManager.removeDimension(dim);
    dimensionManager.save(world);
    DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
    dimensionStorage.removeDimension(dim);
    dimensionStorage.save(world);
    sender.addChatMessage(new ChatComponentText("Dimension deleted."));
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) World(net.minecraft.world.World) ChatComponentText(net.minecraft.util.ChatComponentText) 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