當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityInteractEvent類代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.EntityInteractEvent的典型用法代碼示例。如果您正苦於以下問題:Java EntityInteractEvent類的具體用法?Java EntityInteractEvent怎麽用?Java EntityInteractEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityInteractEvent類屬於net.minecraftforge.event.entity.player包,在下文中一共展示了EntityInteractEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: interactEntityEvent

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
	ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
	if (stack == null)
		return;
	if (!(event.target instanceof EntityAnimal))
		return;

	EntityAnimal animal = (EntityAnimal) event.target;
	if (!animal.isChild()) {
		if (animal instanceof EntityPig) {
			if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
		} else if (animal instanceof EntityChicken)
			if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
	} else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
		feedBaby(animal, event.entityPlayer, stack);
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:20,代碼來源:ServerEventHandler.java

示例2: entityInteract

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = false)
public void entityInteract(final EntityInteractEvent event) {
	if(event.entityPlayer instanceof EntityPlayerMP && event.target instanceof EntityAnimal) {
		final EntityPlayerMP player = (EntityPlayerMP)event.entityPlayer;
		final ItemStack heldItem = player.getCurrentEquippedItem();
		if(heldItem != null) {
			final EntityAnimal animal = (EntityAnimal)event.target;
			if(canBreed(animal, player)) {
				final Set<ItemStackKey> possibleFood = foodItems.get(event.target.getClass());
				if(possibleFood != null && possibleFood.contains(ItemStackKey.getCachedKey(heldItem))) {
					if (!event.entityPlayer.capabilities.isCreativeMode) {
						heldItem.stackSize--;
						if (heldItem.stackSize <= 0)
							player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
					}
					animal.func_146082_f(player);
				}
			}
		}
	}
}
 
開發者ID:OreCruncher,項目名稱:ThermalRecycling,代碼行數:22,代碼來源:BreedingItemManager.java

示例3: onEntityInteractEvent

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityInteractEvent(EntityInteractEvent event){

	if(event.getEntity() instanceof EntityPlayer == false){
		return;
	}
	EntityPlayer entityPlayer = (EntityPlayer)event.getEntity();
	ItemStack held = entityPlayer.getHeldItemMainhand();

	if(held != null && held.getItem() instanceof ItemHorseFood){
		if(event.getTarget() instanceof EntityHorse){
			ItemHorseFood.onHorseInteract((EntityHorse) event.getTarget(), entityPlayer, held);

			event.setCanceled(true);// stop the GUI inventory opening
		}
	}
}
 
開發者ID:LothrazarMinecraftMods,項目名稱:HorseFood,代碼行數:18,代碼來源:ModHorseFood.java

示例4: onEntityInteraction

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityInteraction(EntityInteractEvent e)
{
    ItemStack stack = e.entityPlayer.getCurrentEquippedItem();
    if(stack != null)
    {
        if(stack.getItem() == ModCustomAI.rewriterItem)
        {
            e.setCanceled(true);
            CustomAIPlayerExtendedProperties props = (CustomAIPlayerExtendedProperties)e.entityPlayer.getExtendedProperties(ModCustomAI.MODID);
            if(props == null)
            {
                e.entityPlayer.registerExtendedProperties(ModCustomAI.MODID, new CustomAIPlayerExtendedProperties());
            }
            props.setEntityInteractingWith(e.target.getEntityId(), e.target.getClass());
            FMLNetworkHandler.openGui(e.entityPlayer, ModCustomAI.instance, 0, e.entityPlayer.worldObj, (int)Math.floor(e.entityPlayer.posX), (int)Math.floor(e.entityPlayer.posY), (int)Math.floor(e.entityPlayer.posZ));
        }
        else if(stack.getItem() == ModCustomAI.copierItem)
        {
            e.setCanceled(!((AICopierItem)stack.getItem()).onInteract(e.entityPlayer.worldObj, stack, e.entityPlayer, e.target));
        }
    }
}
 
開發者ID:jglrxavpok,項目名稱:CustomAI,代碼行數:24,代碼來源:EntityEvents.java

示例5: onInteractWithEntity

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void onInteractWithEntity(EntityInteractEvent event)
{
	if (event.entityPlayer != null)
	{
		int x = MathHelper.floor_double(event.target.posX);
		int y = MathHelper.floor_double(event.target.posY);
		int z = MathHelper.floor_double(event.target.posZ);
		
		TileEntity te = event.entity.worldObj.getTileEntity(x, y, z);
		if (te instanceof TileEntityCrate && ((TileEntityCrate) te).getContainedEntity() == event.target)
		{
			((TileEntityCrate) te).releaseEntity();
			event.setCanceled(true);
		}
	}
}
 
開發者ID:Ckathode,項目名稱:archimedes-ships,代碼行數:18,代碼來源:CommonHookContainer.java

示例6: onEntityInteract

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event){
	if (event.entityPlayer.worldObj.isRemote)
		return;

	if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.ENTITY_INTERACT, event.target.posX, event.target.posY, event.target.posZ))
		event.setCanceled(true);
	else
		GriefGuardian._dal.logAction(
				(EntityPlayerMP)event.entityPlayer, 
				Actions.ENTITY_INTERACT, 
				(int)Math.floor(event.entity.posX), 
				(int)Math.floor(event.entity.posY), 
				(int)Math.floor(event.entity.posZ), 
				event.entityPlayer.getCurrentEquippedItem(), 
				"");
}
 
開發者ID:Mithion,項目名稱:GriefGuardian,代碼行數:18,代碼來源:ClaimGuardEventHandler.java

示例7: handleMinecartPainting

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void handleMinecartPainting(EntityInteractEvent event) {
	if (event.entityPlayer.worldObj.isRemote) return;
	
	if (event.entityPlayer.isSneaking() && event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME) != null) {
		ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
		CartLivery livery = (CartLivery) event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME);
		int newColor = ColorUtils.getDyeColor(stack);	
		
		if (newColor != -1 && (!livery.pattern.isEmpty() || newColor != livery.baseColor)) {
			livery.baseColor = newColor;
			livery.pattern = "";
			stack.stackSize--;
			if (stack.stackSize == 0) event.entityPlayer.setCurrentItemOrArmor(0, null);
			
			CommonProxy.network.sendToAllAround(new LiveryUpdateMessage(event.target, livery), NetworkUtil.targetEntity(event.target));
			event.setCanceled(true);
		}
	}
}
 
開發者ID:octarine-noise,項目名稱:CartLivery,代碼行數:21,代碼來源:CommonProxy.java

示例8: handleMinecartStickerApply

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void handleMinecartStickerApply(EntityInteractEvent event) {
	if (event.entityPlayer.worldObj.isRemote) return;
	
	if (event.entityPlayer.isSneaking() && event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME) != null) {
		ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
		if (stack == null || !(stack.getItem() instanceof ItemSticker) || stack.getTagCompound() == null) return;
		
		String pattern = stack.getTagCompound().getString("pattern");
		int patternColor = stack.getTagCompound().getInteger("patternColor");
		if (pattern.isEmpty()) return;
		
		CartLivery livery = (CartLivery) event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME);
		if (!livery.pattern.isEmpty()) return;
		
		livery.pattern = pattern;
		livery.patternColor = patternColor;
		
		stack.stackSize--;
		if (stack.stackSize == 0) event.entityPlayer.setCurrentItemOrArmor(0, null);
		
		CommonProxy.network.sendToAllAround(new LiveryUpdateMessage(event.target, livery), NetworkUtil.targetEntity(event.target));
		event.setCanceled(true);
	}
}
 
開發者ID:octarine-noise,項目名稱:CartLivery,代碼行數:26,代碼來源:CommonProxy.java

示例9: onInteract

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void onInteract(EntityInteractEvent event)
{
    //		if(FMLCommonHandler.instance().getEffectiveSide().isServer() && event.target instanceof EntityLivingBase)
    //		{
    //			System.out.println(event.target);
    //			Morph.proxy.tickHandlerServer.trackingEntities.add();
    //		}
    //		if(FMLCommonHandler.instance().getEffectiveSide().isClient())
    //		{
    //			System.out.println("asdasdasdsad");
    //			if(event.target instanceof EntityLivingBase && !(event.target instanceof EntityMorphAcquisition))
    //			{
    //				event.entityPlayer.worldObj.spawnEntityInWorld(new EntityMorphAcquisition(event.entityPlayer.worldObj, (EntityLivingBase)event.target, event.entityPlayer));
    //			}
    //		}
    //		else
    //		{
    //			return;
    //		}
}
 
開發者ID:iChun,項目名稱:Morph,代碼行數:22,代碼來源:EventHandler.java

示例10: goldenLasso

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void goldenLasso(final EntityInteractEvent event) {
    final ItemStack itemstack = event.entityPlayer.getCurrentEquippedItem();
    if (itemstack != null && ExtraUtils.goldenLasso != null && itemstack.getItem() == ExtraUtils.goldenLasso && event.target instanceof EntityLivingBase && itemstack.interactWithEntity(event.entityPlayer, (EntityLivingBase)event.target)) {
        if (itemstack.stackSize <= 0) {
            event.entityPlayer.destroyCurrentEquippedItem();
        }
        event.setCanceled(true);
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:11,代碼來源:EventHandlerServer.java

示例11: interactWith

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
public boolean interactWith(Entity p_70998_1_)
{
	if (MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(this, p_70998_1_))) {
		return false;
	}
	ItemStack itemstack = getCurrentEquippedItem();
	ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null;
	if (!p_70998_1_.interactFirst(this))
	{
		if ((itemstack != null) && ((p_70998_1_ instanceof EntityLivingBase)))
		{
			if (this.capabilities.isCreativeMode) {
				itemstack = itemstack1;
			}
			if (itemstack.interactWithEntity(this, (EntityLivingBase)p_70998_1_))
			{
				if ((itemstack.stackSize <= 0) && (!this.capabilities.isCreativeMode)) {
					destroyCurrentEquippedItem();
				}
				return true;
			}
		}
		return false;
	}
	if ((itemstack != null) && (itemstack == getCurrentEquippedItem())) {
		if ((itemstack.stackSize <= 0) && (!this.capabilities.isCreativeMode)) {
			destroyCurrentEquippedItem();
		} else if ((itemstack.stackSize < itemstack1.stackSize) && (this.capabilities.isCreativeMode)) {
			itemstack.stackSize = itemstack1.stackSize;
		}
	}
	return true;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:34,代碼來源:EntityPlayer.java

示例12: doTheZorroThing

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void doTheZorroThing(EntityInteractEvent event) {
    EntityPlayer player = event.entityPlayer;
    if (player.worldObj.isRemote) return;
    if (player.isRiding()) return;
    if (!(event.target instanceof EntityHorse)) return;
    EntityHorse horse = (EntityHorse) event.target;
    if (player.fallDistance <= 2) return;
    if (!horse.isHorseSaddled()) return;
    if (horse.getLeashed()) {
        if (!(horse.getLeashedToEntity() instanceof EntityLeashKnot)) return;
        horse.getLeashedToEntity().interactFirst(player);
    }
    boolean awesome = false;
    if (player.fallDistance > 5 && player.getHeldItem() != null) {
        Item held = player.getHeldItem().getItem();
        boolean has_baby = false;
        if (player.riddenByEntity instanceof EntityAgeable) {
            EntityAgeable ea = (EntityAgeable) player.riddenByEntity;
            has_baby = ea.isChild();
        }
        awesome = held instanceof ItemSword || held instanceof ItemAxe || held instanceof ItemBow || player.riddenByEntity instanceof EntityPlayer || has_baby;
    }
    if (awesome) {
        horse.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20 * 40, 2, false, false));
        horse.addPotionEffect(new PotionEffect(Potion.resistance.id, 20 * 40, 1, true, true));
        horse.addPotionEffect(new PotionEffect(Potion.jump.id, 20 * 40, 1, true, true));
    } else {
        horse.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20 * 8, 1, false, false));
    }
    horse.playLivingSound();
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:33,代碼來源:MiscellaneousNonsense.java

示例13: buffedNametag

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public void buffedNametag(EntityInteractEvent event) {
    ItemStack is = event.entityPlayer.getHeldItem();
    if (is == null) return;
    if (is.getItem() != Items.name_tag) return;
    if (!(event.target instanceof EntityLiving)) return;
    final EntityLiving ent = (EntityLiving) event.target;
    final String origName = ent.getCustomNameTag();
    if (!Strings.isNullOrEmpty(origName)) return;
    NBTTagCompound tag = ent.getEntityData();
    final String name = "FZMiscBuffNametags";
    if (tag.hasKey(name)) return;
    tag.setBoolean(name, true);
    ent.tasks.addTask(0, new EntityAIBase() {
        boolean buffApplied = false; // Might not be necessary.
        
        @Override
        public boolean shouldExecute() {
            if (buffApplied) return false;
            buffApplied = true;
            if (ent.getCustomNameTag().equals(origName)) return false;
            float delta = 2*3;
            float origHealth = ent.getMaxHealth();
            float newMaxHealth = origHealth + delta;
            ent.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(newMaxHealth);
            ent.heal(delta);

            EnumParticleTypes particleType = EnumParticleTypes.HEART;
            if (ent instanceof IMob) {
                particleType = EnumParticleTypes.SMOKE_NORMAL;
            }
            if (ent.worldObj instanceof WorldServer) {
                WorldServer ws = (WorldServer) ent.worldObj;
                ws.spawnParticle(particleType, false, ent.posX, ent.posY, ent.posZ, 8, 0.0, 0.0, 0.0, 0.0);
            }
            return false;
        }
    });
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:40,代碼來源:BuffNametags.java

示例14: onInteract

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void onInteract(EntityInteractEvent e) {
	if (e.target instanceof EntityPlayer) {
		FMLClientHandler.instance().getClient().displayGuiScreen(new GuiMarriageProposal((EntityPlayer) e.target));
	}

}
 
開發者ID:ItsAMysterious,項目名稱:Real-Life-Mod-1.8,代碼行數:8,代碼來源:ClientHandler.java

示例15: playerInteract_Entity

import net.minecraftforge.event.entity.player.EntityInteractEvent; //導入依賴的package包/類
@SubscribeEvent
public void playerInteract_Entity(EntityInteractEvent event) {
	if (!this.canRun(event.entityPlayer)) {
		event.setCanceled(true);
	}
	else {
		RacePlayer.get(event.entityPlayer).applyEffectsForItem(
				event.entityPlayer.getHeldItem());
	}
}
 
開發者ID:TheTemportalist,項目名稱:RacesForMinecraft,代碼行數:11,代碼來源:EventHandler.java


注:本文中的net.minecraftforge.event.entity.player.EntityInteractEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。