Search in sources :

Example 11 with DimensionDescriptor

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

the class RfToolsDimensionManager method removeDimension.

public void removeDimension(int id) {
    DimensionDescriptor descriptor = dimensions.get(id);
    dimensions.remove(id);
    dimensionToID.remove(descriptor);
    dimensionInformation.remove(id);
    if (DimensionManager.isDimensionRegistered(id)) {
        DimensionManager.unregisterDimension(id);
    }
    DimensionManager.unregisterProviderType(id);
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor)

Example 12 with DimensionDescriptor

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

the class PacketSyncDimensionInfo method fromBytes.

@Override
public void fromBytes(ByteBuf buf) {
    int size = buf.readInt();
    dimensions = new HashMap<Integer, DimensionDescriptor>();
    for (int i = 0; i < size; i++) {
        int id = buf.readInt();
        PacketBuffer buffer = new PacketBuffer(buf);
        NBTTagCompound tagCompound;
        try {
            tagCompound = buffer.readNBTTagCompoundFromBuffer();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        DimensionDescriptor descriptor = new DimensionDescriptor(tagCompound);
        dimensions.put(id, descriptor);
    }
    size = buf.readInt();
    dimensionInformation = new HashMap<Integer, DimensionInformation>();
    for (int i = 0; i < size; i++) {
        int id = buf.readInt();
        String name = NetworkTools.readString(buf);
        DimensionInformation dimInfo = new DimensionInformation(name, dimensions.get(id), buf);
        dimensionInformation.put(id, dimInfo);
    }
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IOException(java.io.IOException) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) PacketBuffer(net.minecraft.network.PacketBuffer)

Example 13 with DimensionDescriptor

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

the class PacketSyncDimensionInfo method toBytes.

@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(dimensions.size());
    for (Map.Entry<Integer, DimensionDescriptor> me : dimensions.entrySet()) {
        buf.writeInt(me.getKey());
        NBTTagCompound tagCompound = new NBTTagCompound();
        me.getValue().writeToNBT(tagCompound);
        PacketBuffer buffer = new PacketBuffer(buf);
        try {
            buffer.writeNBTTagCompoundToBuffer(tagCompound);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    buf.writeInt(dimensionInformation.size());
    for (Map.Entry<Integer, DimensionInformation> me : dimensionInformation.entrySet()) {
        buf.writeInt(me.getKey());
        DimensionInformation dimInfo = me.getValue();
        NetworkTools.writeString(buf, dimInfo.getName());
        dimInfo.toBytes(buf);
    }
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) PacketBuffer(net.minecraft.network.PacketBuffer)

Example 14 with DimensionDescriptor

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

the class CmdRecover method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length > 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
        return;
    }
    World world = sender.getEntityWorld();
    ItemStack heldItem = null;
    String playerName = null;
    UUID playerUUID = null;
    if (sender instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) sender;
        heldItem = player.getHeldItem();
        playerName = player.getDisplayName();
        playerUUID = player.getGameProfile().getId();
    }
    if (heldItem == null || heldItem.getItem() != DimletSetup.realizedDimensionTab) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You need to hold a realized dimension tab in your hand!"));
        return;
    }
    int specifiedDim = -1;
    if (args.length == 2) {
        specifiedDim = fetchInt(sender, args, 1, -1);
    }
    NBTTagCompound tagCompound = heldItem.getTagCompound();
    int dim = tagCompound.getInteger("id");
    if ((!tagCompound.hasKey("id")) || dim == 0 || dim == -1) {
        if (specifiedDim == -1) {
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension id is missing from the tab!"));
            sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You can specify a dimension id manually"));
            return;
        } else {
            dim = specifiedDim;
        }
    }
    RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
    DimensionInformation information = dimensionManager.getDimensionInformation(dim);
    if (information != null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension information is already present!"));
        return;
    }
    if (DimensionManager.isDimensionRegistered(dim)) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This dimension is already registered!"));
        return;
    }
    DimensionDescriptor descriptor = new DimensionDescriptor(tagCompound);
    String name = tagCompound.getString("name");
    dimensionManager.recoverDimension(world, dim, descriptor, name, playerName, playerUUID);
    sender.addChatMessage(new ChatComponentText("Dimension was succesfully recovered"));
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID) ChatComponentText(net.minecraft.util.ChatComponentText) DimensionInformation(mcjty.rftools.dimension.DimensionInformation) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

Example 15 with DimensionDescriptor

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

the class CmdCreateTab method execute.

@Override
public void execute(ICommandSender sender, String[] args) {
    if (args.length < 2) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameter 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);
    DimensionDescriptor dimensionDescriptor = dimensionManager.getDimensionDescriptor(dim);
    if (dimensionDescriptor == null) {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
        return;
    }
    if (sender instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) sender;
        ItemStack tab = DimensionEnscriberTileEntity.createRealizedTab(dimensionDescriptor, sender.getEntityWorld());
        InventoryHelper.mergeItemStack(player.inventory, false, tab, 0, 35, null);
    } else {
        sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This command only works as a player!"));
    }
}
Also used : DimensionDescriptor(mcjty.rftools.dimension.description.DimensionDescriptor) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) RfToolsDimensionManager(mcjty.rftools.dimension.RfToolsDimensionManager)

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