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);
}
}
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);
}
}
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);
}
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;
}
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);
}
}
}
Aggregations