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

CyclopsMC / IntegratedDynamics / 36319118540

27 Sep 2026 12:28PM UTC coverage: 48.259% (+0.2%) from 48.068%
36319118540

Pull #1753

github

web-flow
Merge 414d3da58 into 2af9e4141
Pull Request #1753: Stop ticking cables without parts

3481 of 9861 branches covered (35.3%)

Branch coverage included in aggregate %.

13734 of 25811 relevant lines covered (53.21%)

2.55 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.multiplayer.ClientLevel;
5
import net.minecraft.client.particle.ParticleEngine;
6
import net.minecraft.client.renderer.block.BlockModelShaper;
7
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
8
import net.minecraft.client.resources.model.BakedModel;
9
import net.minecraft.client.resources.model.ModelResourceLocation;
10
import net.minecraft.core.BlockPos;
11
import net.minecraft.core.registries.BuiltInRegistries;
12
import net.minecraft.resources.ResourceLocation;
13
import net.minecraft.world.inventory.InventoryMenu;
14
import net.minecraft.world.level.BlockAndTintGetter;
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.TextureAtlasStitchedEvent;
21
import net.neoforged.neoforge.client.extensions.common.IClientBlockExtensions;
22
import net.neoforged.neoforge.client.extensions.common.RegisterClientExtensionsEvent;
23
import org.apache.commons.lang3.tuple.Pair;
24
import org.cyclops.cyclopscore.client.model.IDynamicModelElementCommon;
25
import org.cyclops.cyclopscore.config.extendedconfig.BlockClientConfig;
26
import org.cyclops.cyclopscore.config.extendedconfig.BlockConfigCommon;
27
import org.cyclops.cyclopscore.helper.RenderHelpers;
28
import org.cyclops.integrateddynamics.IntegratedDynamics;
29
import org.cyclops.integrateddynamics.Reference;
30
import org.cyclops.integrateddynamics.RegistryEntries;
31
import org.cyclops.integrateddynamics.client.model.CableModel;
32
import org.cyclops.integrateddynamics.core.helper.CableHelpers;
33

34
import javax.annotation.Nullable;
35
import java.util.function.Consumer;
36

37
public class BlockCableClientConfig extends BlockClientConfig<IntegratedDynamics> {
38

39
    public static TextureAtlasSprite BLOCK_TEXTURE;
40

41
    public BlockCableClientConfig(BlockConfigCommon<IntegratedDynamics> blockConfig) {
42
        super(blockConfig);
×
43
        blockConfig.getMod().getModEventBus().addListener(this::onRegisterColors);
×
44
        blockConfig.getMod().getModEventBus().addListener(this::registerClientExtensions);
×
45
        blockConfig.getMod().getModEventBus().addListener(this::postTextureStitch);
×
46
    }
×
47

48
    public void onRegisterColors(RegisterColorHandlersEvent.Block event) {
49
        event.register(new BlockCableClientConfig.BlockColor(), getBlockConfig().getInstance());
×
50
    }
×
51

52
    public void postTextureStitch(TextureAtlasStitchedEvent event) {
53
        if (event.getAtlas().location().equals(InventoryMenu.BLOCK_ATLAS)) {
×
54
            BLOCK_TEXTURE = event.getAtlas().getSprite(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "block/cable"));
×
55
        }
56
    }
×
57

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

74
    @Override
75
    @Nullable
76
    public IDynamicModelElementCommon getDynamicModelElement() {
77
        return new DynamicModel();
×
78
    }
79

80
    public static class BlockColor implements net.minecraft.client.color.block.BlockColor {
×
81
        @Override
82
        public int getColor(BlockState blockState, @Nullable BlockAndTintGetter world, @Nullable BlockPos blockPos, int color) {
83
            // Only modify color if we have a facade
84
            return blockPos == null ?
×
85
                    -1 : CableHelpers.getFacadeMultipartTicking(world, blockPos)
×
86
                    .map(facadeState -> Minecraft.getInstance().getBlockColors().getColor(facadeState, world, blockPos, color))
×
87
                    .orElse(-1);
×
88
        }
89
    }
90

91
    public static class DynamicModel implements IDynamicModelElementCommon {
×
92
        @Override
93
        public BakedModel createDynamicModel(Consumer<Pair<ModelResourceLocation, BakedModel>> modelConsumer) {
94
            CableModel model = new CableModel();
×
95
            ResourceLocation registryName = BuiltInRegistries.BLOCK.getKey(RegistryEntries.BLOCK_CABLE.get());
×
96
            for (BlockState blockState : RegistryEntries.BLOCK_CABLE.get().getStateDefinition().getPossibleStates()) {
×
97
                modelConsumer.accept(Pair.of(BlockModelShaper.stateToModelLocation(blockState), model));
×
98
            }
×
99
            modelConsumer.accept(Pair.of(new ModelResourceLocation(registryName, "inventory"), model));
×
100
            return model;
×
101
        }
102
    }
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc