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

CyclopsMC / IntegratedDynamics / 19256462200

11 Nov 2025 05:53AM UTC coverage: 44.841% (+0.009%) from 44.832%
19256462200

push

github

rubensworks
Fix Grass Block Facades not having biome tints

Closes #1564

2583 of 8544 branches covered (30.23%)

Branch coverage included in aggregate %.

11777 of 23480 relevant lines covered (50.16%)

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

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

36
public class BlockCableClientConfig extends BlockClientConfig<IntegratedDynamics> {
37

38
    public static TextureAtlasSprite BLOCK_TEXTURE;
39

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

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

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

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

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

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

90
    public static class DynamicModel implements IDynamicModelElementCommon {
×
91
        @Override
92
        public BakedModel createDynamicModel(Consumer<Pair<ModelResourceLocation, BakedModel>> modelConsumer) {
93
            CableModel model = new CableModel();
×
94
            ResourceLocation registryName = BuiltInRegistries.BLOCK.getKey(RegistryEntries.BLOCK_CABLE.get());
×
95
            modelConsumer.accept(Pair.of(new ModelResourceLocation(registryName, "waterlogged=false"), model));
×
96
            modelConsumer.accept(Pair.of(new ModelResourceLocation(registryName, "waterlogged=true"), model));
×
97
            modelConsumer.accept(Pair.of(new ModelResourceLocation(registryName, "inventory"), model));
×
98
            return model;
×
99
        }
100
    }
101
}
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