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,19 +88,23 @@ 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){
if(entity instanceof EntityPlayer){ ItemStack stack = player.getHeldItemMainhand();
EntityPlayer playerHit = (EntityPlayer)entity; if(stack != null && stack.getItem() == this){
if(entity instanceof EntityPlayer){
EntityPlayer playerHit = (EntityPlayer)entity;
if(!playerHit.isSneaking()){ if(!playerHit.isSneaking()){
if(!stack.hasTagCompound()){ if(!stack.hasTagCompound()){
stack.setTagCompound(new NBTTagCompound()); stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound compound = stack.getTagCompound();
compound.setString("Name", playerHit.getName());
compound.setUniqueId("UUID", playerHit.getUniqueID());
return true;
} }
NBTTagCompound compound = stack.getTagCompound();
compound.setString("Name", playerHit.getName());
compound.setUniqueId("UUID", playerHit.getUniqueID());
} }
} }
} }