use of mcjty.rftools.dimension.description.DimensionDescriptor in project RFTools by McJty.
the class PacketGetAllReceivers method addRfToolsDimensions.
private void addRfToolsDimensions(World world, List<TeleportDestinationClientInfo> destinationList) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
for (Map.Entry<Integer, DimensionDescriptor> me : dimensionManager.getDimensions().entrySet()) {
int id = me.getKey();
TeleportDestination destination = new TeleportDestination(new Coordinate(0, 70, 0), id);
destination.setName("RfTools Dim: " + id);
TeleportDestinationClientInfo teleportDestinationClientInfo = new TeleportDestinationClientInfo(destination);
destinationList.add(teleportDestinationClientInfo);
}
}
use of mcjty.rftools.dimension.description.DimensionDescriptor in project RFTools 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.dimensionId;
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.rftools.dimension.description.DimensionDescriptor 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.description.DimensionDescriptor in project RFTools by McJty.
the class RfToolsDimensionManager method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound tagCompound) {
NBTTagList lst = new NBTTagList();
for (Map.Entry<Integer, DimensionDescriptor> me : dimensions.entrySet()) {
NBTTagCompound tc = new NBTTagCompound();
Integer id = me.getKey();
tc.setInteger("id", id);
me.getValue().writeToNBT(tc);
DimensionInformation dimensionInfo = dimensionInformation.get(id);
dimensionInfo.writeToNBT(tc);
lst.appendTag(tc);
}
tagCompound.setTag("dimensions", lst);
List<Integer> ids = new ArrayList<Integer>(reclaimedIds);
int[] lstIds = new int[ids.size()];
for (int i = 0; i < ids.size(); i++) {
lstIds[i] = ids.get(i);
}
tagCompound.setIntArray("reclaimedIds", lstIds);
}
use of mcjty.rftools.dimension.description.DimensionDescriptor in project RFTools by McJty.
the class RfToolsDimensionManager method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
dimensions.clear();
dimensionToID.clear();
dimensionInformation.clear();
reclaimedIds.clear();
NBTTagList lst = tagCompound.getTagList("dimensions", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < lst.tagCount(); i++) {
NBTTagCompound tc = lst.getCompoundTagAt(i);
int id = tc.getInteger("id");
DimensionDescriptor descriptor = new DimensionDescriptor(tc);
dimensions.put(id, descriptor);
dimensionToID.put(descriptor, id);
DimensionInformation dimensionInfo = new DimensionInformation(descriptor, tc);
dimensionInformation.put(id, dimensionInfo);
}
int[] lstIds = tagCompound.getIntArray("reclaimedIds");
for (int id : lstIds) {
reclaimedIds.add(id);
}
}
Aggregations