TheBrokenRail
6052e00429
All checks were successful
SorceryCraft/pipeline/head This commit looks good
31 lines
1.3 KiB
Java
31 lines
1.3 KiB
Java
package com.thebrokenrail.sorcerycraft.mixin;
|
|
|
|
import com.thebrokenrail.sorcerycraft.packet.UpdateKnownSpellsS2CPacket;
|
|
import com.thebrokenrail.sorcerycraft.spell.SpellPlayerEntity;
|
|
import com.thebrokenrail.sorcerycraft.spell.SpellTag;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.server.network.ServerPlayerEntity;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
|
|
@SuppressWarnings("unused")
|
|
@Mixin(ServerPlayerEntity.class)
|
|
public abstract class MixinServerPlayerEntity implements SpellPlayerEntity {
|
|
@Inject(at = @At("HEAD"), method = "copyFrom")
|
|
public void copyFrom(ServerPlayerEntity oldPlayer, boolean alive, CallbackInfo ci) {
|
|
SpellPlayerEntity oldSpellPlayer = (SpellPlayerEntity) oldPlayer;
|
|
SpellPlayerEntity newSpellPlayer = this;
|
|
|
|
newSpellPlayer.setSpells(oldSpellPlayer.getSpells());
|
|
}
|
|
|
|
@Inject(at = @At("HEAD"), method = "playerTick")
|
|
public void playerTick(CallbackInfo ignored) {
|
|
CompoundTag tag = new CompoundTag();
|
|
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(getSpells()));
|
|
//noinspection ConstantConditions
|
|
UpdateKnownSpellsS2CPacket.send((ServerPlayerEntity) (Object) this, tag);
|
|
}
|
|
} |