Skip to content

Commit c024d74

Browse files
committed
Work on applying default components for items so that they don't end up in the component patch
1 parent 639dcf0 commit c024d74

38 files changed

+349
-255
lines changed

src/additions/java/mekanism/additions/common/item/ItemWalkieTalkie.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public class ItemWalkieTalkie extends Item implements IModeItem {
2828

2929
public ItemWalkieTalkie(Item.Properties properties) {
30-
super(properties.stacksTo(1));
30+
super(properties.stacksTo(1).component(AdditionsDataComponents.WALKIE_DATA, WalkieData.DEFAULT));
3131
}
3232

3333
@Override

src/api/java/mekanism/api/MekanismAPI.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package mekanism.api;
22

33
import com.mojang.logging.LogUtils;
4-
import com.mojang.serialization.Codec;
54
import com.mojang.serialization.MapCodec;
65
import mekanism.api.annotations.NothingNullByDefault;
76
import mekanism.api.chemical.gas.Gas;
@@ -30,7 +29,7 @@ private MekanismAPI() {
3029
/**
3130
* The version of the api classes - may not always match the mod's version
3231
*/
33-
public static final String API_VERSION = "10.5.20";
32+
public static final String API_VERSION = "10.6.0";
3433
/**
3534
* Mekanism's Mod ID
3635
*/

src/api/java/mekanism/api/MekanismIMC.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ private MekanismIMC() {
2020
* {@link #addModuleContainer(ModuleContainerTarget)} can be used as a helper to send properly structured messages of this type.
2121
*
2222
* @since 10.5.0
23+
*
24+
* @see mekanism.api.gear.IModuleHelper#applyModuleContainerProperties(Item.Properties)
2325
*/
2426
public static final String ADD_MODULE_CONTAINER = "add_module_container";
2527
/**

src/api/java/mekanism/api/gear/IModuleHelper.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ public interface IModuleHelper {
5252
*/
5353
Item createModuleItem(IModuleDataProvider<?> moduleDataProvider, Item.Properties properties);
5454

55+
/**
56+
* Helper method to add an empty component to represent an empty module container.
57+
*
58+
* @param properties Properties for the item.
59+
*
60+
* @return The properties with the component for no stored modules in place
61+
*
62+
* @since 10.6.0
63+
*/
64+
Item.Properties applyModuleContainerProperties(Item.Properties properties);
65+
5566
/**
5667
* Helper to drop any modules stored in a custom module container. Call this from {@link Item#onDestroyed(ItemEntity, DamageSource)}.
5768
*

src/generators/java/mekanism/generators/common/item/ItemBlockFissionLogicAdapter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
import net.minecraft.world.item.Item;
1212
import net.minecraft.world.item.ItemStack;
1313
import net.minecraft.world.item.TooltipFlag;
14-
import net.minecraft.world.level.Level;
1514
import org.jetbrains.annotations.NotNull;
16-
import org.jetbrains.annotations.Nullable;
1715

1816
public class ItemBlockFissionLogicAdapter extends ItemBlockTooltip<BlockBasicMultiblock<TileEntityFissionReactorLogicAdapter>> {
1917

2018
public ItemBlockFissionLogicAdapter(BlockBasicMultiblock<TileEntityFissionReactorLogicAdapter> block, Item.Properties properties) {
21-
super(block, true, properties);
19+
super(block, true, properties.component(GeneratorsDataComponents.FISSION_LOGIC_TYPE, FissionReactorLogic.DISABLED));
2220
}
2321

2422
@Override

src/generators/java/mekanism/generators/common/item/ItemBlockFusionLogicAdapter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
import net.minecraft.world.item.Item;
1414
import net.minecraft.world.item.ItemStack;
1515
import net.minecraft.world.item.TooltipFlag;
16-
import net.minecraft.world.level.Level;
1716
import org.jetbrains.annotations.NotNull;
18-
import org.jetbrains.annotations.Nullable;
1917

2018
public class ItemBlockFusionLogicAdapter extends ItemBlockTooltip<BlockBasicMultiblock<TileEntityFusionReactorLogicAdapter>> {
2119

2220
public ItemBlockFusionLogicAdapter(BlockBasicMultiblock<TileEntityFusionReactorLogicAdapter> block, Properties properties) {
23-
super(block, true, properties);
21+
super(block, true, properties.component(GeneratorsDataComponents.FUSION_LOGIC_TYPE, FusionReactorLogic.DISABLED));
2422
}
2523

2624
@Override

src/generators/java/mekanism/generators/common/registries/GeneratorsDataComponents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ private GeneratorsDataComponents() {
2323
.networkSynchronized(FusionReactorLogic.STREAM_CODEC)
2424
);
2525

26-
public static final MekanismDeferredHolder<DataComponentType<?>, DataComponentType<Boolean>> ACTIVE_COOLED = DATA_COMPONENTS.registerBoolean("active_cooled", false);
26+
public static final MekanismDeferredHolder<DataComponentType<?>, DataComponentType<Boolean>> ACTIVE_COOLED = DATA_COMPONENTS.registerBoolean("active_cooled");
2727
}

src/main/java/mekanism/client/model/baked/DriveArrayBakedModel.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,26 +123,29 @@ public BakedModel resolve(BakedModel model, ItemStack stack, @Nullable ClientLev
123123
} else {
124124
driveStack = ItemStack.EMPTY;
125125
}
126-
if (driveStack.isEmpty() || !(driveStack.getItem() instanceof IQIODriveItem driveItem) || !driveStack.has(MekanismDataComponents.DRIVE_METADATA)) {
126+
if (driveStack.isEmpty() || !(driveStack.getItem() instanceof IQIODriveItem driveItem)) {
127127
status = DriveStatus.NONE;
128-
} else if (hasFrequency) {
129-
allEmpty = false;
130-
//Note: Should never be able to get here if it isn't present
128+
} else {
131129
DriveMetadata metadata = driveStack.getOrDefault(MekanismDataComponents.DRIVE_METADATA, DriveMetadata.EMPTY);
132-
long countCapacity = driveItem.getCountCapacity(driveStack);
133-
if (metadata.count() == countCapacity) {
134-
//If we are at max item capacity: Full
135-
status = DriveStatus.FULL;
136-
} else if (metadata.types() == driveItem.getTypeCapacity(driveStack) || metadata.count() >= countCapacity * 0.75) {
137-
//If we are at max type capacity OR we are at 75% or more capacity: Near full
138-
status = DriveStatus.NEAR_FULL;
130+
if (metadata.isEmpty()) {
131+
status = DriveStatus.NONE;
132+
} else if (hasFrequency) {
133+
allEmpty = false;
134+
long countCapacity = driveItem.getCountCapacity(driveStack);
135+
if (metadata.count() == countCapacity) {
136+
//If we are at max item capacity: Full
137+
status = DriveStatus.FULL;
138+
} else if (metadata.types() == driveItem.getTypeCapacity(driveStack) || metadata.count() >= countCapacity * 0.75) {
139+
//If we are at max type capacity OR we are at 75% or more capacity: Near full
140+
status = DriveStatus.NEAR_FULL;
141+
} else {
142+
//Otherwise: Ready
143+
status = DriveStatus.READY;
144+
}
139145
} else {
140-
//Otherwise: Ready
141-
status = DriveStatus.READY;
146+
allEmpty = false;
147+
status = DriveStatus.OFFLINE;
142148
}
143-
} else {
144-
allEmpty = false;
145-
status = DriveStatus.OFFLINE;
146149
}
147150
driveStatus[i] = status.status();
148151
}

src/main/java/mekanism/client/recipe_viewer/jei/MekanismJEI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public static RecipeType<?>[] recipeType(IRecipeViewerRecipeType<?>... recipeTyp
153153

154154
private static final IIngredientSubtypeInterpreter<ItemStack> MEKANISM_NBT_INTERPRETER = (stack, context) -> {
155155
//TODO - 1.20.5: Re-evaluate if we want the components check or if it should check it slightly differently?
156-
if (context == UidContext.Ingredient && !stack.getComponents().isEmpty()) {
156+
if (context == UidContext.Ingredient && !stack.getComponentsPatch().isEmpty()) {
157157
String representation = getChemicalComponent(stack, ContainerType.GAS, Capabilities.GAS.item());
158158
representation = addInterpretation(representation, getChemicalComponent(stack, ContainerType.INFUSION, Capabilities.INFUSION.item()));
159159
representation = addInterpretation(representation, getChemicalComponent(stack, ContainerType.PIGMENT, Capabilities.PIGMENT.item()));

src/main/java/mekanism/common/attachments/StabilizedChunks.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
public record StabilizedChunks(byte[] chunks) {
1515

1616
private static final int ARRAY_SIZE = TileEntityDimensionalStabilizer.MAX_LOAD_DIAMETER * TileEntityDimensionalStabilizer.MAX_LOAD_DIAMETER;
17+
public static final StabilizedChunks NONE = new StabilizedChunks(new byte[ARRAY_SIZE]);
1718

1819
public static final Codec<StabilizedChunks> CODEC = Codec.BYTE.listOf(ARRAY_SIZE, ARRAY_SIZE).xmap(bytes -> {
1920
byte[] chunks = new byte[ARRAY_SIZE];

0 commit comments

Comments
 (0)