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

CyclopsMC / IntegratedDynamics / 18042102834

26 Sep 2025 03:25PM UTC coverage: 44.791% (-0.1%) from 44.905%
18042102834

push

github

rubensworks
Merge remote-tracking branch 'origin/master-1.20-lts' into master-1.21-lts

2572 of 8540 branches covered (30.12%)

Branch coverage included in aggregate %.

11761 of 23460 relevant lines covered (50.13%)

2.38 hits per line

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

63.35
/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(
57✔
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
    public BlockCable(Properties properties) {
120
        super(properties, BlockEntityMultipartTicking::new);
4✔
121
        this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false));
11✔
122
    }
1✔
123

124
    @Override
125
    protected MapCodec<? extends BaseEntityBlock> codec() {
126
        return CODEC;
×
127
    }
128

129
    @Override
130
    public boolean useShapeForLightOcclusion(BlockState p_60576_) {
131
        return true;
2✔
132
    }
133

134
    @Override
135
    @Nullable
136
    public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState blockState, BlockEntityType<T> blockEntityType) {
137
        return level.isClientSide ? null : createTickerHelper(blockEntityType, RegistryEntries.BLOCK_ENTITY_MULTIPART_TICKING.get(), new BlockEntityMultipartTicking.Ticker<>());
12!
138
    }
139

140
    @Override
141
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
142
        super.createBlockStateDefinition(builder);
3✔
143
        builder.add(WATERLOGGED);
9✔
144
    }
1✔
145

146
    @Override
147
    public BlockState updateShape(BlockState stateIn, Direction facing, BlockState facingState, LevelAccessor worldIn, BlockPos currentPos, BlockPos facingPos) {
148
        if (stateIn.getValue(WATERLOGGED)) {
6!
149
            worldIn.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(worldIn));
×
150
        }
151
        NetworkHelpers.onElementProviderBlockNeighborChange((Level) worldIn, currentPos, facingState.getBlock(), facing, facingPos);
8✔
152
        return super.updateShape(stateIn, facing, facingState, worldIn, currentPos, facingPos);
9✔
153
    }
154

155
    @Override
156
    public BlockState getStateForPlacement(BlockPlaceContext context) {
157
        FluidState ifluidstate = context.getLevel().getFluidState(context.getClickedPos());
6✔
158
        return this.defaultBlockState().setValue(WATERLOGGED, ifluidstate.getType() == Fluids.WATER);
12!
159
    }
160

161
    @Override
162
    public FluidState getFluidState(BlockState state) {
163
        return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
14✔
164
    }
165

166
    @Override
167
    public boolean canPlaceLiquid(@org.jetbrains.annotations.Nullable Player player, BlockGetter worldIn, BlockPos pos, BlockState blockState, Fluid fluidIn) {
168
        return !blockState.getValue(BlockStateProperties.WATERLOGGED) && fluidIn == Fluids.WATER
8!
169
                && !(worldIn instanceof ILevelExtension levelExtension && CableHelpers.hasFacade(levelExtension, pos));
3!
170
    }
171

172
    @Override
173
    public void onBlockExploded(BlockState state, Level world, BlockPos blockPos, Explosion explosion) {
174
        CableHelpers.setRemovingCable(true);
2✔
175
        CableHelpers.onCableRemoving(world, blockPos, true, false, state);
7✔
176
        Collection<Direction> connectedCables = CableHelpers.getExternallyConnectedCables(world, blockPos);
4✔
177
        super.onBlockExploded(state, world, blockPos, explosion);
6✔
178
        CableHelpers.onCableRemoved(world, blockPos, connectedCables);
5✔
179
        CableHelpers.setRemovingCable(false);
2✔
180
    }
1✔
181

182
    @Override
183
    public boolean onDestroyedByPlayer(BlockState state, Level world, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) {
184
        BlockRayTraceResultComponent rayTraceResult = getSelectedShape(state, world, pos, CollisionContext.of(player))
9✔
185
                .rayTrace(pos, player);
2✔
186
        if (rayTraceResult != null && rayTraceResult.getComponent().destroy(world, pos, player, false)) {
10!
187
            return false;
2✔
188
        }
189
        return rayTraceResult != null && super.onDestroyedByPlayer(state, world, pos, player, willHarvest, fluid);
13!
190
    }
191

192
    @Override
193
    public void onRemove(BlockState state, Level world, BlockPos blockPos, BlockState newState, boolean isMoving) {
194
        if (newState.getBlock() != this) {
4!
195
            Collection<Direction> connectedCables = null;
2✔
196
            if (!CableHelpers.isRemovingCable()) {
2✔
197
                CableHelpers.onCableRemoving(world, blockPos, false, false, state);
7✔
198
                connectedCables = CableHelpers.getExternallyConnectedCables(world, blockPos);
4✔
199
            }
200
            super.onRemove(state, world, blockPos, newState, isMoving);
7✔
201
            if (!CableHelpers.isRemovingCable()) {
2✔
202
                CableHelpers.onCableRemoved(world, blockPos, connectedCables);
5✔
203
            }
204
        } else {
1✔
205
            super.onRemove(state, world, blockPos, newState, isMoving);
×
206
        }
207
    }
1✔
208

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

241
    @Override
242
    public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean isMoving) {
243
        super.onPlace(state, world, pos, oldState, isMoving);
7✔
244
        if (!world.isClientSide()) {
3!
245
            ICableFakeable cableFakeable = CableHelpers.getCableFakeable(world, pos, null).orElse(null);
8✔
246
            if (cableFakeable != null && cableFakeable.isRealCable()) {
5!
247
                CableHelpers.onCableAdded(world, pos);
3✔
248
            }
249
        }
250
    }
1✔
251

252
    @Override
253
    public void setPlacedBy(Level world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) {
254
        super.setPlacedBy(world, pos, state, placer, itemStack);
7✔
255
        if (!world.isClientSide()) {
3!
256
            CableHelpers.onCableAddedByPlayer(world, pos, placer);
4✔
257
        }
258
    }
1✔
259

260
    @Override
261
    public ItemStack getCloneItemStack(BlockState state, net.minecraft.world.phys.HitResult target, LevelReader world,
262
                                  BlockPos blockPos, Player player) {
263
        BlockRayTraceResultComponent rayTraceResult = getSelectedShape(state, world, blockPos, CollisionContext.of(player))
×
264
                .rayTrace(blockPos, player);
×
265
        if(rayTraceResult != null) {
×
266
            return rayTraceResult.getComponent().getCloneItemStack((Level) world, blockPos);
×
267
        }
268
        return getCloneItemStack(world, blockPos, state);
×
269
    }
270

271
    @SuppressWarnings("deprecation")
272
    @Override
273
    public void neighborChanged(BlockState state, Level world, BlockPos pos, Block neighborBlock, BlockPos fromPos, boolean isMoving) {
274
        super.neighborChanged(state, world, pos, neighborBlock, fromPos, isMoving);
8✔
275
        NetworkHelpers.onElementProviderBlockNeighborChange(world, pos, neighborBlock, null, fromPos);
6✔
276
    }
1✔
277

278
    @Override
279
    public void onNeighborChange(BlockState state, LevelReader world, BlockPos pos, BlockPos neighbor) {
280
        super.onNeighborChange(state, world, pos, neighbor);
6✔
281
        if (world instanceof Level level) {
6!
282
            NetworkHelpers.onElementProviderBlockNeighborChange(level, pos, world.getBlockState(neighbor).getBlock(), null, neighbor);
9✔
283
        }
284
    }
1✔
285

286
    @Override
287
    public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource rand) {
288
        super.tick(state, world, pos, rand);
×
289
        BlockEntityHelpers.get(world, pos, BlockEntityMultipartTicking.class)
×
290
                .ifPresent(tile -> {
×
291
                    for (Map.Entry<Direction, PartHelpers.PartStateHolder<?, ?>> entry : tile
×
292
                            .getPartContainer().getPartData().entrySet()) {
×
293
                        updateTickPart(entry.getValue().getPart(), world, pos, entry.getValue().getState(), rand);
×
294
                    }
×
295
                });
×
296
    }
×
297

298
    protected void updateTickPart(IPartType partType, Level world, BlockPos pos, IPartState partState, RandomSource random) {
299
        partType.updateTick(world, pos, partState, random);
×
300
    }
×
301

302
    /* --------------- Start shapes and rendering --------------- */
303

304
    public AABB getCableBoundingBox(Direction side) {
305
        if (side == null) {
×
306
            return CABLE_CENTER_BOUNDINGBOX;
×
307
        } else {
308
            return CABLE_SIDE_BOUNDINGBOXES.get(side);
×
309
        }
310
    }
311

312
    public VoxelShapeComponents getSelectedShape(BlockState blockState, BlockGetter world, BlockPos pos, CollisionContext selectionContext) {
313
        return voxelShapeComponentsFactory.createShape(blockState, world, pos, selectionContext);
8✔
314
    }
315

316
    private final Cache<String, VoxelShape> CACHE_COLLISION_SHAPES = CacheBuilder.newBuilder()
4✔
317
            .expireAfterAccess(1, TimeUnit.MINUTES)
1✔
318
            .build();
2✔
319

320
    @SneakyThrows
×
321
    @Override
322
    public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext selectionContext) {
323
        VoxelShapeComponents selectedShape = getSelectedShape(state, world, pos, selectionContext);
7✔
324
        BlockRayTraceResultComponent rayTraceResult = selectedShape.rayTrace(pos, selectionContext instanceof EntityCollisionContext ? ((EntityCollisionContext) selectionContext).getEntity() : null);
11!
325
        if (rayTraceResult != null) {
2!
326
            return rayTraceResult.getComponent().getShape(state, world, pos, selectionContext);
×
327
        }
328

329
        String cableState = selectedShape.getStateId();
3✔
330

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

348
    @Override
349
    public VoxelShape getCollisionShape(BlockState blockState, BlockGetter world, BlockPos pos, CollisionContext selectionContext) {
350
        return (disableCollisionBox || GeneralConfig.disableCableCollision) ? Shapes.empty() : super.getCollisionShape(blockState, world, pos, selectionContext);
12!
351
    }
352

353
    @Override
354
    public boolean hasDynamicShape() {
355
        return BlockCableConfig.dynamicShape;
2✔
356
    }
357

358
    @Override
359
    public int getLightBlock(BlockState blockState, BlockGetter world, BlockPos pos) {
360
        if (world instanceof Level level) {
6✔
361
            if (CableHelpers.isLightTransparent(level, pos, null, blockState)) {
6!
362
                return 0;
×
363
            }
364
            return CableHelpers.getFacade(level, pos, blockState)
8✔
365
                    .map(facade -> facade.getLightBlock(world, pos))
2✔
366
                    .orElse(0);
4✔
367
        }
368
        return 0;
2✔
369
    }
370

371
    @Override
372
    public RenderShape getRenderShape(BlockState blockState) {
373
        return RenderShape.MODEL;
×
374
    }
375

376
    @Override
377
    protected VoxelShape getBlockSupportShape(BlockState pState, BlockGetter pLevel, BlockPos pPos) {
378
        return this.getShape(pState, pLevel, pPos, new CollisionContextBlockSupport());
9✔
379
    }
380

381
    @Override
382
    public boolean shouldDisplayFluidOverlay(BlockState state, BlockAndTintGetter world, BlockPos pos, FluidState fluidState) {
383
        return world instanceof ILevelExtension levelExtension && CableHelpers.getFacade(levelExtension, pos).isPresent();
×
384
    }
385

386
    /* --------------- Start IDynamicRedstone --------------- */
387

388
    @SuppressWarnings("deprecation")
389
    @Override
390
    public boolean isSignalSource(BlockState blockState) {
391
        return true;
×
392
    }
393

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

412
    @SuppressWarnings("deprecation")
413
    @Override
414
    public int getDirectSignal(BlockState blockState, BlockGetter world, BlockPos pos, Direction side) {
415
        if (world instanceof ILevelExtension levelExtension) {
6!
416
            IDynamicRedstone dynamicRedstone = BlockEntityHelpers.getCapability(levelExtension, pos, side.getOpposite(), Capabilities.DynamicRedstone.BLOCK).orElse(null);
10✔
417
            return dynamicRedstone != null && dynamicRedstone.isDirect() ? dynamicRedstone.getRedstoneLevel() : 0;
7!
418
        }
419
        return 0;
×
420
    }
421

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

432
    /* --------------- Start IDynamicLight --------------- */
433

434
    @Override
435
    public int getLightEmission(BlockState blockState, BlockGetter world, BlockPos pos) {
436
        int light = 0;
2✔
437
        if (world instanceof ILevelExtension levelExtension) {
6✔
438
            for (Direction side : Direction.values()) {
16✔
439
                IDynamicLight dynamicLight = levelExtension.getCapability(Capabilities.DynamicLight.BLOCK, pos, blockState, null, side);
9✔
440
                if (dynamicLight != null) {
2✔
441
                    light = Math.max(light, dynamicLight.getLightLevel());
5✔
442
                }
443
            }
444
        }
445
        return light;
2✔
446
    }
447

448
}
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