use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class EntityAwareWorldProvider method setBlock.
@Override
public Block setBlock(Vector3ic pos, Block type) {
if (GameThread.isCurrentThread()) {
EntityRef blockEntity = getBlockEntityAt(pos);
Block oldType = super.setBlock(pos, type);
final Set<Class<? extends Component>> retainComponents = Optional.ofNullable(blockEntity.getComponent(RetainComponentsComponent.class)).map(retainComponentsComponent -> retainComponentsComponent.components).orElse(Collections.emptySet());
if (oldType != null) {
updateBlockEntity(blockEntity, pos, oldType, type, false, retainComponents);
}
return oldType;
}
return null;
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class StandardBatchPropagator method processReduction.
/**
* Process all reducing propagation requests This is done from the largest value through the smallest.
*/
private void processReduction() {
for (int depth = 0; depth < rules.getMaxValue(); depth++) {
byte oldValue = (byte) (rules.getMaxValue() - depth);
while (!reduceQueues[depth].isEmpty()) {
Set<Vector3ic> toProcess = reduceQueues[depth];
reduceQueues[depth] = Sets.newLinkedHashSetWithExpectedSize(toProcess.size());
/* This step will add any new reductions to to the `reduceQueues` set */
for (Vector3ic pos : toProcess) {
purge(pos, oldValue);
}
}
}
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class StandardBatchPropagator method propagateDepth.
private void propagateDepth(Chunk adjChunk, Side side, boolean propagateExternal, Function<Vector3ic, Integer> indexProvider, BlockRegion edgeRegion, int[] depths) {
Vector3i adjPos = new Vector3i();
int[] adjDepth = new int[depths.length];
int dimA = (side == Side.LEFT || side == Side.RIGHT) ? Chunks.SIZE_Y : Chunks.SIZE_X;
int dimB = (side == Side.FRONT || side == Side.BACK) ? Chunks.SIZE_Y : Chunks.SIZE_Z;
BatchPropagator.populateMinAdjacent2D(depths, adjDepth, dimA, dimB, !propagateExternal);
if (propagateExternal) {
for (int y = 0; y < dimB; ++y) {
adjDepth[y * dimA] = 0;
adjDepth[dimA - 1 + y * dimA] = 0;
}
for (int x = 0; x < dimA; ++x) {
adjDepth[x] = 0;
adjDepth[x + dimA * (dimB - 1)] = 0;
}
}
for (Vector3ic pos : edgeRegion) {
int depthIndex = indexProvider.apply(pos);
int adjacentDepth = adjDepth[depthIndex];
for (int i = adjacentDepth; i < depths[depthIndex]; ++i) {
adjPos.set(side.direction());
adjPos.mul(i + 1);
adjPos.add(pos);
adjPos.add(chunkEdgeDeltas.get(side));
byte value = rules.getValue(adjChunk, adjPos);
if (value > 1) {
queueSpreadValue(adjChunk.chunkToWorldPosition(adjPos, new Vector3i()), value);
}
}
}
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class SunlightRegenBatchPropagator method reviewChangeToTop.
private void reviewChangeToTop(BlockChange blockChange) {
PropagationComparison comparison = regenRules.comparePropagation(blockChange.getTo(), blockChange.getFrom(), Side.TOP);
Vector3ic blockChangePosition = blockChange.getPosition();
if (comparison.isPermitting()) {
Vector3i adjPos = Side.TOP.getAdjacentPos(blockChangePosition, new Vector3i());
byte adjValue = regenWorld.getValueAt(adjPos);
if (adjValue != PropagatorWorldView.UNAVAILABLE) {
queueSpreadRegen(adjPos, adjValue);
}
} else if (comparison.isRestricting()) {
byte existingValue = regenWorld.getValueAt(blockChangePosition);
reduce(blockChangePosition, existingValue);
}
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class SunlightRegenBatchPropagator method reviewChangeToBottom.
private void reviewChangeToBottom(BlockChange blockChange) {
PropagationComparison comparison = regenRules.comparePropagation(blockChange.getTo(), blockChange.getFrom(), Side.BOTTOM);
Vector3ic blockChangePosition = blockChange.getPosition();
if (comparison.isPermitting()) {
byte existingValue = regenWorld.getValueAt(blockChangePosition);
queueSpreadRegen(blockChangePosition, existingValue);
} else if (comparison.isRestricting()) {
Vector3i adjPos = Side.BOTTOM.getAdjacentPos(blockChangePosition, new Vector3i());
byte existingValue = regenWorld.getValueAt(adjPos);
reduce(adjPos, existingValue);
}
}
Aggregations