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

CyclopsMC / IntegratedDynamics / 14556514164

20 Apr 2025 05:42AM UTC coverage: 43.947% (+0.4%) from 43.541%
14556514164

push

github

rubensworks
Add network read aspects game tests

2448 of 8393 branches covered (29.17%)

Branch coverage included in aggregate %.

11331 of 22961 relevant lines covered (49.35%)

2.34 hits per line

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

63.44
/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.RegistryEntries;
44
import org.cyclops.integrateddynamics.api.block.IDynamicLight;
45
import org.cyclops.integrateddynamics.api.block.IDynamicRedstone;
46
import org.cyclops.integrateddynamics.api.block.cable.ICableFakeable;
47
import org.cyclops.integrateddynamics.api.part.IPartContainer;
48
import org.cyclops.integrateddynamics.api.part.IPartState;
49
import org.cyclops.integrateddynamics.api.part.IPartType;
50
import org.cyclops.integrateddynamics.api.part.PartRenderPosition;
51
import org.cyclops.integrateddynamics.block.shapes.*;
52
import org.cyclops.integrateddynamics.client.model.CableModel;
53
import org.cyclops.integrateddynamics.client.model.IRenderState;
54
import org.cyclops.integrateddynamics.core.block.BlockRayTraceResultComponent;
55
import org.cyclops.integrateddynamics.core.block.VoxelShapeComponents;
56
import org.cyclops.integrateddynamics.core.block.VoxelShapeComponentsFactory;
57
import org.cyclops.integrateddynamics.core.blockentity.BlockEntityMultipartTicking;
58
import org.cyclops.integrateddynamics.core.helper.CableHelpers;
59
import org.cyclops.integrateddynamics.core.helper.NetworkHelpers;
60
import org.cyclops.integrateddynamics.core.helper.PartHelpers;
61

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

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

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

78
    public static final float BLOCK_HARDNESS = 3.0F;
79

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

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

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

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

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

118
    public BlockCable(Properties properties) {
119
        super(properties, BlockEntityMultipartTicking::new);
4✔
120
        this.registerDefaultState(this.stateDefinition.any().setValue(WATERLOGGED, false));
11✔
121
    }
1✔
122

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

385
    /* --------------- Start IDynamicRedstone --------------- */
386

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

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

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

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

431
    /* --------------- Start IDynamicLight --------------- */
432

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

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