当前位置: 首页>>代码示例>>Java>>正文


Java EntityType.DROPPED_ITEM属性代码示例

本文整理汇总了Java中org.bukkit.entity.EntityType.DROPPED_ITEM属性的典型用法代码示例。如果您正苦于以下问题:Java EntityType.DROPPED_ITEM属性的具体用法?Java EntityType.DROPPED_ITEM怎么用?Java EntityType.DROPPED_ITEM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.entity.EntityType的用法示例。


在下文中一共展示了EntityType.DROPPED_ITEM属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemDamage

@EventHandler
public void onItemDamage(EntityDamageEvent event) {
    if (event.getEntityType() == EntityType.DROPPED_ITEM && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        Vector v = Vector.getRandom().normalize();
        v = v.setX(v.getX() - 0.5f);
        v = v.setZ(v.getZ() - 0.5f);
        v = v.multiply(0.35);
        if (v.getX() > 0 && v.getX() < 0.10)
            v.setX(0.10);
        if (v.getZ() > 0 && v.getZ() < 0.10)
            v.setZ(0.10);
        if (v.getX() < 0 && v.getX() > -0.10)
            v.setX(-0.10);
        if (v.getZ() < 0 && v.getZ() > -0.10)
            v.setZ(-0.10);
        v.setY(0.3);
        event.getEntity().setVelocity(v);
        event.setCancelled(true);
        RScheduler.schedule(plugin, () -> {
            event.getEntity().setFireTicks(0);
        }, RTicks.seconds(1));
    }
    if (event.getEntityType() == EntityType.ARMOR_STAND && (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE_TICK || event.getCause() == DamageCause.FIRE)) {
        event.setCancelled(true);
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:26,代码来源:EnvironmentManager.java

示例2: PlaceCheckDoor

@EventHandler
 public void PlaceCheckDoor(BlockPlaceEvent e) {
     if(ConfigPatch.AntiInfSuagrenable){
if(e.isCancelled()){
	Player p = e.getPlayer();
             List<Entity> entities = p.getNearbyEntities(2, 2, 2);
             for(int i=0;i<entities.size();i++){
                 Entity ent = entities.get(i);
                 if(ent.getType() == EntityType.DROPPED_ITEM){
                     Item item = (Item)ent;
                     if(item.getItemStack().getType() == Material.SUGAR_CANE||item.getItemStack().getType() == Material.CACTUS){
                         ent.remove();
                     }
                 }
             }
}
     }
 }
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:18,代码来源:AntiInfSuagr.java

示例3: onItemSpawn

/**
 * 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()));
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:25,代码来源:RiskyRetrievalModule.java

示例4: onItemSpawn

/**
 * 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()));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:23,代码来源:RapidStackingModule.java

示例5: onItemSpawn

/**
 * 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));
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:27,代码来源:RapidOresModule.java

示例6: onItemSpawn

/**
 * 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);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:25,代码来源:DiamondFlowerModule.java

示例7: ChunkloadClear

@EventHandler
public void ChunkloadClear(ChunkUnloadEvent event) {
	if (ConfigOptimize.UnloadClearenable != true) {
		return;
	}
	Chunk chunk = event.getChunk();
	boolean noclearitemchunk = false;
	int dcs = DeathChunk.size();
	for (int i = 0; i < dcs; i++) {
		Chunk deathchunk = DeathChunk.get(i);
		if (Utils.isSameChunk(chunk, deathchunk)) {
			DeathChunk.remove(chunk);
			noclearitemchunk = true;
			break;
		}
	}
	Entity[] entities = chunk.getEntities();
	for (int i = 0; i < entities.length; i++) {
		Entity ent = entities[i];
		if (ent.getType() == EntityType.DROPPED_ITEM && noclearitemchunk == false && ConfigOptimize.UnloadClearDROPPED_ITEMenable) {
			ent.remove();
		}
		if(ConfigOptimize.UnloadCleartype.contains(ent.getType().name())||ConfigOptimize.UnloadCleartype.contains("*")) {
			ent.remove();
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:27,代码来源:UnloadClear.java

示例8: onEntityDamageEvent

@EventHandler
   public void onEntityDamageEvent(EntityDamageEvent e) {
	if (!(e.getEntity() instanceof ArmorStand) && e.getEntityType() != EntityType.ARMOR_STAND && e.getEntityType() != EntityType.DROPPED_ITEM) {
		Hologram h = new Hologram(ChatColor.RED + "-" + Double.toString(e.getDamage()) + " \u2764", e.getEntity().getLocation());
		h.getHologram().addScoreboardTag("dindicator");
		h.setKillTimer(2);
	}
	if (e.getEntity() instanceof Player) {
		Player player = (Player) e.getEntity();
		player.sendMessage(ChatColor.GRAY + "[DamageIndicator] " + e.getCause().name() + " did " + new DecimalFormat("#0.0").format(((double) Math.round(e.getDamage())) / 2) + ChatColor.RED + " \u2764");
	}
}
 
开发者ID:GigaGamma,项目名称:SuperiorCraft,代码行数:12,代码来源:DamageIndicator.java

示例9: onGhastTearSlimeBlock

@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:
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:15,代码来源:LivingSlime.java

示例10: onItemSpawn

/**
 * 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;
            }
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:34,代码来源:RapidUsefulModule.java

示例11: onItemSpawn

/**
 * 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);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:14,代码来源:NineSlotsModule.java

示例12: onItemSpawn

/**
 * 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())));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:19,代码来源:WorldDropModule.java

示例13: onItemSpawn

/**
 * 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")));
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:17,代码来源:TorchThanCoalModule.java

示例14: onSpawn

@EventHandler
public void onSpawn(EntitySpawnEvent event) {
    if (Skywars.getInstance().isSingleServerMode()) {
        if (event.getEntityType() != EntityType.PLAYER && event.getEntityType() != EntityType.DROPPED_ITEM && event.getEntityType() != EntityType.PRIMED_TNT) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:8,代码来源:EntitySpawn.java

示例15: getType

public EntityType getType() {
    return EntityType.DROPPED_ITEM;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:3,代码来源:CraftItem.java


注:本文中的org.bukkit.entity.EntityType.DROPPED_ITEM属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。