TheBrokenRail
c1e935764d
All checks were successful
SorceryCraft/pipeline/head This commit looks good
Update to 20w10a Add the /spell learn, /spell add, and /spell remove commands Use CurseForge
41 lines
1.4 KiB
Java
41 lines
1.4 KiB
Java
package com.thebrokenrail.sorcerycraft.mixin;
|
|
|
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.util.Identifier;
|
|
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;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
@SuppressWarnings("unused")
|
|
@Mixin(PlayerEntity.class)
|
|
public class MixinPlayerEntity implements SpellPlayerEntity {
|
|
private Map<Identifier, Integer> sorceryCraftSpells = new HashMap<>();
|
|
|
|
@Inject(at = @At("HEAD"), method = "readCustomDataFromTag")
|
|
public void readCustomDataFromTag(CompoundTag tag, CallbackInfo info) {
|
|
sorceryCraftSpells = SpellTag.getSpells(tag);
|
|
}
|
|
|
|
@Inject(at = @At("HEAD"), method = "writeCustomDataToTag")
|
|
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
|
|
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(sorceryCraftSpells));
|
|
}
|
|
|
|
@Override
|
|
public void setSorceryCraftSpells(Map<Identifier, Integer> spells) {
|
|
this.sorceryCraftSpells = spells;
|
|
}
|
|
|
|
@Override
|
|
public Map<Identifier, Integer> getSorceryCraftSpells() {
|
|
return sorceryCraftSpells;
|
|
}
|
|
}
|