use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class CmdCreateTab method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 2) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "The dimension parameter is missing!"));
return;
} else if (args.length > 2) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.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) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.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 {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "This command only works as a player!"));
}
}
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.getDimension();
String dimName = world.provider.getDimensionType().getName();
ChatTools.addChatMessage(sender, new TextComponentString(" 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()) {
ChatTools.addChatMessage(sender, new TextComponentString(" RfTools: id:" + id + ", " + dimName + " (power " + energy + ") (owner " + ownerName + ")"));
} else {
ChatTools.addChatMessage(sender, new TextComponentString(" RfTools: id:" + id + ", " + dimName + " (power " + energy + ")"));
}
}
}
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) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Too many parameters!"));
return;
}
int rf = fetchInt(sender, args, 1, PowerConfiguration.MAX_DIMENSION_POWER);
World world = sender.getEntityWorld();
int dim = world.provider.getDimension();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
if (information == null) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.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 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.getDimension());
if (information != null) {
information.removeProbe();
}
dimensionManager.save(world);
}
}
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;
}
Aggregations