本文整理汇总了Java中org.bukkit.event.entity.ItemSpawnEvent.getEntityType方法的典型用法代码示例。如果您正苦于以下问题:Java ItemSpawnEvent.getEntityType方法的具体用法?Java ItemSpawnEvent.getEntityType怎么用?Java ItemSpawnEvent.getEntityType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.ItemSpawnEvent
的用法示例。
在下文中一共展示了ItemSpawnEvent.getEntityType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Add ore to chest on drop
*
* @param event Item spawn event instance
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM
|| Meta.hasMeta(event.getEntity().getItemStack())
|| event.getEntity().hasMetadata("playerDrop"))
return;
for (int i = 0; i < MATERIALS.length; i++)
{
ItemStack stack = event.getEntity().getItemStack();
if (MATERIALS[i] != stack.getType())
continue;
ItemStack newStack = stack.clone();
this.inventory.addItem(Meta.addMeta(newStack));
event.getEntity().setItemStack(Meta.addMeta(event.getEntity().getItemStack()));
}
}
示例2: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Delete different type of certains blocks
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
if (event.getEntity().hasMetadata("playerDrop"))
return;
Material material = event.getEntity().getItemStack().getType();
if (material == Material.LOG || material == Material.LOG_2)
event.getEntity().setItemStack(new ItemStack(Material.LOG, event.getEntity().getItemStack().getAmount()));
else if (material == Material.COBBLESTONE)
event.getEntity().setItemStack(new ItemStack(Material.COBBLESTONE, event.getEntity().getItemStack().getAmount()));
else if (material == Material.STONE)
event.getEntity().setItemStack(new ItemStack(Material.COBBLESTONE, event.getEntity().getItemStack().getAmount()));
}
示例3: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Soup dropping
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
if (event.getEntity().hasMetadata("playerDrop"))
return;
Material material = event.getEntity().getItemStack().getType();
if (material == Material.BROWN_MUSHROOM || material == Material.RED_MUSHROOM)
event.getEntity().setItemStack(new ItemStack(Material.MUSHROOM_SOUP, 2));
else if (material == Material.POTATO_ITEM)
event.getEntity().setItemStack(new ItemStack(Material.BAKED_POTATO, 1));
else if (material == Material.CARROT_ITEM)
event.getEntity().setItemStack(new ItemStack(Material.GOLDEN_CARROT, 1));
else if (material == Material.WHEAT)
event.getEntity().setItemStack(new ItemStack(Material.BREAD, 1));
else if (material == Material.PUMPKIN)
event.getEntity().setItemStack(new ItemStack(Material.PUMPKIN_PIE, 1));
}
示例4: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Double ore's drop
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
if(Meta.hasMeta(event.getEntity().getItemStack()))
return;
ItemStack stack = event.getEntity().getItemStack();
if (this.drops.containsKey(stack))
{
ItemStack newStack = this.drops.get(stack).getDrop(stack, this.random);
if (newStack != null)
{
event.getEntity().setItemStack(Meta.addMeta(newStack));
this.spawnXP(event.getEntity(), this.drops.get(stack).getExperienceModifier(this.random));
}
}
}
示例5: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Chance to drop a diamond when a player breaks a flower
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
if (event.getEntity().hasMetadata("playerDrop"))
return;
if (event.getEntity().getItemStack().getType() != Material.YELLOW_FLOWER
&& event.getEntity().getItemStack().getType() != Material.RED_ROSE
&& (event.getEntity().getItemStack().getType() != Material.DOUBLE_PLANT
|| (event.getEntity().getItemStack().getDurability() > 1 && event.getEntity().getItemStack().getDurability() < 4)))
return;
if (this.random.nextDouble() <= (double) this.moduleConfiguration.get("chance"))
event.getEntity().getWorld().dropItemNaturally(event.getLocation(), Meta.addMeta(new ItemStack(Material.DIAMOND, (int) this.moduleConfiguration.get("diamonds"))));
event.setCancelled(true);
}
示例6: onGhastTearSlimeBlock
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
@EventHandler
public void onGhastTearSlimeBlock(ItemSpawnEvent e)
{
if(e.getEntityType() == EntityType.DROPPED_ITEM)
{
Item i = (Item)e.getEntity();
switch(i.getItemStack().getType())
{
case GHAST_TEAR:
Bukkit.getScheduler().runTaskLater(Survival.instance, initRunnable(i), 20);
break;
default:
}
}
}
示例7: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Drop some utilities
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
if (Meta.hasMeta(event.getEntity().getItemStack()))
return;
ItemStack stack = event.getEntity().getItemStack();
for (ItemStack drop : this.drops.keySet())
{
if (drop.getType() == stack.getType())
{
if (drop.getDurability() == -1 || (drop.getDurability() == stack.getDurability()))
{
ItemStack finalDrop = this.drops.get(drop).getDrop(stack, this.random);
if (finalDrop == null)
event.setCancelled(true);
else
event.getEntity().setItemStack(finalDrop);
break;
}
}
}
}
示例8: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Remove barrier on drop
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
if (event.getEntity().getItemStack().getType() == Material.BARRIER)
event.setCancelled(true);
}
示例9: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Replace world's drop by custom ones
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
if (Meta.hasMeta(event.getEntity().getItemStack()))
return;
if (!this.drops.containsKey(event.getEntity().getItemStack().getType()))
return;
event.getEntity().setItemStack(Meta.addMeta(this.drops.get(event.getEntity().getItemStack().getType())));
}
示例10: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Replace coal by torch
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
if (event.getEntity().hasMetadata("playerDrop"))
return;
if (event.getEntity().getItemStack().getType() == Material.COAL)
event.getEntity().setItemStack(new ItemStack(Material.TORCH, (int) this.moduleConfiguration.get("torch")));
}
示例11: onItemSpawn
import org.bukkit.event.entity.ItemSpawnEvent; //导入方法依赖的package包/类
/**
* Concentrate stacks
*
* @param event Event
*/
@EventHandler
public void onItemSpawn(ItemSpawnEvent event)
{
if (event.getEntityType() != EntityType.DROPPED_ITEM)
return;
Item newEntity = event.getEntity();
List<Entity> entityList = newEntity.getNearbyEntities(this.radius, 1, this.radius);
int maxSize = newEntity.getItemStack().getMaxStackSize();
for (Entity anEntityList : entityList)
{
if (anEntityList instanceof Item)
{
Item curEntity = (Item) anEntityList;
if (!curEntity.isDead()
&& curEntity.getItemStack().getType().equals(newEntity.getItemStack().getType())
&& curEntity.getItemStack().getData().getData() == newEntity.getItemStack().getData().getData()
&& curEntity.getItemStack().getDurability() == newEntity.getItemStack().getDurability()
&& Math.abs(curEntity.getLocation().getX() - newEntity.getLocation().getX()) <= this.radius
&& Math.abs(curEntity.getLocation().getY() - newEntity.getLocation().getY()) <= this.radius
&& Math.abs(curEntity.getLocation().getZ() - newEntity.getLocation().getZ()) <= this.radius)
{
int newAmount = newEntity.getItemStack().getAmount();
int curAmount = curEntity.getItemStack().getAmount();
int more = Math.min(newAmount, maxSize - curAmount);
curAmount += more;
newAmount -= more;
curEntity.getItemStack().setAmount(curAmount);
newEntity.getItemStack().setAmount(newAmount);
if (newAmount <= 0)
event.setCancelled(true);
return;
}
}
}
}