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


Java EntityHorse.isTame方法代码示例

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


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

示例1: makeHorsesFollowOwner

import net.minecraft.entity.passive.EntityHorse; //导入方法依赖的package包/类
@SubscribeEvent
public void makeHorsesFollowOwner(EntityJoinWorldEvent event)
{
    if(!ConfigHandler.BACKPACK_ABILITIES)return;
    if(event.entity instanceof EntityHorse)
    {

        EntityHorse horse = ((EntityHorse)event.entity);
        if(!horse.isDead && horse.isTame() && horse.hasCustomNameTag())
        {
            String ownerUUIDstring = horse.func_152119_ch();
            if (ownerUUIDstring != null && !ownerUUIDstring.isEmpty())
            {
                boolean set = true;
                if(horse.worldObj.func_152378_a(UUID.fromString(ownerUUIDstring)) != null)
                {
                    for (Object entry : horse.tasks.taskEntries)
                    {
                        if (((EntityAITasks.EntityAITaskEntry) entry).action instanceof EntityAIHorseFollowOwner)
                        {
                        	set = false;
                        }
                    }
                }
                if(set)
                {
                	horse.tasks.addTask(4, new EntityAIHorseFollowOwner(horse, 1.5d, 2.0f, 20.0f));
                	
                	if (horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange) != null)
                	{
                		horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange).setBaseValue(100.0D);
                	}
                }
        	}
        }
    }
}
 
开发者ID:Darkona,项目名称:AdventureBackpack2,代码行数:38,代码来源:GeneralEventHandler.java

示例2: interactWithCreatures

import net.minecraft.entity.passive.EntityHorse; //导入方法依赖的package包/类
@SubscribeEvent
public void interactWithCreatures(EntityInteractEvent event)
{
    EntityPlayer player = event.entityPlayer;
    if (!event.entityPlayer.worldObj.isRemote)
    {
        if (Utils.notNullAndInstanceOf(event.target, EntitySpider.class))
        {
            if (Wearing.isWearingTheRightBackpack(player, "Spider"))
            {
                EntityFriendlySpider pet = new EntityFriendlySpider(event.target.worldObj);
                pet.setLocationAndAngles(event.target.posX, event.target.posY, event.target.posZ, event.target.rotationYaw, event.target.rotationPitch);
                event.target.setDead();
                event.entityPlayer.worldObj.spawnEntityInWorld(pet);
                event.entityPlayer.mountEntity(pet);
            }
        }
        if (Utils.notNullAndInstanceOf(event.target, EntityHorse.class))
        {
            ItemStack stack = player.getCurrentEquippedItem();
            EntityHorse horse = (EntityHorse) event.target;
            if (stack != null && stack.getItem() != null && stack.getItem() instanceof ItemNameTag && stack.hasDisplayName())
            {
                if (horse.getCustomNameTag() == null || horse.getCustomNameTag().equals("") && horse.isTame())
                {
                    horse.setTamedBy(player);
                    horse.tasks.addTask(4, new EntityAIHorseFollowOwner(horse, 1.5d, 2.0f, 20.0f));

                    if (horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange) != null)
                    {
                        horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange).setBaseValue(100.0D);
                        LogHelper.info("The horse follow range is now: " + horse.getEntityAttribute(SharedMonsterAttributes.followRange).getBaseValue());
                    }
                }
            }
        }
    }
    event.setResult(Event.Result.ALLOW);
}
 
开发者ID:Darkona,项目名称:AdventureBackpack2,代码行数:40,代码来源:PlayerEventHandler.java

示例3: process

import net.minecraft.entity.passive.EntityHorse; //导入方法依赖的package包/类
@Override
public void process(List<String> list, Entity entity) {
	if (entity instanceof EntityHorse) {
		EntityHorse horse = (EntityHorse) entity;
		list.add(StatCollector.translateToLocal("smartcursor.mob.jumpStrength") + String.format("%.3f", Utils.round(horse.getHorseJumpStrength(), 4)));
		list.add(StatCollector.translateToLocal("smartcursor.mob.horseSpeed") + String.format("%.3f", Utils.round(horse.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(), 4)));
		if (horse.isTame()) list.add(StatCollector.translateToLocal("smartcursor.mob.tamed"));
		else list.add(StatCollector.translateToLocal("smartcursor.mob.notTamed"));
	}
}
 
开发者ID:asaskevich,项目名称:SmartCursor,代码行数:11,代码来源:EntityHorseModule.java

示例4: setHorseRidden

import net.minecraft.entity.passive.EntityHorse; //导入方法依赖的package包/类
/**
 * Sets the horse as this player's last horse ridden, for Epona's Song
 */
public void setHorseRidden(EntityHorse horse) {
	if (horse.getEntityId() == horseId) {
		setHorseCoordinates(horse);
	} else if (horse.isTame() && horse.getOwnerId().equals(player.getUniqueID().toString())) {
		this.horseId = horse.getEntityId();
		this.horseUUID = horse.getPersistentID();
		setHorseCoordinates(horse);
	}
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:13,代码来源:ZSSPlayerSongs.java

示例5: performEffect

import net.minecraft.entity.passive.EntityHorse; //导入方法依赖的package包/类
@Override
protected void performEffect(EntityPlayer player, ItemStack instrument, int power) {
	List<EntityHorse> horses = player.worldObj.getEntitiesWithinAABB(EntityHorse.class, player.getEntityBoundingBox().expand(8.0D, 4.0D, 8.0D));
	for (EntityHorse horse : horses) {
		if (!horse.isTame()) {
			horse.setTamedBy(player);
			// 18 is flag for heart particles
			player.worldObj.setEntityState(horse, (byte) 18);
		}
	}
	ZSSPlayerSongs songs = ZSSPlayerSongs.get(player);
	// Check for cows for Lon Lon Milk (Fairy Ocarina can be used if you don't want to summon Epona)
	List<EntityCow> cows = player.worldObj.getEntitiesWithinAABB(EntityCow.class, player.getEntityBoundingBox().expand(8.0D, 4.0D, 8.0D));
	for (EntityCow cow : cows) {
		songs.addLonLonCow(cow);
	}
	if (power < 5) {
		return; // only maximum power instruments can teleport Epona
	}
	int x = MathHelper.floor_double(player.posX);
	int y = MathHelper.floor_double(player.getEntityBoundingBox().maxY);
	int z = MathHelper.floor_double(player.posZ);
	if (!player.worldObj.provider.isSurfaceWorld()) {
		PlayerUtils.sendTranslatedChat(player, "chat.zss.song.epona.dimension");
	} else if (!player.worldObj.canBlockSeeSky(new BlockPos(x, y, z))) {
		PlayerUtils.sendTranslatedChat(player, "chat.zss.song.epona.sky");
	} else {
		EntityHorse epona = songs.getLastHorseRidden();
		if (epona == null) {
			PlayerUtils.sendTranslatedChat(player, "chat.zss.song.epona.missing");
		} else {
			// TODO check for clear space where horse should spawn?
			if (epona.riddenByEntity != null) {
				epona.riddenByEntity.mountEntity(null);
			}
			if (epona.getLeashed()) {
				epona.clearLeashed(true, true);
			}
			Vec3 vec3 = player.getLookVec();
			epona.setPosition(player.posX + (vec3.xCoord * 2.0D), player.posY + 1, player.posZ + (vec3.zCoord * 2.0D));
			S18PacketEntityTeleport packet = new S18PacketEntityTeleport(epona);
			PacketDispatcher.sendTo(packet, player); // send to ocarina player first, maybe it will be faster 
			PacketDispatcher.sendToPlayersExcept(packet, player, ((WorldServer) player.worldObj).getEntityTracker().getTrackingPlayers(epona));
			epona.makeHorseRearWithSound();
			songs.setHorseRidden(epona); // sets last chunk coordinates in case player doesn't mount
		}
	}
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:49,代码来源:ZeldaSongEpona.java


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