net.minecraft.entity.passive.VillagerEntity Java Examples

The following examples show how to use net.minecraft.entity.passive.VillagerEntity. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AutoEatHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #2
Source File: AutoSoupHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
private boolean isClickable(HitResult hitResult)
{
	if(hitResult == null)
		return false;
	
	if(hitResult instanceof EntityHitResult)
	{
		Entity entity = ((EntityHitResult)MC.crosshairTarget).getEntity();
		return entity instanceof VillagerEntity
			|| entity instanceof TameableEntity;
	}
	
	if(hitResult instanceof BlockHitResult)
	{
		BlockPos pos = ((BlockHitResult)MC.crosshairTarget).getBlockPos();
		if(pos == null)
			return false;
		
		Block block = MC.world.getBlockState(pos).getBlock();
		return block instanceof BlockWithEntity
			|| block instanceof CraftingTableBlock;
	}
	
	return false;
}
 
Example #3
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "keepRunning", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/inventory/BasicInventory;getInvSize()I"
))
private int plantWart(BasicInventory basicInventory, ServerWorld serverWorld, VillagerEntity villagerEntity, long l)
{
    if (isFarmingCleric) // fill cancel that for loop by setting length to 0
    {
        for(int i = 0; i < basicInventory.getInvSize(); ++i)
        {
            ItemStack itemStack = basicInventory.getInvStack(i);
            boolean bl = false;
            if (!itemStack.isEmpty())
            {
                if (itemStack.getItem() == Items.NETHER_WART)
                {
                    serverWorld.setBlockState(currentTarget, Blocks.NETHER_WART.getDefaultState(), 3);
                    bl = true;
                }
            }

            if (bl)
            {
                serverWorld.playSound(null,
                        currentTarget.getX(), currentTarget.getY(), this.currentTarget.getZ(),
                        SoundEvents.ITEM_NETHER_WART_PLANT, SoundCategory.BLOCKS, 1.0F, 1.0F);
                itemStack.decrement(1);
                if (itemStack.isEmpty())
                {
                    basicInventory.setInvStack(i, ItemStack.EMPTY);
                }
                break;
            }
        }
        return 0;

    }
    return basicInventory.getInvSize();
}
 
Example #4
Source File: MoonVillagerRenderer.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
protected void scale(VillagerEntity villagerEntity, MatrixStack matrixStack, float f) {
    float g = 0.9375F;
    if (villagerEntity.isBaby()) {
        g = (float) ((double) g * 0.5D);
        this.shadowRadius = 0.25F;
    } else {
        this.shadowRadius = 0.5F;
    }

    matrixStack.scale(g, g, g);
}
 
Example #5
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Redirect(method = "shouldRun", at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/item/ItemStack;getItem()Lnet/minecraft/item/Item;",
        ordinal = 0
))
private Item disguiseWartAsSeeds(ItemStack itemStack, ServerWorld serverWorld, VillagerEntity villagerEntity)
{
    Item item = itemStack.getItem();
    if (isFarmingCleric && item == Items.NETHER_WART)
        return Items.WHEAT_SEEDS;
    return item;
}
 
Example #6
Source File: SecondaryPointOfInterestSensor_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(method = "sense", at = @At("HEAD"), cancellable = true)
private void notVanillaCleric(ServerWorld serverWorld, VillagerEntity villagerEntity, CallbackInfo ci)
{
    if(!CarpetExtraSettings.clericsFarmWarts && villagerEntity.getVillagerData().getProfession() == VillagerProfession.CLERIC)
    {
        // in vanilla we want not to find secondary POI for clerics
        Brain<?> brain = villagerEntity.getBrain();
        brain.forget(MemoryModuleType.SECONDARY_JOB_SITE);
        ci.cancel();

    }
}
 
Example #7
Source File: KillauraLegitHack.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onUpdate()
{
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	if(player.getAttackCooldownProgress(0) < 1)
		return;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<LivingEntity> stream = StreamSupport
		.stream(MC.world.getEntities().spliterator(), true)
		.filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e)
		.filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> !WURST.getFriends().contains(e.getEntityName()));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof PlayerEntity))
				return true;
			
			Box box = e.getBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			return world.doesNotCollide(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EndermanEntity));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof PassiveEntity
			&& ((PassiveEntity)e).isBaby()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof TameableEntity
				&& ((TameableEntity)e).isTamed()))
			.filter(e -> !(e instanceof HorseBaseEntity
				&& ((HorseBaseEntity)e).isTame()));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof VillagerEntity));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof GolemEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	target = stream.min(priority.getSelected().comparator).orElse(null);
	if(target == null)
		return;
	
	WURST.getHax().autoSwordHack.setSlot();
	
	// face entity
	if(!faceEntityClient(target))
		return;
	
	// attack entity
	MC.interactionManager.attackEntity(player, target);
	player.swingHand(Hand.MAIN_HAND);
}
 
Example #8
Source File: VillagerPonyRenderer.java    From MineLittlePony with MIT License 4 votes vote down vote up
@Override
public void scale(VillagerEntity villager, MatrixStack stack, float ticks) {
    super.scale(villager, stack, ticks);
    stack.scale(BASE_MODEL_SCALE, BASE_MODEL_SCALE, BASE_MODEL_SCALE);
}
 
Example #9
Source File: VillagerEntity_aiMixin.java    From fabric-carpet with MIT License 4 votes vote down vote up
private boolean canReachHome(VillagerEntity villager, BlockPos pos) {
    Path path = villager.getNavigation().findPathTo(pos, PointOfInterestType.HOME.getSearchDistance());
    return path != null && path.reachesTarget();
}
 
Example #10
Source File: VillagerEntity_aiMixin.java    From fabric-carpet with MIT License 4 votes vote down vote up
@Inject(method = "interactMob", at = @At("HEAD"), cancellable = true)
private void onInteract(PlayerEntity playerEntity_1, Hand hand_1, CallbackInfoReturnable<Boolean> cir)
{
    if (MobAI.isTracking(this, MobAI.TrackingType.VILLAGER_BREEDING))
    {
        ItemStack itemStack_1 = playerEntity_1.getStackInHand(hand_1);
        if (itemStack_1.getItem() == Items.EMERALD)
        {
            GlobalPos bedPos = this.brain.getOptionalMemory(MemoryModuleType.HOME).orElse(null);
            if (bedPos == null || bedPos.getDimension() != dimension)
            {
                sayNo();
                ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.BARRIER, getX(), getY() + getStandingEyeHeight() + 1, getZ(), 1, 0.1, 0.1, 0.1, 0.0);
            }
            else
            {

                ParticleDisplay.drawParticleLine((ServerPlayerEntity) playerEntity_1, getPos(), new Vec3d(bedPos.getPos()).add(0.5, 0.5, 0.5), "dust 0 0 0 1", "happy_villager", 100, 0.2);
            }
        }
        else if (itemStack_1.getItem() == Items.ROTTEN_FLESH)
        {
            while(getAvailableFood() >= 12) eatForBreeding();

        }
        else if (itemStack_1.getItem() instanceof BedItem)
        {
            List<PointOfInterest> list_1 = ((ServerWorld) getEntityWorld()).getPointOfInterestStorage().get(
                    type -> type == PointOfInterestType.HOME,
                    getBlockPos(),
                    48, PointOfInterestStorage.OccupationStatus.ANY).collect(Collectors.toList());
            for (PointOfInterest poi : list_1)
            {
                Vec3d pv = new Vec3d(poi.getPos()).add(0.5, 0.5, 0.5);
                if (!poi.hasSpace())
                {
                    ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.HAPPY_VILLAGER,
                            pv.x, pv.y+1.5, pv.z,
                            50, 0.1, 0.3, 0.1, 0.0);
                }
                else if (canReachHome((VillagerEntity)(Object)this, poi.getPos()))
                    ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.END_ROD,
                            pv.x, pv.y+1, pv.z,
                            50, 0.1, 0.3, 0.1, 0.0);
                else
                    ((ServerWorld) getEntityWorld()).spawnParticles(ParticleTypes.BARRIER,
                            pv.x, pv.y+1, pv.z,
                            1, 0.1, 0.1, 0.1, 0.0);
            }
        }
        cir.setReturnValue(false);
        cir.cancel();
    }
}
 
Example #11
Source File: EntityUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isAnimal(Entity e) {
	return e instanceof AnimalEntity || e instanceof AmbientEntity || e instanceof WaterCreatureEntity ||
			e instanceof GolemEntity || e instanceof VillagerEntity;
}
 
Example #12
Source File: EntityUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isAnimal(Entity e) {
	return e instanceof AnimalEntity || e instanceof AmbientEntity || e instanceof WaterCreatureEntity ||
			e instanceof GolemEntity || e instanceof VillagerEntity;
}
 
Example #13
Source File: EntityUtils.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isAnimal(Entity e) {
	return e instanceof AnimalEntity || e instanceof AmbientEntity || e instanceof WaterCreatureEntity ||
			e instanceof GolemEntity || e instanceof VillagerEntity;
}
 
Example #14
Source File: KillauraHack.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onUpdate()
{
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	if(player.getAttackCooldownProgress(0) < 1)
		return;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<LivingEntity> stream = StreamSupport
		.stream(MC.world.getEntities().spliterator(), true)
		.filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e)
		.filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> !WURST.getFriends().contains(e.getEntityName()));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof PlayerEntity))
				return true;
			
			Box box = e.getBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			return world.doesNotCollide(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EndermanEntity));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof PassiveEntity
			&& ((PassiveEntity)e).isBaby()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof TameableEntity
				&& ((TameableEntity)e).isTamed()))
			.filter(e -> !(e instanceof HorseBaseEntity
				&& ((HorseBaseEntity)e).isTame()));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof VillagerEntity));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof GolemEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	target = stream.min(priority.getSelected().comparator).orElse(null);
	renderTarget = target;
	if(target == null)
		return;
	
	WURST.getHax().autoSwordHack.setSlot();
	
	WURST.getRotationFaker()
		.faceVectorPacket(target.getBoundingBox().getCenter());
}
 
Example #15
Source File: RemoteViewHack.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onEnable()
{
	// find entity if not already set
	if(entity == null)
	{
		Stream<Entity> stream = StreamSupport
			.stream(MC.world.getEntities().spliterator(), true)
			.filter(e -> e instanceof LivingEntity)
			.filter(e -> !e.removed && ((LivingEntity)e).getHealth() > 0)
			.filter(e -> e != MC.player)
			.filter(e -> !(e instanceof FakePlayerEntity));
		
		if(filterPlayers.isChecked())
			stream = stream.filter(e -> !(e instanceof PlayerEntity));
		
		if(filterSleeping.isChecked())
			stream = stream.filter(e -> !(e instanceof PlayerEntity
				&& ((PlayerEntity)e).isSleeping()));
		
		if(filterFlying.getValue() > 0)
			stream = stream.filter(e -> {
				
				if(!(e instanceof PlayerEntity))
					return true;
				
				Box box = e.getBoundingBox();
				box = box.union(box.offset(0, -filterFlying.getValue(), 0));
				return MC.world.doesNotCollide(box);
			});
		
		if(filterMonsters.isChecked())
			stream = stream.filter(e -> !(e instanceof Monster));
		
		if(filterPigmen.isChecked())
			stream =
				stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
		
		if(filterEndermen.isChecked())
			stream = stream.filter(e -> !(e instanceof EndermanEntity));
		
		if(filterAnimals.isChecked())
			stream = stream.filter(e -> !(e instanceof AnimalEntity
				|| e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
		
		if(filterBabies.isChecked())
			stream = stream.filter(e -> !(e instanceof PassiveEntity
				&& ((PassiveEntity)e).isBaby()));
		
		if(filterPets.isChecked())
			stream = stream
				.filter(e -> !(e instanceof TameableEntity
					&& ((TameableEntity)e).isTamed()))
				.filter(e -> !(e instanceof HorseBaseEntity
					&& ((HorseBaseEntity)e).isTame()));
		
		if(filterVillagers.isChecked())
			stream = stream.filter(e -> !(e instanceof VillagerEntity));
		
		if(filterGolems.isChecked())
			stream = stream.filter(e -> !(e instanceof GolemEntity));
		
		if(filterInvisible.isChecked())
			stream = stream.filter(e -> !e.isInvisible());
		
		entity = stream
			.min(Comparator
				.comparingDouble(e -> MC.player.squaredDistanceTo(e)))
			.orElse(null);
		
		// check if entity was found
		if(entity == null)
		{
			ChatUtils.error("Could not find a valid entity.");
			setEnabled(false);
			return;
		}
	}
	
	// save old data
	wasInvisible = entity.isInvisibleTo(MC.player);
	
	// enable NoClip
	MC.player.noClip = true;
	
	// spawn fake player
	fakePlayer = new FakePlayerEntity();
	
	// success message
	ChatUtils.message("Now viewing " + entity.getName().getString() + ".");
	
	// add listener
	EVENTS.add(UpdateListener.class, this);
	EVENTS.add(PacketOutputListener.class, this);
}
 
Example #16
Source File: TriggerBotHack.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
private boolean isCorrectEntity(Entity entity)
{
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<LivingEntity> stream = Stream.of(entity)
		.filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e)
		.filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> !WURST.getFriends().contains(e.getEntityName()));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof PlayerEntity))
				return true;
			
			Box box = e.getBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			return world.doesNotCollide(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EndermanEntity));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof PassiveEntity
			&& ((PassiveEntity)e).isBaby()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof TameableEntity
				&& ((TameableEntity)e).isTamed()))
			.filter(e -> !(e instanceof HorseBaseEntity
				&& ((HorseBaseEntity)e).isTame()));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof VillagerEntity));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof GolemEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	return stream.findFirst().isPresent();
}
 
Example #17
Source File: FollowHack.java    From Wurst7 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onEnable()
{
	if(entity == null)
	{
		Stream<Entity> stream = StreamSupport
			.stream(MC.world.getEntities().spliterator(), true)
			.filter(e -> e instanceof LivingEntity)
			.filter(e -> !e.removed && ((LivingEntity)e).getHealth() > 0)
			.filter(e -> e != MC.player)
			.filter(e -> !(e instanceof FakePlayerEntity));
		
		if(filterPlayers.isChecked())
			stream = stream.filter(e -> !(e instanceof PlayerEntity));
		
		if(filterSleeping.isChecked())
			stream = stream.filter(e -> !(e instanceof PlayerEntity
				&& ((PlayerEntity)e).isSleeping()));
		
		if(filterFlying.getValue() > 0)
			stream = stream.filter(e -> {
				
				if(!(e instanceof PlayerEntity))
					return true;
				
				Box box = e.getBoundingBox();
				box = box.union(box.offset(0, -filterFlying.getValue(), 0));
				return MC.world.doesNotCollide(box);
			});
		
		if(filterMonsters.isChecked())
			stream = stream.filter(e -> !(e instanceof Monster));
		
		if(filterPigmen.isChecked())
			stream =
				stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
		
		if(filterEndermen.isChecked())
			stream = stream.filter(e -> !(e instanceof EndermanEntity));
		
		if(filterAnimals.isChecked())
			stream = stream.filter(e -> !(e instanceof AnimalEntity
				|| e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
		
		if(filterBabies.isChecked())
			stream = stream.filter(e -> !(e instanceof PassiveEntity
				&& ((PassiveEntity)e).isBaby()));
		
		if(filterPets.isChecked())
			stream = stream
				.filter(e -> !(e instanceof TameableEntity
					&& ((TameableEntity)e).isTamed()))
				.filter(e -> !(e instanceof HorseBaseEntity
					&& ((HorseBaseEntity)e).isTame()));
		
		if(filterVillagers.isChecked())
			stream = stream.filter(e -> !(e instanceof VillagerEntity));
		
		if(filterGolems.isChecked())
			stream = stream.filter(e -> !(e instanceof GolemEntity));
		
		if(filterInvisible.isChecked())
			stream = stream.filter(e -> !e.isInvisible());
		
		entity = stream
			.min(Comparator
				.comparingDouble(e -> MC.player.squaredDistanceTo(e)))
			.orElse(null);
		
		if(entity == null)
		{
			ChatUtils.error("Could not find a valid entity.");
			setEnabled(false);
			return;
		}
	}
	
	pathFinder = new EntityPathFinder();
	EVENTS.add(UpdateListener.class, this);
	EVENTS.add(RenderListener.class, this);
	ChatUtils.message("Now following " + entity.getName().getString());
}
 
Example #18
Source File: ServerPlayNetworkHandlerMixin.java    From the-hallow with MIT License 4 votes vote down vote up
@Inject(at = @At("TAIL"), method = "onChatMessage(Lnet/minecraft/server/network/packet/ChatMessageC2SPacket;)V")
public void onChatMessage(ChatMessageC2SPacket packet, CallbackInfo info) {
	if (packet.getChatMessage().toLowerCase().contains("trick or treat")) {
		if (isPlayerWearingCostume(player)) {
			World world = player.getEntityWorld();
			Box box = new Box(player.getX() - 3, player.getY() - 3, player.getZ() - 3, player.getX() + 3, player.getY() + 3, player.getZ() + 3);
			List<VillagerEntity> villagers = world.getNonSpectatingEntities(VillagerEntity.class, box);
			Iterator<VillagerEntity> iterator = villagers.iterator();
			if (iterator.hasNext()) {
				boolean trick = HallowedConfig.TrickOrTreating.enableTricks && world.random.nextInt(HallowedConfig.TrickOrTreating.trickChance) == 0;
				if (trick) {
					player.playSound(SoundEvents.ENTITY_VILLAGER_NO, 1.0f, 1.0f);
					player.sendChatMessage(new TranslatableText("text.thehallow.trick"), MessageType.GAME_INFO);
				} else {
					player.playSound(SoundEvents.ENTITY_VILLAGER_YES, 1.0f, 1.0f);
					player.sendChatMessage(new TranslatableText("text.thehallow.treat"), MessageType.GAME_INFO);
				}
				while (iterator.hasNext()) {
					VillagerEntity entity = iterator.next();
					if (!entity.isBaby()) {
						if (trick) {
							WitchEntity witch = new WitchEntity(EntityType.WITCH, world);
							witch.copyPositionAndRotation(entity);
							witch.setAttacker(player);
							entity.remove();
							world.spawnEntity(witch);
						} else {
							CandyComponent comp = HallowedEntities.CANDY.get(entity);
							if (comp.canGiveCandy(player)) {
								comp.setLastCandyTime(player, world.getTime());
								LootTable supplier = world.getServer().getLootManager().getSupplier(new Identifier("thehallow", "gameplay/trick_or_treat_candy"));
								LootContext context = (new LootContext.Builder((ServerWorld) world))
									.put(LootContextParameters.POSITION, new BlockPos(entity))
									.put(LootContextParameters.THIS_ENTITY, entity).setRandom(entity.getRandom())
									.build(LootContextTypes.GIFT);
								List<ItemStack> stacks = supplier.getDrops(context);
								for (ItemStack stack : stacks) {
									LookTargetUtil.give(entity, stack, player);
								}
							}
						}
					}
				}
			} else {
				player.sendChatMessage(new TranslatableText("text.thehallow.no_one_nearby"), MessageType.GAME_INFO);
			}
		} else {
			player.sendChatMessage(new TranslatableText("text.thehallow.not_wearing_costume"), MessageType.GAME_INFO);
		}
	}
}
 
Example #19
Source File: HallowedEntities.java    From the-hallow with MIT License 4 votes vote down vote up
public static void init() {
	@SuppressWarnings("unused") Object classloading = SpawnRestriction.class;
	SpawnRestrictionInvoker.invokeRegister(HallowedEntities.MUMMY, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, HostileEntity::canSpawnInDark);
	EntityComponentCallback.event(VillagerEntity.class).register((player, components) -> components.put(CANDY, new VillagerCandyComponent()));
}
 
Example #20
Source File: TpAuraHack.java    From Wurst7 with GNU General Public License v3.0 votes vote down vote up
@Override
public void onUpdate()
{
	ClientPlayerEntity player = MC.player;
	
	// set entity
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<LivingEntity> stream = StreamSupport
		.stream(MC.world.getEntities().spliterator(), true)
		.filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e)
		.filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> !WURST.getFriends().contains(e.getEntityName()));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof PlayerEntity))
				return true;
			
			Box box = e.getBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			return MC.world.doesNotCollide(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EndermanEntity));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof PassiveEntity
			&& ((PassiveEntity)e).isBaby()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof TameableEntity
				&& ((TameableEntity)e).isTamed()))
			.filter(e -> !(e instanceof HorseBaseEntity
				&& ((HorseBaseEntity)e).isTame()));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof VillagerEntity));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof GolemEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	Entity entity =
		stream.min(priority.getSelected().comparator).orElse(null);
	if(entity == null)
		return;
	
	WURST.getHax().autoSwordHack.setSlot();
	
	// teleport
	player.updatePosition(entity.getX() + random.nextInt(3) * 2 - 2,
		entity.getY(), entity.getZ() + random.nextInt(3) * 2 - 2);
	
	// check cooldown
	if(player.getAttackCooldownProgress(0) < 1)
		return;
	
	// attack entity
	RotationUtils.Rotation rotations = RotationUtils
		.getNeededRotations(entity.getBoundingBox().getCenter());
	WurstClient.MC.player.networkHandler
		.sendPacket(new PlayerMoveC2SPacket.LookOnly(rotations.getYaw(),
			rotations.getPitch(), MC.player.isOnGround()));
	
	MC.interactionManager.attackEntity(player, entity);
	player.swingHand(Hand.MAIN_HAND);
}
 
Example #21
Source File: ClickAuraHack.java    From Wurst7 with GNU General Public License v3.0 votes vote down vote up
private void attack()
{
	// set entity
	ClientPlayerEntity player = MC.player;
	ClientWorld world = MC.world;
	
	if(player.getAttackCooldownProgress(0) < 1)
		return;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<LivingEntity> stream = StreamSupport
		.stream(MC.world.getEntities().spliterator(), true)
		.filter(e -> e instanceof LivingEntity).map(e -> (LivingEntity)e)
		.filter(e -> !e.removed && e.getHealth() > 0)
		.filter(e -> player.squaredDistanceTo(e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof FakePlayerEntity))
		.filter(e -> !WURST.getFriends().contains(e.getEntityName()));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof PlayerEntity
			&& ((PlayerEntity)e).isSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof PlayerEntity))
				return true;
			
			Box box = e.getBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			return world.doesNotCollide(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof Monster));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EndermanEntity));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(
			e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity
				|| e instanceof WaterCreatureEntity));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof PassiveEntity
			&& ((PassiveEntity)e).isBaby()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof TameableEntity
				&& ((TameableEntity)e).isTamed()))
			.filter(e -> !(e instanceof HorseBaseEntity
				&& ((HorseBaseEntity)e).isTame()));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof VillagerEntity));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof GolemEntity));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	LivingEntity target =
		stream.min(priority.getSelected().comparator).orElse(null);
	if(target == null)
		return;
	
	WURST.getHax().autoSwordHack.setSlot();
	
	// face entity
	Rotation rotation = RotationUtils
		.getNeededRotations(target.getBoundingBox().getCenter());
	PlayerMoveC2SPacket.LookOnly packet = new PlayerMoveC2SPacket.LookOnly(
		rotation.getYaw(), rotation.getPitch(), MC.player.isOnGround());
	MC.player.networkHandler.sendPacket(packet);
	
	// attack entity
	MC.interactionManager.attackEntity(player, target);
	player.swingHand(Hand.MAIN_HAND);
}