mirror of
https://gitlab.com/cable-mc/cobblemon.git
synced 2026-11-05 15:58:53 -05:00
Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41cf6c9efb | ||
|
|
15b73cedb6 | ||
|
|
56e8ed5a92 | ||
|
|
99cfe4f0c3 | ||
|
|
557ace977a | ||
|
|
1ba55b9f90 | ||
|
|
e1960c2b0b | ||
|
|
4bee9412ce | ||
|
|
264c7659f6 | ||
|
|
0c320905e1 | ||
|
|
b92148d0f9 | ||
|
|
6f1ac0c10b | ||
|
|
692d42e626 | ||
|
|
f73e93a5a8 | ||
|
|
21ae3dc9e8 |
No files matched your search
@@ -6,7 +6,6 @@
|
||||
- Added the Partner Mark, which party Pokémon have a very small chance to earn as the player walks, provided they have enough friendship.
|
||||
- Added trades for Saccharine Saplings, Hearty Grains, Chipped Pot, and Masterpiece Teacup to the Wandering Trader.
|
||||
- Added brewing recipe for Throat Spray.
|
||||
- Added official Controlify Support
|
||||
- Added new effects
|
||||
- Mental Restoration: Reduces "Time Since Last Rest" statistic, which controls Insomnia, by half a minute per second per effect level
|
||||
- Negative Effect Cleanse: Removes all negative effects
|
||||
|
||||
@@ -32,10 +32,6 @@ repositories {
|
||||
maven(url = "https://api.modrinth.com/maven")
|
||||
maven(url = "https://maven.neoforged.net/releases")
|
||||
maven(url = "https://maven.gegy.dev")
|
||||
exclusiveContent {
|
||||
forRepository { maven(url = "https://maven.isxander.dev/releases") }
|
||||
filter { includeGroup("dev.isxander") }
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
@@ -66,11 +62,6 @@ dependencies {
|
||||
|
||||
// Unit Testing
|
||||
testImplementation(libs.bundles.unitTesting)
|
||||
|
||||
// Controlify Compat, same as flywheel so we pick one and only use the api
|
||||
modCompileOnlyApi("dev.isxander:controlify:2.4.3+1.21.1-fabric") {
|
||||
isTransitive = false
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.cobblemon.mod.common.duck;
|
||||
|
||||
import net.minecraft.client.sounds.AudioStream;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface SoundBufferLibraryDuck {
|
||||
|
||||
CompletableFuture<AudioStream> getStreamWithLoopPoints(ResourceLocation audioLocation, int loopStart, int loopEnd);
|
||||
|
||||
CompletableFuture<AudioStream> getStreamWithIntro(ResourceLocation introLocation, ResourceLocation endLocation, boolean isLoop);
|
||||
|
||||
CompletableFuture<AudioStream> getStreamWithIntro(ResourceLocation introLocation, ResourceLocation endLocation, int loopStart, int loopEnd);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.cobblemon.mod.common.duck;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
public interface SoundDuck {
|
||||
|
||||
int getLoopStart();
|
||||
|
||||
int getLoopEnd();
|
||||
|
||||
ResourceLocation getIntro();
|
||||
|
||||
void setLoopStart(int startInSamples);
|
||||
|
||||
void setLoopEnd(int endInSamples);
|
||||
|
||||
void setIntro(ResourceLocation intro);
|
||||
|
||||
boolean hasLoopPoints();
|
||||
|
||||
boolean hasIntro();
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.bridges;
|
||||
package com.cobblemon.mod.common.duck;
|
||||
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.sounds.Music;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin {
|
||||
|
||||
/** Used by MusicManager to dispatch the music to play. */
|
||||
@WrapOperation(
|
||||
method = "getSituationalMusic",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/biome/Biome;getBackgroundMusic()Ljava/util/Optional;")
|
||||
)
|
||||
public Optional<Music> getBackgroundMusic(Biome instance, Operation<Optional<Music>> original) {
|
||||
return original.call(instance);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon;
|
||||
import com.cobblemon.mod.common.client.sound.streams.CompoundAudioStream;
|
||||
import com.cobblemon.mod.common.client.sound.streams.LoopPointAudioStream;
|
||||
import com.cobblemon.mod.common.duck.SoundBufferLibraryDuck;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.sounds.AudioStream;
|
||||
import net.minecraft.client.sounds.JOrbisAudioStream;
|
||||
import net.minecraft.client.sounds.LoopingAudioStream;
|
||||
import net.minecraft.client.sounds.SoundBufferLibrary;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
@Mixin(SoundBufferLibrary.class)
|
||||
public class SoundBufferLibraryMixin implements SoundBufferLibraryDuck {
|
||||
|
||||
@Shadow
|
||||
private ResourceProvider resourceManager;
|
||||
|
||||
/**
|
||||
* Creates a LoopPointAudioStream with defined loop points.
|
||||
*
|
||||
* @param audioLocation The audio file to open for stream.
|
||||
* @param loopStart The starting point of the stream's loop.
|
||||
* @param loopEnd The ending point of the stream's loop.
|
||||
*/
|
||||
@Override
|
||||
public CompletableFuture<AudioStream> getStreamWithLoopPoints(ResourceLocation audioLocation, int loopStart, int loopEnd) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
InputStream introStream = this.resourceManager.open(audioLocation);
|
||||
return new LoopPointAudioStream(JOrbisAudioStream::new, introStream, loopStart, loopEnd);
|
||||
} catch (IOException e) {
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
}, Util.nonCriticalIoPool());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CompoundAudioStream from a JOrbisAudioStream intro and LoopPointAudioStream end.
|
||||
*
|
||||
* @param introLocation The audio file to open for the intro stream.
|
||||
* @param endLocation The audio file to open for the end stream.
|
||||
* @param loopStart The starting point of the ending LoopPointAudioStream's loop.
|
||||
* @param loopEnd The ending point of the ending LoopPointAudioStream's loop.
|
||||
*/
|
||||
@Override
|
||||
public CompletableFuture<AudioStream> getStreamWithIntro(ResourceLocation introLocation, ResourceLocation endLocation, int loopStart, int loopEnd) {
|
||||
return createCompoundStream(
|
||||
introLocation,
|
||||
endLocation,
|
||||
(inputStream) -> new LoopPointAudioStream(JOrbisAudioStream::new, inputStream, loopStart, loopEnd)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a CompoundAudioStream from a JOrbisAudioStream intro and a JOrbisAudioStream or LoopingAudioStream end.
|
||||
*
|
||||
* @param introLocation The audio file to open for the intro stream.
|
||||
* @param endLocation The audio file to open for the end stream.
|
||||
* @param isLoop Whether the end stream loops (LoopingAudioStream) or not (JOrbisAudioStream).
|
||||
*/
|
||||
@Override
|
||||
public CompletableFuture<AudioStream> getStreamWithIntro(ResourceLocation introLocation, ResourceLocation endLocation, boolean isLoop) {
|
||||
return createCompoundStream(
|
||||
introLocation,
|
||||
endLocation,
|
||||
!isLoop ? JOrbisAudioStream::new : (inputStream) -> new LoopingAudioStream(JOrbisAudioStream::new, inputStream)
|
||||
);
|
||||
}
|
||||
|
||||
private CompletableFuture<AudioStream> createCompoundStream(ResourceLocation introLocation, ResourceLocation endLocation, LoopingAudioStream.AudioStreamProvider endProvider) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
InputStream introInputStream = this.resourceManager.open(introLocation);
|
||||
InputStream endInputStream = this.resourceManager.open(endLocation);
|
||||
|
||||
AudioStream introStream = new JOrbisAudioStream(introInputStream);
|
||||
AudioStream endStream = endProvider.create(endInputStream);
|
||||
return new CompoundAudioStream(introStream, endStream);
|
||||
} catch (Exception e) {
|
||||
Cobblemon.LOGGER.error(e.getMessage());
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
}, Util.nonCriticalIoPool());
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,24 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon;
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideAttenuationModel;
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideLoopSound;
|
||||
import com.cobblemon.mod.common.client.sound.BattleMusicController;
|
||||
import com.cobblemon.mod.common.duck.ChannelDuck;
|
||||
import com.cobblemon.mod.common.duck.SoundBufferLibraryDuck;
|
||||
import com.cobblemon.mod.common.duck.SoundDuck;
|
||||
import com.cobblemon.mod.common.duck.SoundEngineDuck;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.audio.Channel;
|
||||
import net.minecraft.client.resources.sounds.Sound;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.resources.sounds.TickableSoundInstance;
|
||||
import net.minecraft.client.sounds.AudioStream;
|
||||
import net.minecraft.client.sounds.ChannelAccess;
|
||||
import net.minecraft.client.sounds.SoundBufferLibrary;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
@@ -30,12 +36,10 @@ 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.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Mixin(SoundEngine.class)
|
||||
public abstract class SoundEngineMixin implements SoundEngineDuck {
|
||||
@@ -120,4 +124,23 @@ public abstract class SoundEngineMixin implements SoundEngineDuck {
|
||||
cb.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/** Dispatch custom stream for sounds that have an intro. WrapOperation because the Fabric API has its own Redirect that we don't want to use. */
|
||||
@WrapOperation(method = "play", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sounds/SoundBufferLibrary;getStream(Lnet/minecraft/resources/ResourceLocation;Z)Ljava/util/concurrent/CompletableFuture;"))
|
||||
public CompletableFuture<AudioStream> getStream(SoundBufferLibrary bufferLibrary, ResourceLocation id, boolean looping, Operation<CompletableFuture<AudioStream>> original, SoundInstance soundInstance) {
|
||||
SoundDuck soundDuck = (SoundDuck)soundInstance.getSound();
|
||||
SoundBufferLibraryDuck libraryDuck = (SoundBufferLibraryDuck)bufferLibrary;
|
||||
if (soundDuck.hasIntro() && soundDuck.hasLoopPoints() && looping) {
|
||||
return libraryDuck.getStreamWithIntro(soundDuck.getIntro(), id, soundDuck.getLoopStart(), soundDuck.getLoopEnd());
|
||||
}
|
||||
else if (soundDuck.hasIntro()) {
|
||||
return libraryDuck.getStreamWithIntro(soundDuck.getIntro(), id, looping);
|
||||
}
|
||||
else if (soundDuck.hasLoopPoints() && looping) {
|
||||
return libraryDuck.getStreamWithLoopPoints(id, soundDuck.getLoopStart(), soundDuck.getLoopEnd());
|
||||
}
|
||||
else {
|
||||
return original.call(bufferLibrary, id, looping);
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.duck.SoundDuck;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import net.minecraft.client.resources.sounds.Sound;
|
||||
import net.minecraft.client.resources.sounds.SoundEventRegistrationSerializer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.GsonHelper;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(SoundEventRegistrationSerializer.class)
|
||||
public class SoundEventRegistrationSerializerMixin {
|
||||
|
||||
/** Injects custom fields into Sound resource for loop behavior. */
|
||||
@ModifyReturnValue(method = "getSound", at = @At("RETURN"))
|
||||
private Sound getSound(Sound original, JsonObject json) {
|
||||
int loopStart = GsonHelper.getAsInt(json, "loopStart", 0);
|
||||
int loopEnd = GsonHelper.getAsInt(json, "loopEnd", 0);
|
||||
ResourceLocation intro = ResourceLocation.parse(GsonHelper.getAsString(json, "intro", ""));
|
||||
((SoundDuck)original).setLoopStart(loopStart);
|
||||
((SoundDuck)original).setLoopEnd(loopEnd);
|
||||
((SoundDuck)original).setIntro(intro);
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.duck.SoundDuck;
|
||||
import net.minecraft.client.resources.sounds.Sound;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import static net.minecraft.client.resources.sounds.Sound.SOUND_LISTER;
|
||||
|
||||
@Mixin(Sound.class)
|
||||
public abstract class SoundMixin implements SoundDuck {
|
||||
|
||||
int loopStart = 0;
|
||||
|
||||
int loopEnd = 0;
|
||||
|
||||
ResourceLocation intro = null;
|
||||
|
||||
@Override
|
||||
public ResourceLocation getIntro() {
|
||||
return SOUND_LISTER.idToFile(this.intro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoopStart() {
|
||||
return loopStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLoopEnd() {
|
||||
return loopEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoopStart(int startInSamples) {
|
||||
this.loopStart = startInSamples;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoopEnd(int endInSamples) {
|
||||
this.loopEnd = endInSamples;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIntro(ResourceLocation intro) {
|
||||
this.intro = intro;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLoopPoints() {
|
||||
return (this.loopEnd >= 0 && this.loopStart >= 0) && (this.loopEnd + this.loopStart != 0) && (loopStart < loopEnd || loopStart == 0 || loopEnd == 0);
|
||||
}
|
||||
// this is used to determine if the LoopPointAudioStream is necessary or if the legacy LoopingAudioStream can be used
|
||||
|
||||
@Override
|
||||
public boolean hasIntro() {
|
||||
return this.intro != null && !this.intro.getPath().isBlank();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
|
||||
package com.cobblemon.mod.common.mixin;
|
||||
|
||||
import com.cobblemon.mod.common.bridges.StructureProcessorListBridge;
|
||||
import com.cobblemon.mod.common.duck.StructureProcessorListBridge;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,14 +21,12 @@ import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.mojang.blaze3d.Blaze3D;
|
||||
import kotlin.Pair;
|
||||
import kotlin.jvm.functions.Function4;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.SmoothDouble;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector2d;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -148,12 +146,6 @@ public abstract class MouseHandlerMixin {
|
||||
pokeVehicle.clampPassengerRotation(player);
|
||||
}
|
||||
|
||||
for(Function4<LocalPlayer, Double, Double, Double, Vector2d> rideFun : CobblemonClient.INSTANCE.getRidingTurnInputHandler().values()) {
|
||||
Vector2d vec = rideFun.invoke(player, cursorDeltaX, cursorDeltaY, d);
|
||||
cursorDeltaX = vec.x;
|
||||
cursorDeltaY = vec.y;
|
||||
}
|
||||
|
||||
// If the ride is not orientation controllable then return and perform the normal turnPlayer logic
|
||||
if (!(vehicle instanceof OrientationControllable controllableVehicle) || !controllableVehicle.getOrientationController().isActive()) {
|
||||
xMouseSmoother.reset();
|
||||
|
||||
+3
-4
@@ -24,15 +24,14 @@ import net.minecraft.world.entity.LivingEntity
|
||||
interface EntityQueryRequirement : Requirement {
|
||||
override fun check(pokemon: Pokemon): Boolean {
|
||||
val queriedEntity = pokemon.entity ?: pokemon.getOwnerPlayer() ?: return false
|
||||
return this.check(pokemon, queriedEntity)
|
||||
return this.check(queriedEntity)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given [Pokemon] & [LivingEntity] satisfies the requirement.
|
||||
* Checks if the given [LivingEntity] satisfies the requirement.
|
||||
*
|
||||
* @param pokemon The [Pokemon] being queried.
|
||||
* @param queriedEntity The [LivingEntity] that can be compared in context of a [Level].
|
||||
* @return If the requirement was satisfied.
|
||||
*/
|
||||
fun check(pokemon: Pokemon, queriedEntity: LivingEntity): Boolean
|
||||
fun check(queriedEntity: LivingEntity): Boolean
|
||||
}
|
||||
+6
-8
@@ -22,7 +22,6 @@ import com.cobblemon.mod.common.api.riding.posing.PoseOption
|
||||
import com.cobblemon.mod.common.api.riding.posing.PoseProvider
|
||||
import com.cobblemon.mod.common.api.riding.sound.RideSoundSettingsList
|
||||
import com.cobblemon.mod.common.api.riding.stats.RidingStat
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.entity.PoseType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.blockPositionsAsListRounded
|
||||
@@ -145,12 +144,11 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
|
||||
) {
|
||||
val sprintTimerTickLength = 7 // Emulate vanillas tick timer length
|
||||
var hasDoubleTapped = false
|
||||
val forward = Minecraft.getInstance().player?.input?.up == true
|
||||
|
||||
// If you are not sprinting and you just pressed down and theres no
|
||||
if (!state.forwardHeldLastTick.get() && forward && !state.sprinting.get() && state.sprintTickTimer.get() == 0) {
|
||||
if (!state.forwardHeldLastTick.get() && Minecraft.getInstance().options.keyUp.isDown() && !state.sprinting.get() && state.sprintTickTimer.get() == 0) {
|
||||
state.sprintTickTimer.set(sprintTimerTickLength)
|
||||
} else if (!state.forwardHeldLastTick.get() && forward && state.sprintTickTimer.get() != 0) { // If has double tapped
|
||||
} else if (!state.forwardHeldLastTick.get() && Minecraft.getInstance().options.keyUp.isDown() && state.sprintTickTimer.get() != 0) { // If has double tapped
|
||||
hasDoubleTapped = true
|
||||
}else if(!state.sprinting.get() && state.sprintTickTimer.get() > 0) {
|
||||
state.sprintTickTimer.set(state.sprintTickTimer.get() - 1)
|
||||
@@ -158,9 +156,9 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
|
||||
state.sprintTickTimer.set(0)
|
||||
}
|
||||
|
||||
val tryingToSprint = hasDoubleTapped || CobblemonClient.ridingSprintHandler.any { it.value.invoke() }
|
||||
val tryingToSprint = (Minecraft.getInstance().options.keySprint.isDown() && Minecraft.getInstance().options.keyUp.isDown()) || hasDoubleTapped
|
||||
|
||||
if (state.stamina.get() <= 0.0f || !forward) {
|
||||
if (state.stamina.get() <= 0.0f || !Minecraft.getInstance().options.keyUp.isDown()) {
|
||||
// If stamina runs out or the player is not holding forward then stop sprinting
|
||||
state.sprinting.set(false)
|
||||
if (state.stamina.get() <= 0.0f) {
|
||||
@@ -174,8 +172,8 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
|
||||
state.sprinting.set(true)
|
||||
}
|
||||
|
||||
// Take note of whether forward was held last tick
|
||||
state.forwardHeldLastTick.set(forward)
|
||||
// Take not of whether forward was held last tick
|
||||
state.forwardHeldLastTick.set(Minecraft.getInstance().options.keyUp.isDown())
|
||||
}
|
||||
|
||||
fun tickStamina(
|
||||
|
||||
@@ -207,6 +207,7 @@ object BattleBuilder {
|
||||
val side1Theme = players[0].getBattleTheme()
|
||||
val side2Theme = players[2].getBattleTheme()
|
||||
|
||||
// the music that's played for a side is driven by the opposite leader's theme
|
||||
side1Actors.forEach { it.battleTheme = side2Theme }
|
||||
side2Actors.forEach { it.battleTheme = side1Theme }
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ import com.cobblemon.mod.common.entity.boat.CobblemonBoatType
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.platform.events.PlatformEvents
|
||||
import com.cobblemon.mod.common.pokedex.scanner.PokedexUsageContext
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.cobblemon.mod.common.util.isLookingAt
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.color.block.BlockColor
|
||||
@@ -84,19 +83,16 @@ import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.model.BoatModel
|
||||
import net.minecraft.client.model.ChestBoatModel
|
||||
import net.minecraft.client.model.PlayerModel
|
||||
import net.minecraft.client.player.LocalPlayer
|
||||
import net.minecraft.client.renderer.RenderType
|
||||
import net.minecraft.client.renderer.blockentity.HangingSignRenderer
|
||||
import net.minecraft.client.renderer.blockentity.SignRenderer
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer
|
||||
import net.minecraft.client.renderer.entity.LivingEntityRenderer
|
||||
import net.minecraft.client.resources.PlayerSkin
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.packs.resources.ResourceManager
|
||||
import net.minecraft.world.InteractionHand
|
||||
import net.minecraft.world.entity.player.Player
|
||||
import net.minecraft.world.phys.AABB
|
||||
import org.joml.Vector2d
|
||||
|
||||
object CobblemonClient {
|
||||
|
||||
@@ -116,8 +112,6 @@ object CobblemonClient {
|
||||
val battleOverlay: BattleOverlay by lazy { BattleOverlay() }
|
||||
val pokedexUsageContext: PokedexUsageContext by lazy { PokedexUsageContext() }
|
||||
val rideControlsOverlay: RideControlsOverlay by lazy { RideControlsOverlay() }
|
||||
val ridingTurnInputHandler: MutableMap<ResourceLocation, (LocalPlayer, Double, Double, Double) -> Vector2d> = mutableMapOf()
|
||||
val ridingSprintHandler: MutableMap<ResourceLocation, () -> Boolean> = mutableMapOf()
|
||||
|
||||
fun onLogin() {
|
||||
clientPlayerData = ClientGeneralPlayerData()
|
||||
@@ -198,11 +192,10 @@ object CobblemonClient {
|
||||
}
|
||||
}
|
||||
}
|
||||
BattleMusicController.onTick()
|
||||
ClientPlayerIcon.onTick()
|
||||
PartyOverlayDataControl.tick(event.client.isPaused)
|
||||
}
|
||||
|
||||
ridingSprintHandler.put(cobblemonResource("normal")) { Minecraft.getInstance().options.keySprint.isDown }
|
||||
}
|
||||
|
||||
private fun registerTooltipManagers() {
|
||||
|
||||
+2
-2
@@ -74,12 +74,12 @@ class InteractWheelButton(
|
||||
y = y,
|
||||
width = width,
|
||||
height = height,
|
||||
vOffset = if ((isHovered(mouseX.toFloat(), mouseY.toFloat()) || isFocused) && isEnabled) height else 0,
|
||||
vOffset = if (isHovered(mouseX.toFloat(), mouseY.toFloat()) && isEnabled) height else 0,
|
||||
textureHeight = height * 2,
|
||||
alpha = if (isEnabled) 1f else 0.4F
|
||||
)
|
||||
|
||||
if(isEnabled && (isHovered(mouseX.toFloat(), mouseY.toFloat()) || isFocused)){
|
||||
if(isEnabled && isHovered(mouseX.toFloat(), mouseY.toFloat())){
|
||||
tooltipText?.let {
|
||||
context.renderTooltip(Minecraft.getInstance().font, Component.translatable(it), mouseX, mouseY)
|
||||
}
|
||||
|
||||
+4
-4
@@ -23,9 +23,9 @@ class InteractWheelGUI(private val options: Multimap<Orientation, InteractWheelO
|
||||
private val backgroundResource = cobblemonResource("textures/gui/interact/interact_wheel_base.png")
|
||||
}
|
||||
|
||||
val buttons = mutableListOf<InteractWheelButton>()
|
||||
var maxPage = 1
|
||||
var currentPage = 0
|
||||
private val buttons = mutableListOf<InteractWheelButton>()
|
||||
private var maxPage = 1
|
||||
private var currentPage = 0
|
||||
override fun renderBlurredBackground(delta: Float) { }
|
||||
override fun renderMenuBackground(context: GuiGraphics) {}
|
||||
|
||||
@@ -77,7 +77,7 @@ class InteractWheelGUI(private val options: Multimap<Orientation, InteractWheelO
|
||||
currentPage = page
|
||||
buttons.forEach { removeWidget(it) }
|
||||
buttons.clear()
|
||||
val orientations = Orientation.entries.toTypedArray()
|
||||
val orientations = Orientation.values()
|
||||
orientations.forEach { orientation ->
|
||||
val option = options[orientation].toList().getOrNull(page)
|
||||
addButton(orientation, option)
|
||||
|
||||
-319
@@ -1,319 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.integration.controlify
|
||||
|
||||
import com.cobblemon.mod.common.CobblemonItems
|
||||
import com.cobblemon.mod.common.OrientationControllable
|
||||
import com.cobblemon.mod.common.client.CobblemonClient
|
||||
import com.cobblemon.mod.common.client.CobblemonClient.ridingTurnInputHandler
|
||||
import com.cobblemon.mod.common.client.gui.battle.BattleGUI
|
||||
import com.cobblemon.mod.common.client.gui.behaviour.BehaviourEditorScreen
|
||||
import com.cobblemon.mod.common.client.gui.config.CobblemonConfigScreen
|
||||
import com.cobblemon.mod.common.client.gui.cookingpot.CookingPotScreen
|
||||
import com.cobblemon.mod.common.client.gui.debug.riding.RidingStatsDebugGUI
|
||||
import com.cobblemon.mod.common.client.gui.dialogue.DialogueScreen
|
||||
import com.cobblemon.mod.common.client.gui.interact.battleRequest.BattleConfigureGUI
|
||||
import com.cobblemon.mod.common.client.gui.interact.moveselect.MoveSelectGUI
|
||||
import com.cobblemon.mod.common.client.gui.interact.partyselect.PartySelectGUI
|
||||
import com.cobblemon.mod.common.client.gui.interact.wheel.InteractWheelGUI
|
||||
import com.cobblemon.mod.common.client.gui.npc.NPCEditorScreen
|
||||
import com.cobblemon.mod.common.client.gui.pc.PCGUI
|
||||
import com.cobblemon.mod.common.client.gui.pokedex.PokedexGUI
|
||||
import com.cobblemon.mod.common.client.gui.pokenav.PokeNav
|
||||
import com.cobblemon.mod.common.client.gui.snapshots.SnapshotWarningScreen
|
||||
import com.cobblemon.mod.common.client.gui.startselection.StarterSelectionScreen
|
||||
import com.cobblemon.mod.common.client.gui.summary.Summary
|
||||
import com.cobblemon.mod.common.client.gui.trade.TradeGUI
|
||||
import com.cobblemon.mod.common.client.integration.controlify.gui.CobblemonGUIProcessor
|
||||
import com.cobblemon.mod.common.client.integration.controlify.gui.InteractWheelProcessor
|
||||
import com.cobblemon.mod.common.client.keybind.CobblemonKeyBinds
|
||||
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import dev.isxander.controlify.api.ControlifyApi
|
||||
import dev.isxander.controlify.api.bind.ControlifyBindApi
|
||||
import dev.isxander.controlify.api.bind.InputBindingBuilder
|
||||
import dev.isxander.controlify.api.bind.InputBindingSupplier
|
||||
import dev.isxander.controlify.api.entrypoint.ControlifyEntrypoint
|
||||
import dev.isxander.controlify.api.entrypoint.InitContext
|
||||
import dev.isxander.controlify.api.entrypoint.PreInitContext
|
||||
import dev.isxander.controlify.bindings.BindContext
|
||||
import dev.isxander.controlify.bindings.ControlifyBindings
|
||||
import dev.isxander.controlify.bindings.RadialIcons
|
||||
import dev.isxander.controlify.screenop.ScreenProcessorFactory
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
import net.minecraft.client.player.LocalPlayer
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.Items
|
||||
import org.joml.Vector2d
|
||||
import kotlin.jvm.optionals.getOrNull
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
|
||||
class CobblemonControlifyEntrypoint : ControlifyEntrypoint {
|
||||
override fun onControlifyInit(initContext: InitContext) {
|
||||
ridingTurnInputHandler.put(
|
||||
cobblemonResource("compat.controlify"),
|
||||
({ localPlayer: LocalPlayer, xDelta: Double, yDelta: Double, deltaTime: Double ->
|
||||
val vec = Vector2d(xDelta, yDelta)
|
||||
val controller = initContext.controlify().currentController.getOrNull()
|
||||
val vehicle = localPlayer.vehicle
|
||||
if (vehicle is OrientationControllable && vehicle.orientationController.isActive() && initContext.controlify().currentInputMode().isController && controller != null){
|
||||
val multiplier = deltaTime * 1500
|
||||
val config = controller.input().getOrNull()?.config()?.config()
|
||||
val vSensitivity = config?.vLookSensitivity ?: 0.9f
|
||||
val hSensitivity = config?.hLookSensitivity ?: 1f
|
||||
|
||||
// Should never be null once bindings are set
|
||||
var vAxis = (RIDING_DOWN!!.on(controller).analogueNow() - RIDING_UP!!.on(controller).analogueNow()).toDouble()
|
||||
var hAxis = (RIDING_RIGHT!!.on(controller).analogueNow() - RIDING_LEFT!!.on(controller).analogueNow()).toDouble()
|
||||
|
||||
vAxis *= multiplier * vSensitivity
|
||||
hAxis *= multiplier * hSensitivity
|
||||
vec.x = hAxis
|
||||
vec.y = vAxis
|
||||
}
|
||||
vec
|
||||
})
|
||||
)
|
||||
|
||||
CobblemonClient.ridingSprintHandler.put(
|
||||
cobblemonResource("compat.controlify")
|
||||
) {
|
||||
initContext.controlify().currentController.getOrNull()?.let { ControlifyBindings.SPRINT.on(it).digitalNow() } == true
|
||||
}
|
||||
}
|
||||
|
||||
override fun onControlifyPreInit(initContext: PreInitContext) {
|
||||
val bindings = ControlifyBindApi.get()
|
||||
bindings.registerBindContext(ORIENTATION_CONTROLLER_ACTIVE)
|
||||
|
||||
RIDING_UP =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_up"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.riding_up"))
|
||||
.allowedContexts(ORIENTATION_CONTROLLER_ACTIVE, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
RIDING_DOWN =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_down"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.riding_down"))
|
||||
.allowedContexts(ORIENTATION_CONTROLLER_ACTIVE, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
RIDING_LEFT =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_left"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.riding_left"))
|
||||
.allowedContexts(ORIENTATION_CONTROLLER_ACTIVE, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
RIDING_RIGHT =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_right"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.riding_right"))
|
||||
.allowedContexts(ORIENTATION_CONTROLLER_ACTIVE, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
HIDE_PARTY =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("hide_party"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.hideparty"))
|
||||
.allowedContexts(BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.getItem(Items.BARRIER))
|
||||
.addKeyCorrelation(CobblemonKeyBinds.HIDE_PARTY)
|
||||
.keyEmulation(CobblemonKeyBinds.HIDE_PARTY)
|
||||
}
|
||||
|
||||
SUMMARY =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("summary"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.summary"))
|
||||
.allowedContexts(BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.getItem(CobblemonItems.GREAT_BALL))
|
||||
.addKeyCorrelation(CobblemonKeyBinds.SUMMARY)
|
||||
.keyEmulation(CobblemonKeyBinds.SUMMARY)
|
||||
}
|
||||
|
||||
PARTY_OVERLAY_DOWN =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("party_overlay_down"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.downshiftparty"))
|
||||
.allowedContexts(HAS_POKEMON, BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.EMPTY)
|
||||
.addKeyCorrelation(CobblemonKeyBinds.PARTY_OVERLAY_DOWN)
|
||||
.keyEmulation(CobblemonKeyBinds.PARTY_OVERLAY_DOWN)
|
||||
}
|
||||
|
||||
PARTY_OVERLAY_UP =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("party_overlay_up"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.upshiftparty"))
|
||||
.allowedContexts(HAS_POKEMON, BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.EMPTY)
|
||||
.addKeyCorrelation(CobblemonKeyBinds.PARTY_OVERLAY_UP)
|
||||
.keyEmulation(CobblemonKeyBinds.PARTY_OVERLAY_DOWN)
|
||||
}
|
||||
|
||||
SEND_OUT_POKEMON =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("send_out_pokemon"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.throwpartypokemon"))
|
||||
.allowedContexts(HAS_POKEMON, BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.getItem(CobblemonItems.POKE_BALL))
|
||||
.addKeyCorrelation(CobblemonKeyBinds.SEND_OUT_POKEMON)
|
||||
.keyEmulation(CobblemonKeyBinds.SEND_OUT_POKEMON)
|
||||
}
|
||||
|
||||
|
||||
RIDING_FREELOOK =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("riding_freelook"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("key.cobblemon.ridingfreelook"))
|
||||
.allowedContexts(RIDING_POKEMON, BindContext.IN_GAME)
|
||||
.radialCandidate(RadialIcons.EMPTY)
|
||||
.addKeyCorrelation(CobblemonKeyBinds.RIDING_FREELOOK)
|
||||
.keyEmulation(CobblemonKeyBinds.RIDING_FREELOOK)
|
||||
}
|
||||
|
||||
INTERACT_WHEEL_UP_AXIS =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("interact_wheel_up"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.interact_wheel_up"))
|
||||
.allowedContexts(INTERACT_WHEEL_SCREEN, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
INTERACT_WHEEL_DOWN_AXIS =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("interact_wheel_down"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.interact_wheel_down"))
|
||||
.allowedContexts(INTERACT_WHEEL_SCREEN, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
INTERACT_WHEEL_RIGHT_AXIS =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("interact_wheel_right"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.interact_wheel_right"))
|
||||
.allowedContexts(INTERACT_WHEEL_SCREEN, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
INTERACT_WHEEL_LEFT_AXIS =
|
||||
bindings.registerBinding { builder: InputBindingBuilder ->
|
||||
builder
|
||||
.id(cobblemonResource("interact_wheel_left"))
|
||||
.category(Component.translatable("controlify.category.cobblemon.cobblemon"))
|
||||
.name(Component.translatable("controlify.bind.cobblemon.interact_wheel_left"))
|
||||
.allowedContexts(INTERACT_WHEEL_SCREEN, BindContext.IN_GAME)
|
||||
}
|
||||
|
||||
|
||||
addProcessor(InteractWheelGUI::class, InteractWheelProcessor::class)
|
||||
// This is the lazy way to do all of these (just using the vmouse), if someone with more time and dedication did this that would be better
|
||||
addProcessor(BattleGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(BehaviourEditorScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(CobblemonConfigScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(CookingPotScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(RidingStatsDebugGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(DialogueScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(BattleConfigureGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(MoveSelectGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(PartySelectGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(NPCEditorScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(PCGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(PokedexGUI::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(PokeNav::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(SnapshotWarningScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(StarterSelectionScreen::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(Summary::class, CobblemonGUIProcessor::class)
|
||||
addProcessor(TradeGUI::class, CobblemonGUIProcessor::class)
|
||||
}
|
||||
|
||||
override fun onControllersDiscovered(controlifyApi: ControlifyApi) {
|
||||
}
|
||||
|
||||
// This is jank, but I did it after I got my wisdom teeth extracted so tbh I think I did good enough, but I won't be offended if someone changes it to something sane.
|
||||
fun addProcessor(t: KClass<out Screen>, processorClazz: KClass<out CobblemonGUIProcessor>) {
|
||||
ScreenProcessorFactory.registerProvider(t.java) {
|
||||
processorClazz.primaryConstructor?.call(it)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
var RIDING_UP: InputBindingSupplier? = null
|
||||
var RIDING_DOWN: InputBindingSupplier? = null
|
||||
var RIDING_RIGHT: InputBindingSupplier? = null
|
||||
var RIDING_LEFT: InputBindingSupplier? = null
|
||||
var HIDE_PARTY: InputBindingSupplier? = null
|
||||
var SUMMARY: InputBindingSupplier? = null
|
||||
var PARTY_OVERLAY_DOWN: InputBindingSupplier? = null
|
||||
var PARTY_OVERLAY_UP: InputBindingSupplier? = null
|
||||
var SEND_OUT_POKEMON: InputBindingSupplier? = null
|
||||
var RIDING_FREELOOK: InputBindingSupplier? = null
|
||||
var INTERACT_WHEEL_UP_AXIS: InputBindingSupplier? = null
|
||||
var INTERACT_WHEEL_DOWN_AXIS: InputBindingSupplier? = null
|
||||
var INTERACT_WHEEL_LEFT_AXIS: InputBindingSupplier? = null
|
||||
var INTERACT_WHEEL_RIGHT_AXIS: InputBindingSupplier? = null
|
||||
|
||||
val RIDING_POKEMON: BindContext = BindContext(
|
||||
cobblemonResource("riding"),
|
||||
{ mc: Minecraft ->
|
||||
mc.player?.vehicle is PokemonEntity
|
||||
}
|
||||
)
|
||||
|
||||
val ORIENTATION_CONTROLLER_ACTIVE: BindContext = BindContext(
|
||||
cobblemonResource("orientation_controller_active"),
|
||||
{ mc: Minecraft ->
|
||||
val localPlayer = mc.player
|
||||
if (localPlayer == null) return@BindContext false
|
||||
val vehicle = localPlayer.vehicle
|
||||
vehicle is OrientationControllable && vehicle.getOrientationController().isActive()
|
||||
}
|
||||
)
|
||||
|
||||
val HAS_POKEMON: BindContext = BindContext(
|
||||
cobblemonResource("has_pokemon"),
|
||||
{mc: Minecraft ->
|
||||
!CobblemonClient.storage.party.isEmpty()
|
||||
}
|
||||
)
|
||||
|
||||
val INTERACT_WHEEL_SCREEN: BindContext = BindContext(
|
||||
cobblemonResource("wheel_screen"),
|
||||
{ it.screen is InteractWheelGUI}
|
||||
)
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.integration.controlify.gui
|
||||
|
||||
import com.cobblemon.mod.common.client.integration.controlify.gui.component.ControllerComponentManager
|
||||
import dev.isxander.controlify.screenop.ScreenProcessor
|
||||
import dev.isxander.controlify.virtualmouse.VirtualMouseBehaviour
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
|
||||
open class CobblemonGUIProcessor(open val screen: Screen) : ScreenProcessor<Screen>(screen) {
|
||||
val controllerComponentManager = ControllerComponentManager(screen)
|
||||
|
||||
override fun virtualMouseBehaviour(): VirtualMouseBehaviour {
|
||||
return VirtualMouseBehaviour.DISABLED
|
||||
}
|
||||
}
|
||||
-70
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Cobblemon Contributors
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
package com.cobblemon.mod.common.client.integration.controlify.gui
|
||||
|
||||
import com.cobblemon.mod.common.client.gui.interact.wheel.InteractWheelGUI
|
||||
import com.cobblemon.mod.common.client.integration.controlify.CobblemonControlifyEntrypoint
|
||||
import dev.isxander.controlify.controller.ControllerEntity
|
||||
import dev.isxander.controlify.controller.haptic.HapticEffects
|
||||
import dev.isxander.controlify.screenop.ScreenControllerEventListener
|
||||
import net.minecraft.util.Mth
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
// Lots of this is taken from the RadialMenu in Controlify to make this screen feel consistent with it
|
||||
class InteractWheelProcessor(override val screen: InteractWheelGUI) : CobblemonGUIProcessor(screen), ScreenControllerEventListener {
|
||||
private var selectedButton = -1
|
||||
private var idleTicks: Int = 0
|
||||
private var idleTicksTimeout: Int? = null
|
||||
|
||||
init {
|
||||
addEventListener(this)
|
||||
}
|
||||
|
||||
override fun onControllerInput(controller: ControllerEntity) {
|
||||
if (idleTicksTimeout == null) {
|
||||
idleTicksTimeout = controller.input().orElseThrow().confObj().radialButtonFocusTimeoutTicks
|
||||
}
|
||||
|
||||
// If not created from entrypoint then something is very wrong
|
||||
val x = CobblemonControlifyEntrypoint.INTERACT_WHEEL_RIGHT_AXIS!!.on(controller).analogueNow()
|
||||
- CobblemonControlifyEntrypoint.INTERACT_WHEEL_LEFT_AXIS!!.on(controller).analogueNow()
|
||||
val y = CobblemonControlifyEntrypoint.INTERACT_WHEEL_DOWN_AXIS!!.on(controller).analogueNow()
|
||||
- CobblemonControlifyEntrypoint.INTERACT_WHEEL_UP_AXIS!!.on(controller).analogueNow()
|
||||
val threshold = controller.input().orElseThrow().config().config().buttonActivationThreshold
|
||||
|
||||
if (abs(x) >= threshold || abs(y) >= threshold) {
|
||||
val angle = Mth.wrapDegrees(Mth.RAD_TO_DEG * Mth.atan2(y.toDouble(), x.toDouble()) - 90f) + 180f
|
||||
val buttonCount = screen.buttons.size
|
||||
val each = 360f / buttonCount
|
||||
|
||||
val newSelected = Mth.floor((angle + each / 2f) / each) % buttonCount
|
||||
if (newSelected != selectedButton) {
|
||||
selectedButton = newSelected
|
||||
controller.hdHaptics().ifPresent { haptics -> haptics.playHaptic(HapticEffects.NAVIGATE) }
|
||||
}
|
||||
|
||||
for (button in 0..<buttonCount) {
|
||||
val selected = button == selectedButton
|
||||
screen.buttons[button].isFocused = selected
|
||||
}
|
||||
|
||||
idleTicks = 0
|
||||
} else {
|
||||
idleTicks = idleTicks+ 1
|
||||
if (idleTicks>= idleTicksTimeout!! && selectedButton != -1) {
|
||||
selectedButton = -1
|
||||
for (button in screen.buttons) {
|
||||
button.isFocused = false
|
||||
}
|
||||
controller.hdHaptics().ifPresent { haptics -> haptics.playHaptic(HapticEffects.NAVIGATE) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.controlify.gui.component
|
||||
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
|
||||
class ControllerComponent<T : Screen> {
|
||||
var left: (T) -> ControllerComponent<T>? = { null }
|
||||
var right: (T) -> ControllerComponent<T>? = { null }
|
||||
var up: (T) -> ControllerComponent<T>? = { null }
|
||||
var down: (T) -> ControllerComponent<T>? = { null }
|
||||
|
||||
var associatedGUIElement: GuiEventListener? = null
|
||||
|
||||
fun pairLeft(leftComponent: ControllerComponent<T>) {
|
||||
left = { leftComponent }
|
||||
leftComponent.right = { this }
|
||||
}
|
||||
|
||||
fun pairRight(rightComponent: ControllerComponent<T>) {
|
||||
right = { rightComponent }
|
||||
rightComponent.left = { this }
|
||||
}
|
||||
|
||||
fun pairUp(upComponent: ControllerComponent<T>) {
|
||||
up = { upComponent }
|
||||
upComponent.down = { this }
|
||||
}
|
||||
|
||||
fun pairDown(downComponent: ControllerComponent<T>) {
|
||||
down = { downComponent }
|
||||
downComponent.up = { this }
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package com.cobblemon.mod.common.client.integration.controlify.gui.component
|
||||
|
||||
import net.minecraft.client.gui.screens.Screen
|
||||
|
||||
class ControllerComponentManager<T : Screen>(val screen: T) {
|
||||
var focused: ControllerComponent<T>?
|
||||
get() = focused
|
||||
set(value) {
|
||||
focused = value
|
||||
focused?.associatedGUIElement?.let { screen.focused = it }
|
||||
}
|
||||
|
||||
fun left() = focused?.left?.invoke(screen)?.let { focused = it }
|
||||
fun right() = focused?.right?.invoke(screen)?.let { focused = it }
|
||||
fun up() = focused?.up?.invoke(screen)?.let { focused = it }
|
||||
fun down() = focused?.down?.invoke(screen)?.let { focused = it }
|
||||
}
|
||||
+6
-1
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.api.net.ClientNetworkPacketHandler
|
||||
import com.cobblemon.mod.common.client.sound.BattleMusicController
|
||||
import com.cobblemon.mod.common.client.sound.instances.BattleMusicInstance
|
||||
import com.cobblemon.mod.common.net.messages.client.battle.BattleMusicPacket
|
||||
import com.cobblemon.mod.common.ost.BattleThemes
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.sounds.SoundEvent
|
||||
|
||||
@@ -26,8 +27,12 @@ object BattleMusicHandler : ClientNetworkPacketHandler<BattleMusicPacket> {
|
||||
override fun handle(packet: BattleMusicPacket, client: Minecraft) {
|
||||
val soundManager = client.soundManager
|
||||
val currMusic = BattleMusicController.music
|
||||
|
||||
// TODO to support legacy behavior, use ResourceLocation for BattleTrackConfig THEN SoundEvent
|
||||
|
||||
val newMusic = packet.music?.let {
|
||||
val event = SoundEvent.createVariableRangeEvent(it)
|
||||
val location = BattleThemes.getByIdentifier(it)?.dispatchTrack()? ?: it
|
||||
val event = SoundEvent.createVariableRangeEvent(location)
|
||||
BattleMusicInstance(event, packet.volume, packet.pitch)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
package com.cobblemon.mod.common.client.sound
|
||||
|
||||
import com.cobblemon.mod.common.client.sound.instances.BattleMusicInstance
|
||||
import com.cobblemon.mod.common.ost.BattleMusicCue
|
||||
import com.cobblemon.mod.common.ost.BattleThemeConfig
|
||||
import com.cobblemon.mod.common.util.pauseSounds
|
||||
import com.cobblemon.mod.common.util.resumeSounds
|
||||
import net.minecraft.client.Minecraft
|
||||
@@ -23,6 +25,15 @@ import net.minecraft.sounds.SoundEvents
|
||||
*/
|
||||
object BattleMusicController {
|
||||
|
||||
/** The active [BattleThemeConfig] for dispatching [BattleMusicInstance]s and subscribing to [BattleMusicCue]s. */
|
||||
private var config: BattleThemeConfig? = null
|
||||
|
||||
/** The queued [BattleMusicCue]. */
|
||||
private var queuedCue: BattleMusicCue? = null
|
||||
|
||||
/** The active [BattleMusicCue]. */
|
||||
private var activeCue: BattleMusicCue? = null
|
||||
|
||||
/** The last [BattleMusicInstance] played. */
|
||||
var music = BattleMusicInstance(SoundEvents.EMPTY, 0.0F, 0.0F)
|
||||
private set
|
||||
@@ -56,4 +67,13 @@ object BattleMusicController {
|
||||
/** Fade out and end the current [BattleMusicInstance]. */
|
||||
fun endMusic() = music.setFade()
|
||||
|
||||
/** Processes the [queuedCue]. */
|
||||
private fun processCue(cue: BattleMusicCue) {
|
||||
|
||||
}
|
||||
|
||||
/** */
|
||||
fun onTick() {
|
||||
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.cobblemon.mod.common.client.sound.streams
|
||||
|
||||
import net.minecraft.client.sounds.AudioStream
|
||||
import java.nio.ByteBuffer
|
||||
import javax.sound.sampled.AudioFormat
|
||||
import kotlin.jvm.Throws
|
||||
|
||||
/**
|
||||
* An [AudioStream] composed of multiple streams stitched together.
|
||||
*
|
||||
* Bytes of audio are read according to the active stream's implementation of [AudioStream.read].
|
||||
*
|
||||
* @param streams The [AudioStream]s to chain sequentially. Each stream must share the same [AudioFormat].
|
||||
*
|
||||
* @author Segfault Guy
|
||||
* @since October 19th, 2025
|
||||
*/
|
||||
class CompoundAudioStream @Throws(IllegalArgumentException::class) constructor(vararg streams: AudioStream): AudioStream {
|
||||
|
||||
private val streams = streams.iterator()
|
||||
|
||||
/** The [AudioStream] currently playing. */
|
||||
private var runningStream: AudioStream = this.streams.next()
|
||||
|
||||
private val format = this.runningStream.format
|
||||
|
||||
override fun getFormat() = format
|
||||
|
||||
init {
|
||||
/* Enqueuing buffers of different formats to the same source is not permissible in OpenAL 1.1 standard. */
|
||||
streams.filterNot { runningStream.format.matches(it.format) }.takeIf { it.isNotEmpty() }?.let { incompatibleStreams ->
|
||||
val message = StringBuilder("Cannot compose CompoundAudioStream from streams of different formats:\n${runningStream.format}")
|
||||
incompatibleStreams.forEach {
|
||||
message.append("\n${it.format}")
|
||||
}
|
||||
throw IllegalArgumentException(message.toString())
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads [size] bytes of PCM, from the current [runningStream], for 1 second worth of audio. */
|
||||
override fun read(size: Int): ByteBuffer? {
|
||||
var buffer = this.runningStream.read(size)
|
||||
if (!buffer.hasRemaining() && this.streams.hasNext()) {
|
||||
this.runningStream.close()
|
||||
this.runningStream = this.streams.next()
|
||||
buffer = this.runningStream.read(size)
|
||||
}
|
||||
return buffer // it's fine if the buffer is not completely full - the stream will sound seamless
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
this.runningStream.close()
|
||||
while (streams.hasNext()) streams.next().close()
|
||||
}
|
||||
}
|
||||
+286
@@ -0,0 +1,286 @@
|
||||
package com.cobblemon.mod.common.client.sound.streams
|
||||
|
||||
import com.cobblemon.mod.common.Cobblemon
|
||||
import com.mojang.blaze3d.audio.Channel
|
||||
import net.minecraft.Util
|
||||
import net.minecraft.client.sounds.AudioStream
|
||||
import net.minecraft.client.sounds.LoopingAudioStream
|
||||
import org.lwjgl.BufferUtils
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.nio.ByteBuffer
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import javax.sound.sampled.AudioFormat
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* An [AudioStream] divided into an intro substream and a loop substream, determined by loop points provided with the Sound resource.
|
||||
*
|
||||
* Similar to [LoopingAudioStream], the loop will play indefinitely until stopped.
|
||||
*
|
||||
* @param provider Provider for creating the internal [AudioStream] that decodes the audio.
|
||||
* @param primaryInputStream The initial [InputStream] of the encoded audio to play.
|
||||
* @param loopStart The starting point of the main audio loop in SAMPLES. If 0, loop will run from start until the [loopEnd].
|
||||
* @param loopEnd The ending point of the main audio loop in SAMPLES. If 0, loop will run to completion.
|
||||
*
|
||||
* @author Segfault Guy
|
||||
* @since October 19th, 2025
|
||||
*/
|
||||
class LoopPointAudioStream @Throws(IllegalArgumentException::class) constructor(
|
||||
private val provider: LoopingAudioStream.AudioStreamProvider,
|
||||
primaryInputStream: InputStream,
|
||||
loopStart: Int = 0,
|
||||
loopEnd: Int = 0
|
||||
): AudioStream {
|
||||
|
||||
private val DEBUG_FLAG = true
|
||||
|
||||
/** Amount of buffers of decoded PCM, from the start of the loop, to cache. */
|
||||
private val CACHE_LIMIT = Channel.QUEUED_BUFFER_COUNT // CACHE_LIMIT matches the number of buffers pre-read before feeding to OpenAL
|
||||
|
||||
/** Buffers of PCM that start the loop. */
|
||||
private val bufferCache = mutableListOf<ByteBuffer>() // cache size: 4 buffers, each of size ~176400 (70kb of cache) which is fine
|
||||
|
||||
/** The total number of bytes saved in the [bufferCache]. */
|
||||
private var cacheSize = 0
|
||||
|
||||
/** The number of buffers read from the [bufferCache] */
|
||||
private var bufferCounter = 0
|
||||
|
||||
/** The bytes bytween the end of the cache and the start of the rewinded [decoderStream]. */
|
||||
private var preliminaryBuffer: ByteBuffer? = null
|
||||
|
||||
/** Whether the [preliminaryBuffer] has been read on this pass. */
|
||||
private var readPrem: Boolean = false
|
||||
|
||||
/** The OGG Vorbis. This is encoded audio. */
|
||||
private lateinit var encodedStream: BufferedInputStream
|
||||
|
||||
/** The Vorbis decoder. This decodes PCM from the [encodedStream] on calls to [AudioStream.read]. */
|
||||
private lateinit var decoderStream: AudioStream
|
||||
|
||||
/** The starting point of the loop in BYTES. */
|
||||
private var loopStart by Delegates.notNull<Int>()
|
||||
|
||||
/** The ending point of the loop in BYTES. */
|
||||
private var loopEnd by Delegates.notNull<Int>()
|
||||
|
||||
/** Whether this is the first pass of the [encodedStream] and we haven't looped yet. */
|
||||
private var firstPass = true
|
||||
|
||||
/** Whether [decoderStream] has been rewinded to [loopStart]. */
|
||||
private var loopPrepared = false
|
||||
|
||||
/** The total number of bytes that have been read from the decoded stream. */
|
||||
private var runningRead = 0
|
||||
|
||||
init {
|
||||
if (loopStart > 0 && loopEnd > 0 && loopEnd < loopStart) throw IllegalArgumentException("Invalid loop points: non-zero end precedes non-zero start")
|
||||
if (loopStart < 0 || loopEnd < 0) throw IllegalArgumentException("Invalid loop points: only non-negative values allowed")
|
||||
|
||||
this.encodedStream = BufferedInputStream(primaryInputStream)
|
||||
this.encodedStream.mark(Int.Companion.MAX_VALUE)
|
||||
this.buildDecoderStream()
|
||||
|
||||
this.loopStart = this.samplesToBytes(loopStart)
|
||||
this.loopEnd = this.samplesToBytes(loopEnd)
|
||||
}
|
||||
|
||||
override fun getFormat(): AudioFormat? {
|
||||
return this.decoderStream.format
|
||||
}
|
||||
|
||||
/** Reads 1 second worth of PCM (bytes) for an OpenAL buffer (this will be AT LEAST 176400 bytes for stereo audio formats) */
|
||||
override fun read(size: Int): ByteBuffer? {
|
||||
|
||||
// if decoderStream has not finished rewinding, there's a problem
|
||||
if (!this.firstPass && !this.loopPrepared) {
|
||||
Cobblemon.LOGGER.warn("Decoder not rewinded!")
|
||||
}
|
||||
|
||||
this.debug("read " + size + " | runningRead: " + this.runningRead + " | loopStart: " + this.loopStart + " | loopEnd: " + this.loopEnd)
|
||||
|
||||
val buffer = this.getCachedOrRawBuffer(size)
|
||||
val sizeAfterRead = this.runningRead + buffer.remaining()
|
||||
|
||||
// if this read reaches the end loop point
|
||||
if (loopEnd > 0 && sizeAfterRead >= this.loopEnd) {
|
||||
val remainderBeforeEnd = this.loopEnd - this.runningRead
|
||||
// limit buffer if it goes past the loop point (cached buffers don't apply as they are always within the loop points)
|
||||
if (buffer.remaining() > remainderBeforeEnd)
|
||||
{
|
||||
this.debug("limit and reset read")
|
||||
buffer.limit(remainderBeforeEnd)
|
||||
}
|
||||
else {
|
||||
this.debug("reset read")
|
||||
}
|
||||
this.resetLoop()
|
||||
}
|
||||
// if loopEnd is 0 and the entire stream is read, or exaggerated and the stream is exhausted before reaching the point
|
||||
else if (!buffer.hasRemaining()) {
|
||||
this.debug("exhaustive read")
|
||||
this.resetLoop()
|
||||
}
|
||||
// standard read
|
||||
else {
|
||||
this.debug("standard read")
|
||||
this.runningRead += buffer.remaining();
|
||||
}
|
||||
|
||||
return buffer
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a [ByteBuffer] of varying size from the [bufferCache] if this is not the [firstPass] and a cached buffer
|
||||
* is available, or reads approximately [size] bytes from the [decoderStream].
|
||||
*/
|
||||
private fun getCachedOrRawBuffer(size: Int): ByteBuffer {
|
||||
val cacheExists = CACHE_LIMIT > 0 && !this.bufferCache.isEmpty() && this.bufferCounter < this.bufferCache.size
|
||||
|
||||
// get buffer from cache
|
||||
if (cacheExists && !this.firstPass) {
|
||||
val toReturn = this.bufferCache.get(this.bufferCounter++)
|
||||
this.debug("get cached buffer: " + toReturn.remaining())
|
||||
return toReturn
|
||||
}
|
||||
// TODO coalesce this with bufferCache
|
||||
else if (!this.readPrem && this.preliminaryBuffer != null && !this.firstPass) {
|
||||
this.readPrem = true
|
||||
val toReturn = this.preliminaryBuffer!!
|
||||
this.debug("read prem buffer: " + toReturn.remaining())
|
||||
return toReturn
|
||||
}
|
||||
// decode a buffer of approximate size
|
||||
else {
|
||||
val toReturn = this.decoderStream.read(size)
|
||||
this.debug("read raw: " + toReturn.remaining())
|
||||
this.cacheBuffer(toReturn)
|
||||
return toReturn
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches [buffer] in the [bufferCache] during the [firstPass] if the [CACHE_LIMIT] has not been reached and the buffer
|
||||
* contains bytes within the [loopStart] and the [loopEnd] boundaries.
|
||||
*/
|
||||
private fun cacheBuffer(buffer: ByteBuffer) {
|
||||
val canCacheBuffer = CACHE_LIMIT > 0 && loopStart > 0 && this.bufferCache.size < CACHE_LIMIT && this.firstPass
|
||||
val canStartCaching = this.runningRead + buffer.remaining() > this.loopStart
|
||||
if (!canCacheBuffer || !canStartCaching) return
|
||||
|
||||
// offset used - so that only the tail of a buffer that contains the loopStart point is cached
|
||||
val remainderBeforeStart = Math.max(this.loopStart - this.runningRead, 0)
|
||||
var remainderBeforeEnd = 0
|
||||
|
||||
// only cache the head of a buffer that goes past the loopEnd point
|
||||
if (loopEnd > 0 && buffer.remaining() + this.runningRead > this.loopEnd) {
|
||||
remainderBeforeEnd = this.loopEnd - this.runningRead - remainderBeforeStart
|
||||
// NOTE: read will resetLoop and stop caching if CACHE_LIMIT has not been reached but loopEnd has
|
||||
}
|
||||
// otherwise, cache the entire remainder of the buffer
|
||||
else {
|
||||
remainderBeforeEnd = buffer.remaining() - remainderBeforeStart
|
||||
}
|
||||
|
||||
if (remainderBeforeEnd <= 0) return
|
||||
|
||||
// copy to avoid mutating provided buffer
|
||||
val buffed = BufferUtils.createByteBuffer(remainderBeforeEnd)
|
||||
buffed.put(0, buffer, remainderBeforeStart, remainderBeforeEnd)
|
||||
buffed.rewind()
|
||||
|
||||
this.debug("cache buffer | remainderBeforeStart: " + remainderBeforeStart + " | remainderBeforeEnd: " + remainderBeforeEnd + " | size: " + buffed.remaining())
|
||||
|
||||
this.bufferCache.add(buffed)
|
||||
this.cacheSize += buffed.remaining()
|
||||
|
||||
this.debug("cacheSize: " + cacheSize + " bufferCacheSize: " + this.bufferCache.size)
|
||||
}
|
||||
|
||||
/** Converts PCM samples to bytes. */
|
||||
private fun samplesToBytes(sampleAmount: Int): Int {
|
||||
val format = this.format ?: return 0
|
||||
return sampleAmount * format.getSampleSizeInBits() / 8 * format.getChannels()
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind [decoderStream] to start from [loopStart].
|
||||
*
|
||||
* NOTE: Assumes that [bufferCache] is finalized.
|
||||
*/
|
||||
private fun resetLoop() {
|
||||
// reset state info
|
||||
this.loopPrepared = false
|
||||
this.runningRead = this.loopStart
|
||||
this.bufferCounter = 0
|
||||
this.firstPass = false
|
||||
|
||||
this.debug("reset")
|
||||
|
||||
// if the entire loop is small enough to fit the cache, skip rewinding the decoderStream
|
||||
if (this.bufferCache.size > 0 && this.bufferCache.size < CACHE_LIMIT) {
|
||||
this.debug("comprehensive cache")
|
||||
this.loopPrepared = true
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
Seeking is implemented agnostic of the OGG Vorbis decoder. Seek to the loop start by decoding PCM in bulk from
|
||||
the beginning of the OGG Vorbis up until the desired sample offset is reached. Then for playing the loop, continue
|
||||
streaming decoded PCM into OpenAL buffers.
|
||||
*/
|
||||
this.decoderStream.close()
|
||||
this.encodedStream.reset()
|
||||
this.buildDecoderStream()
|
||||
|
||||
// if loopStart is 0, there's no cache, so loop starts by reading from the new decoderStream
|
||||
if (this.bufferCache.size == 0) {
|
||||
this.debug("nonexistent cache")
|
||||
this.loopPrepared = true
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
After the first pass, encodedStream will have the entire Vorbis OGG buffered and there won't be any subsequent reads
|
||||
from disk. However, there's still latency in decoding a lot of PCM. This needs to be done asynchronously, otherwise
|
||||
the client will momentarily freeze each time the loop resets. In the unlikely case that the decoderStream is not
|
||||
rewinded by the time the Channel needs to read a buffer, it will be read from bufferCache.
|
||||
*/
|
||||
CompletableFuture.supplyAsync<Any?>({
|
||||
try {
|
||||
val decoderStart = this.loopStart + this.cacheSize
|
||||
val buffer = decoderStream.read(decoderStart)
|
||||
|
||||
// because the deecoderStream will only read an approximation, need to account for additional bytes
|
||||
if (this.preliminaryBuffer == null && buffer.remaining() > decoderStart) {
|
||||
this.debug("rewind buffer size: " + buffer.remaining() + " overshot by: " + (buffer.remaining() - decoderStart))
|
||||
this.preliminaryBuffer = BufferUtils.createByteBuffer(buffer.remaining() - decoderStart)
|
||||
this.preliminaryBuffer!!.put(0, buffer, decoderStart, buffer.remaining() - decoderStart)
|
||||
this.preliminaryBuffer!!.rewind()
|
||||
// decoderStream.read is deterministic, so this should only be set once
|
||||
}
|
||||
this.readPrem = false
|
||||
this.loopPrepared = true
|
||||
this.debug("decoderStream rewinded")
|
||||
return@supplyAsync null
|
||||
} catch (e: IOException) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}, Util.nonCriticalIoPool())
|
||||
}
|
||||
|
||||
private fun buildDecoderStream() {
|
||||
this.decoderStream = provider.create(LoopingAudioStream.NoCloseBuffer(this.encodedStream))
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
this.decoderStream.close()
|
||||
this.encodedStream.close() // closes the InputStream used
|
||||
}
|
||||
|
||||
private fun debug(log: String) {
|
||||
if (this.DEBUG_FLAG) Cobblemon.LOGGER.error(log)
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -20,8 +20,10 @@ import net.minecraft.resources.ResourceLocation
|
||||
*
|
||||
* Handled by [com.cobblemon.mod.common.client.net.battle.BattleMusicHandler].
|
||||
*
|
||||
* @property music The location of the sound to play during a battle. If null, gracefully ends the currently playing sound.
|
||||
* @property restartExisting If true and the location of [music] matches the currently playing sound, will restart from the beginning.
|
||||
* @property music The location of a [SoundEvent], or the location of the []to dispatch a sound from, to play during a battle.
|
||||
* If null, gracefully ends the currently playing sound.
|
||||
*
|
||||
* @property restartExisting If true and [music] matches the location of the currently playing sound, will restart from the beginning.
|
||||
*
|
||||
* @author Segfault Guy
|
||||
* @since April 20th, 2023
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package com.cobblemon.mod.common.net.messages.client.data
|
||||
|
||||
class SoundTrackConfigRegistrySyncPacket {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.cobblemon.mod.common.ost
|
||||
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.sounds.SoundEvent
|
||||
|
||||
/**
|
||||
* Event to signal a transition in battle music. When received by the client, will either replace the currently playing
|
||||
* battle music with a new instance, or pause and temporarily switches from the current instance to play a [soundEvent].
|
||||
*
|
||||
* @author Segfault Guy
|
||||
* @since December 16, 2925
|
||||
*/
|
||||
data class BattleMusicCue(
|
||||
/** The identifier of this cue. */
|
||||
val id: ResourceLocation,
|
||||
/** The track or sound effect to play. */
|
||||
val soundEvent: SoundEvent,
|
||||
/** Whether the [soundEvent] should replace and become the main track. */
|
||||
val replace: Boolean,
|
||||
/** Determines which cue's [soundEvent] plays if multiple cues are scheduled at once. Priority is lost when cue becomes
|
||||
* the main track. */
|
||||
val priority: Int,
|
||||
/** Time in seconds before the [soundEvent] starts playing. */
|
||||
val delay: Int,
|
||||
/** If the currently playing track should fade out, and the [soundEvent] should fade in. */
|
||||
val fade: Boolean = false
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.cobblemon.mod.common.ost
|
||||
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
||||
/**
|
||||
* A configuration that dispatches a [BattleTrack] to use when playing battle music.
|
||||
*
|
||||
* @author Segfault Guy
|
||||
* @since January 6th, 2026
|
||||
*/
|
||||
class BattleThemeConfig(
|
||||
id: ResourceLocation,
|
||||
/** */
|
||||
override val tracks: Collection<BattleTrack>,
|
||||
/** 2nd-priority [BattleMusicCue]s that are subscribed by every track in the configuration. */
|
||||
val cues: Collection<BattleMusicCue>,
|
||||
) : SoundTrackConfig(id, tracks)
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.cobblemon.mod.common.ost
|
||||
|
||||
import com.cobblemon.mod.common.api.data.JsonDataRegistry
|
||||
import com.cobblemon.mod.common.api.reactive.SimpleObservable
|
||||
import com.cobblemon.mod.common.util.adapters.IdentifierAdapter
|
||||
import com.cobblemon.mod.common.util.cobblemonResource
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.server.level.ServerPlayer
|
||||
import net.minecraft.server.packs.PackType
|
||||
|
||||
object BattleThemes : JsonDataRegistry<BattleThemeConfig> {
|
||||
|
||||
override val resourcePath = "battle_themes"
|
||||
|
||||
|
||||
override val id: ResourceLocation = cobblemonResource(this.resourcePath)
|
||||
override val type = PackType.SERVER_DATA
|
||||
override val observable = SimpleObservable<BattleThemeConfig>()
|
||||
|
||||
override val gson: Gson = GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.registerTypeAdapter(ResourceLocation::class.java, IdentifierAdapter)
|
||||
.create()
|
||||
|
||||
override val typeToken = TypeToken.get(BattleThemeConfig::class.java)
|
||||
|
||||
/** */
|
||||
private val battleSoundTrackConfigs = mutableMapOf<ResourceLocation, BattleThemeConfig>()
|
||||
|
||||
override fun reload(data: Map<ResourceLocation, BattleThemeConfig>) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun sync(player: ServerPlayer) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getByIdentifier(identifier: ResourceLocation): BattleThemeConfig? = this.battleSoundTrackConfigs[identifier]
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.cobblemon.mod.common.ost
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class BattleTrack(
|
||||
val battle_conditions
|
||||
) : SoundTrack {
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.cobblemon.mod.common.ost
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.EntityQueryRequirement
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
||||
/**
|
||||
* r
|
||||
*
|
||||
* @author Segfault Guy
|
||||
* @since December 16, 2025
|
||||
*/
|
||||
open class SoundTrack {
|
||||
|
||||
val ambient: ResourceLocation
|
||||
val wildLocation: ResourceLocation
|
||||
val trainerLocation: ResourceLocation
|
||||
val priority: Int = 1
|
||||
val requirements: MutableSet<EntityQueryRequirement>
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.cobblemon.mod.common.ost
|
||||
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
||||
/**
|
||||
* A configuration that dispatches a [SoundTrack] to use when playing music.
|
||||
*
|
||||
* @author Segfault Guy
|
||||
* @since January 6th, 2026
|
||||
*/
|
||||
open class SoundTrackConfig(
|
||||
/** The identifier of this configuration. */
|
||||
val id: ResourceLocation,
|
||||
/** The */
|
||||
open val tracks: Collection<SoundTrack>,
|
||||
) {
|
||||
|
||||
fun dispatchTrack(): BattleTrack {
|
||||
// TODO based on requirements
|
||||
}
|
||||
}
|
||||
|
||||
// should this be templated instead?
|
||||
+2
@@ -67,6 +67,8 @@ object CobblemonRequirementAdapter : RequirementAdapter {
|
||||
this.registerType(PropertyRangeRequirement.ADAPTER_VARIANT, PropertyRangeRequirement::class)
|
||||
this.registerType(AdvancementRequirement.ADAPTER_VARIANT, AdvancementRequirement::class)
|
||||
this.registerType(OwnerHoldsItemRequirement.ADAPTER_VARIANT, OwnerHoldsItemRequirement::class)
|
||||
this.registerType(DepthRequirement.ADAPTER_VARIANT, DepthRequirement::class)
|
||||
this.registerType(SkyRequirement.ADAPTER_VARIANT, SkyRequirement::class)
|
||||
}
|
||||
|
||||
val gson: Gson by lazy {
|
||||
|
||||
+2
-3
@@ -9,13 +9,12 @@
|
||||
package com.cobblemon.mod.common.pokemon.requirements
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.EntityQueryRequirement
|
||||
import com.cobblemon.mod.common.pokemon.Pokemon
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.phys.AABB
|
||||
import net.minecraft.world.phys.Vec3
|
||||
|
||||
/**
|
||||
* A [EntityQueryRequirement] for when a [Pokemon] is expected to be in a certain area.
|
||||
* A [EntityQueryRequirement] for when a [LivingEntity] is expected to be in a certain area.
|
||||
*
|
||||
* @property box The [AABB] expected to be in.
|
||||
* @author Licious
|
||||
@@ -27,5 +26,5 @@ class AreaRequirement : EntityQueryRequirement {
|
||||
}
|
||||
|
||||
val box: AABB = AABB.unitCubeFromLowerCorner(Vec3.ZERO)
|
||||
override fun check(pokemon: Pokemon, queriedEntity: LivingEntity) = box.contains(queriedEntity.position())
|
||||
override fun check(queriedEntity: LivingEntity) = box.contains(queriedEntity.position())
|
||||
}
|
||||
+2
-2
@@ -18,7 +18,7 @@ import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.level.biome.Biome
|
||||
|
||||
/**
|
||||
* A [Requirement] for when a [Pokemon] is expected to be in a certain [Biome].
|
||||
* A [Requirement] for when a [LivingEntity] is expected to be in a certain [Biome].
|
||||
*
|
||||
* @property biomeCondition The [ResourceLocation] of the [Biome] the queried entity is expected to be in.
|
||||
* @author Licious
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.world.level.biome.Biome
|
||||
class BiomeRequirement : EntityQueryRequirement {
|
||||
val biomeCondition: RegistryLikeCondition<Biome>? = null
|
||||
val biomeAnticondition: RegistryLikeCondition<Biome>? = null
|
||||
override fun check(pokemon: Pokemon, queriedEntity: LivingEntity): Boolean {
|
||||
override fun check(queriedEntity: LivingEntity): Boolean {
|
||||
val biome = queriedEntity.level().getBiome(queriedEntity.blockPosition()).value()
|
||||
val registry = queriedEntity.level().registryAccess().registryOrThrow(Registries.BIOME)
|
||||
return (biomeCondition == null || biomeCondition.fits(biome, registry)) && (biomeAnticondition == null || !biomeAnticondition.fits(biome, registry))
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.cobblemon.mod.common.pokemon.requirements
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.EntityQueryRequirement
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
/**
|
||||
* An [EntityQueryRequirement] that evaluates whether a [LivingEntity] is at a certain block level.
|
||||
*
|
||||
* @property minY The minimum block level to satisfy this requirement. If null, defaults to the dimension's min height.
|
||||
* @property maxY The maximum block level to satisfy this requirement. If null, defaults to the dimension's max height.
|
||||
* @author Segfault Guy
|
||||
* @since December 16, 2025
|
||||
*/
|
||||
class DepthRequirement(val minY: Int?, val maxY: Int?) : EntityQueryRequirement {
|
||||
|
||||
override fun check(queriedEntity: LivingEntity): Boolean {
|
||||
val minLevelY = queriedEntity.level().minBuildHeight
|
||||
val maxLevelY = queriedEntity.level().maxBuildHeight
|
||||
val test = minY?.coerceIn(minLevelY, maxLevelY) ?: minLevelY
|
||||
val test2 = maxY?.coerceIn(minLevelY, maxLevelY) ?: maxLevelY
|
||||
|
||||
return queriedEntity.blockPosition().y in test..test2
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val ADAPTER_VARIANT = "depth"
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -28,7 +28,7 @@ class MoonPhaseRequirement(moonPhase: MoonPhase) : EntityQueryRequirement {
|
||||
|
||||
val moonPhase: MoonPhase = moonPhase
|
||||
|
||||
override fun check(pokemon: Pokemon, queriedEntity: LivingEntity): Boolean {
|
||||
override fun check(queriedEntity: LivingEntity): Boolean {
|
||||
return try {
|
||||
val moonPhase = MoonPhase.ofWorld(queriedEntity.level())
|
||||
this.moonPhase == moonPhase
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.cobblemon.mod.common.pokemon.requirements
|
||||
|
||||
import com.cobblemon.mod.common.api.pokemon.requirement.EntityQueryRequirement
|
||||
import net.minecraft.world.entity.LivingEntity
|
||||
|
||||
/**
|
||||
* An [EntityQueryRequirement] that evaluates whether a [LivingEntity] is exposed to a dimension's sky.
|
||||
*
|
||||
* @param invert If true, this requirement evaluates whether the entity CANNOT see a dimension's sky.
|
||||
* @author Segfault Guy
|
||||
* @since December 16, 2025
|
||||
*/
|
||||
class SkyRequirement(val invert: Boolean = false) : EntityQueryRequirement {
|
||||
|
||||
override fun check(queriedEntity: LivingEntity) = queriedEntity.level().canSeeSky(queriedEntity.blockPosition()).xor(invert)
|
||||
|
||||
companion object {
|
||||
const val ADAPTER_VARIANT = "sky"
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -16,7 +16,7 @@ import net.minecraft.world.entity.LivingEntity
|
||||
import net.minecraft.world.level.levelgen.structure.Structure
|
||||
|
||||
/**
|
||||
* A [EntityQueryRequirement] for when a [Pokemon] is expected to be in a certain structure.
|
||||
* A [EntityQueryRequirement] for when a [LivingEntity] is expected to be in a certain structure.
|
||||
*
|
||||
* @property structureCondition The [Identifier] of the structure the queried entity is expected to be in.
|
||||
* @author whatsy
|
||||
@@ -25,7 +25,7 @@ import net.minecraft.world.level.levelgen.structure.Structure
|
||||
class StructureRequirement : EntityQueryRequirement {
|
||||
val structureCondition: RegistryLikeCondition<Structure>? = null
|
||||
val structureAnticondition: RegistryLikeCondition<Structure>? = null
|
||||
override fun check(pokemon: Pokemon, queriedEntity: LivingEntity): Boolean {
|
||||
override fun check(queriedEntity: LivingEntity): Boolean {
|
||||
val structures = queriedEntity.level().getChunk(queriedEntity.blockPosition()).allReferences
|
||||
val registry = queriedEntity.level().registryAccess().registryOrThrow(Registries.STRUCTURE)
|
||||
return (structureCondition == null || structures.any { structureCondition.fits(it.key, registry) }) && (structureAnticondition == null || !structures.any { structureAnticondition.fits(it.key, registry) })
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import net.minecraft.world.entity.LivingEntity
|
||||
*/
|
||||
class TimeRangeRequirement : EntityQueryRequirement {
|
||||
val range = TimeRange(0..23999)
|
||||
override fun check(pokemon: Pokemon, queriedEntity: LivingEntity) = this.range.contains((queriedEntity.level().dayTime() % DAY_DURATION).toInt())
|
||||
override fun check(queriedEntity: LivingEntity) = this.range.contains((queriedEntity.level().dayTime() % DAY_DURATION).toInt())
|
||||
companion object {
|
||||
const val ADAPTER_VARIANT = "time_range"
|
||||
private const val DAY_DURATION = 24000
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ class WeatherRequirement : EntityQueryRequirement {
|
||||
val isRaining: Boolean? = null
|
||||
val isThundering: Boolean? = null
|
||||
|
||||
override fun check(pokemon: Pokemon, queriedEntity: LivingEntity): Boolean {
|
||||
override fun check(queriedEntity: LivingEntity): Boolean {
|
||||
val world = queriedEntity.level()
|
||||
return when {
|
||||
isRaining == true && !world.isRaining -> false
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ import net.minecraft.resources.ResourceLocation
|
||||
import net.minecraft.world.level.Level
|
||||
|
||||
/**
|
||||
* A [EntityQueryRequirement] for when a [Pokemon] is expected to be in a [Level].
|
||||
* A [EntityQueryRequirement] for when a [LivingEntity] is expected to be in a [Level].
|
||||
*
|
||||
* @property identifier The [ResourceLocation] of the [Level] the queried entity is expected to be in.
|
||||
* @author Licious
|
||||
@@ -26,5 +26,5 @@ class WorldRequirement : EntityQueryRequirement {
|
||||
const val ADAPTER_VARIANT = "world"
|
||||
}
|
||||
val identifier: ResourceLocation = ResourceLocation.parse("minecraft:the_overworld")
|
||||
override fun check(pokemon: Pokemon, queriedEntity: LivingEntity) = queriedEntity.level().dimension().location() == this.identifier
|
||||
override fun check(queriedEntity: LivingEntity) = queriedEntity.level().dimension().location() == this.identifier
|
||||
}
|
||||
@@ -9457,11 +9457,5 @@
|
||||
"stat.cobblemon.reel_ins": "PokéRod Catches",
|
||||
"stat.cobblemon.riding_land": "Distance by Pokémon on Land",
|
||||
"stat.cobblemon.riding_air": "Distance by Pokémon in Air",
|
||||
"stat.cobblemon.riding_liquid": "Distance by Pokémon in Liquid",
|
||||
|
||||
"controlify.category.cobblemon.cobblemon": "Cobblemon",
|
||||
"controlify.bind.cobblemon.riding_up": "Look Up",
|
||||
"controlify.bind.cobblemon.riding_down": "Look Down",
|
||||
"controlify.bind.cobblemon.riding_left": "Look Left",
|
||||
"controlify.bind.cobblemon.riding_right": "Look Right"
|
||||
"stat.cobblemon.riding_liquid": "Distance by Pokémon in Liquid"
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"defaults": {
|
||||
"cobblemon:riding_up": {
|
||||
"axis": "controlify:axis/right_stick_up"
|
||||
},
|
||||
"cobblemon:riding_down": {
|
||||
"axis": "controlify:axis/right_stick_down"
|
||||
},
|
||||
"cobblemon:riding_left": {
|
||||
"axis": "controlify:axis/right_stick_left"
|
||||
},
|
||||
"cobblemon:riding_right": {
|
||||
"axis": "controlify:axis/right_stick_right"
|
||||
},
|
||||
"cobblemon:interact_wheel_up": {
|
||||
"axis": "controlify:axis/right_stick_up"
|
||||
},
|
||||
"cobblemon:interact_wheel_down": {
|
||||
"axis": "controlify:axis/right_stick_down"
|
||||
},
|
||||
"cobblemon:interact_wheel_left": {
|
||||
"axis": "controlify:axis/right_stick_left"
|
||||
},
|
||||
"cobblemon:interact_wheel_right": {
|
||||
"axis": "controlify:axis/right_stick_right"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,4 +151,9 @@ transitive-accessible method net/minecraft/world/food/FoodData add (IF)V
|
||||
|
||||
transitive-accessible method net/minecraft/client/model/HumanoidModel setupAttackAnimation (Lnet/minecraft/world/entity/LivingEntity;F)V
|
||||
transitive-accessible method net/minecraft/client/model/HumanoidModel poseRightArm (Lnet/minecraft/world/entity/LivingEntity;)V
|
||||
transitive-accessible method net/minecraft/client/model/HumanoidModel poseLeftArm (Lnet/minecraft/world/entity/LivingEntity;)V
|
||||
transitive-accessible method net/minecraft/client/model/HumanoidModel poseLeftArm (Lnet/minecraft/world/entity/LivingEntity;)V
|
||||
|
||||
transitive-accessible class net/minecraft/client/sounds/LoopingAudioStream$NoCloseBuffer
|
||||
transitive-accessible method net/minecraft/client/sounds/LoopingAudioStream$NoCloseBuffer <init> (Ljava/io/InputStream;)V
|
||||
|
||||
transitive-accessible field com/mojang/blaze3d/audio/Channel QUEUED_BUFFER_COUNT I
|
||||
@@ -13,8 +13,11 @@
|
||||
"ItemPropertiesMixin",
|
||||
"MusicManagerMixin",
|
||||
"ParticleManagerMixin",
|
||||
"SoundBufferLibraryMixin",
|
||||
"SoundEngineMixin",
|
||||
"SoundEventRegistrationSerializerMixin",
|
||||
"SoundManagerMixin",
|
||||
"SoundMixin",
|
||||
"VillagerProfessionLayerMixin",
|
||||
"accessor.EntryListWidgetAccessor",
|
||||
"accessor.KeyBindingAccessor",
|
||||
|
||||
@@ -30,9 +30,6 @@
|
||||
],
|
||||
"modmenu": [
|
||||
"com.cobblemon.mod.fabric.client.integration.modmenu.CobblemonModMenu"
|
||||
],
|
||||
"controlify": [
|
||||
"com.cobblemon.mod.common.client.integration.controlify.CobblemonControlifyEntrypoint"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.cobblemon.mod.neoforge.mixin.client;
|
||||
|
||||
import com.cobblemon.mod.common.duck.SoundBufferLibraryDuck;
|
||||
import com.cobblemon.mod.common.duck.SoundDuck;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import net.minecraft.client.resources.sounds.Sound;
|
||||
import net.minecraft.client.resources.sounds.SoundInstance;
|
||||
import net.minecraft.client.sounds.AudioStream;
|
||||
import net.minecraft.client.sounds.SoundBufferLibrary;
|
||||
import net.minecraft.client.sounds.SoundEngine;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Mixin(SoundEngine.class)
|
||||
public class SoundEngineMixin {
|
||||
|
||||
/**
|
||||
* Dispatch custom stream for sounds that have an intro. This is needed because NeoForge overwrites the SoundBufferLibrary$getStream invocation.
|
||||
* Because this is a WrapOperation it's compatible with NeoForge's PlayStreamingSourceEvent.
|
||||
*/
|
||||
@WrapOperation(method = "play", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/sounds/SoundInstance;getStream(Lnet/minecraft/client/sounds/SoundBufferLibrary;Lnet/minecraft/client/resources/sounds/Sound;Z)Ljava/util/concurrent/CompletableFuture;"))
|
||||
public CompletableFuture<AudioStream> getStream(SoundInstance soundInstance, SoundBufferLibrary bufferLibrary, Sound sound, boolean looping, Operation<CompletableFuture<AudioStream>> original) {
|
||||
SoundDuck soundDuck = (SoundDuck)sound;
|
||||
SoundBufferLibraryDuck libraryDuck = (SoundBufferLibraryDuck)bufferLibrary;
|
||||
if (soundDuck.hasIntro() || (soundDuck.hasLoopPoints() && looping)) {
|
||||
return libraryDuck.getCompoundStream();
|
||||
}
|
||||
else {
|
||||
return original.call(soundInstance, bufferLibrary, sound, looping);
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
com.cobblemon.mod.common.client.integration.controlify.CobblemonControlifyEntrypoint
|
||||
Reference in new issue
Block a user