@Override public void setInventorySlotContents(int index, ItemStack stack) { handler.setStackInSlot(index, stack); }
baubles.setStackInSlot(i, ItemStack.EMPTY); baubles.setStackInSlot(i, toEquip); ((IBauble) toEquip.getItem()).onEquipped(toEquip, player);
@Override public ItemStack removeStackFromSlot(int index) { ItemStack out = this.getStackInSlot(index); handler.setStackInSlot(index, ItemStack.EMPTY); return out; }
Minecraft.getMinecraft().addScheduledTask(new Runnable(){ public void run() { World world = Baubles.proxy.getClientWorld(); if (world==null) return; Entity p = world.getEntityByID(message.playerId); if (p !=null && p instanceof EntityPlayer) { IBaublesItemHandler baubles = BaublesApi.getBaublesHandler((EntityPlayer) p); baubles.setStackInSlot(message.slot, message.bauble); } }}); return null;
public void dropItemsAt(EntityPlayer player, List<EntityItem> drops, Entity e) { IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player); for (int i = 0; i < baubles.getSlots(); ++i) { if (baubles.getStackInSlot(i) != null && !baubles.getStackInSlot(i).isEmpty()) { EntityItem ei = new EntityItem(e.world, e.posX, e.posY + e.getEyeHeight(), e.posZ, baubles.getStackInSlot(i).copy()); ei.setPickupDelay(40); float f1 = e.world.rand.nextFloat() * 0.5F; float f2 = e.world.rand.nextFloat() * (float) Math.PI * 2.0F; ei.motionX = (double) (-MathHelper.sin(f2) * f1); ei.motionZ = (double) (MathHelper.cos(f2) * f1); ei.motionY = 0.20000000298023224D; drops.add(ei); baubles.setStackInSlot(i, ItemStack.EMPTY); } } } }
@Override @Nonnull public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) { // Check if the entity we've just hit has a stack in the first slot. If so, use that instead. ItemStack stack = player.getHeldItem(hand); RayTraceResult hit = PlayerHelpers.findHitGuess(player); Entity entity = hit.entityHit; if (hit.typeOfHit == RayTraceResult.Type.ENTITY && !(entity instanceof EntityPlayer) && entity instanceof EntityLivingBase) { if (((EntityLivingBase) entity).getItemStackFromSlot(NeuralHelpers.ARMOR_SLOT).isEmpty() && stack.getCount() == 1) { return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } if (LoadedCache.hasBaubles()) { IBaublesItemHandler handler = BaublesApi.getBaublesHandler(player); for (int slot : NeuralHelpers.getBaubleType().getValidSlots()) { if (handler.getStackInSlot(slot).isEmpty()) { if (!world.isRemote) { handler.setStackInSlot(slot, stack.copy()); if (!player.capabilities.isCreativeMode) stack.grow(-1); } return ActionResult.newResult(EnumActionResult.SUCCESS, stack); } } } return super.onItemRightClick(world, player, hand); }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { if(!world.isRemote) { IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player); for(int i = 0; i < baubles.getSlots(); i++) if((baubles.getStackInSlot(i) == null || baubles.getStackInSlot(i).isEmpty()) && baubles.isItemValidForSlot(i, player.getHeldItem(hand), player)) { baubles.setStackInSlot(i, player.getHeldItem(hand).copy()); if(!player.capabilities.isCreativeMode){ player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY); } onEquipped(player.getHeldItem(hand), player); break; } } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); }
sender.sendMessage(new TextComponentTranslation("\u00a7cUse /baubles help to get help")); } else { baubles.setStackInSlot(slot, ItemStack.EMPTY); sender.sendMessage(new TextComponentTranslation("\u00a73Cleared baubles slot "+slot+" for "+entityplayermp.getName())); entityplayermp.sendMessage(new TextComponentTranslation("\u00a74Your baubles slot "+slot+" has been cleared by admin "+sender.getName())); baubles.setStackInSlot(a, ItemStack.EMPTY);