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

CyclopsMC / CommonCapabilities / #479006709

10 Jun 2024 02:59PM UTC coverage: 39.249% (-0.1%) from 39.389%
#479006709

push

github

rubensworks
Fix capability attachment to wrong capability types

0 of 3 new or added lines in 1 file covered. (0.0%)

38 existing lines in 3 files now uncovered.

889 of 2265 relevant lines covered (39.25%)

0.39 hits per line

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

0.0
/src/main/java/org/cyclops/commoncapabilities/CommonCapabilities.java
1
package org.cyclops.commoncapabilities;
2

3
import net.neoforged.bus.api.EventPriority;
4
import net.neoforged.bus.api.IEventBus;
5
import net.neoforged.fml.common.Mod;
6
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
7
import net.neoforged.fml.event.lifecycle.InterModEnqueueEvent;
8
import net.neoforged.neoforge.registries.NewRegistryEvent;
9
import net.neoforged.neoforge.registries.RegisterEvent;
10
import org.apache.logging.log4j.Level;
11
import org.cyclops.commoncapabilities.api.capability.recipehandler.IPrototypedIngredientAlternatives;
12
import org.cyclops.commoncapabilities.api.capability.recipehandler.PrototypedIngredientAlternativesItemStackTag;
13
import org.cyclops.commoncapabilities.api.capability.recipehandler.PrototypedIngredientAlternativesList;
14
import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
15
import org.cyclops.commoncapabilities.modcompat.vanilla.VanillaModCompat;
16
import org.cyclops.commoncapabilities.proxy.ClientProxy;
17
import org.cyclops.commoncapabilities.proxy.CommonProxy;
18
import org.cyclops.cyclopscore.config.ConfigHandler;
19
import org.cyclops.cyclopscore.init.ModBaseVersionable;
20
import org.cyclops.cyclopscore.modcompat.ModCompatLoader;
21
import org.cyclops.cyclopscore.proxy.IClientProxy;
22
import org.cyclops.cyclopscore.proxy.ICommonProxy;
23

24
import java.util.Objects;
25

26
/**
27
 * The main mod class of this mod.
28
 * @author rubensworks (aka kroeserr)
29
 *
30
 */
31
@Mod(Reference.MOD_ID)
32
public class CommonCapabilities extends ModBaseVersionable<CommonCapabilities> {
33

34
    /**
35
     * The unique instance of this mod.
36
     */
37
    public static CommonCapabilities _instance;
38

39
    public CommonCapabilities(IEventBus modEventBus) {
40
        super(Reference.MOD_ID, (instance) -> _instance = instance, modEventBus);
×
41
        modEventBus.register(IngredientComponent.class);
×
42
        modEventBus.addListener(EventPriority.LOW, this::onRegister);
×
43
        modEventBus.addListener(EventPriority.LOW, this::onRegistriesLoad);
×
44
        modEventBus.addListener(EventPriority.LOW, this::afterCapabilitiesLoaded);
×
45
    }
×
46

47
    @Override
48
    protected void setup(FMLCommonSetupEvent event) {
49
        super.setup(event);
×
50
        Objects.requireNonNull(IngredientComponent.ITEMSTACK, "Item ingredient component is not initialized");
×
51
        Objects.requireNonNull(IngredientComponent.FLUIDSTACK, "Fluid ingredient component is not initialized");
×
52
        Objects.requireNonNull(IngredientComponent.ENERGY, "Energy ingredient component is not initialized");
×
53

NEW
54
        IngredientComponent.REGISTRY.forEach(ingredientComponent -> {
×
NEW
55
            getModEventBus().addListener(ingredientComponent::gatherCapabilities);
×
NEW
56
        });
×
UNCOV
57
    }
×
58

59
    @Override
60
    protected void loadModCompats(ModCompatLoader modCompatLoader) {
61
        super.loadModCompats(modCompatLoader);
×
62
        modCompatLoader.addModCompat(new VanillaModCompat());
×
63
        // TODO: temporarily disable some mod compats
64
        //modCompatLoader.addModCompat(new TConstructModCompat());
65
        //modCompatLoader.addModCompat(new ForestryModCompat());
66
        //modCompatLoader.addModCompat(new ThermalExpansionModCompat());
67
        //modCompatLoader.addModCompat(new EnderIOModCompat());
68
        //modCompatLoader.addModCompat(new Ic2ModCompat());
69
    }
×
70

71
    @Override
72
    protected IClientProxy constructClientProxy() {
73
        return new ClientProxy();
×
74
    }
75

76
    @Override
77
    protected ICommonProxy constructCommonProxy() {
78
        return new CommonProxy();
×
79
    }
80

81
    @Override
82
    protected boolean hasDefaultCreativeModeTab() {
83
        return false;
×
84
    }
85

86
    @Override
87
    protected void onConfigsRegister(ConfigHandler configHandler) {
88
        super.onConfigsRegister(configHandler);
×
89

90
        configHandler.addConfigurable(new GeneralConfig());
×
91
    }
×
92

93
    public void onRegister(NewRegistryEvent event) {
94
        IPrototypedIngredientAlternatives.SERIALIZERS.put(
×
95
                PrototypedIngredientAlternativesList.SERIALIZER.getId(),
×
96
                PrototypedIngredientAlternativesList.SERIALIZER);
97
        IPrototypedIngredientAlternatives.SERIALIZERS.put(
×
98
                PrototypedIngredientAlternativesItemStackTag.SERIALIZER.getId(),
×
99
                PrototypedIngredientAlternativesItemStackTag.SERIALIZER);
100
    }
×
101

102
    public void onRegistriesLoad(RegisterEvent event) {
103
        event.register(IngredientComponent.REGISTRY.key(), IngredientComponents.ITEMSTACK.getName(), () -> IngredientComponents.ITEMSTACK);
×
104
        event.register(IngredientComponent.REGISTRY.key(), IngredientComponents.FLUIDSTACK.getName(), () -> IngredientComponents.FLUIDSTACK);
×
105
        event.register(IngredientComponent.REGISTRY.key(), IngredientComponents.ENERGY.getName(), () -> IngredientComponents.ENERGY);
×
106
    }
×
107

108
    public void afterCapabilitiesLoaded(InterModEnqueueEvent event) {
109
        IngredientComponents.registerStorageWrapperHandlers();
×
110
    }
×
111

112
    /**
113
     * Log a new info message for this mod.
114
     * @param message The message to show.
115
     */
116
    public static void clog(String message) {
117
        clog(Level.INFO, message);
×
118
    }
×
119

120
    /**
121
     * Log a new message of the given level for this mod.
122
     * @param level The level in which the message must be shown.
123
     * @param message The message to show.
124
     */
125
    public static void clog(Level level, String message) {
126
        CommonCapabilities._instance.getLoggerHelper().log(level, message);
×
127
    }
×
128

129
}
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