-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathEvokerEntityWololoGoalMixin.java
More file actions
36 lines (32 loc) · 1.82 KB
/
Copy pathEvokerEntityWololoGoalMixin.java
File metadata and controls
36 lines (32 loc) · 1.82 KB
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
26
27
28
29
30
31
32
33
34
35
36
package com.github.quiltservertools.ledger.mixin.entities;
import com.github.quiltservertools.ledger.callbacks.EntityModifyCallback;
import com.github.quiltservertools.ledger.utility.NbtUtils;
import com.github.quiltservertools.ledger.utility.Sources;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.world.entity.animal.sheep.Sheep;
import net.minecraft.world.entity.monster.illager.Evoker;
import net.minecraft.world.item.Items;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.DyeColor;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Evoker.EvokerWololoSpellGoal.class)
public abstract class EvokerEntityWololoGoalMixin {
@Unique
private CompoundTag oldEntityTags;
@Inject(method = "performSpellCasting", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/sheep/Sheep;setColor(Lnet/minecraft/world/item/DyeColor;)V"))
public void legerLogOldEntity(CallbackInfo ci, @Local Sheep sheepEntity) {
if (sheepEntity.getColor() != DyeColor.RED) {
this.oldEntityTags = NbtUtils.INSTANCE.createNbt(sheepEntity);
}
}
@Inject(method = "performSpellCasting", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/animal/sheep/Sheep;setColor(Lnet/minecraft/world/item/DyeColor;)V", shift = At.Shift.AFTER))
public void ledgerEvokerDyeSheep(CallbackInfo ci, @Local Sheep sheepEntity) {
if (oldEntityTags != null) {
EntityModifyCallback.EVENT.invoker().modify(sheepEntity.level(), sheepEntity.blockPosition(), oldEntityTags, sheepEntity, Items.DYE.red().getDefaultInstance(), null, Sources.DYE);
}
}
}