/** * Sunlight can spread if the block is not a liquid * <p> * {@inheritDoc} */ @Override public boolean canSpreadInto(Block block, Side side) { return !block.isLiquid() && super.canSpreadInto(block, side); } }
/** * Sunlight can only spread out of the bottom of a non-liquid block * <p> * {@inheritDoc} */ @Override public boolean canSpreadOutOf(Block block, Side side) { return side == Side.BOTTOM && !block.isLiquid() && (super.canSpreadOutOf(block, side)); }
LiquidVoxelInfo(Block block, Vector3i position) { this.shape = block.getCollisionShape(); this.offset = block.getCollisionOffset(); this.colliding = block.isLiquid(); this.blocking = false; this.position = position; }
/** * 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()); }
@ReceiveEvent public void onEnterBlock(OnEnterBlockEvent event, EntityRef entity, CharacterSoundComponent characterSounds) { // only play this sound if the feet hit the water if (event.getCharacterRelativePosition().y == 0 && characterSounds.lastSoundTime + MIN_TIME < time.getGameTimeInMs()) { boolean oldBlockIsLiquid = event.getOldBlock().isLiquid(); boolean newBlockIsLiquid = event.getNewBlock().isLiquid(); StaticSound sound = null; if (!oldBlockIsLiquid && newBlockIsLiquid) { sound = random.nextItem(characterSounds.enterWaterSounds); } else if (oldBlockIsLiquid && !newBlockIsLiquid) { sound = random.nextItem(characterSounds.leaveWaterSounds); } if (sound != null) { entity.send(new PlaySoundEvent(entity, sound, characterSounds.diveVolume)); characterSounds.lastSoundTime = time.getGameTimeInMs(); entity.saveComponent(characterSounds); } } }
/** * Returns True if the head of the player is underwater. False otherwise. * * Takes in account waves if present. * * @return True if the head of the player is underwater. False otherwise. */ public boolean isUnderWater() { // TODO: Making this as a subscribable value especially for node "ChunksRefractiveReflectiveNode", // TODO: glDisable and glEnable state changes on that node will be dynamically added/removed based on this value. Vector3f cameraPosition = new Vector3f(this.getPosition()); // Compensate for waves if (renderingConfig.isAnimateWater()) { cameraPosition.y -= RenderHelper.evaluateOceanHeightAtPosition(cameraPosition, worldProvider.getTime().getDays()); } if (worldProvider.isBlockRelevant(cameraPosition)) { return worldProvider.getBlock(cameraPosition).isLiquid(); } return false; } }
@Override public Block constructCustomBlock(String defaultName, BlockShape shape, Rotation rotation, SectionDefinitionData section, BlockUri uri, BlockFamily blockFamily) { Block block = createRawBlock(defaultName, section); block.setRotation(rotation); block.setPrimaryAppearance(createAppearance(shape, section.getBlockTiles(), rotation)); setBlockFullSides(block, shape, rotation); block.setCollision(shape.getCollisionOffset(rotation), shape.getCollisionShape(rotation)); for (BlockPart part : BlockPart.values()) { block.setColorSource(part, section.getColorSources().get(part)); block.setColorOffset(part, section.getColorOffsets().get(part)); } block.setUri(uri); block.setBlockFamily(blockFamily); // Lowered mesh for liquids if (block.isLiquid()) { applyLiquidShapes(block, section.getBlockTiles()); } return block; }
if (selfBlock.isLiquid()) { Block topBlock = adjacentBlocks.get(Side.TOP); if (topBlock.isLiquid()) { for (Side side : Side.horizontalSides()) { Vector3i offset = side.getVector3i(); Block adjacent = adjacentBlocks.get(side); if (adjacent.isLiquid() && !adjacentAbove.isLiquid()) { drawParts[side.ordinal()] = selfBlock.getTopLiquidMesh(side);