use of net.mcft.copy.betterstorage.tile.stand.TileEntityArmorStand in project BetterStorage by copygirl.
the class ClientProxy method getArmorStandHighlightBox.
private AxisAlignedBB getArmorStandHighlightBox(EntityPlayer player, World world, int x, int y, int z, Vec3 hitVec) {
int metadata = world.getBlockMetadata(x, y, z);
if (metadata > 0)
y -= 1;
TileEntityArmorStand armorStand = WorldUtils.get(world, x, y, z, TileEntityArmorStand.class);
if (armorStand == null)
return null;
int slot = Math.max(0, Math.min(3, (int) ((hitVec.yCoord - y) * 2)));
double minX = x + 2 / 16.0;
double minY = y + slot / 2.0;
double minZ = z + 2 / 16.0;
double maxX = x + 14 / 16.0;
double maxY = y + slot / 2.0 + 0.5;
double maxZ = z + 14 / 16.0;
EnumArmorStandRegion region = EnumArmorStandRegion.values()[slot];
for (ArmorStandEquipHandler handler : BetterStorageArmorStand.getEquipHandlers(region)) {
ItemStack item = armorStand.getItem(handler);
if (player.isSneaking()) {
// Check if we can swap the player's equipped armor with armor stand's.
ItemStack equipped = handler.getEquipment(player);
if (((item == null) && (equipped == null)) || ((item != null) && !handler.isValidItem(player, item)) || ((equipped != null) && !handler.isValidItem(player, equipped)) || !handler.canSetEquipment(player, item))
continue;
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
} else {
// Check if we can swap the player's held item with armor stand's.
ItemStack holding = player.getCurrentEquippedItem();
if (((item == null) && (holding == null)) || ((holding != null) && !handler.isValidItem(player, holding)))
continue;
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
}
return AxisAlignedBB.getBoundingBox(minX, y, minZ, maxX, y + 2, maxZ);
}
Aggregations