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);
}
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);
}
}
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);
}
}
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"));
}
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!"));
}
}
Aggregations