public BlockComponent(Block block, Vector3i pos) { this.block = block; this.position.set(pos); }
public OnChunkGenerated(Vector3i chunkPos) { this.chunkPos.set(chunkPos); }
public BeforeChunkUnload(Vector3i chunkPos) { this.chunkPos.set(chunkPos); }
public OnChunkLoaded(Vector3i chunkPos) { this.chunkPos.set(chunkPos); }
/** * @deprecated Deprecated on 21/Sep/2018, because it is needlessly verbose. */ @Deprecated public void setPosition(Vector3i pos) { position.set(pos); }
public ChunkRelevanceRegion(EntityRef entity, Vector3i relevanceDistance) { this.entity = entity; this.relevanceDistance.set(relevanceDistance); LocationComponent loc = entity.getComponent(LocationComponent.class); if (loc == null) { dirty = false; } else { center.set(ChunkMath.calcChunkPos(loc.getWorldPosition())); currentRegion = calculateRegion(); dirty = true; } }
@Override public boolean next() { pos.x++; if (pos.x >= endPos.x) { pos.x = 0; pos.y++; if (pos.y >= endPos.y) { pos.y = 0; pos.z++; if (pos.z >= endPos.z) { return false; } } } blockPos.set(pos.x + worldOffset.x, pos.y + worldOffset.y, pos.z + worldOffset.z); block = blockManager.getBlock((short) data.get(pos.x, pos.y, pos.z)); return true; }
public void setRelevanceDistance(Vector3i distance) { if (!distance.equals(this.relevanceDistance)) { reviewRelevantChunks(distance); this.relevanceDistance.set(distance); this.currentRegion = calculateRegion(); dirty = true; } }
public LocalChunkView(Chunk[] chunks, PropagationRules rules) { this.chunks = chunks; this.rules = rules; //TODO fix this to not hardcode 13. This is a ugly smell topLeft.set(chunks[13].getPosition().x - 1, chunks[13].getPosition().y - 1, chunks[13].getPosition().z - 1); }
public void update() { if (!isValid()) { dirty = false; } else { Vector3i newCenter = calculateCenter(); if (!newCenter.equals(center)) { dirty = true; center.set(newCenter); currentRegion = calculateRegion(); reviewRelevantChunks(relevanceDistance); } } }
public ChunkImpl(Vector3i chunkPos, TeraArray blocks, TeraArray biome, TeraArray[] extra, BlockManager blockManager, BiomeManager biomeManager) { this.chunkPos.set(Preconditions.checkNotNull(chunkPos)); this.blockData = Preconditions.checkNotNull(blocks); this.biomeData = Preconditions.checkNotNull(biome); this.extraData = Preconditions.checkNotNull(extra); sunlightData = new TeraDenseArray8Bit(getChunkSizeX(), getChunkSizeY(), getChunkSizeZ()); sunlightRegenData = new TeraDenseArray8Bit(getChunkSizeX(), getChunkSizeY(), getChunkSizeZ()); lightData = new TeraDenseArray8Bit(getChunkSizeX(), getChunkSizeY(), getChunkSizeZ()); dirty = true; this.blockManager = blockManager; this.biomeManager = biomeManager; region = Region3i.createFromMinAndSize(new Vector3i(chunkPos.x * ChunkConstants.SIZE_X, chunkPos.y * ChunkConstants.SIZE_Y, chunkPos.z * ChunkConstants.SIZE_Z), ChunkConstants.CHUNK_SIZE); ChunkMonitor.fireChunkCreated(this); }
private void sendNewChunks(NetData.NetMessage.Builder message) { if (!readyChunks.isEmpty()) { chunkSendCounter += chunkSendRate * NET_TICK_RATE * networkSystem.getBandwidthPerClient(); if (chunkSendCounter > 1.0f) { chunkSendCounter -= 1.0f; Vector3i center = new Vector3i(); LocationComponent loc = getEntity().getComponent(ClientComponent.class).character.getComponent(LocationComponent.class); if (loc != null) { center.set(ChunkMath.calcChunkPos(new Vector3i(loc.getWorldPosition(), RoundingMode.HALF_UP))); } Vector3i pos = null; int distance = Integer.MAX_VALUE; for (Vector3i chunkPos : readyChunks.keySet()) { int chunkDistance = chunkPos.distanceSquared(center); if (pos == null || chunkDistance < distance) { pos = chunkPos; distance = chunkDistance; } } Chunk chunk = readyChunks.remove(pos); relevantChunks.add(pos); message.addChunkInfo(chunk.encode()); } } else { chunkSendCounter = 1.0f; } }
@Test public void testSetCopy() { Vector3i v = new Vector3i(); v.set(v2); assertEquals(v2, v); }
@Test public void testSetTriple() { Vector3i v = new Vector3i(v1); v.set(v2.x, v2.y, v2.z); assertEquals(v2, v); }
int adjacentDepth = adjDepth[depthIndex]; for (int i = adjacentDepth; i < depths[depthIndex]; ++i) { adjPos.set(side.getVector3i()); adjPos.mul(i + 1); adjPos.add(pos);
private void renderOverlayForOneBlockSelection(BlockSelectionComponent blockSelectionComponent, BlockSelectionRenderer selectionRenderer) { selectionRenderer.beginRenderOverlay(); if (blockSelectionComponent.currentSelection == null) { if (blockSelectionComponent.startPosition != null) { selectionRenderer.renderMark(blockSelectionComponent.startPosition); } } else { Vector3i size = blockSelectionComponent.currentSelection.size(); Vector3i block = new Vector3i(); for (int z = 0; z < size.z; z++) { for (int y = 0; y < size.y; y++) { for (int x = 0; x < size.x; x++) { block.set(x, y, z); block.add(blockSelectionComponent.currentSelection.min()); selectionRenderer.renderMark(block); } } } } selectionRenderer.endRenderOverlay(); }
pos.set(x, ChunkConstants.SIZE_Y - 1, z);
adjPos.set(x, y, z); adjPos.add(chunkEdgeDeltas.get(side));
void doExplosion(ExplosionActionComponent explosionComp, Vector3f origin, EntityRef instigatingBlockEntity) { EntityBuilder builder = entityManager.newBuilder("core:smokeExplosion"); builder.getComponent(LocationComponent.class).setWorldPosition(origin); EntityRef smokeEntity = builder.build(); smokeEntity.send(new PlaySoundEvent(getRandomExplosionSound(), 1f)); Vector3i blockPos = new Vector3i(); for (int i = 0; i < explosionComp.maxRange; i++) { Vector3f direction = random.nextVector3f(1.0f); for (int j = 0; j < 4; j++) { Vector3f target = new Vector3f(origin); target.x += direction.x * j; target.y += direction.y * j; target.z += direction.z * j; blockPos.set((int) target.x, (int) target.y, (int) target.z); Block currentBlock = worldProvider.getBlock(blockPos); /* PHYSICS */ if (currentBlock.isDestructible()) { EntityRef blockEntity = blockEntityRegistry.getEntityAt(blockPos); // allow explosions to chain together, but do not chain on the instigating block if (!blockEntity.equals(instigatingBlockEntity) && blockEntity.hasComponent(ExplosionActionComponent.class)) { doExplosion(blockEntity.getComponent(ExplosionActionComponent.class), blockPos.toVector3f(), blockEntity); } else { blockEntity.send(new DoDamageEvent(explosionComp.damageAmount, explosionComp.damageType)); } } } } }