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

CyclopsMC / IntegratedDynamics / 22186773560

19 Feb 2026 02:52PM UTC coverage: 52.603% (+0.2%) from 52.363%
22186773560

push

github

web-flow
Remove Lombok dependency (#1604)

2911 of 8664 branches covered (33.6%)

Branch coverage included in aggregate %.

17683 of 30486 relevant lines covered (58.0%)

3.01 hits per line

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

14.29
/src/main/java/org/cyclops/integrateddynamics/core/evaluate/variable/ValueObjectTypeBlock.java
1
package org.cyclops.integrateddynamics.core.evaluate.variable;
2

3
import net.minecraft.core.registries.BuiltInRegistries;
4
import net.minecraft.network.chat.Component;
5
import net.minecraft.network.chat.MutableComponent;
6
import net.minecraft.world.item.BlockItem;
7
import net.minecraft.world.item.ItemStack;
8
import net.minecraft.world.level.block.Blocks;
9
import net.minecraft.world.level.block.state.BlockState;
10
import net.minecraft.world.level.storage.ValueInput;
11
import net.minecraft.world.level.storage.ValueOutput;
12
import org.cyclops.cyclopscore.helper.IModHelpers;
13
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeNamed;
14
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeNullable;
15
import org.cyclops.integrateddynamics.api.evaluate.variable.IValueTypeUniquelyNamed;
16
import org.cyclops.integrateddynamics.core.helper.L10NValues;
17
import org.cyclops.integrateddynamics.core.logicprogrammer.ValueTypeItemStackLPElement;
18
import org.cyclops.integrateddynamics.core.logicprogrammer.ValueTypeLPElementBase;
19

20
/**
21
 * Value type with values that are blocks (these are internally stored as blockstates).
22
 * @author rubensworks
23
 */
24
public class ValueObjectTypeBlock extends ValueObjectTypeBase<ValueObjectTypeBlock.ValueBlock> implements
25
        IValueTypeNamed<ValueObjectTypeBlock.ValueBlock>, IValueTypeUniquelyNamed<ValueObjectTypeBlock.ValueBlock>,
26
        IValueTypeNullable<ValueObjectTypeBlock.ValueBlock> {
27

28
    public ValueObjectTypeBlock() {
29
        super("block", ValueObjectTypeBlock.ValueBlock.class);
4✔
30
    }
1✔
31

32
    public static MutableComponent getBlockkDisplayNameSafe(BlockState blockState) {
33
        return Component.translatable(blockState.getBlock().getDescriptionId());
×
34
    }
35

36
    @Override
37
    public ValueBlock getDefault() {
38
        return ValueBlock.of(Blocks.AIR.defaultBlockState());
×
39
    }
40

41
    @Override
42
    public MutableComponent toCompactString(ValueBlock value) {
43
        if (value.getRawValue().isPresent()) {
×
44
            BlockState blockState = value.getRawValue().get();
×
45
            ItemStack itemStack = IModHelpers.get().getBlockHelpers().getItemStackFromBlockState(blockState);
×
46
            if (!itemStack.isEmpty()) {
×
47
                return ValueObjectTypeItemStack.getItemStackDisplayNameSafe(itemStack);
×
48
            }
49
            return ValueObjectTypeBlock.getBlockkDisplayNameSafe(blockState);
×
50
        }
51
        return Component.literal("");
×
52
    }
53

54
    @Override
55
    public void serialize(ValueOutput valueOutput, ValueBlock value) {
56
        value.getRawValue().ifPresent(v -> valueOutput.store("v", BlockState.CODEC, v));
×
57
    }
×
58

59
    @Override
60
    public ValueBlock deserialize(ValueInput valueInput) {
61
        return ValueBlock.of(valueInput.read("v", BlockState.CODEC).orElseGet(Blocks.AIR::defaultBlockState));
13✔
62
    }
63

64
    @Override
65
    public String getName(ValueBlock a) {
66
        return toCompactString(a).getString();
×
67
    }
68

69
    @Override
70
    public boolean isNull(ValueBlock a) {
71
        return !a.getRawValue().isPresent();
×
72
    }
73

74
    @Override
75
    public ValueTypeLPElementBase createLogicProgrammerElement() {
76
        return new ValueTypeItemStackLPElement<>(this, new ValueTypeItemStackLPElement.IItemStackToValue<ValueObjectTypeBlock.ValueBlock>() {
×
77
            @Override
78
            public boolean isNullable() {
79
                return true;
×
80
            }
81

82
            @Override
83
            public Component validate(ItemStack itemStack) {
84
                if(!itemStack.isEmpty() && !(itemStack.getItem() instanceof BlockItem)) {
×
85
                    return Component.translatable(L10NValues.VALUETYPE_OBJECT_BLOCK_ERROR_NOBLOCK);
×
86
                }
87
                return null;
×
88
            }
89

90
            @Override
91
            public ValueObjectTypeBlock.ValueBlock getValue(ItemStack itemStack) {
92
                return ValueObjectTypeBlock.ValueBlock.of(
×
93
                        itemStack.isEmpty() ? Blocks.AIR.defaultBlockState() : IModHelpers.get().getBlockHelpers().getBlockStateFromItemStack(itemStack));
×
94
            }
95

96
            @Override
97
            public ItemStack getValueAsItemStack(ValueBlock value) {
98
                return value.getRawValue()
×
99
                        .map(IModHelpers.get().getBlockHelpers()::getItemStackFromBlockState)
×
100
                        .orElse(ItemStack.EMPTY);
×
101
            }
102
        });
103
    }
104

105
    @Override
106
    public String getUniqueName(ValueBlock value) {
107
        if (value.getRawValue().isPresent()) {
×
108
            BlockState blockState = value.getRawValue().get();
×
109
            return BuiltInRegistries.BLOCK.getKey(blockState.getBlock()).toString();
×
110
        }
111
        return "";
×
112
    }
113

114
    public static class ValueBlock extends ValueOptionalBase<BlockState> {
115

116
        private ValueBlock(BlockState blockState) {
117
            super(ValueTypes.OBJECT_BLOCK, blockState);
4✔
118
        }
1✔
119

120
        public static ValueBlock of(BlockState blockState) {
121
            return new ValueBlock(blockState);
5✔
122
        }
123

124
        @Override
125
        protected boolean isEqual(BlockState a, BlockState b) {
126
            return a.equals(b);
4✔
127
        }
128

129
        @Override
130
        public String toString() {
131
            return "ValueBlock()";
×
132
        }
133
    }
134

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