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

View File

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

View File

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