Allay sounds + AI improvements
This commit is contained in:
parent
de1f058dfb
commit
9675def3b3
|
@ -9,6 +9,7 @@ import com.cursedcauldron.wildbackport.common.registry.WBGameEvents;
|
|||
import com.cursedcauldron.wildbackport.common.registry.entity.WBMemoryModules;
|
||||
import com.cursedcauldron.wildbackport.common.tag.WBGameEventTags;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.GlobalPos;
|
||||
|
@ -54,6 +55,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.gameevent.GameEventListener;
|
||||
import net.minecraft.world.level.gameevent.GameEventListenerRegistrar;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -366,7 +368,16 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationL
|
|||
if (tag.contains("listener", 10)) VibrationListenerSource.codec(this).parse(new Dynamic<>(NbtOps.INSTANCE, tag.getCompound("listener"))).resultOrPartial(WildBackport.LOGGER::error).ifPresent(listener -> this.listener = listener);
|
||||
}
|
||||
|
||||
//iterate pathfinding start node candidate positions
|
||||
public Iterable<BlockPos> iteratePathfindingStartNodeCandidatePositions() {
|
||||
AABB box = this.getBoundingBox();
|
||||
int minX = Mth.floor(box.minX - 0.5D);
|
||||
int maxX = Mth.floor(box.maxX + 0.5D);
|
||||
int minY = Mth.floor(box.minY - 0.5D);
|
||||
int maxY = Mth.floor(box.maxY + 0.5D);
|
||||
int minZ = Mth.floor(box.minZ - 0.5D);
|
||||
int maxZ = Mth.floor(box.maxZ + 0.5D);
|
||||
return BlockPos.betweenClosed(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getLeashOffset() {
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package com.cursedcauldron.wildbackport.core.mixin.access;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(Mob.class)
|
||||
public interface MobAccessor {
|
||||
@Accessor
|
||||
Entity getLeashHolder();
|
||||
|
||||
@Accessor
|
||||
CompoundTag getLeashInfoTag();
|
||||
|
||||
@Invoker
|
||||
void callRestoreLeashFromSave();
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.cursedcauldron.wildbackport.core.mixin.access;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.world.level.pathfinder.WalkNodeEvaluator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(WalkNodeEvaluator.class)
|
||||
public interface WalkNodeEvaluatorAccessor {
|
||||
@Invoker
|
||||
BlockPathTypes callGetBlockPathType(Mob mob, BlockPos blockPos);
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package com.cursedcauldron.wildbackport.core.mixin.common;
|
||||
|
||||
import net.minecraft.world.level.levelgen.Beardifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(Beardifier.class)
|
||||
public class BeardifierMixin {
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.cursedcauldron.wildbackport.core.mixin.common;
|
||||
|
||||
import com.cursedcauldron.wildbackport.common.entities.Allay;
|
||||
import com.cursedcauldron.wildbackport.core.mixin.access.WalkNodeEvaluatorAccessor;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.pathfinder.BlockPathTypes;
|
||||
import net.minecraft.world.level.pathfinder.FlyNodeEvaluator;
|
||||
import net.minecraft.world.level.pathfinder.Node;
|
||||
import net.minecraft.world.level.pathfinder.WalkNodeEvaluator;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
//<>
|
||||
|
||||
@Mixin(FlyNodeEvaluator.class)
|
||||
public abstract class FlyNodeEvaluatorMixin extends WalkNodeEvaluator {
|
||||
@Shadow protected abstract BlockPathTypes getCachedBlockPathType(int i, int j, int k);
|
||||
|
||||
@Shadow @Nullable protected abstract Node getNode(int i, int j, int k);
|
||||
|
||||
@Shadow public abstract BlockPathTypes getBlockPathType(BlockGetter blockGetter, int i, int j, int k);
|
||||
|
||||
@Inject(method = "getStart", at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableSet;of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;", shift = At.Shift.AFTER), cancellable = true)
|
||||
private void wb$start(CallbackInfoReturnable<Node> cir) {
|
||||
if (this.mob instanceof Allay allay) {
|
||||
for (BlockPos pos : allay.iteratePathfindingStartNodeCandidatePositions()) {
|
||||
BlockPathTypes types = this.getCachedBlockPathType(pos.getX(), pos.getY(), pos.getZ());
|
||||
if (this.mob.getPathfindingMalus(types) >= 0.0F) {
|
||||
Node node = this.getNode(pos);
|
||||
if (node != null) {
|
||||
node.type = ((WalkNodeEvaluatorAccessor)this).callGetBlockPathType(this.mob, node.asBlockPos());
|
||||
node.costMalus = this.mob.getPathfindingMalus(node.type);
|
||||
}
|
||||
|
||||
cir.setReturnValue(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.cursedcauldron.wildbackport.core.mixin.common;
|
||||
|
||||
import com.cursedcauldron.wildbackport.common.entities.Allay;
|
||||
import net.minecraft.world.entity.PathfinderMob;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(PathfinderMob.class)
|
||||
public class PathfinderMobMixin {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Inject(method = "tickLeash", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/ai/goal/GoalSelector;enableControlFlag(Lnet/minecraft/world/entity/ai/goal/Goal$Flag;)V", shift = At.Shift.BEFORE), cancellable = true)
|
||||
private void wb$tickLeash(CallbackInfo ci) {
|
||||
if (PathfinderMob.class.cast(this) instanceof Allay) ci.cancel();
|
||||
}
|
||||
}
|
|
@ -1801,6 +1801,135 @@
|
|||
],
|
||||
"subtitle": "subtitles.item.goat_horn.play"
|
||||
},
|
||||
"entity.allay.ambient_with_item": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "wildbackport:mob/allay/idle_with_item1",
|
||||
"pitch": 1.25,
|
||||
"volume": 0.3
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/idle_with_item2",
|
||||
"pitch": 1.25,
|
||||
"volume": 0.3
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/idle_with_item3",
|
||||
"pitch": 1.25,
|
||||
"volume": 0.3
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/idle_with_item4",
|
||||
"pitch": 1.25,
|
||||
"volume": 0.3
|
||||
}
|
||||
],
|
||||
"subtitle": "subtitles.entity.allay.ambient_with_item"
|
||||
},
|
||||
"entity.allay.ambient_without_item": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "wildbackport:mob/allay/idle_without_item1",
|
||||
"volume": 0.25
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/idle_without_item2",
|
||||
"volume": 0.25
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/idle_without_item3",
|
||||
"volume": 0.25
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/idle_without_item4",
|
||||
"volume": 0.25
|
||||
}
|
||||
],
|
||||
"subtitle": "subtitles.entity.allay.ambient_without_item"
|
||||
},
|
||||
"entity.allay.death": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "wildbackport:mob/allay/death1",
|
||||
"volume": 0.6
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/death2",
|
||||
"volume": 0.6
|
||||
}
|
||||
],
|
||||
"subtitle": "subtitles.entity.allay.death"
|
||||
},
|
||||
"entity.allay.hurt": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "wildbackport:mob/allay/hurt1",
|
||||
"pitch": 1.5,
|
||||
"volume": 0.8
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/hurt2",
|
||||
"pitch": 1.5,
|
||||
"volume": 0.8
|
||||
}
|
||||
],
|
||||
"subtitle": "subtitles.entity.allay.hurt"
|
||||
},
|
||||
"entity.allay.item_given": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "wildbackport:mob/allay/item_given1",
|
||||
"volume": 0.1
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/item_given2",
|
||||
"volume": 0.1
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/item_given3",
|
||||
"volume": 0.1
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/item_given4",
|
||||
"volume": 0.1
|
||||
}
|
||||
],
|
||||
"subtitle": "subtitles.entity.allay.item_given"
|
||||
},
|
||||
"entity.allay.item_taken": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "wildbackport:mob/allay/item_taken1",
|
||||
"pitch": 1.25,
|
||||
"volume": 0.1
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/item_taken2",
|
||||
"pitch": 1.25,
|
||||
"volume": 0.1
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/item_taken3",
|
||||
"pitch": 1.25,
|
||||
"volume": 0.1
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/allay/item_taken4",
|
||||
"pitch": 1.25,
|
||||
"volume": 0.1
|
||||
}
|
||||
],
|
||||
"subtitle": "subtitles.entity.allay.item_taken"
|
||||
},
|
||||
"entity.allay.item_thrown": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "wildbackport:mob/allay/item_thrown1",
|
||||
"volume": 0.25
|
||||
}
|
||||
],
|
||||
"subtitle": "subtitles.entity.allay.item_thrown"
|
||||
},
|
||||
"entity.warden.sonic_boom": {
|
||||
"sounds": [
|
||||
"wildbackport:mob/warden/sonic_boom1",
|
||||
|
@ -2415,19 +2544,19 @@
|
|||
"entity.frog.tongue": {
|
||||
"sounds": [
|
||||
{
|
||||
"name": "wildbackport:mob/frog/tounge1",
|
||||
"name": "wildbackport:mob/frog/tongue1",
|
||||
"volume": 0.5
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/frog/tounge2",
|
||||
"name": "wildbackport:mob/frog/tongue2",
|
||||
"volume": 0.5
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/frog/tounge3",
|
||||
"name": "wildbackport:mob/frog/tongue3",
|
||||
"volume": 0.5
|
||||
},
|
||||
{
|
||||
"name": "wildbackport:mob/frog/tounge4",
|
||||
"name": "wildbackport:mob/frog/tongue4",
|
||||
"volume": 0.5
|
||||
}
|
||||
]
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -18,11 +18,13 @@
|
|||
"access.StairBlockAccessor",
|
||||
"access.StructureTemplatePoolAccessor",
|
||||
"access.TrapDoorBlockAccessor",
|
||||
"access.WalkNodeEvaluatorAccessor",
|
||||
"access.WoodButtonBlockAccessor",
|
||||
"access.WoodTypeAccessor",
|
||||
"common.BeardifierMixin",
|
||||
"common.BlockEntityTypeMixin",
|
||||
"common.FlyNodeEvaluatorMixin",
|
||||
"common.LivingEntityMixin",
|
||||
"common.PathfinderMobMixin",
|
||||
"common.PlayerMixin",
|
||||
"extension.BoatTypeMixin",
|
||||
"extension.PoseMixin",
|
||||
|
|
Loading…
Reference in a new issue