use of net.mcft.copy.betterstorage.api.stand.ArmorStandEquipHandler in project BetterStorage by copygirl.
the class TileEntityArmorStand method dropContents.
@Override
public void dropContents() {
ItemStack item;
for (EnumArmorStandRegion region : EnumArmorStandRegion.values()) for (ArmorStandEquipHandler handler : BetterStorageArmorStand.getEquipHandlers(region)) if ((item = getItem(handler)) != null)
WorldUtils.dropStackFromBlock(worldObj, xCoord, yCoord, zCoord, item);
clearItems();
}
use of net.mcft.copy.betterstorage.api.stand.ArmorStandEquipHandler in project BetterStorage by copygirl.
the class TileEntityArmorStand method onBlockActivated.
@Override
public boolean onBlockActivated(EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (worldObj.isRemote)
return true;
int slot = Math.max(0, Math.min(3, (int) (hitY * 2)));
EnumArmorStandRegion region = EnumArmorStandRegion.values()[slot];
for (ArmorStandEquipHandler handler : BetterStorageArmorStand.getEquipHandlers(region)) {
ItemStack item = getItem(handler);
if (player.isSneaking()) {
// Swap 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;
setItem(handler, equipped);
handler.setEquipment(player, item);
} else {
// Swap player's held item with armor stand's.
ItemStack holding = player.getCurrentEquippedItem();
if (((item == null) && (holding == null)) || ((holding != null) && !handler.isValidItem(player, holding)))
continue;
setItem(handler, holding);
player.setCurrentItemOrArmor(EquipmentSlot.HELD, item);
break;
}
}
return true;
}
use of net.mcft.copy.betterstorage.api.stand.ArmorStandEquipHandler 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);
}
use of net.mcft.copy.betterstorage.api.stand.ArmorStandEquipHandler in project BetterStorage by copygirl.
the class TileEntityArmorStand method write.
public void write(NBTTagCompound compound) {
compound.setByte("rotation", (byte) rotation);
NBTTagCompound items = new NBTTagCompound();
for (EnumArmorStandRegion region : EnumArmorStandRegion.values()) {
NBTTagCompound regionCompound = new NBTTagCompound();
ItemStack item;
for (ArmorStandEquipHandler handler : BetterStorageArmorStand.getEquipHandlers(region)) if ((item = getItem(handler)) != null)
regionCompound.setTag(handler.id, item.writeToNBT(new NBTTagCompound()));
items.setTag(region.toString(), regionCompound);
}
compound.setTag("Items", items);
}
use of net.mcft.copy.betterstorage.api.stand.ArmorStandEquipHandler in project BetterStorage by copygirl.
the class TileEntityArmorStand method onPickBlock.
@Override
public ItemStack onPickBlock(ItemStack block, MovingObjectPosition target) {
int slot = Math.max(0, Math.min(3, (int) ((target.hitVec.yCoord - yCoord) * 2)));
EnumArmorStandRegion region = EnumArmorStandRegion.values()[slot];
ItemStack item;
for (ArmorStandEquipHandler handler : BetterStorageArmorStand.getEquipHandlers(region)) if ((item = getItem(handler)) != null)
return item;
return block;
}
Aggregations