summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/mixins/transformers/UpdateDataWatcherEventPatch.java
blob: bcc30f42dc4758a5ae8ed9b7c23f50717a92cb68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package at.hannibal2.skyhanni.mixins.transformers;

import at.hannibal2.skyhanni.events.DataWatcherUpdatedEvent;
import net.minecraft.entity.DataWatcher;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.List;

@Mixin(DataWatcher.class)
public class UpdateDataWatcherEventPatch {
    @Shadow
    @Final
    private Entity owner;

    @Inject(method = "updateWatchedObjectsFromList", at = @At("TAIL"))
    public void onWhatever(List<DataWatcher.WatchableObject> list, CallbackInfo ci) {
        new DataWatcherUpdatedEvent(owner, list).postAndCatch();
    }
}