diff --git a/build.gradle b/build.gradle index 397ce50e..964a37c9 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,7 @@ reckon { } repositories { + flatDir { dirs 'lib' } maven { name 'pehkui'; url 'https://jitpack.io' } maven { name 'modmenu'; url 'https://maven.terraformersmc.com/releases' } maven { name 'minelp'; url 'https://repo.minelittlepony-mod.com/maven/snapshot' } @@ -57,7 +58,11 @@ dependencies { modApi "com.minelittlepony:kirin:${project.kirin_version}" include "com.minelittlepony:kirin:${project.kirin_version}" - modCompileOnly "com.minelittlepony:minelittlepony:${project.minelp_version}" + if (project.use_minelp == '1') { + modCompileOnly "com.minelittlepony:minelittlepony:${project.minelp_version}" + } else { + modCompileOnly "com.minelittlepony:minelittlepony-dummy:${project.minelp_version}" + } modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}") // modImplementation "com.github.Virtuoel:Pehkui:${project.pehkui_version}" diff --git a/gradle.properties b/gradle.properties index 7f6495b4..43b940d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,10 +3,10 @@ org.gradle.daemon=false # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version=1.21.1 - yarn_mappings=1.21.1+build.3 - loader_version=0.16.4 - fabric_version=0.102.0+1.21.1 + minecraft_version=1.21.3 + yarn_mappings=1.21.3+build.2 + loader_version=0.16.8 + fabric_version=0.106.1+1.21.3 # Mod Properties group=com.presencefootsteps @@ -16,12 +16,15 @@ org.gradle.daemon=false url=http://presencefootsteps.ha3.eu # Publishing - minecraft_version_range=>=1.21 + minecraft_version_range=>=1.21.3 modrinth_loader_type=fabric modrinth_project_id=rcTfTZr3 +# Testing + use_minelp=0 + # Dependencies - modmenu_version=11.0.0-beta.1 - minelp_version=4.12.0+1.21 - kirin_version=1.20.0+1.21 + modmenu_version=12.0.0-beta.1 + minelp_version=4.12.1+1.21 + kirin_version=1.20.1+1.21.3 pehkui_version=3.7.2 diff --git a/lib/minelittlepony-dummy-4.12.1+1.21.jar b/lib/minelittlepony-dummy-4.12.1+1.21.jar new file mode 100644 index 00000000..74c610d5 Binary files /dev/null and b/lib/minelittlepony-dummy-4.12.1+1.21.jar differ diff --git a/src/main/java/eu/ha3/presencefootsteps/PFDebugHud.java b/src/main/java/eu/ha3/presencefootsteps/PFDebugHud.java index a42fb88c..61689a3d 100644 --- a/src/main/java/eu/ha3/presencefootsteps/PFDebugHud.java +++ b/src/main/java/eu/ha3/presencefootsteps/PFDebugHud.java @@ -73,7 +73,7 @@ public void render(HitResult blockHit, HitResult fluidHit, List finalLis } list.add(String.format(Locale.ENGLISH, "Primitive Key: %s", PrimitiveLookup.getKey(state.getSoundGroup()))); BlockPos above = pos.up(); - boolean hasRain = client.world.isRaining() && client.world.getBiome(above).value().getPrecipitation(above) == Biome.Precipitation.RAIN; + boolean hasRain = client.world.isRaining() && client.world.getBiome(above).value().getPrecipitation(above, client.world.getSeaLevel()) == Biome.Precipitation.RAIN; boolean hasLava = client.world.getBlockState(above).getFluidState().isIn(FluidTags.LAVA); boolean hasWater = client.world.hasRain(above) || state.getFluidState().isIn(FluidTags.WATER) diff --git a/src/main/java/eu/ha3/presencefootsteps/sound/SoundEngine.java b/src/main/java/eu/ha3/presencefootsteps/sound/SoundEngine.java index 20cc559e..d4d93499 100644 --- a/src/main/java/eu/ha3/presencefootsteps/sound/SoundEngine.java +++ b/src/main/java/eu/ha3/presencefootsteps/sound/SoundEngine.java @@ -11,6 +11,8 @@ import org.jetbrains.annotations.Nullable; +import com.mojang.datafixers.util.Unit; + import eu.ha3.presencefootsteps.PFConfig; import eu.ha3.presencefootsteps.PresenceFootsteps; import eu.ha3.presencefootsteps.sound.player.ImmediateSoundPlayer; @@ -39,6 +41,7 @@ import net.minecraft.util.crash.CrashReport; import net.minecraft.util.crash.CrashReportSection; import net.minecraft.util.profiler.Profiler; +import net.minecraft.util.profiler.Profilers; public class SoundEngine implements IdentifiableResourceReloadListener { private static final Identifier ID = PresenceFootsteps.id("sounds"); @@ -170,10 +173,10 @@ public void onFrame(MinecraftClient client, Entity cameraEntity) { public boolean onSoundRecieved(@Nullable RegistryEntry event, SoundCategory category) { return event != null && isRunning(MinecraftClient.getInstance()) && event.getKeyOrValue().right().filter(sound -> { - return event == SoundEvents.ENTITY_PLAYER_SWIM - || event == SoundEvents.ENTITY_PLAYER_SPLASH - || event == SoundEvents.ENTITY_PLAYER_BIG_FALL - || event == SoundEvents.ENTITY_PLAYER_SMALL_FALL; + return sound == SoundEvents.ENTITY_PLAYER_SWIM + || sound == SoundEvents.ENTITY_PLAYER_SPLASH + || sound == SoundEvents.ENTITY_PLAYER_BIG_FALL + || sound == SoundEvents.ENTITY_PLAYER_SMALL_FALL; }).isPresent(); } @@ -183,15 +186,12 @@ public Identifier getFabricId() { } @Override - public CompletableFuture reload(Synchronizer sync, ResourceManager sender, - Profiler serverProfiler, Profiler clientProfiler, - Executor serverExecutor, Executor clientExecutor) { - return sync.whenPrepared(null).thenRunAsync(() -> { - clientProfiler.startTick(); - clientProfiler.push("Reloading PF Sounds"); + public CompletableFuture reload(Synchronizer sync, ResourceManager sender, Executor serverExecutor, Executor clientExecutor) { + return sync.whenPrepared(Unit.INSTANCE).thenRunAsync(() -> { + Profiler profiler = Profilers.get(); + profiler.push("Reloading PF Sounds"); reloadEverything(sender); - clientProfiler.pop(); - clientProfiler.endTick(); + profiler.pop(); }, clientExecutor); } diff --git a/src/main/java/eu/ha3/presencefootsteps/sound/acoustics/AcousticsPlayer.java b/src/main/java/eu/ha3/presencefootsteps/sound/acoustics/AcousticsPlayer.java index 50b9b12d..bc773095 100644 --- a/src/main/java/eu/ha3/presencefootsteps/sound/acoustics/AcousticsPlayer.java +++ b/src/main/java/eu/ha3/presencefootsteps/sound/acoustics/AcousticsPlayer.java @@ -48,7 +48,7 @@ public void playStep(Association association, State event, Options options) { } soundPlayer.playSound(association.source(), - soundType.getStepSound().getId().toString(), + soundType.getStepSound().id().toString(), soundType.getVolume() * 0.15F, soundType.getPitch(), options diff --git a/src/main/java/eu/ha3/presencefootsteps/sound/generator/TerrestrialStepSoundGenerator.java b/src/main/java/eu/ha3/presencefootsteps/sound/generator/TerrestrialStepSoundGenerator.java index 135f0fb0..ae25a21e 100644 --- a/src/main/java/eu/ha3/presencefootsteps/sound/generator/TerrestrialStepSoundGenerator.java +++ b/src/main/java/eu/ha3/presencefootsteps/sound/generator/TerrestrialStepSoundGenerator.java @@ -1,11 +1,12 @@ package eu.ha3.presencefootsteps.sound.generator; import net.minecraft.client.network.OtherClientPlayerEntity; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.EquippableComponent; import net.minecraft.entity.EquipmentSlot; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.passive.AbstractHorseEntity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.ArmorItem; import net.minecraft.registry.tag.FluidTags; import net.minecraft.util.math.BlockPos; import org.jetbrains.annotations.Nullable; @@ -329,8 +330,10 @@ private void simulateBrushes() { protected void playStep(Association association, State eventType) { if (engine.getConfig().getEnabledFootwear()) { - if (entity.getEquippedStack(EquipmentSlot.FEET).getItem() instanceof ArmorItem bootItem) { - SoundsKey bootSound = engine.getIsolator().primitives().getAssociation(bootItem.getEquipSound().value(), Substrates.DEFAULT); + + EquippableComponent equipable = entity.getEquippedStack(EquipmentSlot.FEET).get(DataComponentTypes.EQUIPPABLE); + if (equipable != null) { + SoundsKey bootSound = engine.getIsolator().primitives().getAssociation(equipable.equipSound().value(), Substrates.DEFAULT); if (bootSound.isEmitter()) { engine.getIsolator().acoustics().playStep(association, eventType, Options.singular("volume_percentage", 0.5F)); engine.getIsolator().acoustics().playAcoustic(entity, bootSound, eventType, Options.EMPTY); diff --git a/src/main/java/eu/ha3/presencefootsteps/world/HeuristicStateLookup.java b/src/main/java/eu/ha3/presencefootsteps/world/HeuristicStateLookup.java index 50542be4..d8bd76bc 100644 --- a/src/main/java/eu/ha3/presencefootsteps/world/HeuristicStateLookup.java +++ b/src/main/java/eu/ha3/presencefootsteps/world/HeuristicStateLookup.java @@ -1,7 +1,9 @@ package eu.ha3.presencefootsteps.world; +import java.util.Arrays; import java.util.Optional; import java.util.function.Function; +import java.util.stream.Stream; import org.jetbrains.annotations.Nullable; @@ -13,16 +15,10 @@ public class HeuristicStateLookup { private final Function> leafBlockCache = Util.memoize(block -> { - String id = Registries.BLOCK.getId(block).getPath(); - - for (String part : id.split("_")) { - Optional leavesBlock = Registries.BLOCK.getOrEmpty(Identifier.of(part + "_leaves")); - if (leavesBlock.isPresent()) { - return leavesBlock; - } - } - - return Optional.empty(); + return Stream.of(Registries.BLOCK.getId(block).getPath()) + .flatMap(id -> Arrays.stream(id.split("_"))) + .flatMap(part -> Registries.BLOCK.getOptionalValue(Identifier.of(part + "_leaves")).stream()) + .findFirst(); }); @Nullable diff --git a/src/main/java/eu/ha3/presencefootsteps/world/LocomotionLookup.java b/src/main/java/eu/ha3/presencefootsteps/world/LocomotionLookup.java index 7285a431..945d4bf5 100644 --- a/src/main/java/eu/ha3/presencefootsteps/world/LocomotionLookup.java +++ b/src/main/java/eu/ha3/presencefootsteps/world/LocomotionLookup.java @@ -9,6 +9,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.SpawnReason; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.registry.Registries; import net.minecraft.sound.BlockSoundGroup; @@ -55,7 +56,7 @@ public void writeToReport(boolean full, JsonObjectWriter writer, Map { Identifier id = EntityType.getId(type); if (full || !contains(id)) { - if (type.create(MinecraftClient.getInstance().world) instanceof LivingEntity) { + if (type.create(MinecraftClient.getInstance().world, SpawnReason.CHUNK_GENERATION) instanceof LivingEntity) { writer.field(id.toString(), values.getOrDefault(id, Locomotion.NONE).name()); } } diff --git a/src/main/java/eu/ha3/presencefootsteps/world/PrimitiveLookup.java b/src/main/java/eu/ha3/presencefootsteps/world/PrimitiveLookup.java index 83f8d9d1..074f8c90 100644 --- a/src/main/java/eu/ha3/presencefootsteps/world/PrimitiveLookup.java +++ b/src/main/java/eu/ha3/presencefootsteps/world/PrimitiveLookup.java @@ -11,7 +11,7 @@ public class PrimitiveLookup extends AbstractSubstrateLookup { @Override protected Identifier getId(SoundEvent key) { - return key.getId(); + return key.id(); } @Override @@ -29,6 +29,6 @@ public static String getSubstrate(BlockSoundGroup group) { } public static String getKey(BlockSoundGroup group) { - return group.getStepSound().getId().toString() + "@" + getSubstrate(group); + return group.getStepSound().id().toString() + "@" + getSubstrate(group); } } diff --git a/src/main/java/eu/ha3/presencefootsteps/world/StateLookup.java b/src/main/java/eu/ha3/presencefootsteps/world/StateLookup.java index 32b0a348..52f63a09 100644 --- a/src/main/java/eu/ha3/presencefootsteps/world/StateLookup.java +++ b/src/main/java/eu/ha3/presencefootsteps/world/StateLookup.java @@ -74,7 +74,7 @@ public void writeToReport(boolean full, JsonObjectWriter writer, Map