use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class DimensionEnscriberTileEntity method setName.
private void setName(String name) {
ItemStack realizedTab = inventoryHelper.getStackInSlot(DimensionEnscriberContainer.SLOT_TAB);
if (realizedTab != null) {
NBTTagCompound tagCompound = realizedTab.getTagCompound();
if (tagCompound == null) {
tagCompound = new NBTTagCompound();
realizedTab.setTagCompound(tagCompound);
}
tagCompound.setString("name", name);
if (tagCompound.hasKey("id")) {
Integer id = tagCompound.getInteger("id");
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(worldObj);
DimensionInformation information = dimensionManager.getDimensionInformation(id);
if (information != null) {
information.setName(name);
dimensionManager.save(worldObj);
}
}
markDirty();
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools 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(DimletSetup.realizedDimensionTab, 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.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class ActivityProbeBlock method breakBlock.
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
super.breakBlock(world, x, y, z, block, meta);
if (!world.isRemote) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.dimensionId);
if (information != null) {
information.removeProbe();
}
dimensionManager.save(world);
}
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class DialingDeviceTileEntity method checkStatus.
// Server side only
private int checkStatus(Coordinate c, int dim) {
int cost = TeleportConfiguration.rfPerCheck;
cost = (int) (cost * (2.0f - getInfusedFactor()) / 2.0f);
if (getEnergyStored(ForgeDirection.DOWN) < cost) {
return DialingDeviceTileEntity.DIAL_DIALER_POWER_LOW_MASK;
}
consumeEnergy(cost);
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(worldObj);
World w = dimensionManager.getWorldForDimension(dim);
if (w == null) {
TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
destinations.cleanupInvalid(worldObj);
return DialingDeviceTileEntity.DIAL_INVALID_DESTINATION_MASK;
}
TileEntity tileEntity = w.getTileEntity(c.getX(), c.getY(), c.getZ());
if (!(tileEntity instanceof MatterReceiverTileEntity)) {
TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
destinations.cleanupInvalid(worldObj);
return DialingDeviceTileEntity.DIAL_INVALID_DESTINATION_MASK;
}
if (dimensionManager.getDimensionInformation(dim) != null) {
// This is an RFTools dimension. Check power.
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(w);
int energyLevel = dimensionStorage.getEnergyLevel(dim);
if (energyLevel < DimletConfiguration.DIMPOWER_WARN_TP) {
return DialingDeviceTileEntity.DIAL_DIMENSION_POWER_LOW_MASK;
}
}
MatterReceiverTileEntity matterReceiverTileEntity = (MatterReceiverTileEntity) tileEntity;
return matterReceiverTileEntity.checkStatus();
}
use of mcjty.rftools.dimension.RfToolsDimensionManager in project RFTools by McJty.
the class CmdDelDimension method execute.
@Override
public void execute(ICommandSender sender, String[] args) {
if (args.length < 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "The dimension parameters is missing!"));
return;
} else if (args.length > 2) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Too many parameters!"));
return;
}
int dim = fetchInt(sender, args, 1, 0);
World world = sender.getEntityWorld();
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
if (dimensionManager.getDimensionDescriptor(dim) == null) {
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Not an RFTools dimension!"));
return;
}
dimensionManager.removeDimension(dim);
dimensionManager.save(world);
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(world);
dimensionStorage.removeDimension(dim);
dimensionStorage.save(world);
sender.addChatMessage(new ChatComponentText("Dimension deleted."));
}
Aggregations