• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CyclopsMC / IntegratedDynamics / 22182377337

19 Feb 2026 12:46PM UTC coverage: 44.49% (-1.7%) from 46.183%
22182377337

push

github

rubensworks
Fix performance workflow failing

2663 of 8850 branches covered (30.09%)

Branch coverage included in aggregate %.

12028 of 24171 relevant lines covered (49.76%)

2.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.29
/src/main/java/org/cyclops/integrateddynamics/block/BlockCable.java
1
package org.cyclops.integrateddynamics.block;
2

3
import com.google.common.cache.Cache;
4
import com.google.common.cache.CacheBuilder;
5
import com.mojang.serialization.MapCodec;
6
import lombok.Setter;
7
import lombok.SneakyThrows;
8
import net.minecraft.core.BlockPos;
9
import net.minecraft.core.Direction;
10
import net.minecraft.server.level.ServerLevel;
11
import net.minecraft.util.RandomSource;
12
import net.minecraft.world.InteractionHand;
13
import net.minecraft.world.InteractionResult;
14
import net.minecraft.world.ItemInteractionResult;
15
import net.minecraft.world.entity.LivingEntity;
16
import net.minecraft.world.entity.player.Player;
17
import net.minecraft.world.item.ItemStack;
18
import net.minecraft.world.item.context.BlockPlaceContext;
19
import net.minecraft.world.level.*;
20
import net.minecraft.world.level.block.BaseEntityBlock;
21
import net.minecraft.world.level.block.Block;
22
import net.minecraft.world.level.block.RenderShape;
23
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
24
import net.minecraft.world.level.block.entity.BlockEntity;
25
import net.minecraft.world.level.block.entity.BlockEntityTicker;
26
import net.minecraft.world.level.block.entity.BlockEntityType;
27
import net.minecraft.world.level.block.state.BlockState;
28
import net.minecraft.world.level.block.state.StateDefinition;
29
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
30
import net.minecraft.world.level.block.state.properties.BooleanProperty;
31
import net.minecraft.world.level.material.Fluid;
32
import net.minecraft.world.level.material.FluidState;
33
import net.minecraft.world.level.material.Fluids;
34
import net.minecraft.world.phys.AABB;
35
import net.minecraft.world.phys.BlockHitResult;
36
import net.minecraft.world.phys.shapes.*;
37
import net.neoforged.neoforge.client.model.data.ModelProperty;
38
import net.neoforged.neoforge.common.extensions.ILevelExtension;
39
import org.cyclops.cyclopscore.block.BlockWithEntity;
40
import org.cyclops.cyclopscore.datastructure.EnumFacingMap;
41
import org.cyclops.cyclopscore.helper.BlockEntityHelpers;
42
import org.cyclops.integrateddynamics.Capabilities;
43
import org.cyclops.integrateddynamics.GeneralConfig;
44
import org.cyclops.integrateddynamics.RegistryEntries;
45
import org.cyclops.integrateddynamics.api.block.IDynamicLight;
46
import org.cyclops.integrateddynamics.api.block.IDynamicRedstone;
47
import org.cyclops.integrateddynamics.api.block.cable.ICableFakeable;
48
import org.cyclops.integrateddynamics.api.part.IPartContainer;
49
import org.cyclops.integrateddynamics.api.part.IPartState;
50
import org.cyclops.integrateddynamics.api.part.IPartType;
51
import org.cyclops.integrateddynamics.api.part.PartRenderPosition;
52
import org.cyclops.integrateddynamics.block.shapes.*;
53
import org.cyclops.integrateddynamics.client.model.CableModel;
54
import org.cyclops.integrateddynamics.client.model.IRenderState;
55
import org.cyclops.integrateddynamics.core.block.BlockRayTraceResultComponent;
56
import org.cyclops.integrateddynamics.core.block.VoxelShapeComponents;
57
import org.cyclops.integrateddynamics.core.block.VoxelShapeComponentsFactory;
58
import org.cyclops.integrateddynamics.core.blockentity.BlockEntityMultipartTicking;
59
import org.cyclops.integrateddynamics.core.helper.CableHelpers;
60
import org.cyclops.integrateddynamics.core.helper.NetworkHelpers;
61
import org.cyclops.integrateddynamics.core.helper.PartHelpers;
62

63
import javax.annotation.Nullable;
64
import java.util.Collection;
65
import java.util.Iterator;
66
import java.util.Map;
67
import java.util.Optional;
68
import java.util.concurrent.TimeUnit;
69

70
/**
71
 * A block that is built up from different parts.
72
 * This block refers to a ticking part entity.
73
 * @author rubensworks
74
 */
75
public class BlockCable extends BlockWithEntity implements SimpleWaterloggedBlock {
76

77
    public static final MapCodec<BlockCable> CODEC = simpleCodec(BlockCable::new);
3✔
78

79
    public static final float BLOCK_HARDNESS = 3.0F;
80

81
    public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
2✔
82

83
    // Model Properties
84
    public static final ModelProperty<Boolean> REALCABLE = new ModelProperty<>();
4✔
85
    public static final ModelProperty<Boolean>[] CONNECTED = new ModelProperty[6];
3✔
86
    public static final ModelProperty<PartRenderPosition>[] PART_RENDERPOSITIONS = new ModelProperty[6];
3✔
87
    public static final ModelProperty<Optional<BlockState>> FACADE = new ModelProperty<>();
4✔
88
    static {
89
        for(Direction side : Direction.values()) {
16✔
90
            CONNECTED[side.ordinal()] = new ModelProperty<>();
7✔
91
            PART_RENDERPOSITIONS[side.ordinal()] = new ModelProperty<>();
7✔
92
        }
93
    }
94
    public static final ModelProperty<IPartContainer> PARTCONTAINER = new ModelProperty<>();
4✔
95
    public static final ModelProperty<IRenderState> RENDERSTATE = new ModelProperty<>();
4✔
96

97
    // Collision boxes
98
    public final static AABB CABLE_CENTER_BOUNDINGBOX = new AABB(
10✔
99
            CableModel.MIN, CableModel.MIN, CableModel.MIN, CableModel.MAX, CableModel.MAX, CableModel.MAX);
100
    private final static EnumFacingMap<AABB> CABLE_SIDE_BOUNDINGBOXES = EnumFacingMap.forAllValues(
56✔
101
            new AABB(CableModel.MIN, 0, CableModel.MIN, CableModel.MAX, CableModel.MIN, CableModel.MAX), // DOWN
102
            new AABB(CableModel.MIN, CableModel.MAX, CableModel.MIN, CableModel.MAX, 1, CableModel.MAX), // UP
103
            new AABB(CableModel.MIN, CableModel.MIN, 0, CableModel.MAX, CableModel.MAX, CableModel.MIN), // NORTH
104
            new AABB(CableModel.MIN, CableModel.MAX, CableModel.MAX, CableModel.MAX, CableModel.MIN, 1), // SOUTH
105
            new AABB(0, CableModel.MIN, CableModel.MIN, CableModel.MIN, CableModel.MAX, CableModel.MAX), // WEST
106
            new AABB(CableModel.MAX, CableModel.MIN, CableModel.MIN, 1, CableModel.MAX, CableModel.MAX) // EAST
107
    );
108

109
    private final VoxelShapeComponentsFactory voxelShapeComponentsFactory = new VoxelShapeComponentsFactory(
31✔
110
            new VoxelShapeComponentsFactoryHandlerCableCenter(),
111
            new VoxelShapeComponentsFactoryHandlerCableConnections(),
112
            new VoxelShapeComponentsFactoryHandlerParts(),
113
            new VoxelShapeComponentsFactoryHandlerFacade()
114
    );
115

116
    @Setter
7✔
117
    private boolean disableCollisionBox = false;
118

119
    /**
120
     * Flag to skip expensive network initialization during bulk cable placement.
121
     * When true, onCableAdded calls are skipped in onPlace.
122
     * Network initialization should be done manually after all cables are placed.
123
     */
124
    public static boolean SKIP_NETWORK_INIT = false;
3✔
125

126
    public BlockCable(Properties properties) {
127
        super(properties, BlockEntityMultipartTicking::new);
4✔
128
        this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false));
11✔
129
    }
1✔
130

131
    @Override
132
    protected MapCodec<? extends BaseEntityBlock> codec() {
133
        return CODEC;
×
134
    }
135

136
    @Override
137
    public boolean useShapeForLightOcclusion(BlockState p_60576_) {
138
        return true;
2✔
139
    }
140

141
    @Override
142
    @Nullable
143
    public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
144
        return level.isClientSide ? null : createTickerHelper(blockEntityType, RegistryEntries.BLOCK_ENTITY_MULTIPART_TICKING.get(), new BlockEntityMultipartTicking.Ticker<>());
12!
145
    }
146

147
    @Override
148
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
149
        super.createBlockStateDefinition(builder);
3✔
150
        builder.add(WATERLOGGED);
9✔
151
    }
1✔
152

153
    @Override
154
    public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) {
155
        if (stateIn.getValue(WATERLOGGED)) {
6!
156
            worldIn.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(worldIn));
×
157
        }
158
        NetworkHelpers.onElementProviderBlockNeighborChange((Level) worldIn, currentPos, facingState.getBlock(), facing, facingPos);
8✔
159
        return super.updateShape(stateIn, facing, facingState, worldIn, currentPos, facingPos);
9✔
160
    }
161

162
    @Override
163
    public BlockState getStateForPlacement(BlockPlaceContext context) {
164
        FluidState ifluidstate = context.getLevel().getFluidState(context.getClickedPos());
6✔
165
        return this.defaultBlockState().setValue(WATERLOGGED, ifluidstate.getType() == Fluids.WATER);
12!
166
    }
167

168
    @Override
169
    public FluidState getFluidState(BlockState state) {
170
        return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
14✔
171
    }
172

173
    @Override
174
    public boolean canPlaceLiquid(@org.jetbrains.annotations.Nullable Player player, BlockGetter worldIn, BlockPos pos, BlockState blockState, Fluid fluidIn) {
175
        return !blockState.getValue(BlockStateProperties.WATERLOGGED) && fluidIn == Fluids.WATER
8!
176
                && !(worldIn instanceof ILevelExtension levelExtension && CableHelpers.hasFacade(levelExtension, pos));
3!
177
    }
178

179
    @Override
180
    public void onBlockExploded(BlockState state, Level world, BlockPos blockPos, Explosion explosion) {
181
        CableHelpers.setRemovingCable(true);
2✔
182
        CableHelpers.onCableRemoving(world, blockPos, true, false, state);
7✔
183
        Collection<Direction> connectedCables = CableHelpers.getExternallyConnectedCables(world, blockPos);
4✔
184
        super.onBlockExploded(state, world, blockPos, explosion);
6✔
185
        CableHelpers.onCableRemoved(world, blockPos, connectedCables);
5✔
186
        CableHelpers.setRemovingCable(false);
2✔
187
    }
1✔
188

189
    @Override
190
    public boolean onDestroyedByPlayer(BlockState state, Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) {
191
        BlockRayTraceResultComponent rayTraceResult = getSelectedShape(state, world, pos, CollisionContext.of(player))
9✔
192
                .rayTrace(pos, player);
2✔
193
        if (rayTraceResult != null && rayTraceResult.getComponent().destroy(world, pos, player, false)) {
10!
194
            return false;
2✔
195
        }
196
        return rayTraceResult != null && super.onDestroyedByPlayer(state, world, pos, player, willHarvest, fluid);
13!
197
    }
198

199
    @Override
200
    public void onRemove(BlockState state, Level world, BlockPos blockPos, BlockState newState, boolean isMoving) {
201
        if (newState.getBlock() != this) {
4!
202
            Collection<Direction> connectedCables = null;
2✔
203
            if (!CableHelpers.isRemovingCable()) {
2✔
204
                CableHelpers.onCableRemoving(world, blockPos, false, false, state);
7✔
205
                connectedCables = CableHelpers.getExternallyConnectedCables(world, blockPos);
4✔
206
            }
207
            super.onRemove(state, world, blockPos, newState, isMoving);
7✔
208
            if (!CableHelpers.isRemovingCable() && !SKIP_NETWORK_INIT) {
4!
209
                CableHelpers.onCableRemoved(world, blockPos, connectedCables);
5✔
210
            }
211
        } else {
1✔
212
            super.onRemove(state, world, blockPos, newState, isMoving);
×
213
        }
214
    }
1✔
215

216
    @Override
217
    protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHitResult) {
218
        /*
219
            Wrench: sneak + right-click anywhere on cable to remove cable
220
                    right-click on a cable side to disconnect on that side
221
                    sneak + right-click on part to remove that part
222
            No wrench: right-click to open GUI
223
         */
224
        BlockEntityMultipartTicking tile = BlockEntityHelpers.get(pLevel, pPos, BlockEntityMultipartTicking.class).orElse(null);
8✔
225
        if(tile != null) {
2!
226
            BlockRayTraceResultComponent rayTraceResult = getSelectedShape(pState, pLevel, pPos, CollisionContext.of(pPlayer))
9✔
227
                    .rayTrace(pPos, pPlayer);
2✔
228
            if(rayTraceResult != null) {
2!
229
                InteractionResult actionResultType = rayTraceResult.getComponent().onBlockActivated(pState, pLevel, pPos, pPlayer, pHand, rayTraceResult);
10✔
230
                if (actionResultType.consumesAction()) {
3!
231
                    // TODO: in next major, return ItemInteractionResult in onBlockActivated so this workaround can be removed.
232
                    if (actionResultType == InteractionResult.SUCCESS) {
3!
233
                        return ItemInteractionResult.SUCCESS;
2✔
234
                    } else if (actionResultType == InteractionResult.CONSUME) {
×
235
                        return ItemInteractionResult.CONSUME;
×
236
                    } else if (actionResultType == InteractionResult.CONSUME_PARTIAL) {
×
237
                        return ItemInteractionResult.CONSUME_PARTIAL;
×
238
                    } else if (actionResultType == InteractionResult.SUCCESS_NO_ITEM_USED) {
×
239
                        return ItemInteractionResult.SUCCESS;
×
240
                    }
241
                    return ItemInteractionResult.SUCCESS;
×
242
                }
243
            }
244
        }
245
        return super.useItemOn(pStack, pState, pLevel, pPos, pPlayer, pHand, pHitResult);
×
246
    }
247

248
    @Override
249
    public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) {
250
        super.onPlace(state, world, pos, oldState, isMoving);
7✔
251
        if (!world.isClientSide() && !SKIP_NETWORK_INIT) {
5!
252
            ICableFakeable cableFakeable = CableHelpers.getCableFakeable(world, pos, null).orElse(null);
8✔
253
            if (cableFakeable != null && cableFakeable.isRealCable()) {
5!
254
                CableHelpers.onCableAdded(world, pos);
3✔
255
            }
256
        }
257
    }
1✔
258

259
    @Override
260
    public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
261
        super.setPlacedBy(world, pos, state, placer, itemStack);
7✔
262
        if (!world.isClientSide()) {
3!
263
            CableHelpers.onCableAddedByPlayer(world, pos, placer);
4✔
264
        }
265
    }
1✔
266

267
    @Override
268
    public ItemStack getCloneItemStack(BlockState state, net.minecraft.world.phys.HitResult target, LevelReader world,
269
                                  BlockPos blockPos, Player player) {
270
        BlockRayTraceResultComponent rayTraceResult = getSelectedShape(state, world, blockPos, CollisionContext.of(player))
×
271
                .rayTrace(blockPos, player);
×
272
        if(rayTraceResult != null) {
×
273
            return rayTraceResult.getComponent().getCloneItemStack((Level) world, blockPos);
×
274
        }
275
        return getCloneItemStack(world, blockPos, state);
×
276
    }
277

278
    @SuppressWarnings("deprecation")
279
    @Override
280
    public void neighborChanged(BlockState state, Level world, BlockPos pos, Block neighborBlock, BlockPos fromPos, boolean isMoving) {
281
        super.neighborChanged(state, world, pos, neighborBlock, fromPos, isMoving);
8✔
282
        NetworkHelpers.onElementProviderBlockNeighborChange(world, pos, neighborBlock, null, fromPos);
6✔
283
    }
1✔
284

285
    @Override
286
    public void onNeighborChange(BlockState state, LevelReader world, BlockPos pos, BlockPos neighbor) {
287
        super.onNeighborChange(state, world, pos, neighbor);
6✔
288
        if (world instanceof Level level) {
6!
289
            NetworkHelpers.onElementProviderBlockNeighborChange(level, pos, world.getBlockState(neighbor).getBlock(), null, neighbor);
9✔
290
        }
291
    }
1✔
292

293
    @Override
294
    public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource rand) {
295
        super.tick(state, world, pos, rand);
×
296
        BlockEntityHelpers.get(world, pos, BlockEntityMultipartTicking.class)
×
297
                .ifPresent(tile -> {
×
298
                    for (Map.Entry<Direction, PartHelpers.PartStateHolder<?, ?>> entry : tile
×
299
                            .getPartContainer().getPartData().entrySet()) {
×
300
                        updateTickPart(entry.getValue().getPart(), world, pos, entry.getValue().getState(), rand);
×
301
                    }
×
302
                });
×
303
    }
×
304

305
    protected void updateTickPart(IPartType partType, Level world, BlockPos pos, IPartState partState, RandomSource random) {
306
        partType.updateTick(world, pos, partState, random);
×
307
    }
×
308

309
    /* --------------- Start shapes and rendering --------------- */
310

311
    public AABB getCableBoundingBox(Direction side) {
312
        if (side == null) {
×
313
            return CABLE_CENTER_BOUNDINGBOX;
×
314
        } else {
315
            return CABLE_SIDE_BOUNDINGBOXES.get(side);
×
316
        }
317
    }
318

319
    public VoxelShapeComponents getSelectedShape(BlockState blockState, BlockGetter world, BlockPos pos, CollisionContext selectionContext) {
320
        return voxelShapeComponentsFactory.createShape(blockState, world, pos, selectionContext);
8✔
321
    }
322

323
    private final Cache<String, VoxelShape> CACHE_COLLISION_SHAPES = CacheBuilder.newBuilder()
4✔
324
            .expireAfterAccess(1, TimeUnit.MINUTES)
1✔
325
            .build();
2✔
326

327
    @SneakyThrows
×
328
    @Override
329
    public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) {
330
        VoxelShapeComponents selectedShape = getSelectedShape(state, world, pos, selectionContext);
7✔
331
        BlockRayTraceResultComponent rayTraceResult = selectedShape.rayTrace(pos, selectionContext instanceof EntityCollisionContext ? ((EntityCollisionContext) selectionContext).getEntity() : null);
11!
332
        if (rayTraceResult != null) {
2!
333
            return rayTraceResult.getComponent().getShape(state, world, pos, selectionContext);
×
334
        }
335

336
        String cableState = selectedShape.getStateId();
3✔
337

338
        // Cache the operations below, as they are too expensive to execute each render tick
339
        return CACHE_COLLISION_SHAPES.get(cableState, () -> {
8✔
340
            // Combine all VoxelShapes using IBooleanFunction.OR,
341
            // because for some reason our VoxelShapeComponents aggregator does not handle collisions properly.
342
            // This can probably be fixed, but I spent too much time on this already, and the current solution works just fine.
343
            Iterator<VoxelShape> it = selectedShape.iterator();
3✔
344
            if (!it.hasNext()) {
3✔
345
                return Shapes.empty();
2✔
346
            }
347
            VoxelShape shape = it.next();
4✔
348
            while (it.hasNext()) {
3✔
349
                shape = Shapes.join(shape, it.next(), BooleanOp.OR);
8✔
350
            }
351
            return shape.optimize();
3✔
352
        });
353
    }
354

355
    @Override
356
    public VoxelShape getCollisionShape(BlockState blockState, BlockGetter world, BlockPos pos, CollisionContext selectionContext) {
357
        return (disableCollisionBox || GeneralConfig.disableCableCollision) ? Shapes.empty() : super.getCollisionShape(blockState, world, pos, selectionContext);
12!
358
    }
359

360
    @Override
361
    public boolean hasDynamicShape() {
362
        return BlockCableConfig.dynamicShape;
2✔
363
    }
364

365
    @Override
366
    public int getLightBlock(BlockState blockState, BlockGetter world, BlockPos pos) {
367
        if (world instanceof Level level) {
6✔
368
            if (CableHelpers.isLightTransparent(level, pos, null, blockState)) {
6!
369
                return 0;
×
370
            }
371
            return CableHelpers.getFacade(level, pos, blockState)
8✔
372
                    .map(facade -> facade.getLightBlock(world, pos))
2✔
373
                    .orElse(0);
4✔
374
        }
375
        return 0;
2✔
376
    }
377

378
    @Override
379
    public RenderShape getRenderShape(BlockState blockState) {
380
        return RenderShape.MODEL;
×
381
    }
382

383
    @Override
384
    protected VoxelShape getBlockSupportShape(BlockState pState, BlockGetter pLevel, BlockPos pPos) {
385
        return this.getShape(pState, pLevel, pPos, new CollisionContextBlockSupport());
9✔
386
    }
387

388
    @Override
389
    public boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter world, BlockPos pos, FluidState fluidState) {
390
        return world instanceof ILevelExtension levelExtension && CableHelpers.getFacade(levelExtension, pos).isPresent();
×
391
    }
392

393
    /* --------------- Start IDynamicRedstone --------------- */
394

395
    @SuppressWarnings("deprecation")
396
    @Override
397
    public boolean isSignalSource(BlockState blockState) {
398
        return true;
×
399
    }
400

401
    @Override
402
    public boolean canConnectRedstone(BlockState blockState, BlockGetter world, BlockPos pos, Direction side) {
403
        if (world instanceof ILevelExtension levelExtension) {
6!
404
            if (side == null) {
2!
405
                for (Direction dummySide : Direction.values()) {
×
406
                    IDynamicRedstone dynamicRedstone = BlockEntityHelpers.getCapability(levelExtension, pos, dummySide, Capabilities.DynamicRedstone.BLOCK).orElse(null);
×
407
                    if (dynamicRedstone != null && (dynamicRedstone.getRedstoneLevel() >= 0 || dynamicRedstone.isAllowRedstoneInput())) {
×
408
                        return true;
×
409
                    }
410
                }
411
                return false;
×
412
            }
413
            IDynamicRedstone dynamicRedstone = BlockEntityHelpers.getCapability(levelExtension, pos, side.getOpposite(), Capabilities.DynamicRedstone.BLOCK).orElse(null);
10✔
414
            return dynamicRedstone != null && (dynamicRedstone.getRedstoneLevel() >= 0 || dynamicRedstone.isAllowRedstoneInput());
12!
415
        }
416
        return false;
×
417
    }
418

419
    @SuppressWarnings("deprecation")
420
    @Override
421
    public int getDirectSignal(BlockState blockState, BlockGetter world, BlockPos pos, Direction side) {
422
        if (world instanceof ILevelExtension levelExtension) {
6!
423
            IDynamicRedstone dynamicRedstone = BlockEntityHelpers.getCapability(levelExtension, pos, side.getOpposite(), Capabilities.DynamicRedstone.BLOCK).orElse(null);
10✔
424
            return dynamicRedstone != null && dynamicRedstone.isDirect() ? dynamicRedstone.getRedstoneLevel() : 0;
7!
425
        }
426
        return 0;
×
427
    }
428

429
    @SuppressWarnings("deprecation")
430
    @Override
431
    public int getSignal(BlockState blockState, BlockGetter world, BlockPos pos, Direction side) {
432
        if (world instanceof ILevelExtension levelExtension) {
6!
433
            IDynamicRedstone dynamicRedstone = BlockEntityHelpers.getCapability(levelExtension, pos, side.getOpposite(), Capabilities.DynamicRedstone.BLOCK).orElse(null);
10✔
434
            return dynamicRedstone != null ? dynamicRedstone.getRedstoneLevel() : 0;
6!
435
        }
436
        return 0;
×
437
    }
438

439
    /* --------------- Start IDynamicLight --------------- */
440

441
    @Override
442
    public int getLightEmission(BlockState blockState, BlockGetter world, BlockPos pos) {
443
        int light = 0;
2✔
444
        if (world instanceof ILevelExtension levelExtension) {
6✔
445
            for (Direction side : Direction.values()) {
16✔
446
                IDynamicLight dynamicLight = levelExtension.getCapability(Capabilities.DynamicLight.BLOCK, pos, blockState, null, side);
9✔
447
                if (dynamicLight != null) {
2✔
448
                    light = Math.max(light, dynamicLight.getLightLevel());
5✔
449
                }
450
            }
451
        }
452
        return light;
2✔
453
    }
454

455
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc