Search in sources :

Example 1 with EntityTameable

use of net.minecraft.entity.passive.EntityTameable in project PneumaticCraft by MineMaarten.

the class HackableTameable method onHackFinished.

@Override
public void onHackFinished(Entity entity, EntityPlayer player) {
    EntityTameable tameable = (EntityTameable) entity;
    if (entity.worldObj.isRemote) {
        tameable.handleHealthUpdate((byte) 7);
    } else {
        tameable.setPathToEntity((PathEntity) null);
        tameable.setAttackTarget((EntityLivingBase) null);
        tameable.setHealth(20.0F);
        //setOwner
        tameable.func_152115_b(player.getUniqueID().toString());
        entity.worldObj.setEntityState(tameable, (byte) 7);
        tameable.setTamed(true);
    }
}
Also used : EntityTameable(net.minecraft.entity.passive.EntityTameable)

Example 2 with EntityTameable

use of net.minecraft.entity.passive.EntityTameable in project ArsMagica2 by Mithion.

the class EntityUtilities method makeSummon_PlayerFaction.

public static void makeSummon_PlayerFaction(EntityCreature entityliving, EntityPlayer player, boolean storeForRevert) {
    if (isAIEnabled(entityliving) && !(entityliving instanceof IBossDisplayData) && ExtendedProperties.For(player).getCanHaveMoreSummons()) {
        if (storeForRevert)
            storedTasks.put(entityliving.getEntityId(), new ArrayList(entityliving.targetTasks.taskEntries));
        boolean addMeleeAttack = false;
        ArrayList<EntityAITaskEntry> toRemove = new ArrayList<EntityAITaskEntry>();
        for (Object task : entityliving.tasks.taskEntries) {
            EntityAITaskEntry base = (EntityAITaskEntry) task;
            if (base.action instanceof EntityAIAttackOnCollide) {
                toRemove.add(base);
                addMeleeAttack = true;
            }
        }
        entityliving.tasks.taskEntries.removeAll(toRemove);
        if (storeForRevert)
            storedAITasks.put(entityliving.getEntityId(), toRemove);
        if (addMeleeAttack) {
            float speed = entityliving.getAIMoveSpeed();
            if (speed <= 0)
                speed = 1.0f;
            entityliving.tasks.addTask(3, new EntityAIAttackOnCollide(entityliving, EntityMob.class, speed, true));
            entityliving.tasks.addTask(3, new EntityAIAttackOnCollide(entityliving, IMob.class, speed, true));
            entityliving.tasks.addTask(3, new EntityAIAttackOnCollide(entityliving, EntitySlime.class, speed, true));
        }
        entityliving.targetTasks.taskEntries.clear();
        entityliving.targetTasks.addTask(1, new EntityAIHurtByTarget(entityliving, true));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntityMob.class, 0, true, false, SummonEntitySelector.instance));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntitySlime.class, 0, true));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntityGhast.class, 0, true));
        if (!entityliving.worldObj.isRemote && entityliving.getAttackTarget() != null && entityliving.getAttackTarget() instanceof EntityPlayer)
            AMCore.proxy.addDeferredTargetSet(entityliving, null);
        if (entityliving instanceof EntityTameable) {
            ((EntityTameable) entityliving).setTamed(true);
            ((EntityTameable) entityliving).func_152115_b(player.getCommandSenderName());
        }
        entityliving.getEntityData().setBoolean(isSummonKey, true);
        ExtendedProperties.For(player).addSummon(entityliving);
    }
}
Also used : EntitySlime(net.minecraft.entity.monster.EntitySlime) ArrayList(java.util.ArrayList) EntityGhast(net.minecraft.entity.monster.EntityGhast) EntityAIHurtByTarget(net.minecraft.entity.ai.EntityAIHurtByTarget) EntityAINearestAttackableTarget(net.minecraft.entity.ai.EntityAINearestAttackableTarget) EntityMob(net.minecraft.entity.monster.EntityMob) EntityAIAttackOnCollide(net.minecraft.entity.ai.EntityAIAttackOnCollide) IMob(net.minecraft.entity.monster.IMob) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAITaskEntry(net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry) EntityTameable(net.minecraft.entity.passive.EntityTameable)

Example 3 with EntityTameable

use of net.minecraft.entity.passive.EntityTameable in project Railcraft by Railcraft.

the class TileChestRailcraft method isCatOnChest.

private boolean isCatOnChest() {
    AxisAlignedBB searchBox = AABBFactory.start().createBoxForTileAt(getPos()).offset(0.0, 1.0, 0.0).build();
    List<EntityOcelot> cats = worldObj.getEntitiesWithinAABB(EntityOcelot.class, searchBox);
    return cats.stream().anyMatch(EntityTameable::isSitting);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EntityOcelot(net.minecraft.entity.passive.EntityOcelot) EntityTameable(net.minecraft.entity.passive.EntityTameable)

Example 4 with EntityTameable

use of net.minecraft.entity.passive.EntityTameable in project ArsMagica2 by Mithion.

the class EntityUtilities method revertAI.

public static boolean revertAI(EntityCreature entityliving) {
    int ownerID = getOwner(entityliving);
    Entity owner = entityliving.worldObj.getEntityByID(ownerID);
    if (owner != null && owner instanceof EntityLivingBase) {
        ExtendedProperties.For((EntityLivingBase) owner).removeSummon();
        if (ExtendedProperties.For((EntityLivingBase) owner).isManaLinkedTo(entityliving)) {
            ExtendedProperties.For((EntityLivingBase) owner).updateManaLink(entityliving);
            ExtendedProperties.For((EntityLivingBase) owner).forceSync();
        }
    }
    entityliving.getEntityData().setBoolean(isSummonKey, false);
    setOwner(entityliving, null);
    if (storedTasks.containsKey(entityliving.getEntityId())) {
        entityliving.targetTasks.taskEntries.clear();
        entityliving.targetTasks.taskEntries.addAll(storedTasks.get(entityliving.getEntityId()));
        storedTasks.remove(entityliving.getEntityId());
        if (storedAITasks.get(entityliving.getEntityId()) != null) {
            ArrayList<EntityAITaskEntry> toRemove = new ArrayList<EntityAITaskEntry>();
            for (Object task : entityliving.tasks.taskEntries) {
                EntityAITaskEntry base = (EntityAITaskEntry) task;
                if (base.action instanceof EntityAIAttackOnCollide || base.action instanceof EntityAISummonFollowOwner) {
                    toRemove.add(base);
                }
            }
            entityliving.tasks.taskEntries.removeAll(toRemove);
            entityliving.tasks.taskEntries.addAll(storedAITasks.get(entityliving.getEntityId()));
            storedAITasks.remove(entityliving.getEntityId());
        }
        if (!entityliving.worldObj.isRemote && entityliving.getAttackTarget() != null)
            AMCore.proxy.addDeferredTargetSet(entityliving, null);
        if (entityliving instanceof EntityTameable) {
            ((EntityTameable) entityliving).setTamed(false);
        }
        return true;
    }
    return false;
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityAIAttackOnCollide(net.minecraft.entity.ai.EntityAIAttackOnCollide) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ArrayList(java.util.ArrayList) EntityAISummonFollowOwner(am2.entities.ai.EntityAISummonFollowOwner) EntityAITaskEntry(net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry) EntityTameable(net.minecraft.entity.passive.EntityTameable)

Example 5 with EntityTameable

use of net.minecraft.entity.passive.EntityTameable in project Railcraft by Railcraft.

the class TamingInteractHandler method interact.

//TODO: test
@SubscribeEvent
public void interact(PlayerInteractEvent.EntityInteract event) {
    Entity entity = event.getTarget();
    if (entity instanceof EntityTameable) {
        EntityTameable tamable = (EntityTameable) entity;
        UUID ownerId = tamable.getOwnerId();
        if (tamable.isTamed() && ownerId == null) {
            if (rand.nextInt(3) == 0) {
                tamable.setOwnerId(event.getEntityPlayer().getUniqueID());
                playTameEffect(tamable, true);
                tamable.getAISit().setSitting(true);
                tamable.worldObj.setEntityState(tamable, (byte) 7);
            } else {
                playTameEffect(tamable, false);
                tamable.worldObj.setEntityState(tamable, (byte) 6);
            }
            event.setCanceled(true);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) UUID(java.util.UUID) EntityTameable(net.minecraft.entity.passive.EntityTameable) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

EntityTameable (net.minecraft.entity.passive.EntityTameable)5 ArrayList (java.util.ArrayList)2 Entity (net.minecraft.entity.Entity)2 EntityAIAttackOnCollide (net.minecraft.entity.ai.EntityAIAttackOnCollide)2 EntityAITaskEntry (net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)2 EntityAISummonFollowOwner (am2.entities.ai.EntityAISummonFollowOwner)1 UUID (java.util.UUID)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityAIHurtByTarget (net.minecraft.entity.ai.EntityAIHurtByTarget)1 EntityAINearestAttackableTarget (net.minecraft.entity.ai.EntityAINearestAttackableTarget)1 IBossDisplayData (net.minecraft.entity.boss.IBossDisplayData)1 EntityGhast (net.minecraft.entity.monster.EntityGhast)1 EntityMob (net.minecraft.entity.monster.EntityMob)1 EntitySlime (net.minecraft.entity.monster.EntitySlime)1 IMob (net.minecraft.entity.monster.IMob)1 EntityOcelot (net.minecraft.entity.passive.EntityOcelot)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1