• 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

18.18
/src/main/java/org/cyclops/integrateddynamics/core/evaluate/operator/PositionedOperator.java
1
package org.cyclops.integrateddynamics.core.evaluate.operator;
2

3
import net.minecraft.core.Direction;
4
import net.minecraft.network.chat.Component;
5
import net.minecraft.resources.ResourceLocation;
6
import net.minecraft.world.level.storage.ValueInput;
7
import net.minecraft.world.level.storage.ValueOutput;
8
import org.cyclops.cyclopscore.datastructure.DimPos;
9
import org.cyclops.cyclopscore.persist.nbt.INBTProvider;
10
import org.cyclops.cyclopscore.persist.nbt.NBTClassType;
11
import org.cyclops.integrateddynamics.api.evaluate.EvaluationException;
12
import org.cyclops.integrateddynamics.api.evaluate.operator.IOperator;
13
import org.cyclops.integrateddynamics.api.evaluate.operator.IOperatorSerializer;
14
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType;
15
import org.cyclops.integrateddynamics.api.logicprogrammer.IConfigRenderPattern;
16
import org.cyclops.integrateddynamics.core.helper.L10NValues;
17

18
import java.lang.reflect.Constructor;
19
import java.lang.reflect.InvocationTargetException;
20

21
/**
22
 * An abstract operator that is based on something positioned.
23
 * @author rubensworks
24
 */
25
public abstract class PositionedOperator extends OperatorBase implements INBTProvider {
26

27
    private DimPos pos;
28
    private Direction side;
29

30
    protected PositionedOperator(String symbol, String operatorName, String interactName, IValueType[] inputTypes, IValueType outputType,
31
                                 IFunction function, IConfigRenderPattern renderPattern, DimPos pos, Direction side) {
32
        super(symbol, operatorName, interactName, null, false, inputTypes, outputType, function, renderPattern);
×
33
        this.pos = pos;
×
34
        this.side = side;
×
35
    }
×
36

37
    @Override
38
    public IOperator materialize() {
39
        return this;
×
40
    }
41

42
    @Override
43
    public void writeGeneratedFieldsToNBT(ValueOutput output) {
44
        NBTClassType.writeNbt(DimPos.class, "pos", pos, output);
×
45
        NBTClassType.writeNbt(Direction.class, "side", side, output);
×
46
    }
×
47

48
    @Override
49
    public void readGeneratedFieldsFromNBT(ValueInput input) {
50
        this.pos = NBTClassType.readNbt(DimPos.class, "pos", input);
×
51
        this.side = NBTClassType.readNbt(Direction.class, "side", input);
×
52
    }
×
53

54
    public DimPos getPos() {
55
        return pos;
×
56
    }
57

58
    public void setPos(DimPos pos) {
59
        this.pos = pos;
×
60
    }
×
61

62
    public Direction getSide() {
63
        return side;
×
64
    }
65

66
    public void setSide(Direction side) {
67
        this.side = side;
×
68
    }
×
69

70
    public static class Serializer implements IOperatorSerializer<PositionedOperator> {
71

72
        private final Class<? extends PositionedOperator> clazz;
73
        private final ResourceLocation uniqueName;
74

75
        public Serializer(Class<? extends PositionedOperator> clazz, ResourceLocation uniqueName) {
2✔
76
            this.clazz = clazz;
3✔
77
            this.uniqueName = uniqueName;
3✔
78
        }
1✔
79

80
        @Override
81
        public boolean canHandle(IOperator operator) {
82
            return this.clazz.isInstance(operator);
5✔
83
        }
84

85
        @Override
86
        public ResourceLocation getUniqueName() {
87
            return this.uniqueName;
3✔
88
        }
89

90
        @Override
91
        public void serialize(ValueOutput valueOutput, PositionedOperator operator) {
92
            operator.writeGeneratedFieldsToNBT(valueOutput);
×
93
        }
×
94

95
        @Override
96
        public PositionedOperator deserialize(ValueInput valueInput) throws EvaluationException {
97
            try {
98
                Constructor<? extends PositionedOperator> constructor = this.clazz.getConstructor();
×
99
                PositionedOperator proxy = constructor.newInstance();
×
100
                proxy.readGeneratedFieldsFromNBT(valueInput);
×
101
                return proxy;
×
102
            } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | ClassCastException | IllegalAccessException e) {
×
103
                e.printStackTrace();
×
104
                throw new EvaluationException(Component.translatable(L10NValues.VALUETYPE_ERROR_DESERIALIZE,
×
105
                        valueInput.toString(), e.getMessage()));
×
106
            }
107
        }
108
    }
109
}
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