/** * Light can spread into a block if * - it is translucent, * - or the side isn't ful * <p> * {@inheritDoc} */ @Override public boolean canSpreadInto(Block block, Side side) { return block.isTranslucent() || !block.isFullSide(side); } }
/** * Light is more permissive if the block is changed to be translucent or has an open side, * otherwise is less permissive or identical. * <p> * {@inheritDoc} */ @Override public PropagationComparison comparePropagation(Block newBlock, Block oldBlock, Side side) { if (newBlock.isTranslucent() && oldBlock.isTranslucent()) { return PropagationComparison.IDENTICAL; } else if (newBlock.isTranslucent()) { if (oldBlock.isFullSide(side)) { return PropagationComparison.MORE_PERMISSIVE; } } else if (oldBlock.isTranslucent()) { if (newBlock.isFullSide(side)) { return PropagationComparison.MORE_RESTRICTED; } } else { boolean newBlocked = newBlock.isFullSide(side); boolean oldBlocked = oldBlock.isFullSide(side); if (newBlocked && !oldBlocked) { return PropagationComparison.MORE_RESTRICTED; } if (oldBlocked && !newBlocked) { return PropagationComparison.MORE_PERMISSIVE; } } return PropagationComparison.IDENTICAL; }
/** * Light can spread out of a block if * - it has luminance (ie, glows), * - it is translucent * - or the side isn't full * <p> * {@inheritDoc} */ @Override public boolean canSpreadOutOf(Block block, Side side) { return block.getLuminance() > 0 || block.isTranslucent() || !block.isFullSide(side); }
/** * Returns true if the side should be rendered adjacent to the second side provided. * * @param blockToCheck The block to check * @param currentBlock The current block * @return True if the side is visible for the given block types */ private boolean isSideVisibleForBlockTypes(Block blockToCheck, Block currentBlock, Side side) { // Liquids can be transparent but there should be no visible adjacent faces if (currentBlock.isLiquid() && blockToCheck.isLiquid()) { return false; } return currentBlock.isWaving() != blockToCheck.isWaving() || blockToCheck.getMeshGenerator() == null || !blockToCheck.isFullSide(side.reverse()) || (!currentBlock.isTranslucent() && blockToCheck.isTranslucent()); }
public static void addOrUpdateBlockMeshComponent(BlockItemComponent blockItemComponent, MutableComponentContainer entity) { if (blockItemComponent != null) { MeshComponent meshComponent = null; if (entity.hasComponent(MeshComponent.class)) { meshComponent = entity.getComponent(MeshComponent.class); } else { meshComponent = new MeshComponent(); } BlockFamily blockFamily = blockItemComponent.blockFamily; if (blockFamily == null) { return; } meshComponent.mesh = blockFamily.getArchetypeBlock().getMeshGenerator().getStandaloneMesh(); meshComponent.material = Assets.getMaterial("engine:terrain").get(); meshComponent.translucent = blockFamily.getArchetypeBlock().isTranslucent(); float luminance = blockFamily.getArchetypeBlock().getLuminance() / 15f; meshComponent.selfLuminance = luminance; if (luminance > 0 && !entity.hasComponent(LightComponent.class)) { LightComponent lightComponent = entity.addComponent(new LightComponent()); //scale the light back if it is a less bright block lightComponent.lightAttenuationRange *= luminance; } entity.addOrSaveComponent(meshComponent); } } }
if (!selfBlock.isTranslucent()) { renderType = ChunkMesh.RenderType.OPAQUE;
Block b = blocks[i]; if (b.isShadowCasting() && !b.isTranslucent()) { occCounter++; } else if (b.isShadowCasting()) {