SHARE
TWEET

Untitled

a guest Aug 26th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.mewna.mc.box.components.mobstacking
  2.  
  3. import com.mewna.mc.box.framework.di.Auto
  4. import org.bukkit.entity.LivingEntity
  5. import org.bukkit.event.{EventHandler, Listener}
  6. import org.bukkit.event.entity.EntityDropItemEvent
  7.  
  8. /**
  9.  * @author broman
  10.  * @since 8/14/19.
  11.  */
  12. class MobHarvestListener extends Listener {
  13.   //noinspection VarCouldBeVal
  14.   @Auto
  15.   private var component: ComponentMobStacking = _
  16.   @EventHandler
  17.   def onMobHarvest(event: EntityDropItemEvent): Unit = {
  18.     val entity = event.getEntity
  19.     if(event.getEntity.isInstanceOf[LivingEntity]) {
  20.       val le = event.getEntity.asInstanceOf[LivingEntity]
  21.       if (component.isStackable(entity)) {
  22.         val item = event.getItemDrop
  23.         val count = component.count(le)
  24.         for(_ <- 0 until count) {
  25.           entity.getWorld.dropItem(item.getLocation, item.getItemStack)
  26.         }
  27.       }
  28.     }
  29.   }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top