use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories-core by Hugobros3.
the class Chest method output.
@Override
public void output(World csWorld, int csX, int csY, int csZ, int minecraftBlockId, int minecraftMetaData, MinecraftRegion region, int minecraftCuurrentChunkXinsideRegion, int minecraftCuurrentChunkZinsideRegion, int x, int y, int z) {
Chunk chunk = csWorld.getChunkWorldCoordinates(csX, csY, csZ);
assert chunk != null;
/*int baked = voxelID;
if (voxel instanceof VoxelChest)
try {
baked = ((VoxelChest) voxel).onPlace(chunk.peek(csX, csY, csZ), baked, null);
} catch (WorldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
else
System.out.println("fuck you 666");
csWorld.pokeRawSilently(csX, csY, csZ, baked);*/
csWorld.pokeSimpleSilently(new FutureCell(csWorld, csX, csY, csZ, voxel));
}
use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories-core by Hugobros3.
the class Door method output.
@Override
public void output(World csWorld, int csX, int csY, int csZ, int minecraftBlockId, int minecraftMetaData, MinecraftRegion region, int minecraftCuurrentChunkXinsideRegion, int minecraftCuurrentChunkZinsideRegion, int x, int y, int z) {
Chunk chunk = csWorld.getChunkWorldCoordinates(csX, csY, csZ);
assert chunk != null;
int upper = (minecraftMetaData & 0x8) >> 3;
int open = (minecraftMetaData & 0x4) >> 2;
// We only place the lower half of the door and the other half is created by the placing logic of chunk stories
if (upper != 1) {
int upperMeta = region.getChunk(minecraftCuurrentChunkXinsideRegion, minecraftCuurrentChunkZinsideRegion).getBlockMeta(x, y + 1, z);
int hingeSide = upperMeta & 0x01;
int direction = minecraftMetaData & 0x3;
csWorld.pokeSimple(csX, csY, csZ, voxel, -1, -1, VoxelDoor.computeMeta(open == 1, hingeSide == 1, VoxelSide.getSideMcDoor(direction)));
} else
return;
}
use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories-core by Hugobros3.
the class Sign method output.
@Override
public void output(World csWorld, int csX, int csY, int csZ, int minecraftBlockId, int minecraftMetaData, MinecraftRegion region, int minecraftCuurrentChunkXinsideRegion, int minecraftCuurrentChunkZinsideRegion, int x, int y, int z) {
Chunk chunk = csWorld.getChunkWorldCoordinates(csX, csY, csZ);
assert chunk != null;
if (voxel instanceof VoxelSign) {
if (!voxel.getName().endsWith("_post")) {
if (minecraftMetaData == 2)
minecraftMetaData = 8;
else if (minecraftMetaData == 3)
minecraftMetaData = 0;
else if (minecraftMetaData == 4)
minecraftMetaData = 4;
else if (minecraftMetaData == 5)
minecraftMetaData = 12;
}
/*baked = VoxelFormat.changeMeta(baked, minecraftMetaData);
try {
baked = ((VoxelSign) voxel).onPlace(chunk.peek(csX, csY, csZ), baked, null);
} catch (WorldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
csWorld.pokeRawSilently(csX, csY, csZ, baked);*/
FutureCell future = new FutureCell(csWorld, csX, csY, csZ, voxel);
future.setMetaData(minecraftMetaData);
csWorld.pokeSimple(future);
try {
translateSignText(csWorld.peek(csX, csY, csZ).components().get("signData"), region.getChunk(minecraftCuurrentChunkXinsideRegion, minecraftCuurrentChunkZinsideRegion), x, y, z);
} catch (WorldException e) {
e.printStackTrace();
}
// TODO Move Sign text getting here ?
} else
System.out.println("fuck you 666");
}
use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories-core by Hugobros3.
the class NearbyVoxelsVolumeTexture method update.
public void update(RenderingInterface renderingContext) {
if (test == null) {
test = renderingContext.newTexture3D(TextureFormat.RGBA_8BPP, 32, 32, 32);
}
final int SIZE = size;
final int mod = SIZE / 32;
int offCenter = SIZE / 2;
int chunkX = (int) ((renderingContext.getCamera().getCameraPosition().x() - offCenter) / 32);
int chunkY = (int) ((renderingContext.getCamera().getCameraPosition().y() - offCenter) / 32);
int chunkZ = (int) ((renderingContext.getCamera().getCameraPosition().z() - offCenter) / 32);
offsetX = chunkX % mod;
offsetY = chunkY % mod;
offsetZ = chunkZ % mod;
if (bx != chunkX || by != chunkY || bz != chunkZ) {
bx = chunkX;
by = chunkY;
bz = chunkZ;
ByteBuffer bb = ByteBuffer.allocateDirect(4 * SIZE * SIZE * SIZE);
byte[] empty = { 0, 0, 0, 0 };
Chunk zChunk = null;
Vector4f col = new Vector4f();
for (int a = 0; a * 32 < SIZE; a++) for (int b = 0; b * 32 < SIZE; b++) for (int c = 0; c * 32 < SIZE; c++) {
zChunk = worldRenderer.getWorld().getChunk(chunkX + a, chunkY + b, chunkZ + c);
if (zChunk != null) {
for (int z = 0; z < 32; z++) for (int y = 0; y < 32; y++) {
int dx = (0 + a) % mod;
int dy = (0 + b) % mod;
int dz = (0 + c) % mod;
bb.position(4 * ((dz * 32 + z) * SIZE * SIZE + (dy * 32 + y) * SIZE + 0 + dx * 32));
for (int x = 0; x < 32; x++) {
CellData cell = zChunk.peek(x, y, z);
// zChunk.peekSimple(x, y, z);
Voxel voxel = cell.getVoxel();
if (voxel.isAir() || voxel.getName().startsWith("glass") || voxel instanceof VoxelPane || (!voxel.getDefinition().isSolid() && !voxel.getDefinition().isLiquid() && voxel.getDefinition().getEmittedLightLevel() == 0)) {
bb.put(empty);
} else {
col.set(voxel.getVoxelTexture(VoxelSide.TOP, cell).getColor());
if (col.w() < 1.0) {
col.mul(new Vector4f(0.1f, 0.5f, 0.1f, 1.0f));
}
if (voxel.getDefinition().getEmittedLightLevel() > 0) {
Vector4f emits = new Vector4f(1.0f, 1.0f, 1.0f, 1.0f);
float alpha = col.w;
// if(alpha <= 0.0f)
alpha = 1.0f;
if (voxel.getName().contains("torch"))
alpha = 2f;
bb.put((byte) (int) Math.max(0.0, col.x() * 255.0 * alpha));
bb.put((byte) (int) Math.max(0.0, col.y() * 255.0 * alpha));
bb.put((byte) (int) Math.max(0.0, col.z() * 255.0 * alpha));
bb.put((byte) 20);
} else {
bb.put((byte) (int) (col.x() * 255));
bb.put((byte) (int) (col.y() * 255));
bb.put((byte) (int) (col.z() * 255));
bb.put((byte) 1);
}
}
}
}
}
}
bb.position(0);
bb.limit(bb.capacity());
test.uploadTextureData(SIZE, SIZE, SIZE, bb);
test.setTextureWrapping(true);
System.out.println("do an upload");
// MemoryUtil.memFree(bb);
}
}
use of io.xol.chunkstories.api.world.chunk.Chunk in project chunkstories-core by Hugobros3.
the class BigVoxel method onPlace.
@Override
public void onPlace(FutureCell context, WorldModificationCause cause) throws IllegalBlockModificationException {
// Be cool with the system doing it's thing
if (cause == null)
return;
int x = context.getX();
int y = context.getY();
int z = context.getZ();
// Check if there is space for it ...
for (int a = x; a < x + xWidth; a++) {
for (int b = y; b < y + yWidth; b++) {
for (int c = z; c < z + zWidth; c++) {
Chunk chunk = context.getWorld().getChunkWorldCoordinates(a, b, c);
if (chunk == null)
throw new IllegalBlockModificationException(context, "All chunks upon wich this block places itself must be fully loaded !");
CellData stuff = context.getWorld().peekSafely(a, b, c);
if (stuff.getVoxel() == null || stuff.getVoxel().isAir() || !stuff.getVoxel().getDefinition().isSolid()) {
// These blocks are replaceable
continue;
} else
throw new IllegalBlockModificationException(context, "Can't overwrite block at " + a + ": " + b + ": " + c);
}
}
}
// Actually build the thing then
for (int a = 0; a < 0 + xWidth; a++) {
for (int b = 0; b < 0 + yWidth; b++) {
for (int c = 0; c < 0 + zWidth; c++) {
int metadata = (byte) (((a & xMask) << xShift) | ((b & yMask) << yShift) | ((c & zMask) << zShift));
context.getWorld().pokeSimple(a + x, b + y, c + z, this, -1, -1, metadata);
}
}
}
}
Aggregations