Skip to content

Commit

Permalink
Temporary fix for belts being activatable after death #1217
Browse files Browse the repository at this point in the history
This does not solve the problem, only prevent the crash. It'll cause clientside desyncs until the belt is re-equipped.
  • Loading branch information
bonii-xx committed Dec 21, 2014
1 parent 139b1fb commit 224a3d4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/java/tconstruct/armor/PlayerAbilityHelper.java
Expand Up @@ -28,6 +28,9 @@ public static void swapBelt (EntityPlayer player, ArmorExtended armor)
{
NBTTagList slots = new NBTTagList();
InventoryPlayer hotbar = player.inventory;
ItemStack belt = armor.inventory[3];
if(belt == null)
return;

NBTTagCompound itemTag;

Expand All @@ -43,7 +46,6 @@ public static void swapBelt (EntityPlayer player, ArmorExtended armor)
hotbar.mainInventory[i] = null;
}

ItemStack belt = armor.inventory[3];
NBTTagList replaceSlots = belt.getTagCompound().getTagList("Inventory", 10);
for (int i = 0; i < replaceSlots.tagCount(); ++i)
{
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/tconstruct/armor/player/TPlayerHandler.java
Expand Up @@ -10,6 +10,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import mantle.player.PlayerUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.*;
import net.minecraft.entity.Entity.EnumEntitySize;
Expand All @@ -20,6 +21,7 @@
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import tconstruct.TConstruct;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.tools.TinkerTools;
Expand Down Expand Up @@ -237,13 +239,15 @@ public void livingFall (LivingFallEvent evt) // Only for negating fall damage
@SubscribeEvent
public void playerDeath (LivingDeathEvent event)
{
if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer)
if(!(event.entity instanceof EntityPlayer))
return;

if (!event.entity.worldObj.isRemote)
{
TPlayerStats properties = (TPlayerStats) event.entity.getExtendedProperties(TPlayerStats.PROP_NAME);
properties.hunger = ((EntityPlayer) event.entity).getFoodStats().getFoodLevel();
playerStats.put(((EntityPlayer) event.entity).getPersistentID(), properties);
}

}

@SubscribeEvent
Expand Down Expand Up @@ -362,7 +366,4 @@ public void buildStickURLDatabase (String location)
TConstruct.logger.error(e.getMessage() != null ? e.getMessage() : "UNKOWN DL ERROR", e);
}
}

Random rand = new Random();

}

0 comments on commit 224a3d4

Please sign in to comment.