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