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

CyclopsMC / IntegratedDynamics / 16552051255

27 Jul 2025 01:58PM UTC coverage: 53.206% (+8.0%) from 45.161%
16552051255

push

github

rubensworks
Resolve minor TODOs

2888 of 8740 branches covered (33.04%)

Branch coverage included in aggregate %.

17341 of 29280 relevant lines covered (59.22%)

3.08 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.model.BlockStateModel;
7
import net.minecraft.client.renderer.item.ItemModel;
8
import net.minecraft.client.renderer.texture.TextureAtlas;
9
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
10
import net.minecraft.core.BlockPos;
11
import net.minecraft.core.registries.BuiltInRegistries;
12
import net.minecraft.resources.ResourceLocation;
13
import net.minecraft.world.level.BlockAndTintGetter;
14
import net.minecraft.world.level.Level;
15
import net.minecraft.world.level.block.state.BlockState;
16
import net.minecraft.world.phys.BlockHitResult;
17
import net.minecraft.world.phys.HitResult;
18
import net.neoforged.neoforge.client.event.RegisterColorHandlersEvent;
19
import net.neoforged.neoforge.client.event.RegisterItemModelsEvent;
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 net.neoforged.neoforge.common.extensions.ILevelExtension;
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 javax.annotation.Nullable;
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(ResourceLocation.fromNamespaceAndPath(Reference.MOD_ID, "cable"), ItemModelCable.Unbaked.MAP_CODEC));
×
50
    }
×
51

52
    public void onRegisterColors(RegisterColorHandlersEvent.Block event) {
53
        event.register(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(ResourceLocation.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)) {
×
68
                    CableHelpers.getFacade(world, blockPos)
×
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
    @Nullable
80
    public IDynamicModelElementCommon getDynamicModelElement() {
81
        return new DynamicModel();
×
82
    }
83

84
    public static class BlockColor implements net.minecraft.client.color.block.BlockColor {
×
85
        @Override
86
        public int getColor(BlockState blockState, @Nullable BlockAndTintGetter world, @Nullable BlockPos blockPos, int color) {
87
            // Only modify color if we have a facade
88
            return blockPos == null || (!(world instanceof ILevelExtension levelExtension)) ?
×
89
                    -1 : CableHelpers.getFacade(levelExtension, blockPos)
×
90
                    .map(facadeState -> Minecraft.getInstance().getBlockColors().getColor(facadeState, world, blockPos, color))
×
91
                    .orElse(-1);
×
92
        }
93
    }
94

95
    public static class DynamicModel implements IDynamicModelElementCommon {
×
96
        @Override
97
        public BlockStateModel createDynamicBlockModel(Consumer<Pair<BlockState, BlockStateModel>> modelConsumer, Function<BlockState, BlockStateModel> modelRetriever) {
98
            CableModel model = new CableModel();
×
99
            modelConsumer.accept(Pair.of(RegistryEntries.BLOCK_CABLE.get().defaultBlockState(), model));
×
100
            modelConsumer.accept(Pair.of(RegistryEntries.BLOCK_CABLE.get().defaultBlockState().setValue(BlockCable.WATERLOGGED, true), model));
×
101
            return model;
×
102
        }
103

104
        @Override
105
        public ItemModel createDynamicItemModel(Consumer<Pair<ResourceLocation, ItemModel>> modelConsumer, Function<ResourceLocation, ItemModel> modelRetriever) {
106
            ItemModelCable model = new ItemModelCable(new CableModel());
×
107
            ResourceLocation registryName = BuiltInRegistries.BLOCK.getKey(RegistryEntries.BLOCK_CABLE.get());
×
108
            modelConsumer.accept(Pair.of(registryName, model));
×
109
            return model;
×
110
        }
111
    }
112
}
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