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

CyclopsMC / IntegratedDynamics / 24034486947

06 Apr 2026 01:51PM UTC coverage: 53.645% (-0.08%) from 53.721%
24034486947

push

github

rubensworks
Update to MC 26.1.1

3052 of 8931 branches covered (34.17%)

Branch coverage included in aggregate %.

18680 of 31580 relevant lines covered (59.15%)

3.07 hits per line

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

0.0
/src/main/java/org/cyclops/integrateddynamics/block/BlockCableClientConfig.java
1
package org.cyclops.integrateddynamics.block;
2

3
import net.minecraft.client.Minecraft;
4
import net.minecraft.client.color.block.BlockTintSource;
5
import net.minecraft.client.multiplayer.ClientLevel;
6
import net.minecraft.client.particle.ParticleEngine;
7
import net.minecraft.client.renderer.block.BlockAndTintGetter;
8
import net.minecraft.client.renderer.block.dispatch.BlockStateModel;
9
import net.minecraft.client.renderer.item.ItemModel;
10
import net.minecraft.client.renderer.texture.TextureAtlas;
11
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
12
import net.minecraft.core.BlockPos;
13
import net.minecraft.core.registries.BuiltInRegistries;
14
import net.minecraft.resources.Identifier;
15
import net.minecraft.world.level.Level;
16
import net.minecraft.world.level.block.state.BlockState;
17
import net.minecraft.world.phys.BlockHitResult;
18
import net.minecraft.world.phys.HitResult;
19
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
20
import net.neoforged.neoforge.client.event.RegisterItemModelsEvent;
21
import net.neoforged.neoforge.client.event.TextureAtlasStitchedEvent;
22
import net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions;
23
import net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent;
24
import org.apache.commons.lang3.tuple.Pair;
25
import org.cyclops.cyclopscore.client.model.IDynamicModelElementCommon;
26
import org.cyclops.cyclopscore.config.extendedconfig.BlockClientConfig;
27
import org.cyclops.cyclopscore.config.extendedconfig.BlockConfigCommon;
28
import org.cyclops.cyclopscore.helper.IModHelpers;
29
import org.cyclops.integrateddynamics.IntegratedDynamics;
30
import org.cyclops.integrateddynamics.Reference;
31
import org.cyclops.integrateddynamics.RegistryEntries;
32
import org.cyclops.integrateddynamics.client.model.CableModel;
33
import org.cyclops.integrateddynamics.core.client.model.ItemModelCable;
34
import org.cyclops.integrateddynamics.core.helper.CableHelpers;
35

36
import java.util.List;
37
import java.util.function.Consumer;
38
import java.util.function.Function;
39

40
public class BlockCableClientConfig extends BlockClientConfig<IntegratedDynamics> {
41

42
    public static TextureAtlasSprite BLOCK_TEXTURE;
43

44
    public BlockCableClientConfig(BlockConfigCommon<IntegratedDynamics> blockConfig) {
45
        super(blockConfig);
×
46
        blockConfig.getMod().getModEventBus().addListener(this::onRegisterColors);
×
47
        blockConfig.getMod().getModEventBus().addListener(this::registerClientExtensions);
×
48
        blockConfig.getMod().getModEventBus().addListener(this::postTextureStitch);
×
49
        blockConfig.getMod().getModEventBus().addListener((RegisterItemModelsEvent event) -> event.register(Identifier.fromNamespaceAndPath(Reference.MOD_ID, "cable"), ItemModelCable.Unbaked.MAP_CODEC));
×
50
    }
×
51

52
    public void onRegisterColors(RegisterColorHandlersEvent.BlockTintSources event) {
53
        event.register(List.of(new BlockCableClientConfig.BlockColor()), getBlockConfig().getInstance());
×
54
    }
×
55

56
    public void postTextureStitch(TextureAtlasStitchedEvent event) {
57
        if (event.getAtlas().location().equals(TextureAtlas.LOCATION_BLOCKS)) {
×
58
            BLOCK_TEXTURE = event.getAtlas().getSprite(Identifier.fromNamespaceAndPath(Reference.MOD_ID, "block/cable"));
×
59
        }
60
    }
×
61

62
    public void registerClientExtensions(RegisterClientExtensionsEvent event) {
63
        event.registerBlock(new IClientBlockExtensions() {
×
64
            @Override
65
            public boolean addHitEffects(BlockState blockState, Level world, HitResult target, ParticleEngine particleManager) {
66
                BlockPos blockPos = ((BlockHitResult) target).getBlockPos();
×
67
                if(CableHelpers.hasFacade(world, blockPos, blockState)) {
×
68
                    CableHelpers.getFacade(world, blockPos, blockState)
×
69
                            .ifPresent(facadeState -> IModHelpers.get().getRenderHelpers().addBlockHitEffects(particleManager, (ClientLevel) world, facadeState, blockPos, ((BlockHitResult) target).getDirection()));
×
70
                    return true;
×
71
                } else {
72
                    return false;
×
73
                }
74
            }
75
        }, getBlockConfig().getInstance());
×
76
    }
×
77

78
    @Override
79
    public IDynamicModelElementCommon getDynamicModelElement() {
80
        return new DynamicModel();
×
81
    }
82

83
    public static class BlockColor implements BlockTintSource {
×
84
        @Override
85
        public int color(BlockState blockState) {
86
            return -1;
×
87
        }
88

89
        @Override
90
        public int colorInWorld(BlockState blockState, BlockAndTintGetter world, BlockPos blockPos) {
91
            return CableHelpers.getFacadeMultipartTicking(world, blockPos)
×
92
                    .map(facadeState -> {
×
93
                        BlockTintSource tintSource = Minecraft.getInstance().getBlockColors().getTintSource(facadeState, 0);
×
94
                        if (tintSource != null) {
×
95
                            return tintSource.colorInWorld(facadeState, world, blockPos);
×
96
                        }
97
                        return -1;
×
98
                    })
99
                    .orElse(-1);
×
100
        }
101
    }
102

103
    public static class DynamicModel implements IDynamicModelElementCommon {
×
104
        @Override
105
        public BlockStateModel createDynamicBlockModel(Consumer<Pair<BlockState, BlockStateModel>> modelConsumer, Function<BlockState, BlockStateModel> modelRetriever) {
106
            CableModel model = new CableModel();
×
107
            modelConsumer.accept(Pair.of(RegistryEntries.BLOCK_CABLE.get().defaultBlockState(), model));
×
108
            modelConsumer.accept(Pair.of(RegistryEntries.BLOCK_CABLE.get().defaultBlockState().setValue(BlockCable.WATERLOGGED, true), model));
×
109
            return model;
×
110
        }
111

112
        @Override
113
        public ItemModel createDynamicItemModel(Consumer<Pair<Identifier, ItemModel>> modelConsumer, Function<Identifier, ItemModel> modelRetriever) {
114
            ItemModelCable model = new ItemModelCable(new CableModel());
×
115
            Identifier registryName = BuiltInRegistries.BLOCK.getKey(RegistryEntries.BLOCK_CABLE.get());
×
116
            modelConsumer.accept(Pair.of(registryName, model));
×
117
            return model;
×
118
        }
119
    }
120
}
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