use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager 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.getDimensionId();
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 + ")"));
}
}
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions 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(ModItems.realizedDimensionTabItem, 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;
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager 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.getDimensionId());
if (information != null) {
information.removeProbe();
}
dimensionManager.save(world);
}
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class CmdSetPower method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length > 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
int rf = fetchInt(sender, args, 1, PowerConfiguration.MAX_DIMENSION_POWER);
World world = sender.getEntityWorld();
int dim = world.provider.getDimensionId();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
if (information == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
return;
}
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
storage.setEnergyLevel(dim, rf);
storage.save(world);
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class CmdCreateDimension method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The name and terrain parameters are missing!"));
return;
} else if (args.length > 3) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
String name = fetchString(sender, args, 1, "");
String terrainName = fetchString(sender, args, 2, "Void");
TerrainType terrainType = TerrainType.getTerrainById(terrainName);
if (terrainType == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Unknown terrain type!"));
return;
}
if (!(sender instanceof EntityPlayer)) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "You must be a player to use this command!"));
return;
}
EntityPlayer player = (EntityPlayer) sender;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(sender.getEntityWorld());
List<DimletKey> descriptors = new ArrayList<>();
descriptors.add(new DimletKey(DimletType.DIMLET_TERRAIN, terrainType.getId()));
DimensionDescriptor descriptor = new DimensionDescriptor(descriptors, 0);
int dim = 0;
try {
dim = dimensionManager.createNewDimension(sender.getEntityWorld(), descriptor, name, player.getDisplayName().toString(), player.getPersistentID());
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.GREEN + "Created dimension: " + dim));
dimensionManager.save(sender.getEntityWorld());
}
Aggregations