use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project MorePlanets by SteveKunG.
the class ChunkGeneratorNibiru method generateOil.
private void generateOil(World world, Random rand, int xx, int zz) {
BlockVec3 pos = new BlockVec3();
if (this.oilPresent(world, rand, xx, zz, pos)) {
int x = pos.x;
int cy = pos.y;
int z = pos.z;
int r = 3 + rand.nextInt(5);
int r2 = r * r;
for (int bx = -r; bx <= r; bx++) {
for (int by = -r + 2; by <= r - 2; by++) {
for (int bz = -r; bz <= r; bz++) {
int d2 = bx * bx + by * by * 3 + bz * bz;
if (d2 <= r2) {
if (this.checkBlockOil(world, bx + x - 1, by + cy, bz + z)) {
continue;
}
if (this.checkBlockOil(world, bx + x + 1, by + cy, bz + z)) {
continue;
}
if (this.checkBlockOil(world, bx + x, by + cy - 1, bz + z)) {
continue;
}
if (this.checkBlockOil(world, bx + x, by + cy, bz + z - 1)) {
continue;
}
if (this.checkBlockOil(world, bx + x, by + cy, bz + z + 1)) {
continue;
}
world.setBlockState(new BlockPos(bx + x, by + cy, bz + z), GCBlocks.crudeOil.getDefaultState(), 2);
}
}
}
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project MorePlanets by SteveKunG.
the class ChunkGeneratorNibiru method generateGas.
private void generateGas(World world, Random rand, int xx, int zz) {
BlockVec3 pos = new BlockVec3();
if (this.gasPresent(world, rand, xx, zz, pos)) {
int x = pos.x;
int cy = pos.y;
int z = pos.z;
int r = 2 + rand.nextInt(2);
int r2 = r * r;
for (int bx = -r; bx <= r; bx++) {
for (int by = -r + 2; by <= r - 2; by++) {
for (int bz = -r; bz <= r; bz++) {
int d2 = bx * bx + by * by * 3 + bz * bz;
if (d2 <= r2) {
if (this.checkBlockGas(world, bx + x - 1, by + cy, bz + z)) {
continue;
}
if (this.checkBlockGas(world, bx + x + 1, by + cy, bz + z)) {
continue;
}
if (this.checkBlockGas(world, bx + x, by + cy - 1, bz + z)) {
continue;
}
if (this.checkBlockGas(world, bx + x, by + cy, bz + z - 1)) {
continue;
}
if (this.checkBlockGas(world, bx + x, by + cy, bz + z + 1)) {
continue;
}
world.setBlockState(new BlockPos(bx + x, by + cy, bz + z), NibiruBlocks.HELIUM_GAS_BLOCK.getDefaultState(), 2);
}
}
}
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class AsteroidsTickHandlerServer method onServerTick.
@SubscribeEvent
public void onServerTick(TickEvent.ServerTickEvent event) {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
// Prevent issues when clients switch to LAN servers
if (server == null) {
return;
}
if (event.phase == TickEvent.Phase.START) {
TileEntityMinerBase.checkNewMinerBases();
if (AsteroidsTickHandlerServer.spaceRaceData == null) {
World world = server.worldServerForDimension(0);
AsteroidsTickHandlerServer.spaceRaceData = (ShortRangeTelepadHandler) world.getMapStorage().loadData(ShortRangeTelepadHandler.class, ShortRangeTelepadHandler.saveDataID);
if (AsteroidsTickHandlerServer.spaceRaceData == null) {
AsteroidsTickHandlerServer.spaceRaceData = new ShortRangeTelepadHandler(ShortRangeTelepadHandler.saveDataID);
world.getMapStorage().setData(ShortRangeTelepadHandler.saveDataID, AsteroidsTickHandlerServer.spaceRaceData);
}
}
int index = -1;
for (EntityAstroMiner miner : activeMiners) {
index++;
if (miner.isDead) {
// minerIt.remove(); Don't remove it, we want the index number to be static for the others
continue;
}
if (miner.playerMP != null) {
GCPlayerStats stats = GCPlayerStats.get(miner.playerMP);
if (stats != null) {
List<BlockVec3> list = stats.getActiveAstroMinerChunks();
boolean inListAlready = false;
Iterator<BlockVec3> it = list.iterator();
while (it.hasNext()) {
BlockVec3 data = it.next();
if (// SideDoneBits won't be saved to NBT, but during an active server session we can use it as a cross-reference to the index here - it's a 4th data int hidden inside a BlockVec3
data.sideDoneBits == index) {
if (miner.isDead) {
// Player stats should not save position of dead AstroMiner entity (probably broken by player deliberately breaking it)
it.remove();
} else {
data.x = miner.chunkCoordX;
data.z = miner.chunkCoordZ;
}
inListAlready = true;
break;
}
}
if (!inListAlready && !miner.isDead) {
BlockVec3 data = new BlockVec3(miner.chunkCoordX, miner.dimension, miner.chunkCoordZ);
data.sideDoneBits = index;
list.add(data);
}
}
}
}
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class AsteroidsTickHandlerServer method loadAstroChunkList.
/**
* How this works: every spawned or saved (in player stats) miner is added to the
* activeMiners list here.
* Once per server tick its position will be saved to player stats.
* When the player quits, the saved miner positions will be saved with the player's stats NBT
* When the player next loads, loadAstroChunkList will force load those chunks, therefore
* reactivating AstroMiners if those chunks weren't already loaded.
*/
public static void loadAstroChunkList(List<BlockVec3> activeChunks) {
List<BlockVec3> copyList = new LinkedList<>(activeChunks);
activeChunks.clear();
if (!(AsteroidsTickHandlerServer.loadingSavedChunks.getAndSet(true))) {
for (BlockVec3 data : copyList) {
WorldProvider p = WorldUtil.getProviderForDimensionServer(data.y);
if (p != null && p.worldObj != null) {
GCLog.debug("Loading chunk " + data.y + ": " + data.x + "," + data.z + " - should contain a miner!");
((WorldServer) p.worldObj).theChunkProviderServer.loadChunk(data.x, data.z);
}
}
AsteroidsTickHandlerServer.loadingSavedChunks.set(false);
}
}
use of micdoodle8.mods.galacticraft.api.vector.BlockVec3 in project Galacticraft by micdoodle8.
the class TileEntityBeamOutput method initiateReflector.
public void initiateReflector() {
this.nodeList.clear();
int chunkXMin = this.getPos().getX() - 15 >> 4;
int chunkZMin = this.getPos().getZ() - 15 >> 4;
int chunkXMax = this.getPos().getX() + 15 >> 4;
int chunkZMax = this.getPos().getZ() + 15 >> 4;
for (int cX = chunkXMin; cX <= chunkXMax; cX++) {
for (int cZ = chunkZMin; cZ <= chunkZMax; cZ++) {
if (this.worldObj.getChunkProvider().chunkExists(cX, cZ)) {
Chunk chunk = this.worldObj.getChunkFromChunkCoords(cX, cZ);
for (Object obj : chunk.getTileEntityMap().values()) {
if (obj != this && obj instanceof ILaserNode) {
BlockVec3 deltaPos = new BlockVec3(this).subtract(new BlockVec3(((ILaserNode) obj).getTile()));
if (deltaPos.x < 16 && deltaPos.y < 16 && deltaPos.z < 16) {
ILaserNode laserNode = (ILaserNode) obj;
if (this.canConnectTo(laserNode) && laserNode.canConnectTo(this)) {
this.addNode(laserNode);
laserNode.addNode(this);
}
}
}
}
}
}
}
this.setTarget(this.nodeList.peekFirst());
}
Aggregations