use of net.minecraft.entity.passive.TameableEntity in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAITameAndLeashPet method canUse.
@Override
public boolean canUse() {
if (!this.entity.canTameEntity()) {
return false;
}
if ((!(this.entity.getHeldItemMainhand().getItem() instanceof LeadItem) && !(this.entity.getMainHandItem().getItem() instanceof LeadItem))) {
return false;
}
if (this.random.nextInt(10) == 0) {
Vector3d vec1 = this.entity.position().add(PET_SEARCH_RADIUS, PET_SEARCH_RADIUS * 0.5D, PET_SEARCH_RADIUS);
Vector3d vec2 = this.entity.position().subtract(PET_SEARCH_RADIUS, PET_SEARCH_RADIUS * 0.5D, PET_SEARCH_RADIUS);
AxisAlignedBB aabb = new AxisAlignedBB(vec1.x, vec1.y, vec1.z, vec2.x, vec2.y, vec2.z);
List<TameableEntity> possiblePets = this.entity.world.getEntitiesWithinAABB(TameableEntity.class, aabb, input -> TargetUtil.PREDICATE_PETS.apply(input) && this.entity.getSensing().canSee(input));
if (!possiblePets.isEmpty()) {
this.entityToTame = TargetUtil.getNearestEntity(this.entity, possiblePets);
return true;
}
}
return false;
}
use of net.minecraft.entity.passive.TameableEntity in project ChocolateQuestRepoured by TeamChocoQuest.
the class AbstractEntityCQR method spawnShoulderEntity.
private void spawnShoulderEntity(@Nullable CompoundNBT compound) {
if (!this.level.isClientSide && compound != null && !compound.isEmpty()) {
Entity entity = EntityList.createEntityFromNBT(compound, this.level);
if (entity instanceof TameableEntity) {
((TameableEntity) entity).setOwnerUUID(this.getUUID());
}
final Vector3d pos = this.position().add(0, 0.699999988079071D, 0);
entity.setPos(pos.x, pos.y, pos.z);
this.level.addFreshEntity(entity);
}
}
use of net.minecraft.entity.passive.TameableEntity in project ChaosAwakens by ChaosAwakens.
the class UltimateArrowEntity method onHitEntity.
@Override
protected void onHitEntity(EntityRayTraceResult result) {
Entity entity = result.getEntity();
if (entity instanceof PlayerEntity || (entity instanceof TameableEntity && ((TameableEntity) entity).isTame() && ((TameableEntity) entity).getOwner() == this.getOwner())) {
((LivingEntity) entity).heal(5.0F);
remove();
return;
}
super.onHitEntity(result);
}
use of net.minecraft.entity.passive.TameableEntity in project Client by MatHax.
the class EntityOwner method onRender2D.
@EventHandler
private void onRender2D(Render2DEvent event) {
for (Entity entity : mc.world.getEntities()) {
UUID ownerUuid;
if (entity instanceof TameableEntity)
ownerUuid = ((TameableEntity) entity).getOwnerUuid();
else if (entity instanceof HorseBaseEntity)
ownerUuid = ((HorseBaseEntity) entity).getOwnerUuid();
else if (entity instanceof ProjectileEntity && projectiles.get())
ownerUuid = ((ProjectileEntityAccessor) entity).getOwnerUuid();
else
continue;
if (ownerUuid != null) {
pos.set(entity, event.tickDelta);
pos.add(0, entity.getEyeHeight(entity.getPose()) + 0.75, 0);
if (NametagUtils.to2D(pos, scale.get())) {
renderNametag(getOwnerName(ownerUuid));
}
}
}
}
use of net.minecraft.entity.passive.TameableEntity in project LittleMaidReBirth-Fabric by SistrScarlet.
the class SyncIFFPacket method applyIFFServer.
private static void applyIFFServer(int id, CompoundTag tag, PlayerEntity player) {
Entity entity = player.world.getEntityById(id);
if (!(entity instanceof HasIFF)) {
return;
}
if (entity instanceof TameableEntity && !player.getUuid().equals(((TameableEntity) entity).getOwnerUuid())) {
return;
}
ListTag list = tag.getList("IFFs", 10);
List<IFF> iffs = list.stream().map(t -> (CompoundTag) t).map(t -> IFFTypeManager.getINSTANCE().loadIFF(t)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
((HasIFF) entity).setIFFs(iffs);
}
Aggregations