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

CyclopsMC / IntegratedDynamics / 19267223570

11 Nov 2025 01:30PM UTC coverage: 53.046% (+0.04%) from 53.006%
19267223570

push

github

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

2875 of 8772 branches covered (32.77%)

Branch coverage included in aggregate %.

17354 of 29363 relevant lines covered (59.1%)

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.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 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.IModHelpers;
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.client.model.ItemModelCable;
33
import org.cyclops.integrateddynamics.core.helper.CableHelpers;
34

35
import javax.annotation.Nullable;
36
import java.util.function.Consumer;
37
import java.util.function.Function;
38

39
public class BlockCableClientConfig extends BlockClientConfig<IntegratedDynamics> {
40

41
    public static TextureAtlasSprite BLOCK_TEXTURE;
42

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

51
    public void onRegisterColors(RegisterColorHandlersEvent.Block event) {
52
        event.register(new BlockCableClientConfig.BlockColor(), getBlockConfig().getInstance());
×
53
    }
×
54

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

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

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

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

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

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