Fixed player probe being broken

Thanks for help tiemo42 ^-^
This commit is contained in:
Ellpeck 2016-07-14 13:41:29 +02:00
parent bb0d64e869
commit 16d74df3cc

View file

@ -45,7 +45,7 @@ public class ItemPlayerProbe extends ItemBase{
if(!world.isRemote){ if(!world.isRemote){
if(stack.hasTagCompound()){ if(stack.hasTagCompound()){
NBTTagCompound compound = stack.getTagCompound(); NBTTagCompound compound = stack.getTagCompound();
if(compound.hasKey("UUID")){ if(compound.hasKey("UUIDMost")){
UUID id = compound.getUniqueId("UUID"); UUID id = compound.getUniqueId("UUID");
EntityPlayer player = world.getPlayerEntityByUUID(id); EntityPlayer player = world.getPlayerEntityByUUID(id);
if(player != null){ if(player != null){
@ -57,7 +57,7 @@ public class ItemPlayerProbe extends ItemBase{
} }
else{ else{
stack.setTagCompound(new NBTTagCompound()); stack.setTagCompound(new NBTTagCompound());
entity.addChatMessage(new TextComponentString("tooltip."+ModUtil.MOD_ID+".playerProbe.disconnect.2")); entity.addChatMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".playerProbe.disconnect.2"));
} }
} }
} }
@ -70,13 +70,15 @@ public class ItemPlayerProbe extends ItemBase{
if(tile instanceof TileEntityPlayerInterface){ if(tile instanceof TileEntityPlayerInterface){
if(stack.hasTagCompound()){ if(stack.hasTagCompound()){
NBTTagCompound compound = stack.getTagCompound(); NBTTagCompound compound = stack.getTagCompound();
if(compound.hasKey("UUID")){ if(compound.hasKey("UUIDMost")){
if(!world.isRemote){ if(!world.isRemote){
TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile; TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile;
face.connectedPlayer = compound.getUniqueId("UUID"); face.connectedPlayer = compound.getUniqueId("UUID");
face.playerName = compound.getString("Name"); face.playerName = compound.getString("Name");
face.markDirty(); face.markDirty();
face.sendUpdate(); face.sendUpdate();
stack.setTagCompound(new NBTTagCompound());
} }
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }
@ -86,8 +88,10 @@ public class ItemPlayerProbe extends ItemBase{
} }
@Override @Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity, EnumHand hand){ public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand){
if(!player.worldObj.isRemote){ if(!player.worldObj.isRemote){
ItemStack stack = player.getHeldItemMainhand();
if(stack != null && stack.getItem() == this){
if(entity instanceof EntityPlayer){ if(entity instanceof EntityPlayer){
EntityPlayer playerHit = (EntityPlayer)entity; EntityPlayer playerHit = (EntityPlayer)entity;
@ -99,6 +103,8 @@ public class ItemPlayerProbe extends ItemBase{
NBTTagCompound compound = stack.getTagCompound(); NBTTagCompound compound = stack.getTagCompound();
compound.setString("Name", playerHit.getName()); compound.setString("Name", playerHit.getName());
compound.setUniqueId("UUID", playerHit.getUniqueID()); compound.setUniqueId("UUID", playerHit.getUniqueID());
return true;
}
} }
} }
} }