Use @Unique
All checks were successful
SorceryCraft/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-03-27 14:07:47 -04:00
parent 4d0e4b6411
commit 0664de5de5
3 changed files with 12 additions and 9 deletions

View File

@ -22,7 +22,6 @@ public class MixinClientPlayNetworkHandler {
@Shadow
private ClientWorld world;
@Environment(EnvType.CLIENT)
@Inject(method = "onEntitySpawn", at = @At(value = "TAIL"))
public void onEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo info) {
EntityType<?> entityType = packet.getEntityTypeId();

View File

@ -16,7 +16,9 @@ import java.util.Map;
@Mixin(ClientPlayerEntity.class)
@Environment(EnvType.CLIENT)
public class MixinClientPlayerEntity extends MixinPlayerEntity {
@Shadow @Final protected MinecraftClient client;
@Shadow
@Final
protected MinecraftClient client;
@Override
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {

View File

@ -9,6 +9,7 @@ import net.minecraft.screen.ScreenHandler;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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;
@ -19,23 +20,24 @@ import java.util.Map;
@SuppressWarnings("unused")
@Mixin(PlayerEntity.class)
public class MixinPlayerEntity implements SpellPlayerEntity {
@Shadow public ScreenHandler currentScreenHandler;
// Namespace Fields
private Map<Identifier, Integer> sorceryCraftDiscoveredSpells = new HashMap<>();
@Shadow
public ScreenHandler currentScreenHandler;
@Unique
private Map<Identifier, Integer> discoveredSpells = new HashMap<>();
@Inject(at = @At("HEAD"), method = "readCustomDataFromTag")
public void readCustomDataFromTag(CompoundTag tag, CallbackInfo info) {
sorceryCraftDiscoveredSpells = SpellHelper.getSpells(tag);
discoveredSpells = SpellHelper.getSpells(tag);
}
@Inject(at = @At("HEAD"), method = "writeCustomDataToTag")
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
tag.put(SpellHelper.SPELL_TAG, SpellHelper.createSpellsTag(sorceryCraftDiscoveredSpells));
tag.put(SpellHelper.SPELL_TAG, SpellHelper.createSpellsTag(discoveredSpells));
}
@Override
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {
this.sorceryCraftDiscoveredSpells = spells;
discoveredSpells = spells;
if (currentScreenHandler instanceof CastingTableScreenHandler) {
//noinspection ConstantConditions
((CastingTableScreenHandler) currentScreenHandler).setSpells((PlayerEntity) (Object) this);
@ -44,6 +46,6 @@ public class MixinPlayerEntity implements SpellPlayerEntity {
@Override
public Map<Identifier, Integer> getDiscoveredSpells() {
return sorceryCraftDiscoveredSpells;
return discoveredSpells;
}
}