Search in sources :

Example 6 with DimensionDescriptor

use of mcjty.rftools.dimension.description.DimensionDescriptor in project RFTools by McJty.

the class PacketGetAllReceivers method addRfToolsDimensions.

private void addRfToolsDimensions(World world, List<TeleportDestinationClientInfo> destinationList) {
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    for (Map.Entry<Integer, DimensionDescriptor> me : dimensionManager.getDimensions().entrySet()) {
        int id = me.getKey();
        TeleportDestination destination = new TeleportDestination(new Coordinate(0, 70, 0), id);
        destination.setName("RfTools Dim: " + id);
        TeleportDestinationClientInfo teleportDestinationClientInfo = new TeleportDestinationClientInfo(destination);
        destinationList.add(teleportDestinationClientInfo);
    }
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) Coordinate(mcjty.lib.varia.Coordinate) TeleportDestinationClientInfo(mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo) Map(java.util.Map) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager) TeleportDestination(mcjty.rftools.blocks.teleporter.TeleportDestination)

Example 7 with DimensionDescriptor

use of mcjty.rftools.dimension.description.DimensionDescriptor in project RFTools 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.dimensionId;
        String dimName = world.provider.getDimensionName();
        sender.addChatMessage(new ChatComponentText("    Loaded: id:" + id + ", " + dimName));
    }
    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()) {
            sender.addChatMessage(new ChatComponentText("    RfTools: id:" + id + ", " + dimName + " (power " + energy + ") (owner " + ownerName + ")"));
        } else {
            sender.addChatMessage(new ChatComponentText("    RfTools: id:" + id + ", " + dimName + " (power " + energy + ")"));
        }
    }
}
Also used : DimensionStorage(mcjty.rftools.dimension.DimensionStorage) DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) WorldServer(net.minecraft.world.WorldServer) ChatComponentText(net.minecraft.util.ChatComponentText) Map(java.util.Map) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 8 with DimensionDescriptor

use of mcjty.rftools.dimension.description.DimensionDescriptor in project RFTools by McJty.

the class DimensionBuilderTileEntity method createDimensionTick.

private int createDimensionTick(NBTTagCompound tagCompound, int ticksLeft) {
    if (DimletConfiguration.dimensionBuilderNeedsOwner) {
        if (getOwnerUUID() == null) {
            // No valid owner so we don't build the dimension.
            errorMode = ERROR_NOOWNER;
            return ticksLeft;
        }
        if (DimletConfiguration.maxDimensionsPerPlayer >= 0) {
            int tickCost = tagCompound.getInteger("tickCost");
            if (ticksLeft == tickCost || ticksLeft < 5) {
                // Check if we are allow to make the dimension.
                RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(worldObj);
                int cnt = manager.countOwnedDimensions(getOwnerUUID());
                if (cnt >= DimletConfiguration.maxDimensionsPerPlayer) {
                    errorMode = ERROR_TOOMANYDIMENSIONS;
                    return ticksLeft;
                }
            }
        }
    }
    errorMode = OK;
    int createCost = tagCompound.getInteger("rfCreateCost");
    createCost = (int) (createCost * (2.0f - getInfusedFactor()) / 2.0f);
    if (isCreative() || (getEnergyStored(ForgeDirection.DOWN) >= createCost)) {
        if (isCreative()) {
            ticksLeft = 0;
        } else {
            consumeEnergy(createCost);
            ticksLeft--;
            if (random.nextFloat() < getInfusedFactor()) {
                // Randomly reduce another tick if the device is infused.
                ticksLeft--;
                if (ticksLeft < 0) {
                    ticksLeft = 0;
                }
            }
        }
        tagCompound.setInteger("ticksLeft", ticksLeft);
        if (ticksLeft <= 0) {
            RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(worldObj);
            DimensionDescriptor descriptor = new DimensionDescriptor(tagCompound);
            String name = tagCompound.getString("name");
            int id = manager.createNewDimension(worldObj, descriptor, name, getOwnerName(), getOwnerUUID());
            tagCompound.setInteger("id", id);
        }
    }
    return ticksLeft;
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 9 with DimensionDescriptor

use of mcjty.rftools.dimension.description.DimensionDescriptor in project RFTools by McJty.

the class RfToolsDimensionManager method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound tagCompound) {
    NBTTagList lst = new NBTTagList();
    for (Map.Entry<Integer, DimensionDescriptor> me : dimensions.entrySet()) {
        NBTTagCompound tc = new NBTTagCompound();
        Integer id = me.getKey();
        tc.setInteger("id", id);
        me.getValue().writeToNBT(tc);
        DimensionInformation dimensionInfo = dimensionInformation.get(id);
        dimensionInfo.writeToNBT(tc);
        lst.appendTag(tc);
    }
    tagCompound.setTag("dimensions", lst);
    List<Integer> ids = new ArrayList<Integer>(reclaimedIds);
    int[] lstIds = new int[ids.size()];
    for (int i = 0; i < ids.size(); i++) {
        lstIds[i] = ids.get(i);
    }
    tagCompound.setIntArray("reclaimedIds", lstIds);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 10 with DimensionDescriptor

use of mcjty.rftools.dimension.description.DimensionDescriptor in project RFTools by McJty.

the class RfToolsDimensionManager method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tagCompound) {
    dimensions.clear();
    dimensionToID.clear();
    dimensionInformation.clear();
    reclaimedIds.clear();
    NBTTagList lst = tagCompound.getTagList("dimensions", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < lst.tagCount(); i++) {
        NBTTagCompound tc = lst.getCompoundTagAt(i);
        int id = tc.getInteger("id");
        DimensionDescriptor descriptor = new DimensionDescriptor(tc);
        dimensions.put(id, descriptor);
        dimensionToID.put(descriptor, id);
        DimensionInformation dimensionInfo = new DimensionInformation(descriptor, tc);
        dimensionInformation.put(id, dimensionInfo);
    }
    int[] lstIds = tagCompound.getIntArray("reclaimedIds");
    for (int id : lstIds) {
        reclaimedIds.add(id);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

DimensionDescriptor (mcjty.rftools.dimension.description.DimensionDescriptor)15 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)5 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)4 ItemStack (net.minecraft.item.ItemStack)4 Map (java.util.Map)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 NBTTagList (net.minecraft.nbt.NBTTagList)3 ChatComponentText (net.minecraft.util.ChatComponentText)3 World (net.minecraft.world.World)3 IOException (java.io.IOException)2 Coordinate (mcjty.lib.varia.Coordinate)2 PacketBuffer (net.minecraft.network.PacketBuffer)2 WorldServer (net.minecraft.world.WorldServer)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 TeleportDestination (mcjty.rftools.blocks.teleporter.TeleportDestination)1 TeleportDestinationClientInfo (mcjty.rftools.blocks.teleporter.TeleportDestinationClientInfo)1 DimensionStorage (mcjty.rftools.dimension.DimensionStorage)1