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


Java ItemExpireEvent类代码示例

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


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

示例1: itemExpire

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入依赖的package包/类
@SubscribeEvent
public void itemExpire(ItemExpireEvent event) {
	ItemStack stack=event.getEntityItem().getItem();
	String thrower=event.getEntityItem().getThrower();
	if(stack.getItem() instanceof ItemFromData && thrower!=null){
		//System.out.println("put");
		HashMap<String,MerchantRecipeList> map=event.getEntityItem().world.getCapability(TF2weapons.WORLD_CAP, null).lostItems;
		if(!map.containsKey(thrower))
			map.put(thrower, new MerchantRecipeList());
		int cost = ItemFromData.getData(stack).getInt(PropertyType.COST)/3;
		ItemStack ingot = new ItemStack(TF2weapons.itemTF2, cost / 9, 2);
		ItemStack nugget = new ItemStack(TF2weapons.itemTF2, cost % 9, 6);
		map.get(thrower).add(new MerchantRecipe(ingot.getCount() > 0 ? ingot : nugget,
				nugget.getCount() > 0 && ingot.getCount() > 0 ? nugget : null, stack, 0, 1));
		
		//ItemHandlerHelper.insertItemStacked(map.get(thrower), stack, false);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:19,代码来源:TF2EventsCommon.java

示例2: 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

示例3: 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

示例4: onItemExpire

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入依赖的package包/类
@SuppressWarnings({ "NumericCastThatLosesPrecision", "MethodMayBeStatic" })
@SubscribeEvent
public void onItemExpire(ItemExpireEvent event)
{
    if (Settings.INSTANCE.doPlantGrowable())
    {
        final Item item = event.entityItem.getEntityItem().getItem();
        final Block block = Block.getBlockFromItem(item);

        if (block instanceof IGrowable)
        {
            final World world = event.entityItem.worldObj;
            final int x = (int) event.entityItem.posX;
            final int y = (int) event.entityItem.posY;
            final int z = (int) event.entityItem.posZ;
            final int metadata = event.entityItem.getEntityItem().getItemDamage();

            plantGrowable(world, x, y, z, block, metadata);
        }
    }
}
 
开发者ID:MinecraftModArchive,项目名称:ScottsTweaks,代码行数:22,代码来源:Planter.java

示例5: 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

示例6: onItemExpire

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入依赖的package包/类
public static int onItemExpire(EntityItem entity, ItemStack item)
{
    if (item == null) return -1;
    ItemExpireEvent event = new ItemExpireEvent(entity, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, entity.worldObj)));
    if (!MinecraftForge.EVENT_BUS.post(event)) return -1;
    return event.getExtraLife();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:ForgeEventFactory.java

示例7: 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

示例8: 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

示例9: onItemExpireEvent

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入依赖的package包/类
@SubscribeEvent
public void onItemExpireEvent(ItemExpireEvent event) {
  if (saplingDespawnGrow) {
    EntityItem entityItem = event.getEntityItem();
    BlockPos pos = entityItem.getPosition();
    Entity entity = event.getEntity();
    ItemStack is = entityItem.getItem();
    World world = entity.getEntityWorld();
    if (is.isEmpty()) {
      return;
    }
    // plant the sapling, replacing the air and on top of dirt/plantable
    if (Block.getBlockFromItem(is.getItem()) == Blocks.RED_MUSHROOM)
      world.setBlockState(entityItem.getPosition(), Blocks.RED_MUSHROOM.getDefaultState());
    else if (Block.getBlockFromItem(is.getItem()) == Blocks.BROWN_MUSHROOM)
      world.setBlockState(entityItem.getPosition(), Blocks.BROWN_MUSHROOM.getDefaultState());
    else if (UtilOreDictionary.doesMatchOreDict(is, "treeSapling")) {
      Block saplingBlock = Block.getBlockFromItem(is.getItem());
      boolean success = false;
      if (saplingBlock != Blocks.AIR
          && saplingBlock.canPlaceBlockAt(world, pos)) {
        success = world.setBlockState(pos, UtilItemStack.getStateFromMeta(Block.getBlockFromItem(is.getItem()), is.getItemDamage()));
      }
      //only do the fake player strategy if the normal one fails
      if (success == false && world instanceof WorldServer) {
        if (fakePlayer == null) {
          fakePlayer = UtilFakePlayer.initFakePlayer(((WorldServer) world), UUID.randomUUID(), "sapling_regrowth");
          if (fakePlayer == null) {
            ModCyclic.logger.error("Fake player failed to init ");
            return;
          }
        }
        fakePlayer.get().setHeldItem(EnumHand.MAIN_HAND, is);
        fakePlayer.get().interactionManager.processRightClickBlock(fakePlayer.get(), world, is, EnumHand.MAIN_HAND, pos, EnumFacing.DOWN, .5F, .5F, .5F);
        //          IBlockState toPlace =   saplingBlock.getStateForPlacement(world, pos, EnumFacing.DOWN, .5F, .5F, .5F, is.getItemDamage(), fakePlayer.get() );
      }
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:40,代码来源:EnvironmentTweaksModule.java

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: blockItemExpired

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入依赖的package包/类
@ForgeSubscribe
public void blockItemExpired(ItemExpireEvent event) {
	EntityItem eitem = event.entityItem;
	World world = eitem.worldObj;
	// See if this item corresponds to a block item that we are supposed to
	// handle
	BlockItemSetting bbis = lookupSetting(eitem.getEntityItem().itemID);
	if (bbis == null) return;

	int x = (int) Math.round(eitem.posX - 0.5);
	int y = (int) (eitem.posY + 0.0); // was + 0.5
	int z = (int) Math.round(eitem.posZ - 0.5);
	int num = eitem.getEntityItem().stackSize;
	// Find closest empty air block in a pyramid surrounding the
	// expiration point
	for (int radius1 = 0; num > 0 && radius1 < 4; radius1++)
		for (int dy = 0; num > 0 && dy <= 2 * radius1; dy++) {
			int radius2 = (int) (radius1 - Math.round(dy * 0.4));
			// TODO - repeating this inner loop is redundant for the
			// interiors...
			for (int dx = -radius2; num > 0 && dx <= radius2; dx++)
				for (int dz = -radius2; num > 0 && dz <= radius2; dz++)
					if (world.isAirBlock(x + dx, y + dy, z + dz)) {
						if (bbis.metaData != -1)
							world.setBlockAndMetadataWithNotify(x + dx, y
									+ dy, z + dz,
									eitem.getEntityItem().itemID,
									bbis.metaData);
						else
							world.setBlockAndMetadataWithNotify(x + dx, y + dy,
									z + dz, eitem.getEntityItem().itemID, eitem.getEntityItem().getItemDamage());

						num--;
					}
		}

}
 
开发者ID:mbrx,项目名称:PilesOfBlocks,代码行数:38,代码来源:EventListener.java

示例15: onItemExpire

import net.minecraftforge.event.entity.item.ItemExpireEvent; //导入依赖的package包/类
@SubscribeEvent
public void onItemExpire(ItemExpireEvent event) {
	tossedSticks.remove(event.entityItem);
}
 
开发者ID:Hunternif,项目名称:MosesMod,代码行数:5,代码来源:ItemWatcher.java


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