2020-03-01 18:19:59 +00:00
|
|
|
package com.thebrokenrail.sorcerycraft.mixin;
|
|
|
|
|
2020-03-06 23:35:29 +00:00
|
|
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
|
|
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
2020-03-01 18:19:59 +00:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
2020-03-03 23:08:22 +00:00
|
|
|
import net.minecraft.util.Identifier;
|
2020-03-01 18:19:59 +00:00
|
|
|
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;
|
|
|
|
|
2020-03-02 22:11:37 +00:00
|
|
|
import java.util.HashMap;
|
2020-03-01 18:19:59 +00:00
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
@Mixin(PlayerEntity.class)
|
|
|
|
public class MixinPlayerEntity implements SpellPlayerEntity {
|
2020-03-16 15:21:06 +00:00
|
|
|
// Namespace Fields
|
|
|
|
private Map<Identifier, Integer> sorceryCraftDiscoveredSpells = new HashMap<>();
|
2020-03-01 18:19:59 +00:00
|
|
|
|
|
|
|
@Inject(at = @At("HEAD"), method = "readCustomDataFromTag")
|
|
|
|
public void readCustomDataFromTag(CompoundTag tag, CallbackInfo info) {
|
2020-03-16 15:21:06 +00:00
|
|
|
sorceryCraftDiscoveredSpells = SpellTag.getSpells(tag);
|
2020-03-01 18:19:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Inject(at = @At("HEAD"), method = "writeCustomDataToTag")
|
|
|
|
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
|
2020-03-16 15:21:06 +00:00
|
|
|
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(sorceryCraftDiscoveredSpells));
|
2020-03-01 18:19:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-03-16 15:21:06 +00:00
|
|
|
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {
|
|
|
|
this.sorceryCraftDiscoveredSpells = spells;
|
2020-03-01 18:19:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-03-16 15:21:06 +00:00
|
|
|
public Map<Identifier, Integer> getDiscoveredSpells() {
|
|
|
|
return sorceryCraftDiscoveredSpells;
|
2020-03-01 18:19:59 +00:00
|
|
|
}
|
|
|
|
}
|