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

CyclopsMC / IntegratedDynamics / 20210191346

14 Dec 2025 03:32PM UTC coverage: 19.514% (-33.5%) from 53.061%
20210191346

push

github

rubensworks
Remove deprecations

663 of 8728 branches covered (7.6%)

Branch coverage included in aggregate %.

6786 of 29445 relevant lines covered (23.05%)

1.09 hits per line

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

21.74
/src/main/java/org/cyclops/integrateddynamics/part/aspect/AspectBase.java
1
package org.cyclops.integrateddynamics.part.aspect;
2

3
import net.minecraft.network.chat.Component;
4
import net.minecraft.resources.ResourceLocation;
5
import net.minecraft.world.MenuProvider;
6
import net.minecraft.world.SimpleContainer;
7
import net.minecraft.world.entity.player.Inventory;
8
import net.minecraft.world.entity.player.Player;
9
import net.minecraft.world.inventory.AbstractContainerMenu;
10
import org.apache.commons.lang3.tuple.Triple;
11
import org.cyclops.cyclopscore.helper.IModHelpers;
12
import org.cyclops.integrateddynamics.api.evaluate.variable.IValue;
13
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
14
import org.cyclops.integrateddynamics.api.part.*;
15
import org.cyclops.integrateddynamics.api.part.aspect.IAspect;
16
import org.cyclops.integrateddynamics.api.part.aspect.property.IAspectProperties;
17
import org.cyclops.integrateddynamics.api.part.aspect.property.IAspectPropertyTypeInstance;
18
import org.cyclops.integrateddynamics.core.helper.L10NValues;
19
import org.cyclops.integrateddynamics.core.helper.PartHelpers;
20
import org.cyclops.integrateddynamics.core.inventory.container.ContainerAspectSettings;
21
import org.cyclops.integrateddynamics.core.part.PartTypeBase;
22

23
import javax.annotation.Nullable;
24
import java.util.Collection;
25
import java.util.Collections;
26
import java.util.Optional;
27
import java.util.function.Consumer;
28

29
/**
30
 * Base class for aspects.
31
 * @author rubensworks
32
 */
33
public abstract class AspectBase<V extends IValue, T extends IValueType<V>> implements IAspect<V, T> {
34

35
    private final IAspectProperties defaultProperties;
36

37
    private final String modId;
38
    private String translationKey = null;
3✔
39

40
    public AspectBase(String modId, IAspectProperties defaultProperties) {
2✔
41
        this.modId = modId;
3✔
42
        this.defaultProperties = defaultProperties == null ? createDefaultProperties() : defaultProperties;
8✔
43
    }
1✔
44

45
    @Override
46
    public ResourceLocation getUniqueName() {
47
        return ResourceLocation.fromNamespaceAndPath(getModId(), getUnlocalizedType().replaceAll("\\.", "_"));
9✔
48
    }
49

50
    @Override
51
    public String getTranslationKey() {
52
        return translationKey != null ? translationKey : (translationKey = getUnlocalizedPrefix());
×
53
    }
54

55
    protected String getUnlocalizedPrefix() {
56
        return "aspect." + getModId() + "." + getUnlocalizedType();
×
57
    }
58

59
    protected abstract String getUnlocalizedType();
60

61
    @Override
62
    public void loadTooltip(Consumer<Component> tooltipAdder, boolean appendOptionalInfo) {
63
        Component aspectName = Component.translatable(getTranslationKey());
×
64
        Component valueTypeName = Component.translatable(getValueType().getTranslationKey());
×
65
        tooltipAdder.accept(Component.translatable(L10NValues.ASPECT_TOOLTIP_ASPECTNAME, aspectName));
×
66
        tooltipAdder.accept(Component.translatable(L10NValues.ASPECT_TOOLTIP_VALUETYPENAME, valueTypeName)
×
67
                .withStyle(getValueType().getDisplayColorFormat()));
×
68
        if(appendOptionalInfo) {
×
69
            IModHelpers.get().getL10NHelpers().addOptionalInfo(tooltipAdder, getUnlocalizedPrefix());
×
70
        }
71
    }
×
72

73
    @Override
74
    public <P extends IPartType<P, S>, S extends IPartState<P>> boolean hasProperties() {
75
        return getDefaultProperties() != null;
×
76
    }
77

78
    @Override
79
    public <P extends IPartType<P, S>, S extends IPartState<P>> IAspectProperties getProperties(P partType, PartTarget target, S state) {
80
        IAspectProperties properties = state.getAspectProperties(this);
×
81
        if(properties == null) {
×
82
            properties = getDefaultProperties().clone();
×
83
            setProperties(partType, target, state, properties);
×
84
        }
85
        return properties;
×
86
    }
87

88
    @Override
89
    public <P extends IPartType<P, S>, S extends IPartState<P>> void setProperties(P partType, PartTarget target, S state, IAspectProperties properties) {
90
        state.setAspectProperties(this, properties);
×
91
    }
×
92

93
    @Override
94
    public final IAspectProperties getDefaultProperties() {
95
        return defaultProperties;
×
96
    }
97

98
    @SuppressWarnings("deprecation")
99
    @Override
100
    public Collection<IAspectPropertyTypeInstance> getPropertyTypes() {
101
        return hasProperties() ? getDefaultProperties().getTypes() : Collections.emptyList();
×
102
    }
103

104
    @Override
105
    public MenuProvider getPropertiesContainerProvider(PartPos pos) {
106
        return new MenuProvider() {
×
107
            @Override
108
            public Component getDisplayName() {
109
                return Component.translatable("gui.integrateddynamics.aspect_settings");
×
110
            }
111

112
            @Nullable
113
            @Override
114
            public AbstractContainerMenu createMenu(int id, Inventory playerInventory, Player playerEntity) {
115
                Triple<IPartContainer, PartTypeBase, PartTarget> data = PartHelpers.getContainerPartConstructionData(pos);
×
116
                return new ContainerAspectSettings(id, playerInventory, new SimpleContainer(0),
×
117
                        Optional.of(data.getRight()), Optional.of(data.getLeft()), Optional.of(data.getMiddle()), AspectBase.this);
×
118
            }
119

120
            @Override
121
            public boolean shouldTriggerClientSideContainerClosingOnOpen() {
122
                return false;
×
123
            }
124
        };
125
    }
126

127
    /**
128
     * Creates the default properties for this aspect, only called once.
129
     * @return The default properties.
130
     */
131
    @Deprecated
132
    protected IAspectProperties createDefaultProperties() {
133
        return null;
2✔
134
    }
135

136
    protected String getModId() {
137
        return this.modId;
3✔
138
    }
139

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