use of io.xol.chunkstories.api.entity.EntityLiving in project chunkstories-core by Hugobros3.
the class EntityZombie method damage.
@Override
public float damage(DamageCause cause, HitBox osef, float damage) {
if (!isDead())
world.getSoundManager().playSoundEffect("sounds/entities/zombie/hurt.ogg", Mode.NORMAL, this.getLocation(), (float) Math.random() * 0.4f + 0.8f, 1.5f + Math.min(0.5f, damage / 15.0f));
if (cause instanceof EntityLiving) {
EntityLiving entity = (EntityLiving) cause;
this.zombieAi.setAiTask(zombieAi.new AiTaskAttackEntity(entity, 15f, 20f, zombieAi.currentTask(), stage().attackCooldown, stage().attackDamage));
}
return super.damage(cause, osef, damage);
}
use of io.xol.chunkstories.api.entity.EntityLiving 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.entity.EntityLiving in project chunkstories-core by Hugobros3.
the class ItemMeleeWeapon method onControllerInput.
@Override
public boolean onControllerInput(Entity owner, ItemPile pile, Input input, Controller controller) {
if (input.getName().startsWith("mouse.left")) {
// Checks current swing is done
if (System.currentTimeMillis() - currentSwingStart > swingDuration) {
currentSwingStart = System.currentTimeMillis();
hasHitYet = false;
}
return true;
} else if (input.getName().equals("shootGun") && owner.getWorld() instanceof WorldMaster) {
// Actually hits
EntityLiving shooter = (EntityLiving) owner;
Vector3dc direction = shooter.getDirectionLookingAt();
Vector3d eyeLocation = new Vector3d(shooter.getLocation());
if (shooter instanceof EntityPlayer)
eyeLocation.add(new Vector3d(0.0, ((EntityPlayer) shooter).eyePosition, 0.0));
// Find wall collision
Location shotBlock = owner.getWorld().collisionsManager().raytraceSolid(eyeLocation, direction, range);
Vector3d nearestLocation = new Vector3d();
// Loops to try and break blocks
while (owner.getWorld() instanceof WorldMaster && shotBlock != null) {
EditableCell peek = owner.getWorld().peekSafely(shotBlock);
if (!peek.getVoxel().isAir() && peek.getVoxel().getMaterial().resolveProperty("bulletBreakable") != null && peek.getVoxel().getMaterial().resolveProperty("bulletBreakable").equals("true")) {
// TODO: Spawn an event to check if it's okay
// Destroy it
peek.setVoxel(getDefinition().store().parent().voxels().air());
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();
owner.getWorld().getParticlesManager().spawnParticleAtPositionWithVelocity("voxel_frag", shotBlock, smashedVoxelParticleDirection);
}
owner.getWorld().getSoundManager().playSoundEffect("sounds/environment/glass.ogg", Mode.NORMAL, shotBlock, (float) Math.random() * 0.2f + 0.9f, 1.0f);
// Re-raytrace the ray
shotBlock = owner.getWorld().collisionsManager().raytraceSolid(eyeLocation, direction, range);
} else
break;
}
if (shotBlock != null) {
Location shotBlockOuter = owner.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);
CellData peek = owner.getWorld().peekSafely(shotBlock);
// This seems fine
for (CollisionBox box : peek.getTranslatedCollisionBoxes()) {
Vector3dc thisLocation = box.lineIntersection(eyeLocation, direction);
if (thisLocation != null) {
if (nearestLocation == null || nearestLocation.distance(eyeLocation) > thisLocation.distance(eyeLocation))
nearestLocation.set(thisLocation);
}
}
// Position adjustements so shot blocks always shoot proper particles
if (shotBlock.x() - nearestLocation.x() <= -1.0)
nearestLocation.add(-0.01, 0.0, 0.0);
if (shotBlock.y() - nearestLocation.y() <= -1.0)
nearestLocation.add(0.0, -0.01, 0.0);
if (shotBlock.z() - nearestLocation.z() <= -1.0)
nearestLocation.add(0.0, 0.0, -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(nearestLocation);
owner.getWorld().getParticlesManager().spawnParticleAtPositionWithVelocity("voxel_frag", ppos, untouchedReflection);
owner.getWorld().getSoundManager().playSoundEffect(owner.getWorld().peekSafely(shotBlock).getVoxel().getMaterial().resolveProperty("landingSounds"), Mode.NORMAL, ppos, 1, 0.25f);
}
owner.getWorld().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 = owner.getWorld().collisionsManager().rayTraceEntities(eyeLocation, direction, range);
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;
// Deal damage
((EntityLiving) shotEntity).damage(pileAsDamageCause(pile), hitBox, (float) damage);
// Spawn blood particles
Vector3d bloodDir = new Vector3d();
direction.normalize(bloodDir).mul(0.25);
for (int i = 0; i < 250; 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(3.0), "blood");
}
}
}
}
}
return false;
}
use of io.xol.chunkstories.api.entity.EntityLiving in project chunkstories by Hugobros3.
the class DebugInfoRenderer method drawF3debugMenu.
public void drawF3debugMenu(RenderingInterface renderingInterface) {
CameraInterface camera = renderingInterface.getCamera();
Entity playerEntity = client.getPlayer().getControlledEntity();
/*int timeTook = Client.profiler.timeTook();
String debugInfo = Client.profiler.reset("gui").toString();
if (timeTook > 400)
System.out.println("Lengty frame, printing debug information : \n" + debugInfo);*/
// Memory usage
long total = Runtime.getRuntime().totalMemory();
long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
// By default use the camera position
int bx = ((int) camera.getCameraPosition().x());
int by = ((int) camera.getCameraPosition().y());
int bz = ((int) camera.getCameraPosition().z());
int lx = bx, ly = by, lz = bz;
// If the player can look use that
if (playerEntity != null && playerEntity instanceof EntityControllable) {
Location loc = ((EntityControllable) playerEntity).getBlockLookingAt(true);
if (loc != null) {
lx = (int) loc.x();
ly = (int) loc.y();
lz = (int) loc.z();
}
}
int raw_data = world.peekRaw(lx, ly, lz);
CellData cell = world.peekSafely(lx, ly, lz);
// System.out.println(VoxelFormat.id(raw_data));
int cx = bx / 32;
int cy = by / 32;
int cz = bz / 32;
int csh = world.getRegionsSummariesHolder().getHeightAtWorldCoordinates(bx, bz);
// Obtain the angle the player is facing
VoxelSide side = VoxelSide.TOP;
float angleX = -1;
if (playerEntity != null && playerEntity instanceof EntityLiving)
angleX = Math.round(((EntityLiving) playerEntity).getEntityRotationComponent().getHorizontalRotation());
double dx = Math.sin(angleX / 360 * 2.0 * Math.PI);
double dz = Math.cos(angleX / 360 * 2.0 * Math.PI);
if (Math.abs(dx) > Math.abs(dz)) {
if (dx > 0)
side = VoxelSide.RIGHT;
else
side = VoxelSide.LEFT;
} else {
if (dz > 0)
side = VoxelSide.FRONT;
else
side = VoxelSide.BACK;
}
// Count all the entities
int ec = 0;
IterableIterator<Entity> i = world.getAllLoadedEntities();
while (i.hasNext()) {
i.next();
ec++;
}
Chunk current = world.getChunk(cx, cy, cz);
int x_top = renderingInterface.getWindow().getHeight() - 16;
Font font = null;
font = renderingInterface.getFontRenderer().getFont("LiberationSans-Regular", 12);
if (font == null)
font = renderingInterface.getFontRenderer().getFont("LiberationSans-Regular", 12);
int lineHeight = font.getLineHeight();
int posx, posy;
String text;
posx = 8;
posy = x_top - posx;
text = GLCalls.getStatistics() + " Chunks in view : " + world.getWorldRenderer().getChunksRenderer().getChunksVisible() + " Entities " + ec + " Particles :" + ((ClientParticlesRenderer) world.getParticlesManager()).count() + " #FF0000Render FPS: " + Client.getInstance().getGameWindow().getFPS() + " avg: " + Math.floor(10000.0 / Client.getInstance().getGameWindow().getFPS()) / 10.0 + " #00FFFFSimulation FPS: " + world.getWorldRenderer().getWorld().getGameLogic().getSimulationFps();
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
posy -= lineHeight;
text = "RAM usage : " + used / 1024 / 1024 + " / " + total / 1024 / 1024 + " MB used, chunks loaded in ram: " + world.getRegionsHolder().countChunksWithData() + "/" + world.getRegionsHolder().countChunks() + " " + Math.floor(world.getRegionsHolder().countChunksWithData() * 4 * 32 * 32 * 32 / (1024L * 1024 / 100f)) / 100f + "MB used by chunks";
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
long totalVram = (renderingInterface.getTotalVramUsage()) / 1024 / 1024;
posy -= lineHeight;
text = "VRAM usage : " + totalVram + "MB as " + Texture2DGL.getTotalNumberOfTextureObjects() + " textures using " + Texture2DGL.getTotalVramUsage() / 1024 / 1024 + "MB + " + VertexBufferGL.getTotalNumberOfVerticesObjects() + " vbos using " + renderingInterface.getVertexDataVramUsage() / 1024 / 1024 + " MB";
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
posy -= lineHeight;
text = "Worker threads: " + world.getGameContext().tasks() + " - " + world.ioHandler.toString();
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
posy -= lineHeight;
text = "Position : x:" + bx + " y:" + by + " z:" + bz + " dir: " + angleX + " side: " + side + " #FF0000Block looking at#FFFFFF : pos: " + lx + ": " + ly + ": " + lz + " data: " + raw_data + " voxel_type: " + cell.getVoxel().getName() + " sl:" + cell.getSunlight() + " bl: " + cell.getBlocklight() + " meta:" + cell.getMetaData() + " csh:" + csh;
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
posy -= lineHeight;
text = "Current Summary : " + world.getRegionsSummariesHolder().getHeightmapChunkCoordinates(cx, cz);
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
posy -= lineHeight;
text = "Current Region : " + world.getRegionChunkCoordinates(cx, cy, cz);
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
if (current == null) {
posy -= lineHeight;
text = "Current chunk null";
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
} else if (current instanceof ChunkRenderable) {
ChunkRenderDataHolder chunkRenderData = ((ClientChunk) current).getChunkRenderData();
if (chunkRenderData != null) {
posy -= lineHeight;
text = "Current Chunk : " + current + " - " + chunkRenderData.toString();
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
} else {
posy -= lineHeight;
text = "Current Chunk : " + current + " - No rendering data";
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
}
}
if (playerEntity != null && playerEntity instanceof Entity) {
posy -= lineHeight;
text = "Controlled Entity : " + playerEntity;
renderingInterface.getFontRenderer().drawStringWithShadow(font, posx, posy, text, 1, 1, new Vector4f(1));
}
}
use of io.xol.chunkstories.api.entity.EntityLiving in project chunkstories by Hugobros3.
the class PhysicsWireframeDebugger method render.
public void render(RenderingInterface renderer) {
Vector3dc cameraPosition = renderer.getCamera().getCameraPosition();
// int id, data;
int drawDebugDist = 6;
// Iterate over nearby voxels
for (int i = ((int) (double) cameraPosition.x()) - drawDebugDist; i <= ((int) (double) cameraPosition.x()) + drawDebugDist; i++) for (int j = ((int) (double) cameraPosition.y()) - drawDebugDist; j <= ((int) (double) cameraPosition.y()) + drawDebugDist; j++) for (int k = ((int) (double) cameraPosition.z()) - drawDebugDist; k <= ((int) (double) cameraPosition.z()) + drawDebugDist; k++) {
// data = world.peekSimple(i, j, k);
// id = VoxelFormat.id(data);
CellData cell = world.peekSafely(i, j, k);
// System.out.println(i+":"+j+":"+k);
// System.out.println(cell.getX() + ":"+cell.getY()+":"+cell.getZ());
CollisionBox[] tboxes = cell.getTranslatedCollisionBoxes();
// System.out.println(tboxes.length);
if (tboxes != null) {
// Draw all their collision boxes
for (CollisionBox box : tboxes) {
if (cell.getVoxel().getDefinition().isSolid())
// Red if solid
FakeImmediateModeDebugRenderer.renderCollisionBox(box, new Vector4f(1, 0, 0, 1.0f));
else
// Yellow otherwise
FakeImmediateModeDebugRenderer.renderCollisionBox(box, new Vector4f(1, 1, 0, 0.25f));
}
}
}
// Iterate over each entity
Iterator<Entity> ie = world.getAllLoadedEntities();
while (ie.hasNext()) {
Entity e = ie.next();
// Entities with hitboxes see all of those being drawn
if (e instanceof EntityLiving) {
EntityLiving eli = (EntityLiving) e;
for (HitBox hitbox : eli.getHitBoxes()) {
hitbox.draw(renderer);
}
}
// Get the entity bounding box
if (e.getTranslatedBoundingBox().lineIntersection(cameraPosition, new Vector3d(renderer.getCamera().getViewDirection())) != null)
FakeImmediateModeDebugRenderer.renderCollisionBox(e.getTranslatedBoundingBox(), new Vector4f(0, 0, 0.5f, 1.0f));
else
FakeImmediateModeDebugRenderer.renderCollisionBox(e.getTranslatedBoundingBox(), new Vector4f(0, 1f, 1f, 1.0f));
// And the collision box
for (CollisionBox box : e.getCollisionBoxes()) {
box.translate(e.getLocation());
FakeImmediateModeDebugRenderer.renderCollisionBox(box, new Vector4f(0, 1, 0.5f, 1.0f));
}
}
}
Aggregations