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


Java ItemExpireEvent.setCanceled方法代码示例

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


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

示例1: itemExpire

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void itemExpire(ItemExpireEvent event){
	//TODO: Add items to inventory upon expire
	ItemStack item = event.entityItem.getEntityItem();
	if(item == null)
		return;
	if(isSoulbound(item) && MinecraftServer.getServer() != null){
		for(Object ply : MinecraftServer.getServer().getConfigurationManager().playerEntityList)
		{
			EntityPlayer player = (EntityPlayer) ply;
			if(getID(player).equalsIgnoreCase(getFidelisID(item)))
			{
				if(player.inventory.addItemStackToInventory(item))
					if(item.stackSize <= 0)
						item = null;
			}
		}
	}

	if(item != null)
		event.setCanceled(true);

}
 
开发者ID:UnderMybrella,项目名称:Fidelis,代码行数:24,代码来源:Fidelis.java

示例2: onItemExpired

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemExpired( ItemExpireEvent event )
{
	ItemStack stack = event.entityItem.getEntityItem();
	if ( !( stack.getItem() instanceof EquipmentItem ) )
	{
		return;
	}

	EquipmentItem item = ( EquipmentItem ) stack.getItem();
	int level = item.equipment.getModifierLevel( stack, "persistance" );
	if ( ( level & PersistanceModifier.TIME ) != 0 )
	{
		event.setCanceled( true );
		event.extraLife = 20 * 60 * 5; // 5 minutes
	}
}
 
开发者ID:spacechase0,项目名称:ComponentEquipment,代码行数:18,代码来源:PersistanceEventHandler.java

示例3: onEntityItemExpire

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityItemExpire(ItemExpireEvent parEvent)
{
	if (!REFORESTATION) return;
	if (!(Block.getBlockFromItem(parEvent.entityItem.getEntityItem().getItem()) instanceof BlockSapling)) return;

	BlockSapling sapling = (BlockSapling) Block.getBlockFromItem(parEvent.entityItem.getEntityItem().getItem());
	int x = (int) (parEvent.entity.posX);
	int y = (int) (parEvent.entity.posY + 0.5);
	int z = (int) (parEvent.entity.posZ);
	BlockPos pos = new BlockPos(x, y, z);

	if (sapling.canBlockStay(parEvent.entity.worldObj, pos, sapling.getDefaultState()))
	{
		parEvent.entity.worldObj.setBlockState(pos, sapling.getStateFromMeta(parEvent.entityItem.getEntityItem().getItemDamage()), 3);
	}
	else
	{
		parEvent.extraLife = parEvent.entityItem.lifespan - REFOREST_AGE;
		parEvent.setCanceled(true);
	}
}
 
开发者ID:andykuo1,项目名称:mcplus_mods,代码行数:23,代码来源:EventHandlerOvergrowth.java

示例4: handleDespawn

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void handleDespawn(ItemExpireEvent event){
	ItemStack stack = event.getEntityItem().getEntityItem();
	if(ItemStackTools.isValid(stack)){
		InventoryBackpackUpgrades upgrades = BackpackUtil.getUpgradeInventory(stack);
		if(upgrades !=null && upgrades.hasUpgrade(BackpackUpgrade.DESPAWN)){
			event.getEntityItem().setNoDespawn();
			event.setCanceled(true);
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:12,代码来源:EventHandler.java

示例5: itemDespawn

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入方法依赖的package包/类
/**
 * Handles:
 * - fuel on firepit despawn prevention
 */
@SubscribeEvent
public void itemDespawn(ItemExpireEvent event)
{
    EntityItem entity = event.entityItem;
    World world = entity.worldObj;
    if (!world.isRemote)
    {
        Item item = entity.getEntityItem().getItem();
        if (maxAge == 0) event.setCanceled(true);
        else if (entity.age < maxAge)
        {
            event.extraLife = maxAge - entity.age;
            event.setCanceled(true);
        }
        if (item == TFCItems.logs || item == Item.getItemFromBlock(TFCBlocks.peat))
        {
            if (world.getTileEntity(MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ)) instanceof TEFirepit)
            {
                if (fuelOnFireMaxAge == 0) event.setCanceled(true);
                else if (entity.age < fuelOnFireMaxAge)
                {
                    event.extraLife = fuelOnFireMaxAge - entity.age;
                    event.setCanceled(true);
                }
            }
        }
    }
}
 
开发者ID:dries007,项目名称:TFC-Tweaks,代码行数:33,代码来源:EventHandlers.java

示例6: despawn

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void despawn(ItemExpireEvent event) {
    if (event.entityItem.getEntityItem() != null) {
        if (event.entityItem.getEntityItem().getItem() instanceof ItemHorcrux) {
            if (event.entityItem.getEntityItem().hasTagCompound()) {
                if (event.entityItem.getEntityItem().stackTagCompound.hasKey("owner")) {
                    event.setCanceled(true);
                }
            }
        }
    }
}
 
开发者ID:MagiciansArtificeTeam,项目名称:Magicians-Artifice,代码行数:13,代码来源:ItemHorcrux.java

示例7: itemDespawn

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void itemDespawn(ItemExpireEvent event) {

	if (event.entityItem.getDataWatcher().getWatchableObjectItemStack(10).getItem() instanceof VoluciteNecklace) {
		VoluciteNecklace item = (VoluciteNecklace)(event.entityItem.getDataWatcher().getWatchableObjectItemStack(10).getItem());
		ItemStack stack = event.entityItem.getDataWatcher().getWatchableObjectItemStack(10);
		item.addPower(stack, 2);
		item.addCooldown(stack, -1);
		event.setCanceled(true);
		event.extraLife = 60;
	}

}
 
开发者ID:mookie1097,项目名称:NausicaaMod,代码行数:14,代码来源:NausicaaEventHandler.java

示例8: onItemDespawned

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onItemDespawned(ItemExpireEvent event)
{
	EventCancellable despawnEvent = new EventItemDespawned(event.entityItem);
	EventFactory.fireEvent(despawnEvent);
	
	if (despawnEvent.isCancelled())
	{
		//COUGH COUGH WRONG SPELLING OF CANCELLED COUGH COUGH #blamelex (Just kidding :P Not about the bad spelling, Cancelled is
		// spelt with two ls)
		//Also note that isCancelled is spelt correctly.
		event.setCanceled(true);
	}
}
 
开发者ID:Niadel,项目名称:N-API,代码行数:15,代码来源:EventHandlerForge.java

示例9: onItemExpire

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemExpire(ItemExpireEvent evt) {
	if (shouldPreventDespawn(evt.getEntityItem())) {
		evt.setExtraLife(evt.getExtraLife() + 0x12F58BF);
		evt.setCanceled(true);
	}
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:8,代码来源:LuggageDropHandler.java


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