Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.wispforest.accessories.mixin;

import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
import net.minecraft.core.component.DataComponentPatch;
import net.minecraft.core.component.DataComponentType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.Optional;

@Mixin(DataComponentPatch.class)
public interface DataComponentPatchAccessor {
@Accessor
Reference2ObjectMap<DataComponentType<?>, Optional<?>> getMap();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.*;

@Mixin(PatchedDataComponentMap.class)
public abstract class PatchedDataComponentMapMixin implements PatchedDataComponentMapExtension {
Expand Down Expand Up @@ -96,7 +93,11 @@ public abstract class PatchedDataComponentMapMixin implements PatchedDataCompone

this.inApplyPatchLock = false;

var changedDataTypes = (List<DataComponentType<?>>) (List) patch.entrySet().stream().map(Map.Entry::getKey).toList();
if (this.mutationEvent == null) {
return;
}

var changedDataTypes = new ArrayList<>(((DataComponentPatchAccessor) (Object) patch).getMap().keySet());

this.accessories$handleMutationEvent(changedDataTypes);
}
Expand All @@ -114,7 +115,11 @@ public abstract class PatchedDataComponentMapMixin implements PatchedDataCompone
private void accessories$updateChangeValue_restorePatch(DataComponentPatch patch, CallbackInfo ci){
this.changeCheckStack = true;

var changedDataTypes = (List<DataComponentType<?>>) (List) patch.entrySet().stream().map(Map.Entry::getKey).toList();
if (this.mutationEvent == null) {
return;
}

var changedDataTypes = new ArrayList<>(((DataComponentPatchAccessor) (Object) patch).getMap().keySet());

this.accessories$handleMutationEvent(changedDataTypes);
}
Expand Down
7 changes: 4 additions & 3 deletions common/src/main/resources/accessories-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"mixins": [
"AbstractContainerMenuMixin",
"ApplyBonusCountMixin",
"TooltipFlagMixin",
"CommandSelectionAccessor",
"CraftingMenuAccessor",
"CriteriaTriggersAccessor",
"DataComponentPatchAccessor",
"DataPackContentsMixin",
"DefaultDispenseItemBehaviorAccessor",
"DispenserBlockMixin",
Expand All @@ -63,6 +63,8 @@
"EquipmentSlotMixin",
"EquipmentSlotTypeMixin",
"FileToIdConverterMixin",
"GameRulesAccessor",
"GameRulesAccessor$BooleanValueAccessor",
"HorseInventoryMenuAccessor",
"InventoryMixin",
"ItemStackAccessor",
Expand All @@ -79,8 +81,7 @@
"SimpleJsonResourceReloadListenerAccessor",
"SimpleJsonResourceReloadListenerMixin",
"StateHolderAccessor",
"GameRulesAccessor",
"GameRulesAccessor$BooleanValueAccessor",
"TooltipFlagMixin",
"owo.ConfigWrapperAccessor",
"owo.DumpdataCommandMixin",
"owo.NbtDeserializerMixin",
Expand Down