本文整理汇总了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);
}
示例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
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}
}
}
示例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);
}
}
}
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
}