Search in sources :

Example 1 with VillagerEntity

use of net.minecraft.entity.passive.VillagerEntity in project mostructures by frqnny.

the class VillagerEntityFeature method getEntity.

@Override
public Entity getEntity(StructureWorldAccess world, BlockPos pos, DefaultFeatureConfig config) {
    VillagerEntity villager = new VillagerEntity(EntityType.VILLAGER, world.toServerWorld(), VillagerType.forBiome(world.getBiomeKey(pos)));
    villager.updateTrackedPosition(pos.getX(), pos.getY(), pos.getZ());
    return villager;
}
Also used : VillagerEntity(net.minecraft.entity.passive.VillagerEntity)

Example 2 with VillagerEntity

use of net.minecraft.entity.passive.VillagerEntity in project golemsgalore by frqnny.

the class TrackGhastlyGolemTargetGoal method canStart.

public boolean canStart() {
    Box box = this.golem.getBoundingBox().expand(10.0D, 8.0D, 10.0D);
    List<? extends LivingEntity> list = this.golem.world.getTargets(VillagerEntity.class, this.targetPredicate, this.golem, box);
    List<PlayerEntity> list2 = this.golem.world.getPlayers(this.targetPredicate, this.golem, box);
    for (LivingEntity livingEntity : list) {
        VillagerEntity villagerEntity = (VillagerEntity) livingEntity;
        for (PlayerEntity playerEntity : list2) {
            int i = villagerEntity.getReputation(playerEntity);
            if (i <= -100) {
                this.target = playerEntity;
            }
        }
    }
    if (this.target == null) {
        return false;
    } else
        return !(this.target instanceof PlayerEntity) || !this.target.isSpectator() && !((PlayerEntity) this.target).isCreative();
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) VillagerEntity(net.minecraft.entity.passive.VillagerEntity) Box(net.minecraft.util.math.Box) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 3 with VillagerEntity

use of net.minecraft.entity.passive.VillagerEntity in project Wurst7 by Wurst-Imperium.

the class AutoEatHack method isClickable.

private boolean isClickable(HitResult hitResult) {
    if (hitResult == null)
        return false;
    if (hitResult instanceof EntityHitResult) {
        Entity entity = ((EntityHitResult) hitResult).getEntity();
        return entity instanceof VillagerEntity || entity instanceof TameableEntity;
    }
    if (hitResult instanceof BlockHitResult) {
        BlockPos pos = ((BlockHitResult) hitResult).getBlockPos();
        if (pos == null)
            return false;
        Block block = MC.world.getBlockState(pos).getBlock();
        return block instanceof BlockWithEntity || block instanceof CraftingTableBlock;
    }
    return false;
}
Also used : VillagerEntity(net.minecraft.entity.passive.VillagerEntity) BlockWithEntity(net.minecraft.block.BlockWithEntity) Entity(net.minecraft.entity.Entity) BlockWithEntity(net.minecraft.block.BlockWithEntity) VillagerEntity(net.minecraft.entity.passive.VillagerEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) CraftingTableBlock(net.minecraft.block.CraftingTableBlock) CraftingTableBlock(net.minecraft.block.CraftingTableBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) EntityHitResult(net.minecraft.util.hit.EntityHitResult)

Example 4 with VillagerEntity

use of net.minecraft.entity.passive.VillagerEntity in project libr-getter by gXLg.

the class LibrGetCommand method runSelector.

private static int runSelector(CommandContext<FabricClientCommandSource> context) {
    if (Worker.getState() != Worker.State.STANDBY) {
        context.getSource().sendFeedback(new LiteralText("LibrGetter is running!").formatted(Formatting.RED));
        return 1;
    }
    MinecraftClient client = MinecraftClient.getInstance();
    ClientWorld world = client.world;
    if (world == null) {
        context.getSource().sendFeedback(new LiteralText("InternalError: world == null").formatted(Formatting.RED));
        return 1;
    }
    ClientPlayerEntity player = client.player;
    if (player == null) {
        context.getSource().sendFeedback(new LiteralText("InternalError: player == null").formatted(Formatting.RED));
        return 1;
    }
    HitResult hit = client.crosshairTarget;
    if (hit == null) {
        context.getSource().sendFeedback(new LiteralText("InternalError: hit == null").formatted(Formatting.RED));
        return 1;
    }
    HitResult.Type hitType = hit.getType();
    if (hitType == HitResult.Type.MISS) {
        context.getSource().sendFeedback(new LiteralText("You are not targeting anything!").formatted(Formatting.RED));
        return 1;
    }
    if (hitType == HitResult.Type.BLOCK) {
        BlockPos blockPos = ((BlockHitResult) hit).getBlockPos();
        if (!world.getBlockState(blockPos).isOf(Blocks.LECTERN)) {
            context.getSource().sendFeedback(new LiteralText("Block is not a lectern!").formatted(Formatting.RED));
            return 1;
        }
        Worker.setBlock(blockPos);
        context.getSource().sendFeedback(new LiteralText("Block selected"));
    } else if (hitType == HitResult.Type.ENTITY) {
        EntityHitResult entityHitResult = (EntityHitResult) hit;
        Entity entity = entityHitResult.getEntity();
        if (!(entity instanceof MerchantEntity)) {
            context.getSource().sendFeedback(new LiteralText("Entity is not a villager!").formatted(Formatting.RED));
            return 1;
        }
        VillagerEntity villager = (VillagerEntity) entity;
        if (villager.getVillagerData().getProfession() != VillagerProfession.LIBRARIAN) {
            context.getSource().sendFeedback(new LiteralText("Villager is not a librarian!").formatted(Formatting.RED));
            return 1;
        }
        context.getSource().sendFeedback(new LiteralText("Villager selected"));
        Worker.setVillager(villager);
    }
    return 0;
}
Also used : BlockHitResult(net.minecraft.util.hit.BlockHitResult) HitResult(net.minecraft.util.hit.HitResult) EntityHitResult(net.minecraft.util.hit.EntityHitResult) VillagerEntity(net.minecraft.entity.passive.VillagerEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) Entity(net.minecraft.entity.Entity) VillagerEntity(net.minecraft.entity.passive.VillagerEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) MinecraftClient(net.minecraft.client.MinecraftClient) BlockPos(net.minecraft.util.math.BlockPos) ClientWorld(net.minecraft.client.world.ClientWorld) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) BlockHitResult(net.minecraft.util.hit.BlockHitResult) EntityHitResult(net.minecraft.util.hit.EntityHitResult) LiteralText(net.minecraft.text.LiteralText)

Example 5 with VillagerEntity

use of net.minecraft.entity.passive.VillagerEntity in project Miskatonic-Mysteries-Fabric by cybercat5555.

the class GoldenFlockRite method shouldContinue.

@Override
public boolean shouldContinue(OctagramBlockEntity octagram) {
    if (octagram.getOriginalCaster() == null) {
        return false;
    }
    if (octagram.targetedEntity == null && !octagram.getWorld().isClient) {
        octagram.tickCount++;
        Vec3d pos = octagram.getSummoningPos();
        octagram.targetedEntity = octagram.getWorld().getClosestEntity(VillagerEntity.class, TargetPredicate.createNonAttackable().setPredicate(villager -> villager instanceof VillagerEntity && villager.hasStatusEffect(MMStatusEffects.MANIA)), null, pos.x, pos.y, pos.z, octagram.getSelectionBox().expand(10, 5, 10));
        if (octagram.targetedEntity != null) {
            octagram.tickCount = 0;
            SyncRiteTargetPacket.send(octagram.targetedEntity, octagram);
            octagram.markDirty();
            octagram.sync();
        }
    }
    return !(octagram.targetedEntity == null && octagram.tickCount > 20);
}
Also used : VillagerEntity(net.minecraft.entity.passive.VillagerEntity) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

VillagerEntity (net.minecraft.entity.passive.VillagerEntity)14 BlockPos (net.minecraft.util.math.BlockPos)6 Entity (net.minecraft.entity.Entity)5 LivingEntity (net.minecraft.entity.LivingEntity)4 HasturCultistEntity (com.miskatonicmysteries.common.feature.entity.HasturCultistEntity)3 TameableEntity (net.minecraft.entity.passive.TameableEntity)3 Box (net.minecraft.util.math.Box)3 List (java.util.List)2 Block (net.minecraft.block.Block)2 BlockWithEntity (net.minecraft.block.BlockWithEntity)2 CraftingTableBlock (net.minecraft.block.CraftingTableBlock)2 ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)2 ClientWorld (net.minecraft.client.world.ClientWorld)2 ItemFrameEntity (net.minecraft.entity.decoration.ItemFrameEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 BlockHitResult (net.minecraft.util.hit.BlockHitResult)2 EntityHitResult (net.minecraft.util.hit.EntityHitResult)2 Vec3d (net.minecraft.util.math.Vec3d)2 ItemEntityAccessor (carpettisaddition.mixins.command.info.entity.ItemEntityAccessor)1 ZombieVillagerEntityAccessor (carpettisaddition.mixins.command.info.entity.ZombieVillagerEntityAccessor)1