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) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Too many parameters!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
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) {
ITextComponent component = new TextComponentString(TextFormatting.RED + "Not an RFTools dimension!");
if (sender instanceof EntityPlayer) {
((EntityPlayer) sender).sendStatusMessage(component, false);
} else {
sender.sendMessage(component);
}
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 ForgeEventHandlers 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.syncDimletRules(player);
}
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 DimensionMonitorItem method addInformation.
// @SideOnly(Side.CLIENT)
// @Override
// public IIcon getIconIndex(ItemStack stack) {
// EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
// int id = player.worldObj.provider.dimensionId;
// DimensionStorage storage = DimensionStorage.getDimensionStorage(player.worldObj);
// int energyLevel = storage.getEnergyLevel(id);
// int level = (9*energyLevel) / DimletConfiguration.MAX_DIMENSION_POWER;
// if (level < 0) {
// level = 0;
// } else if (level > 8) {
// level = 8;
// }
// return powerLevel[8-level];
// }
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemStack, World world, List<String> list, ITooltipFlag whatIsThis) {
super.addInformation(itemStack, world, list, whatIsThis);
if (world == null || world.provider == null) {
return;
}
int id = world.provider.getDimension();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManagerClientNullable(world);
DimensionInformation dimensionInformation = dimensionManager == null ? null : dimensionManager.getDimensionInformation(id);
if (dimensionInformation == null) {
list.add("Not an RFTools dimension!");
} else {
if (System.currentTimeMillis() - lastTime > 500) {
lastTime = System.currentTimeMillis();
RFToolsDimMessages.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
}
String name = dimensionInformation.getName();
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
int power = storage != null ? storage.getEnergyLevel(id) : 0;
list.add(TextFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
list.add(TextFormatting.YELLOW + "Power: " + power + " RF");
}
}
use of mcjty.rftoolsdim.dimensions.RfToolsDimensionManager in project RFToolsDimensions by McJty.
the class DimensionMonitorItem method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote) {
int id = player.getEntityWorld().provider.getDimension();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.getEntityWorld());
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, TextFormatting.BLUE + "Name: " + name + " (Id " + id + ")" + TextFormatting.YELLOW + " Power: " + power + " RF");
if (player.isSneaking()) {
Logging.message(player, TextFormatting.RED + "Description: " + dimensionInformation.getDescriptor().getDescriptionString());
System.out.println("Description: = " + dimensionInformation.getDescriptor().getDescriptionString());
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}
Aggregations