private boolean hasRequiredSupportOnSideForBlock(Vector3i location, Side sideChanged, Block block) { final BlockMeshPart part = block.getPrimaryAppearance().getPart(BlockPart.fromSide(sideChanged)); if (part != null) { // This block has mesh on this side, therefore it requires a support on that side if (!hasSupportFromBlockOnSide(location, sideChanged, Collections.<Vector3i, Block>emptyMap())) { return false; } } return true; }
/** * Creates a new entity for the block damage particle effect. * * If the terrain texture of the damaged block is available, the particles will have the block texture. Otherwise, * the default sprite (smoke) is used. * * @param family the {@link BlockFamily} of the damaged block * @param location the location of the damaged block */ private void createBlockParticleEffect(BlockFamily family, Vector3f location) { EntityBuilder builder = entityManager.newBuilder("core:defaultBlockParticles"); builder.getComponent(LocationComponent.class).setWorldPosition(location); Optional<Texture> terrainTexture = Assets.getTexture("engine:terrain"); if (terrainTexture.isPresent() && terrainTexture.get().isLoaded()) { final BlockAppearance blockAppearance = family.getArchetypeBlock().getPrimaryAppearance(); final float relativeTileSize = worldAtlas.getRelativeTileSize(); final float particleScale = 0.25f; final float spriteSize = relativeTileSize * particleScale; ParticleDataSpriteComponent spriteComponent = builder.getComponent(ParticleDataSpriteComponent.class); spriteComponent.texture = terrainTexture.get(); spriteComponent.textureSize.set(spriteSize, spriteSize); final List<Vector2f> offsets = computeOffsets(blockAppearance, particleScale); TextureOffsetGeneratorComponent textureOffsetGeneratorComponent = builder.getComponent(TextureOffsetGeneratorComponent.class); textureOffsetGeneratorComponent.validOffsets.addAll(offsets); } builder.build(); }
private void generateMesh() { Tessellator tessellator = new Tessellator(); for (BlockPart dir : BlockPart.values()) { BlockMeshPart part = block.getPrimaryAppearance().getPart(dir); if (part != null) { if (block.isDoubleSided()) { tessellator.addMeshPartDoubleSided(part); } else { tessellator.addMeshPart(part); } } } mesh = tessellator.generateMesh(new ResourceUrn("engine", "blockmesh", block.getURI().toString())); } }