use of io.xol.chunkstories.api.voxel.Voxel in project chunkstories-core by Hugobros3.
the class HorizonGenerator method generateChunk.
@Override
public Chunk generateChunk(Chunk chunk) {
int cx = chunk.getChunkX();
int cy = chunk.getChunkY();
int cz = chunk.getChunkZ();
rnd.setSeed(cx * 32 + cz + 48716148);
// CubicChunk c = new CubicChunk(region, cx, cy, cz);
Voxel type = null;
for (int x = 0; x < 32; x++) for (int z = 0; z < 32; z++) {
// int v = getHeightAt(cx * 32 + x, cz * 32 + z);
int v = world.getRegionsSummariesHolder().getHeightAtWorldCoordinates(cx * 32 + x, cz * 32 + z);
// int v = 250;
int y = cy * 32;
while (y < cy * 32 + 32 && y < v) {
if (v - y >= 3)
type = STONE_VOXEL;
else if (v - y > 1 || y + 1 < 60)
type = UNDERGROUND_VOXEL;
else
type = GROUND_VOXEL;
chunk.pokeSimpleSilently(x, y, z, type, -1, -1, 0);
y++;
}
while (y < cy * 32 + 32 && y < 60) {
chunk.pokeSimpleSilently(x, y, z, WATER_VOXEL, -1, -1, 0);
y++;
}
}
return chunk;
}
use of io.xol.chunkstories.api.voxel.Voxel in project chunkstories-core by Hugobros3.
the class ItemFirearm method onControllerInput.
@Override
public boolean onControllerInput(Entity user, ItemPile pile, Input input, Controller controller) {
// Don't do anything with the left mouse click
if (input.getName().startsWith("mouse.")) {
return true;
}
if (input.getName().equals("shootGun")) {
if (user instanceof EntityLiving) {
EntityLiving shooter = (EntityLiving) user;
// Serverside checks
// if (user.getWorld() instanceof WorldMaster)
{
// Is the reload cooldown done
if (cooldownEnd > System.currentTimeMillis())
return false;
// Do we have any bullets to shoot
boolean bulletPresence = (user instanceof EntityCreative && ((EntityCreative) user).isCreativeMode()) || checkBullet(pile);
if (!bulletPresence) {
// Dry.ogg
return true;
} else if (!(user instanceof EntityCreative && ((EntityCreative) user).isCreativeMode())) {
consumeBullet(pile);
}
}
// Jerk client view a bit
if (shooter.getWorld() instanceof WorldClient) {
EntityComponentRotation rot = ((EntityLiving) user).getEntityRotationComponent();
rot.applyInpulse(shake * (Math.random() - 0.5) * 3.0, shake * -(Math.random() - 0.25) * 5.0);
}
// Play sounds
if (controller != null) {
controller.getSoundManager().playSoundEffect(this.soundName, Mode.NORMAL, user.getLocation(), 1.0f, 1.0f, 1.0f, (float) soundRange);
}
playAnimation();
// Raytrace shot
Vector3d eyeLocation = new Vector3d(shooter.getLocation());
if (shooter instanceof EntityPlayer)
eyeLocation.add(new Vector3d(0.0, ((EntityPlayer) shooter).eyePosition, 0.0));
// For each shot
for (int ss = 0; ss < shots; ss++) {
Vector3d direction = new Vector3d(shooter.getDirectionLookingAt());
direction.add(new Vector3d(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize().mul(accuracy / 100d));
direction.normalize();
// Find wall collision
Location shotBlock = user.getWorld().collisionsManager().raytraceSolid(eyeLocation, direction, range);
Vector3dc nearestLocation = null;
// Loops to try and break blocks
boolean brokeLastBlock = false;
while (user.getWorld() instanceof WorldMaster && shotBlock != null) {
WorldCell peek = user.getWorld().peekSafely(shotBlock);
// int data = peek.getData();
Voxel voxel = peek.getVoxel();
brokeLastBlock = false;
if (!voxel.isAir() && voxel.getMaterial().resolveProperty("bulletBreakable") != null && voxel.getMaterial().resolveProperty("bulletBreakable").equals("true")) {
// TODO Spawn an event to check if it's okay
// Destroy it
peek.setVoxel(voxel.store().air());
brokeLastBlock = true;
for (int i = 0; i < 25; i++) {
Vector3d smashedVoxelParticleDirection = new Vector3d(direction);
smashedVoxelParticleDirection.mul(2.0);
smashedVoxelParticleDirection.add(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
smashedVoxelParticleDirection.normalize();
user.getWorld().getParticlesManager().spawnParticleAtPositionWithVelocity("voxel_frag", shotBlock, smashedVoxelParticleDirection);
}
user.getWorld().getSoundManager().playSoundEffect("sounds/environment/glass.ogg", Mode.NORMAL, shotBlock, (float) Math.random() * 0.2f + 0.9f, 1.0f);
// Re-raytrace the ray
shotBlock = user.getWorld().collisionsManager().raytraceSolid(eyeLocation, direction, range);
} else
break;
}
// Spawn decal and particles on block the bullet embedded itself in
if (shotBlock != null && !brokeLastBlock) {
Location shotBlockOuter = user.getWorld().collisionsManager().raytraceSolidOuter(eyeLocation, direction, range);
if (shotBlockOuter != null) {
Vector3d normal = shotBlockOuter.sub(shotBlock);
double NbyI2x = 2.0 * direction.dot(normal);
Vector3d NxNbyI2x = new Vector3d(normal);
NxNbyI2x.mul(NbyI2x);
Vector3d reflected = new Vector3d(direction);
reflected.sub(NxNbyI2x);
// Vector3d.sub(direction, NxNbyI2x, reflected);
// shotBlock.setX(shotBlock.getX() + 1);
WorldCell peek = user.getWorld().peekSafely(shotBlock);
for (CollisionBox box : peek.getTranslatedCollisionBoxes()) {
Vector3dc thisLocation = box.lineIntersection(eyeLocation, direction);
if (thisLocation != null) {
if (nearestLocation == null || nearestLocation.distance(eyeLocation) > thisLocation.distance(eyeLocation))
nearestLocation = thisLocation;
}
}
Vector3d particleSpawnPosition = new Vector3d(nearestLocation);
// Position adjustements so shot blocks always shoot proper particles
if (shotBlock.x() - particleSpawnPosition.x() <= -1.0)
particleSpawnPosition.add(-0.01, 0d, 0d);
if (shotBlock.y() - particleSpawnPosition.y() <= -1.0)
particleSpawnPosition.add(0d, -0.01, 0d);
if (shotBlock.z() - particleSpawnPosition.z() <= -1.0)
particleSpawnPosition.add(0d, 0d, -0.01);
for (int i = 0; i < 25; i++) {
Vector3d untouchedReflection = new Vector3d(reflected);
Vector3d random = new Vector3d(Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0);
random.mul(0.5);
untouchedReflection.add(random);
untouchedReflection.normalize();
untouchedReflection.mul(0.25);
// Vector3d ppos = new Vector3d(particleSpawnPosition);
controller.getParticlesManager().spawnParticleAtPositionWithVelocity("voxel_frag", particleSpawnPosition, untouchedReflection);
}
controller.getSoundManager().playSoundEffect(peek.getVoxel().getMaterial().resolveProperty("landingSounds"), Mode.NORMAL, particleSpawnPosition, 1, 0.05f);
/*double bspeed = 5/60.0 * (1 + Math.random() * 3 * Math.random());
Vector3d ppos = new Vector3d(reflected);
ppos.normalize();
ppos.scale(0.5);
ppos.add(nearestLocation);
WorldEffects.createFireball(shooter.getWorld(), ppos, 1f, damage*0.15*bspeed, (float) (0.0 + 0.05*damage));
*/
controller.getDecalsManager().drawDecal(nearestLocation, normal.negate(), new Vector3d(0.5), "bullethole");
}
}
// Hitreg takes place on server bois
if (shooter.getWorld() instanceof WorldMaster) {
// Iterate over each found entities
Iterator<Entity> shotEntities = user.getWorld().collisionsManager().rayTraceEntities(eyeLocation, direction, 256f);
while (shotEntities.hasNext()) {
Entity shotEntity = shotEntities.next();
// Don't shoot itself & only living things get shot
if (!shotEntity.equals(shooter) && shotEntity instanceof EntityLiving) {
// Get hit location
for (HitBox hitBox : ((EntityLiving) shotEntity).getHitBoxes()) {
Vector3dc hitPoint = hitBox.lineIntersection(eyeLocation, direction);
if (hitPoint == null)
continue;
// System.out.println("shot" + hitBox.getName());
// Deal damage
((EntityLiving) shotEntity).damage(pileAsDamageCause(pile), hitBox, (float) damage);
// Spawn blood particles
Vector3d bloodDir = direction.normalize().mul(0.75);
for (int i = 0; i < 120; i++) {
Vector3d random = new Vector3d(Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0, Math.random() * 2.0 - 1.0);
random.mul(0.25);
random.add(bloodDir);
shooter.getWorld().getParticlesManager().spawnParticleAtPositionWithVelocity("blood", hitPoint, random);
}
// Spawn blood on walls
if (nearestLocation != null)
shooter.getWorld().getDecalsManager().drawDecal(nearestLocation, bloodDir, new Vector3d(Math.min(3, shots) * damage / 20f), "blood");
}
}
}
}
}
controller.getParticlesManager().spawnParticleAtPosition("muzzle", eyeLocation);
FirearmShotEvent event = new FirearmShotEvent(this, shooter, controller);
shooter.getWorld().getGameContext().getPluginManager().fireEvent(event);
return (shooter.getWorld() instanceof WorldMaster);
}
}
return false;
}
use of io.xol.chunkstories.api.voxel.Voxel 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.voxel.Voxel in project chunkstories-core by Hugobros3.
the class DefaultVoxelRenderer method bakeInto.
@Override
public int bakeInto(ChunkRenderer chunkRenderer, ChunkRenderContext bakingContext, Chunk chunk, CellData cell) {
Voxel vox = cell.getVoxel();
int i = cell.getX() & 0x1F;
int k = cell.getY() & 0x1F;
int j = cell.getZ() & 0x1F;
VoxelBakerCubic vbc = chunkRenderer.getLowpolyBakerFor(LodLevel.ANY, ShadingType.OPAQUE);
byte wavyVegetationFlag = (byte) (vox.getDefinition().resolveProperty("affectedByWind", "false").equals("true") ? 3 : 0);
int vertices = 0;
if (shallBuildWallArround(cell, 5) && (k != 0 || bakingContext.isBottomChunkLoaded())) {
addQuadBottom(chunk, bakingContext, vbc, i, k, j, vox.getVoxelTexture(VoxelSide.BOTTOM, cell), wavyVegetationFlag);
vertices += 6;
}
if (shallBuildWallArround(cell, 4) && (k != 31 || bakingContext.isTopChunkLoaded())) {
addQuadTop(chunk, bakingContext, vbc, i, k, j, vox.getVoxelTexture(VoxelSide.TOP, cell), wavyVegetationFlag);
vertices += 6;
}
if (shallBuildWallArround(cell, 2) && (i != 31 || bakingContext.isRightChunkLoaded())) {
addQuadRight(chunk, bakingContext, vbc, i, k, j, vox.getVoxelTexture(VoxelSide.RIGHT, cell), wavyVegetationFlag);
vertices += 6;
}
if (shallBuildWallArround(cell, 0) && (i != 0 || bakingContext.isLeftChunkLoaded())) {
addQuadLeft(chunk, bakingContext, vbc, i, k, j, vox.getVoxelTexture(VoxelSide.LEFT, cell), wavyVegetationFlag);
vertices += 6;
}
if (shallBuildWallArround(cell, 1) && (j != 31 || bakingContext.isFrontChunkLoaded())) {
addQuadFront(chunk, bakingContext, vbc, i, k, j, vox.getVoxelTexture(VoxelSide.FRONT, cell), wavyVegetationFlag);
vertices += 6;
}
if (shallBuildWallArround(cell, 3) && (j != 0 || bakingContext.isBackChunkLoaded())) {
addQuadBack(chunk, bakingContext, vbc, i, k, j, vox.getVoxelTexture(VoxelSide.BACK, cell), wavyVegetationFlag);
vertices += 6;
}
vbc.reset();
return vertices;
}
use of io.xol.chunkstories.api.voxel.Voxel in project chunkstories-core by Hugobros3.
the class SmoothStepVoxelRenderer method bakeInto.
@Override
public int bakeInto(ChunkRenderer chunkRenderer, ChunkRenderContext bakingContext, Chunk chunk, CellData voxelInformations) {
int x = bakingContext.getRenderedVoxelPositionInChunkX();
int y = bakingContext.getRenderedVoxelPositionInChunkY();
int z = bakingContext.getRenderedVoxelPositionInChunkZ();
// Check we have 8 neighbours
World world = voxelInformations.getWorld();
int wx = x + chunk.getChunkX() * 32;
int wy = y + chunk.getChunkY() * 32;
int wz = z + chunk.getChunkZ() * 32;
// bakingContext.getCurrentVoxelLighter().getSunlightLevelInterpolated(x + 0.5f, y + 0.5f, z + 0.5f);
byte sunlight = 0;
// bakingContext.getCurrentVoxelLighter().getBlocklightLevelInterpolated(x + 0.5f, y + 0.5f, z + 0.5f);
byte blockLight = 15;
byte ao = bakingContext.getCurrentVoxelLighter().getAoLevelInterpolated(x + 0.5f, y + 0.5f, z + 0.5f);
VoxelBakerHighPoly baker = chunkRenderer.getHighpolyBakerFor(LodLevel.ANY, ShadingType.OPAQUE);
/*for(int a = wx - 1; a <= wx + 1; a++)
for(int b = wz - 1; b <= wz + 1; b ++) {
//If a single one is fucky
if(VoxelFormat.id(world.getVoxelData(a, wy, b)) != voxel.getId())
return old(voxelInformations).renderInto(chunkRenderer, bakingContext, chunk, voxelInformations);
}*/
// if(true)
// return old(voxelInformations).renderInto(chunkRenderer, bakingContext, chunk, voxelInformations);
VoxelTexture texture = voxel.getVoxelTexture(VoxelSide.TOP, voxelInformations);
baker.usingTexture(texture);
// int offset = texture.getAtlasOffset() / texture.getTextureScale();
// int textureS = texture.getAtlasS() + (x % texture.getTextureScale()) * offset;
// int textureT = texture.getAtlasT() + (z % texture.getTextureScale()) * offset;
// final int max_step = 8;
float[] height = new float[9];
for (int a = wx - 1; a <= wx + 1; a++) bLoop: for (int b = wz - 1; b <= wz + 1; b++) {
for (int h = wy + 1; h >= wy - 1; h--) {
Voxel peek = world.peekSimple(a, h, b);
int raw = world.peekRaw(a, h, b);
if (voxel.sameKind(peek)) {
height[(a - wx + 1) * 3 + b - wz + 1] = h - chunk.getChunkY() * 32 + 1 / 8f + VoxelFormat.meta(raw) / 8f;
continue bLoop;
}
}
return old(voxelInformations).bakeInto(chunkRenderer, bakingContext, chunk, voxelInformations);
}
// X --->
// 036
// 147
// 258
float corner00 = (height[0] + height[3] + height[1] + height[4]) / 4f;
float corner10 = (height[3] + height[4] + height[7] + height[6]) / 4f;
float corner01 = (height[1] + height[4] + height[2] + height[5]) / 4f;
float corner11 = (height[4] + height[7] + height[5] + height[8]) / 4f;
/*float corner00, corner01, corner10, corner11;
int data00, data01, data10, data11;
data00 = world.getVoxelData(wx, wy, wz);
corner00 = 1/8f + y + VoxelFormat.meta(data00) / 8f;
//Merge with left/top upper lip
int dataN0p = world.getVoxelData(wx - 1, wy + 1, wz);
int data0Np = world.getVoxelData(wx, wy + 1, wz - 1);
int dataNNp = world.getVoxelData(wx - 1, wy + 1, wz - 1);
if(VoxelFormat.id(dataN0p) == voxel.getId()) {
int meta = VoxelFormat.meta(dataN0p);
if(meta < max_step)
corner00 = Math.max(0, 1/8f + y + 1 + meta / 8f);
}
else if(VoxelFormat.id(data0Np) == voxel.getId()) {
int meta = VoxelFormat.meta(data0Np);
if(meta < max_step)
corner00 = Math.max(0, 1/8f + y + 1 + meta / 8f);
}
else if(VoxelFormat.id(dataNNp) == voxel.getId()) {
int meta = VoxelFormat.meta(dataNNp);
if(meta < max_step)
corner00 = Math.max(0, 1/8f + y + 1 + meta / 8f);
}
int data01p = world.getVoxelData(wx, wy + 1, wz + 1);
if(VoxelFormat.id(data01p) == voxel.getId()) {
corner01 = 1/8f + y + 1 +VoxelFormat.meta(data01p) / 8f;
}
else {
data01 = world.getVoxelData(wx, wy, wz + 1);
if(VoxelFormat.id(data01) == voxel.getId()) {
corner01 = 1/8f + y +VoxelFormat.meta(data01) / 8f;
}
else {
corner01 = corner00;
}
}
if(VoxelFormat.id(dataN0p) == voxel.getId()) {
int meta = VoxelFormat.meta(dataN0p);
if(meta < max_step)
corner01 = Math.max(0, 1/8f + y + 1 + meta / 8f);
}
int data10p = world.getVoxelData(wx + 1, wy + 1, wz);
if(VoxelFormat.id(data10p) == voxel.getId()) {
corner10 = 1/8f + y + 1 +VoxelFormat.meta(data10p) / 8f;
}
else {
data10 = world.getVoxelData(wx + 1, wy, wz);
if(VoxelFormat.id(data10) == voxel.getId()) {
corner10 = 1/8f + y +VoxelFormat.meta(data10) / 8f;
}
else {
corner10 = corner00;
}
}
if(VoxelFormat.id(data0Np) == voxel.getId()) {
int meta = VoxelFormat.meta(data0Np);
if(meta < max_step)
corner10 = Math.max(0, 1/8f + y + 1 + meta / 8f);
}
int data11p = world.getVoxelData(wx + 1, wy + 1, wz + 1);
if(VoxelFormat.id(data11p) == voxel.getId()) {
corner11 = 1/8f + y + 1 +VoxelFormat.meta(data11p) / 8f;
}
else {
data11 = world.getVoxelData(wx + 1, wy, wz + 1);
if(VoxelFormat.id(data11) == voxel.getId()) {
corner11 = 1/8f + y +VoxelFormat.meta(data11) / 8f;
}
else {
corner11 = corner00;
}
}
/*float corner00 = 1/8f + y + VoxelFormat.meta(world.getVoxelData(wx, wy, wz)) / 8f;
int dataN0p = world.getVoxelData(wx - 1, wy + 1, wz);
int data0Np = world.getVoxelData(wx, wy + 1, wz - 1);
int dataNNp = world.getVoxelData(wx - 1, wy + 1, wz - 1);
if(VoxelFormat.id(dataN0p) == voxel.getId()) {
int meta = VoxelFormat.meta(dataN0p);
if(meta < max_step)
corner00 = Math.max(corner00, 1/8f + y + 1 + meta / 8f);
}
else if(VoxelFormat.id(data0Np) == voxel.getId()) {
int meta = VoxelFormat.meta(data0Np);
if(meta < max_step)
corner00 = Math.max(corner00, 1/8f + y + 1 + meta / 8f);
}
else if(VoxelFormat.id(dataNNp) == voxel.getId()) {
int meta = VoxelFormat.meta(dataNNp);
if(meta < max_step)
corner00 = Math.max(corner00, 1/8f + y + 1 + meta / 8f);
}
int data01 = world.getVoxelData(wx, wy, wz + 1);
float corner01;
if(VoxelFormat.id(data01) == voxel.getId()) {
corner01 = 1/8f + y + VoxelFormat.meta(data01) / 8f;
}
else {
corner01 = corner00;
int data01p = world.getVoxelData(wx, wy + 1, wz + 1);
if(VoxelFormat.id(data01p) == voxel.getId()) {
int meta = VoxelFormat.meta(data01p);
if(meta < max_step)
corner01 = 1/8f + y + 1 + meta / 8f;
}
}
int dataN1p = world.getVoxelData(wx - 1, wy + 1, wz);
if(VoxelFormat.id(dataN1p) == voxel.getId()) {
int meta = VoxelFormat.meta(dataN1p);
if(meta < max_step)
corner01 = Math.max(corner01, 1/8f + y + 1 + meta / 8f);
}
//float corner01 = VoxelFormat.id(data01) == voxel.getId() ? 1/8f + y + VoxelFormat.meta(data01) / 8f : corner00;
int data10 = world.getVoxelData(wx + 1, wy, wz);
float corner10;
if(VoxelFormat.id(data10) == voxel.getId()) {
corner10 = 1/8f + y + VoxelFormat.meta(data10) / 8f;
}
else {
corner10 = corner00;
int data10p = world.getVoxelData(wx + 1, wy + 1, wz);
if(VoxelFormat.id(data10p) == voxel.getId()) {
int meta = VoxelFormat.meta(data10p);
if(meta < max_step)
corner10 = 1/8f + y + 1 + meta / 8f;
}
}
//float corner10 = VoxelFormat.id(data10) == voxel.getId() ? 1/8f + y + VoxelFormat.meta(data10) / 8f : corner00;
int data1Np = world.getVoxelData(wx, wy + 1, wz - 1);
if(VoxelFormat.id(data1Np) == voxel.getId()) {
int meta = VoxelFormat.meta(data1Np);
if(meta < max_step)
corner10 = Math.max(corner10, 1/8f + y + 1 + meta / 8f);
}
int data11 = world.getVoxelData(wx + 1, wy, wz + 1);
float corner11;
if(VoxelFormat.id(data11) == voxel.getId()) {
corner11 = 1/8f + y + VoxelFormat.meta(data11) / 8f;
}
else {
corner11 = Math.max(corner10, corner01);
int data11p = world.getVoxelData(wx + 1, wy + 1, wz + 1);
if(VoxelFormat.id(data11p) == voxel.getId()) {
int meta = VoxelFormat.meta(data11p);
if(meta < max_step)
corner11 = 1/8f + y + 1 + meta / 8f;
}
}*/
// float corner11 = VoxelFormat.id(data11) == voxel.getId() ? 1/8f + y + VoxelFormat.meta(data11) / 8f : Math.min(corner10, corner01);
baker.setNormal(0f, 1f, 0f);
baker.beginVertex(x, corner00, z);
baker.setTextureCoordinates(0, 0);
baker.setVoxelLight(sunlight, blockLight, ao);
// baker.addNormalsInt(511, 1023, 511, (byte)0);
baker.endVertex();
baker.beginVertex(x + 1, corner11, z + 1);
baker.setTextureCoordinates(0 + 1, 0 + 1);
baker.setVoxelLight(sunlight, blockLight, ao);
// baker.addNormalsInt(511, 1023, 511, (byte)0);
baker.endVertex();
baker.beginVertex(x + 1, corner10, z);
baker.setTextureCoordinates(0 + 1, 0);
baker.setVoxelLight(sunlight, blockLight, ao);
// baker.addNormalsInt(511, 1023, 511, (byte)0);
baker.endVertex();
// <- ------------------- ->
baker.beginVertex(x, corner01, z + 1);
baker.setTextureCoordinates(0, 0 + 1);
baker.setVoxelLight(sunlight, blockLight, ao);
// baker.addNormalsInt(511, 1023, 511, (byte)0);
baker.endVertex();
baker.beginVertex(x + 1, corner11, z + 1);
baker.setTextureCoordinates(0 + 1, 0 + 1);
baker.setVoxelLight(sunlight, blockLight, ao);
// baker.addNormalsInt(511, 1023, 511, (byte)0);
baker.endVertex();
baker.beginVertex(x, corner00, z);
baker.setTextureCoordinates(0, 0);
baker.setVoxelLight(sunlight, blockLight, ao);
// baker.addNormalsInt(511, 1023, 511, (byte)0);
baker.endVertex();
return 6;
}
Aggregations