use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class DimensionMonitorItem method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (!world.isRemote) {
int id = player.worldObj.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.worldObj);
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
if (dimensionInformation == null) {
Logging.message(player, "Not an RFTools dimension!");
} else {
String name = dimensionInformation.getName();
DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
int power = storage != null ? storage.getEnergyLevel(id) : 0;
Logging.message(player, EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")" + EnumChatFormatting.YELLOW + " Power: " + power + " RF");
if (player.isSneaking()) {
Logging.message(player, EnumChatFormatting.RED + "Description: " + dimensionInformation.getDescriptor().getDescriptionString());
System.out.println("Description: = " + dimensionInformation.getDescriptor().getDescriptionString());
}
}
return stack;
}
return stack;
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class FMLEventHandlers method onPlayerLoggedIn.
@SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
Logging.log("SMP: Player logged in: Sync diminfo to clients");
EntityPlayer player = event.player;
RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld());
manager.syncDimInfoToClients(player.getEntityWorld());
manager.checkDimletConfig(player);
}
use of mcjty.rftools.dimension.RfToolsDimensionManager 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;
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class CmdSaveDims method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The directory parameters is missing!"));
return;
} else if (args.length > 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
String directory = fetchString(sender, args, 1, null);
if (!directory.endsWith(File.separator)) {
directory += File.separator;
}
if (!new File(directory).mkdirs()) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Failed to create directory!"));
return;
}
World world = sender.getEntityWorld();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
for (Integer dim : dimensionManager.getDimensions().keySet()) {
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
if (information != null) {
String filename = directory + "dimension" + dim;
String error = information.buildJson(filename);
if (error != null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Error: " + error));
}
}
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class CmdInfo method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
int dim = 0;
World world = sender.getEntityWorld();
if (args.length == 2) {
dim = fetchInt(sender, args, 1, 0);
} else if (args.length > 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
} else {
dim = world.provider.dimensionId;
}
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(dim);
if (information == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
return;
}
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Dimension ID " + dim));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Description string " + information.getDescriptor().getDescriptionString()));
String ownerName = information.getOwnerName();
if (ownerName != null && !ownerName.isEmpty()) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Owned by: " + ownerName));
}
if (sender instanceof EntityPlayer) {
information.dump((EntityPlayer) sender);
}
}
Aggregations