Skip to content

Commit

Permalink
Make villager run to snow
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivoz committed Dec 28, 2022
1 parent e6aa04d commit d4c041e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static void snowballingMixinStaticInit(final CallbackInfo ci) {
@Inject(at = @At("HEAD"), method = "registerBrainGoals")
public void snowballingMixinRegisterBrainGoals(final Brain<Villager> brain, final CallbackInfo ci) {
float speed = 0.5F;
brain.addActivity(SnowballingActivities.SNOWBALL_FIGHT.get(), ImmutableList.of(Pair.of(0, new GateBehavior<>(Map.of(), Set.of(), GateBehavior.OrderPolicy.ORDERED, GateBehavior.RunningPolicy.RUN_ONE, List.of(Pair.of(new EndSnowballFight(), 0), Pair.of(new SnowballAttack(speed), 1), Pair.of(new TakeOrMakeSnowballs(), 1), Pair.of(new SetSnowAsWalkTarget(speed), 1)))), VillagerGoalPackages.getMinimalLookBehavior()));
brain.addActivity(SnowballingActivities.SNOWBALL_FIGHT.get(), ImmutableList.of(Pair.of(0, new GateBehavior<>(Map.of(), Set.of(), GateBehavior.OrderPolicy.ORDERED, GateBehavior.RunningPolicy.RUN_ONE, List.of(Pair.of(new EndSnowballFight(), 0), Pair.of(new SnowballAttack(speed), 1), Pair.of(new TakeOrMakeSnowballs(), 1), Pair.of(new SetSnowAsWalkTarget(speed * 1.5F), 1)))), VillagerGoalPackages.getMinimalLookBehavior()));
}

@Inject(at = @At("HEAD"), method = "mobInteract", cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.behavior.Behavior;
import net.minecraft.world.entity.ai.behavior.BehaviorUtils;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraft.world.entity.ai.memory.MemoryStatus;
import net.minecraft.world.entity.ai.memory.WalkTarget;
import net.minecraft.world.entity.ai.village.poi.PoiManager;
import net.minecraft.world.entity.npc.Villager;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -46,6 +46,6 @@ protected void start(final ServerLevel serverLevel, final Villager villager, fin

Brain<Villager> brain = villager.getBrain();
brain.setMemory(SnowballingMemoryModules.SNOW_AT.get(), optionalSnowPos.orElseThrow());
brain.setMemory(MemoryModuleType.WALK_TARGET, new WalkTarget(optionalSnowPos.orElseThrow(), speedModifier, 1));
BehaviorUtils.setWalkAndLookTargetMemories(villager, optionalSnowPos.orElseThrow(), speedModifier, 1);
}
}

0 comments on commit d4c041e

Please sign in to comment.