use of net.silentchaos512.gems.item.quiver.IQuiver in project SilentGems by SilentChaos512.
the class ContainerQuiver method canTake.
public boolean canTake(int slotId, Slot slot, int button, EntityPlayer player, ClickType clickType) {
if (slotId == blocked)
return false;
if (slotId <= ItemQuiver.MAX_STACKS - 1) {
if (player.inventory.getItemStack().getItem() instanceof IQuiver)
return false;
}
// Hotbar swapping via number keys
if (clickType == ClickType.SWAP) {
int hotbarId = ItemQuiver.MAX_STACKS + 27 + button;
// Block swapping with quiver
if (blocked == hotbarId)
return false;
Slot hotbarSlot = getSlot(hotbarId);
if (slotId <= ItemQuiver.MAX_STACKS - 1) {
if (slot.getStack().getItem() instanceof IQuiver || hotbarSlot.getStack().getItem() instanceof IQuiver)
return false;
}
}
return true;
}
use of net.silentchaos512.gems.item.quiver.IQuiver in project SilentGems by SilentChaos512.
the class GuiQuiverArrowOverlay method onRenderGameOverlay.
@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent event) {
if (!GemsConfig.SHOW_ARROW_COUNT || event.getType() != ElementType.HOTBAR) {
return;
}
// Player holding a bow?
EntityPlayer player = SilentGems.proxy.getClientPlayer();
ItemStack bow = getActiveBow(player);
if (StackHelper.isValid(bow)) {
// Get the "arrow" the bow would fire.
ItemStack arrow = StackHelper.empty();
int arrowCount = 0;
ItemStack stack = findAmmo(player);
if (StackHelper.isValid(stack)) {
// Is it a quiver?
if (stack.getItem() instanceof IQuiver) {
// Find first arrow.
IItemHandler itemHandler = ((IQuiver) stack.getItem()).getInventory(stack);
for (int i = 0; i < itemHandler.getSlots(); ++i) {
ItemStack itemstack = itemHandler.getStackInSlot(i);
if (StackHelper.isValid(itemstack) && itemstack.getItem() instanceof ItemArrow) {
if (StackHelper.isEmpty(arrow)) {
arrow = itemstack;
arrowCount = arrow.getCount();
} else if (arrow.isItemEqual(itemstack) && ((!arrow.hasTagCompound() && !itemstack.hasTagCompound()) || itemstack.getTagCompound().equals(arrow.getTagCompound()))) {
arrowCount += itemstack.getCount();
}
}
}
} else {
// It's just an arrow.
arrow = stack;
arrowCount = arrow.getCount();
}
}
if (StackHelper.isValid(arrow)) {
renderArrow(arrow, arrowCount, player);
}
}
}
Aggregations