use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.
the class DimensionMonitorItem method getIconIndex.
@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];
}
use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.
the class DimensionMonitorItem method addInformation.
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) {
super.addInformation(itemStack, player, list, whatIsThis);
int id = player.worldObj.provider.dimensionId;
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(player.worldObj);
DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
if (dimensionInformation == null) {
list.add("Not an RFTools dimension!");
} else {
if (System.currentTimeMillis() - lastTime > 500) {
lastTime = System.currentTimeMillis();
RFToolsMessages.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
}
String name = dimensionInformation.getName();
DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
int power = storage != null ? storage.getEnergyLevel(id) : 0;
list.add(EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")");
list.add(EnumChatFormatting.YELLOW + "Power: " + power + " RF");
}
}
use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.
the class GenericWorldProvider method getRespawnDimension.
@Override
public int getRespawnDimension(EntityPlayerMP player) {
getDimensionInformation();
if (DimletConfiguration.respawnSameDim || (dimensionInformation != null && dimensionInformation.isRespawnHere())) {
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(worldObj);
int power = dimensionStorage.getEnergyLevel(dimensionId);
if (power < 1000) {
return DimletConfiguration.spawnDimension;
} else {
return dimensionId;
}
}
return DimletConfiguration.spawnDimension;
}
use of mcjty.rftools.dimension.DimensionStorage in project RFTools 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, DimletConfiguration.MAX_DIMENSION_POWER);
World world = sender.getEntityWorld();
int 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;
}
DimensionStorage storage = DimensionStorage.getDimensionStorage(world);
storage.setEnergyLevel(dim, rf);
storage.save(world);
}
use of mcjty.rftools.dimension.DimensionStorage in project RFTools by McJty.
the class PacketGetDimensionEnergy method onMessage.
@Override
public PacketReturnEnergy onMessage(PacketGetDimensionEnergy message, MessageContext ctx) {
World world = ctx.getServerHandler().playerEntity.worldObj;
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
return new PacketReturnEnergy(message.dimension, dimensionStorage.getEnergyLevel(message.dimension));
}
Aggregations