1.0.6
All checks were successful
SorceryCraft/pipeline/head This commit looks good

Namespace PlayerEntity Mixin
This commit is contained in:
TheBrokenRail 2020-03-03 20:34:36 -05:00
parent dd228acf79
commit 8448acca6a
10 changed files with 22 additions and 18 deletions

View File

@ -1,5 +1,8 @@
### Changelog
**1.0.6**
* Namespace PlayerEntity Mixin
**1.0.5**
* Clean up code

View File

@ -7,6 +7,7 @@ compileJava {
targetCompatibility = JavaVersion.VERSION_1_8
}
archivesBaseName = project.archives_base_name
version = project.mod_version as Object
group = project.maven_group as Object

View File

@ -8,7 +8,7 @@ org.gradle.jvmargs = -Xmx1G
loader_version = 0.7.8+build.184
# Mod Properties
mod_version = 1.0.5
mod_version = 1.0.6
maven_group = com.thebrokenrail
archives_base_name = sorcerycraft

View File

@ -47,7 +47,7 @@ public class CastingTableContainer extends Container {
spells = SpellRegistry.getSpells();
} else {
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) playerInventory.player;
Map<Identifier, Integer> spellsMap = spellPlayer.getSpells();
Map<Identifier, Integer> spellsMap = spellPlayer.getSorceryCraftSpells();
List<Spell> spellsArray = new ArrayList<>();
Spell[] allSpells = SpellRegistry.getSpells();

View File

@ -25,7 +25,7 @@ public class SpellCommand {
PlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
ctx.getSource().sendFeedback(new TranslatableText("command." + SorceryCraft.NAMESPACE + ".spell.listing_spells", player.getDisplayName()), false);
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
Map<Identifier, Integer> spells = spellPlayer.getSpells();
Map<Identifier, Integer> spells = spellPlayer.getSorceryCraftSpells();
for (Map.Entry<Identifier, Integer> entry : spells.entrySet()) {
ctx.getSource().sendFeedback(SpellTag.getTranslatedSpell(entry.getKey(), entry.getValue()).formatted(Formatting.YELLOW), false);
}
@ -38,7 +38,7 @@ public class SpellCommand {
.executes(ctx -> {
PlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
spellPlayer.setSpells(new HashMap<>());
spellPlayer.setSorceryCraftSpells(new HashMap<>());
ctx.getSource().sendFeedback(new TranslatableText("command." + SorceryCraft.NAMESPACE + ".spell.cleared_spells", player.getDisplayName()), true);
return 1;
})

View File

@ -94,7 +94,7 @@ public class SpellItem extends Item {
PlayerEntity player = (PlayerEntity) entity;
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) player;
Map<Identifier, Integer> playerSpells = spellPlayer.getSpells();
Map<Identifier, Integer> playerSpells = spellPlayer.getSorceryCraftSpells();
Map<Identifier, Integer> itemSpells = SpellTag.getSpells(player.inventory.getInvStack(slot));
boolean changed = false;
@ -119,7 +119,7 @@ public class SpellItem extends Item {
if (changed) {
SorceryCraft.playSpellSound(player);
spellPlayer.setSpells(playerSpells);
spellPlayer.setSorceryCraftSpells(playerSpells);
}
}
}

View File

@ -16,25 +16,25 @@ import java.util.Map;
@SuppressWarnings("unused")
@Mixin(PlayerEntity.class)
public class MixinPlayerEntity implements SpellPlayerEntity {
private Map<Identifier, Integer> spells = new HashMap<>();
private Map<Identifier, Integer> sorceryCraftSpells = new HashMap<>();
@Inject(at = @At("HEAD"), method = "readCustomDataFromTag")
public void readCustomDataFromTag(CompoundTag tag, CallbackInfo info) {
spells = SpellTag.getSpells(tag);
sorceryCraftSpells = SpellTag.getSpells(tag);
}
@Inject(at = @At("HEAD"), method = "writeCustomDataToTag")
public void writeCustomDataToTag(CompoundTag tag, CallbackInfo info) {
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(spells));
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(sorceryCraftSpells));
}
@Override
public void setSpells(Map<Identifier, Integer> spells) {
this.spells = spells;
public void setSorceryCraftSpells(Map<Identifier, Integer> spells) {
this.sorceryCraftSpells = spells;
}
@Override
public Map<Identifier, Integer> getSpells() {
return spells;
public Map<Identifier, Integer> getSorceryCraftSpells() {
return sorceryCraftSpells;
}
}

View File

@ -18,13 +18,13 @@ public abstract class MixinServerPlayerEntity implements SpellPlayerEntity {
SpellPlayerEntity oldSpellPlayer = (SpellPlayerEntity) oldPlayer;
SpellPlayerEntity newSpellPlayer = this;
newSpellPlayer.setSpells(oldSpellPlayer.getSpells());
newSpellPlayer.setSorceryCraftSpells(oldSpellPlayer.getSorceryCraftSpells());
}
@Inject(at = @At("HEAD"), method = "playerTick")
public void playerTick(CallbackInfo ignored) {
CompoundTag tag = new CompoundTag();
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(getSpells()));
tag.put(SpellTag.SPELL_TAG, SpellTag.createSpellsTag(getSorceryCraftSpells()));
//noinspection ConstantConditions
UpdateKnownSpellsS2CPacket.send((ServerPlayerEntity) (Object) this, tag);
}

View File

@ -16,7 +16,7 @@ public class UpdateKnownSpellsS2CPacket {
CompoundTag tag = bytes.readCompoundTag();
if (context.getPlayer() != null) {
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) context.getPlayer();
spellPlayer.setSpells(SpellTag.getSpells(tag));
spellPlayer.setSorceryCraftSpells(SpellTag.getSpells(tag));
}
}

View File

@ -5,7 +5,7 @@ import net.minecraft.util.Identifier;
import java.util.Map;
public interface SpellPlayerEntity {
void setSpells(Map<Identifier, Integer> spells);
void setSorceryCraftSpells(Map<Identifier, Integer> spells);
Map<Identifier, Integer> getSpells();
Map<Identifier, Integer> getSorceryCraftSpells();
}