This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
SorceryCraft/src/main/java/com/thebrokenrail/sorcerycraft/mixin/MixinPlayerEntity.java

41 lines
1.4 KiB
Java
Raw Normal View History

2020-03-01 18:19:59 +00:00
package com.thebrokenrail.sorcerycraft.mixin;
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;
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-04 01:34:36 +00:00
private Map<Identifier, Integer> sorceryCraftSpells = 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-04 01:34:36 +00:00
sorceryCraftSpells = 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-04 01:34:36 +00:00
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(sorceryCraftSpells));
2020-03-01 18:19:59 +00:00
}
@Override
2020-03-04 01:34:36 +00:00
public void setSorceryCraftSpells(Map<Identifier, Integer> spells) {
this.sorceryCraftSpells = spells;
2020-03-01 18:19:59 +00:00
}
@Override
2020-03-04 01:34:36 +00:00
public Map<Identifier, Integer> getSorceryCraftSpells() {
return sorceryCraftSpells;
2020-03-01 18:19:59 +00:00
}
}