use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.
the class BedControl method trySleep.
public static boolean trySleep(World world, EntityPlayer player, int x, int y, int z, int meta) {
if (BlockBed.func_149976_c(meta)) {
EntityPlayer entityplayer1 = null;
for (Object playerEntity : world.playerEntities) {
EntityPlayer entityplayer2 = (EntityPlayer) playerEntity;
if (entityplayer2.isPlayerSleeping()) {
ChunkCoordinates chunkcoordinates = entityplayer2.playerLocation;
if (chunkcoordinates.posX == x && chunkcoordinates.posY == y && chunkcoordinates.posZ == z) {
entityplayer1 = entityplayer2;
}
}
}
if (entityplayer1 != null) {
player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.occupied"));
return true;
}
BlockBed.func_149979_a(world, x, y, z, false);
}
EntityPlayer.EnumStatus enumstatus = player.sleepInBedAt(x, y, z);
if (enumstatus == EntityPlayer.EnumStatus.OK) {
BlockBed.func_149979_a(world, x, y, z, true);
RfToolsDimensionManager manager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = manager.getDimensionInformation(world.provider.dimensionId);
if (DimletConfiguration.respawnSameDim || (information != null && information.isRespawnHere())) {
player.addChatComponentMessage(new ChatComponentText("Somehow this place feels more like home now."));
}
return true;
} else {
if (enumstatus == EntityPlayer.EnumStatus.NOT_POSSIBLE_NOW) {
player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.noSleep"));
} else if (enumstatus == EntityPlayer.EnumStatus.NOT_SAFE) {
player.addChatComponentMessage(new ChatComponentTranslation("tile.bed.notSafe"));
}
return true;
}
}
use of mcjty.rftools.dimension.DimensionInformation 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.DimensionInformation in project RFTools by McJty.
the class ActivityProbeBlock method onBlockPlaced.
@Override
public int onBlockPlaced(World world, int x, int y, int z, int side, float sx, float sy, float sz, int meta) {
int rc = super.onBlockPlaced(world, x, y, z, side, sx, sy, sz, meta);
if (!world.isRemote) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
DimensionInformation information = dimensionManager.getDimensionInformation(world.provider.dimensionId);
if (information != null) {
information.addProbe();
}
dimensionManager.save(world);
}
return rc;
}
use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.
the class DimensionEditorTileEntity method safeDeleteDimension.
private void safeDeleteDimension(int id, ItemStack dimensionTab) {
World w = DimensionManager.getWorld(id);
if (w != null) {
// Dimension is still loaded. Do nothing.
Broadcaster.broadcast(worldObj, xCoord, yCoord, zCoord, "Dimension cannot be deleted. It is still in use!", 10);
return;
}
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(worldObj);
DimensionInformation information = dimensionManager.getDimensionInformation(id);
if (information.getOwner() == null) {
Broadcaster.broadcast(worldObj, xCoord, yCoord, zCoord, "You cannot delete a dimension without an owner!", 10);
return;
}
if (getOwnerUUID() == null) {
Broadcaster.broadcast(worldObj, xCoord, yCoord, zCoord, "This machine has no proper owner and cannot delete dimensions!", 10);
return;
}
if (!getOwnerUUID().equals(information.getOwner())) {
Broadcaster.broadcast(worldObj, xCoord, yCoord, zCoord, "This machine's owner differs from the dimensions owner!", 10);
return;
}
TeleportDestinations destinations = TeleportDestinations.getDestinations(worldObj);
destinations.removeDestinationsInDimension(id);
destinations.save(worldObj);
dimensionManager.removeDimension(id);
dimensionManager.reclaimId(id);
dimensionManager.save(worldObj);
DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(worldObj);
dimensionStorage.removeDimension(id);
dimensionStorage.save(worldObj);
if (DimletConfiguration.dimensionFolderIsDeletedWithSafeDel) {
File rootDirectory = DimensionManager.getCurrentSaveRootDirectory();
try {
FileUtils.deleteDirectory(new File(rootDirectory.getPath() + File.separator + "DIM" + id));
Broadcaster.broadcast(worldObj, xCoord, yCoord, zCoord, "Dimension deleted and dimension folder succesfully wiped!", 10);
} catch (IOException e) {
Broadcaster.broadcast(worldObj, xCoord, yCoord, zCoord, "Dimension deleted but dimension folder could not be completely wiped!", 10);
}
} else {
Broadcaster.broadcast(worldObj, xCoord, yCoord, zCoord, "Dimension deleted. Please remove the dimension folder from disk!", 10);
}
dimensionTab.getTagCompound().removeTag("id");
int tickCost = dimensionTab.getTagCompound().getInteger("tickCost");
dimensionTab.getTagCompound().setInteger("ticksLeft", tickCost);
}
use of mcjty.rftools.dimension.DimensionInformation in project RFTools by McJty.
the class DimensionEditorTileEntity method checkStateServer.
@Override
protected void checkStateServer() {
ItemStack injectableItemStack = validateInjectableItemStack();
if (injectableItemStack == null) {
return;
}
ItemStack dimensionItemStack = validateDimensionItemStack();
if (dimensionItemStack == null) {
return;
}
if (ticksLeft == -1) {
// We were not injecting. Start now.
if (isMatterReceiver(injectableItemStack)) {
ticksCost = DimletCosts.baseDimensionTickCost + 1000;
ticksLeft = ticksCost;
rfPerTick = DimletCosts.baseDimensionCreationCost + 200;
} else if (isTNT(injectableItemStack)) {
ticksCost = 600;
ticksLeft = ticksCost;
rfPerTick = 10;
} else {
DimletKey key = KnownDimletConfiguration.getDimletKey(injectableItemStack, worldObj);
DimletEntry dimletEntry = KnownDimletConfiguration.getEntry(key);
ticksCost = DimletCosts.baseDimensionTickCost + dimletEntry.getTickCost();
ticksLeft = ticksCost;
rfPerTick = DimletCosts.baseDimensionCreationCost + dimletEntry.getRfCreateCost();
}
} else {
int rf = getEnergyStored(ForgeDirection.DOWN);
int rfpt = rfPerTick;
rfpt = (int) (rfpt * (2.0f - getInfusedFactor()) / 2.0f);
if (rf >= rfpt) {
// Enough energy.
consumeEnergy(rfpt);
ticksLeft--;
if (ticksLeft <= 0) {
RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(worldObj);
ItemStack dimensionTab = validateDimensionItemStack();
NBTTagCompound tagCompound = dimensionTab.getTagCompound();
int id = tagCompound.getInteger("id");
injectableItemStack = validateInjectableItemStack();
if (isMatterReceiver(injectableItemStack)) {
World dimWorld = dimensionManager.getWorldForDimension(id);
int y = findGoodReceiverLocation(dimWorld);
if (y == -1) {
y = dimWorld.getHeight() / 2;
}
dimWorld.setBlock(8, y, 8, TeleporterSetup.matterReceiverBlock, 0, 2);
TeleporterSetup.matterReceiverBlock.onBlockPlaced(dimWorld, 8, y, 8, 0, 0, 0, 0, 0);
TeleporterSetup.matterReceiverBlock.onBlockPlacedBy(dimWorld, 8, y, 8, null, injectableItemStack);
dimWorld.setBlockToAir(8, y + 1, 8);
dimWorld.setBlockToAir(8, y + 2, 8);
} else if (isTNT(injectableItemStack)) {
safeDeleteDimension(id, dimensionTab);
} else {
DimletKey key = KnownDimletConfiguration.getDimletKey(injectableItemStack, worldObj);
DimensionInformation information = dimensionManager.getDimensionInformation(id);
information.injectDimlet(key);
dimensionManager.save(worldObj);
}
inventoryHelper.decrStackSize(DimensionEditorContainer.SLOT_INJECTINPUT, 1);
stopInjecting();
}
}
}
markDirty();
setState();
}
Aggregations