本文整理匯總了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);
}
示例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);
}
}
}
}
}
示例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
}
}
}
示例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));
}
}
}
示例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);
}
}
}
示例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(),
"");
}
示例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);
}
}
}
示例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);
}
}
示例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;
// }
}
示例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);
}
}
示例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;
}
示例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();
}
示例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;
}
});
}
示例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));
}
}
示例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());
}
}