Skip to content

Commit

Permalink
fix NPE on death (closes #22)
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Jun 14, 2021
1 parent 484e883 commit d23c269
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static TaterzenNPC loadTaterzenFromPreset(File preset, World world) {
*/
public static void saveTaterzenToPreset(TaterzenNPC taterzen, File preset) {
NbtCompound saveTag = new NbtCompound();
taterzen.saveNbt(saveTag);
taterzen.writeNbt(saveTag);

//todo Weird as it is, those cannot be read back :(
saveTag.remove("ArmorDropChances");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ private void changeEntityType(Packet<?> packet, GenericFutureListener<? extends
if(packet instanceof PlayerSpawnS2CPacket && !this.taterzens$skipCheck) {
Entity entity = world.getEntityById(((PlayerSpawnS2CPacketAccessor) packet).getId());

if(!(entity instanceof TaterzenNPC))
if(!(entity instanceof TaterzenNPC npc))
return;

TaterzenNPC npc = (TaterzenNPC) entity;
GameProfile profile = npc.getGameProfile();

PlayerListS2CPacket playerAddPacket = new PlayerListS2CPacket(ADD_PLAYER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ public void onDeath(DamageSource source) {

@Override
public void remove(Entity.RemovalReason reason) {
super.remove(null);
super.remove(reason);
TATERZEN_NPCS.remove(this);

for(TaterzenProfession profession : this.professions.values()) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fabric_version=0.34.9+1.17
forge_version=36.0.46

# Mod Properties
mod_version = 1.1.2
mod_version = 1.1.3
maven_group = org.samo_lego
archives_base_name = taterzens

Expand Down

0 comments on commit d23c269

Please sign in to comment.