package net.mcft.copy.betterstorage.inventory;

import net.mcft.copy.betterstorage.item.ItemBackpack;
import net.mcft.copy.betterstorage.utils.DirectionUtils;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;

public class InventoryBackpackEquipped extends InventoryWrapper {
	
	public final EntityPlayer player;
	public final EntityLiving carrier;
	
	public InventoryBackpackEquipped(EntityPlayer player, EntityLiving carrier) {
		super(ItemBackpack.getBackpackItems(carrier).contents);
		this.player = player;
		this.carrier = carrier;
	}
	
	@Override
	public boolean isUseableByPlayer(EntityPlayer player) {
		if (!carrier.isEntityAlive() || player.getDistanceToEntity(carrier) > 1.5) return false;
		double direction = DirectionUtils.angleBetween(carrier, player);
		direction = DirectionUtils.angleDifference(carrier.renderYawOffset + 90.0F, direction);
		return (Math.abs(direction) > 135);
	}
	
}

@@ -651,262 +651,430 @@
 %7B%0A%09%09
-if (!carrier.isEntityAlive() %7C%7C player.getDistanceToEntity(carrier) %3E 1.5) return false;%0A%09%09double direction = DirectionUtils.angleBetween(carrier, player);%0A%09%09direction = DirectionUtils.angleDifference(carrier.renderYawOffset + 90.0F, direction);%0A%09%09return
+boolean carriesBackpack = (ItemBackpack.getBackpackItems(carrier).contents == allContents%5B0%5D); %0A%09%09double distance = player.getDistanceToEntity(carrier);%0A%09%09double direction = DirectionUtils.angleDifference(carrier.renderYawOffset + 90.0F,%0A%09%09                                                  DirectionUtils.angleBetween(carrier, player));%0A%09%09return (carrier.isEntityAlive() && carriesBackpack &&%0A%09%09        (distance %3C 1.5) &&
  (Ma
@@ -1097,16 +1097,17 @@
 ) %3E 135)
+)
 ;%0A%09%7D%0A%09%0A%7D

Fix unequipping backpack not closing GUI