forked from ChomeNS/chipmunkmod
1.20.2
This commit is contained in:
parent
ee5b2a0892
commit
43939452fc
12 changed files with 29 additions and 133 deletions
|
@ -29,7 +29,7 @@ dependencies {
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
modImplementation include("net.kyori:adventure-platform-fabric:5.8.0") // for Minecraft 1.19.4
|
modImplementation include("net.kyori:adventure-platform-fabric:5.10.0") // for Minecraft 1.20.2
|
||||||
|
|
||||||
modImplementation include("net.kyori:adventure-text-serializer-legacy:4.13.1")
|
modImplementation include("net.kyori:adventure-text-serializer-legacy:4.13.1")
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ org.gradle.parallel=true
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.20.1
|
minecraft_version=1.20.2
|
||||||
yarn_mappings=1.20.1+build.9
|
yarn_mappings=1.20.2+build.1
|
||||||
loader_version=0.14.21
|
loader_version=0.14.22
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.0
|
mod_version = 1.0.0
|
||||||
|
@ -14,6 +14,6 @@ org.gradle.parallel=true
|
||||||
archives_base_name = chipmunkmod
|
archives_base_name = chipmunkmod
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.84.0+1.20.1
|
fabric_version=0.89.2+1.20.2
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,15 @@ import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.ConnectScreen;
|
import net.minecraft.client.gui.screen.ConnectScreen;
|
||||||
import net.minecraft.client.gui.screen.TitleScreen;
|
import net.minecraft.client.gui.screen.TitleScreen;
|
||||||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
|
|
||||||
import net.minecraft.client.network.ServerInfo;
|
import net.minecraft.client.network.ServerInfo;
|
||||||
import net.minecraft.client.network.ServerAddress;
|
import net.minecraft.client.network.ServerAddress;
|
||||||
import net.minecraft.client.util.Session;
|
import net.minecraft.client.session.Session;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import land.chipmunk.chipmunkmod.mixin.MinecraftClientAccessor;
|
import land.chipmunk.chipmunkmod.mixin.MinecraftClientAccessor;
|
||||||
|
|
||||||
public class UsernameCommand {
|
public class UsernameCommand {
|
||||||
|
@ -45,7 +46,7 @@ public class UsernameCommand {
|
||||||
public static int updateUsername (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
public static int updateUsername (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
|
||||||
final String username = getString(context, "username");
|
final String username = getString(context, "username");
|
||||||
if (username.length() > 16) throw USERNAME_TOO_LONG.create();
|
if (username.length() > 16) throw USERNAME_TOO_LONG.create();
|
||||||
final Session session = new Session(username, "", "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG);
|
final Session session = new Session(username, new UUID(0L, 0L), "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG);
|
||||||
return updateSession(context, session);
|
return updateSession(context, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,6 @@ public interface ClientPlayNetworkHandlerAccessor {
|
||||||
@Accessor("CHAT_VALIDATION_FAILED_TEXT")
|
@Accessor("CHAT_VALIDATION_FAILED_TEXT")
|
||||||
static Text chatValidationFailedText () { throw new AssertionError(); }
|
static Text chatValidationFailedText () { throw new AssertionError(); }
|
||||||
|
|
||||||
@Accessor("connection")
|
|
||||||
ClientConnection connection();
|
|
||||||
|
|
||||||
@Accessor("playerListEntries")
|
@Accessor("playerListEntries")
|
||||||
Map<UUID, PlayerListEntry> playerListEntries();
|
Map<UUID, PlayerListEntry> playerListEntries();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package land.chipmunk.chipmunkmod.mixin;
|
package land.chipmunk.chipmunkmod.mixin;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
|
||||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||||
import land.chipmunk.chipmunkmod.command.CommandManager;
|
import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||||
|
@ -8,26 +7,21 @@ import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||||
import land.chipmunk.chipmunkmod.modules.*;
|
import land.chipmunk.chipmunkmod.modules.*;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
|
||||||
import net.minecraft.client.network.ClientDynamicRegistryType;
|
|
||||||
import net.minecraft.client.network.ServerInfo;
|
|
||||||
import net.minecraft.client.util.telemetry.WorldSession;
|
|
||||||
import net.minecraft.command.CommandRegistryAccess;
|
import net.minecraft.command.CommandRegistryAccess;
|
||||||
import net.minecraft.network.ClientConnection;
|
|
||||||
import net.minecraft.network.encryption.NetworkEncryptionUtils;
|
import net.minecraft.network.encryption.NetworkEncryptionUtils;
|
||||||
import net.minecraft.network.message.LastSeenMessagesCollector;
|
import net.minecraft.network.message.LastSeenMessagesCollector;
|
||||||
import net.minecraft.network.message.MessageBody;
|
import net.minecraft.network.message.MessageBody;
|
||||||
import net.minecraft.network.message.MessageChain;
|
import net.minecraft.network.message.MessageChain;
|
||||||
import net.minecraft.network.message.MessageSignatureData;
|
import net.minecraft.network.message.MessageSignatureData;
|
||||||
import net.minecraft.network.packet.Packet;
|
|
||||||
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
|
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
|
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket;
|
import net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket;
|
||||||
import net.minecraft.registry.CombinedDynamicRegistries;
|
import net.minecraft.registry.DynamicRegistryManager;
|
||||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableTextContent;
|
import net.minecraft.text.TranslatableTextContent;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
@ -38,22 +32,16 @@ import java.time.Instant;
|
||||||
|
|
||||||
@Mixin(value = net.minecraft.client.network.ClientPlayNetworkHandler.class, priority = 1001)
|
@Mixin(value = net.minecraft.client.network.ClientPlayNetworkHandler.class, priority = 1001)
|
||||||
public class ClientPlayNetworkHandlerMixin {
|
public class ClientPlayNetworkHandlerMixin {
|
||||||
|
@Final
|
||||||
@Shadow private FeatureSet enabledFeatures;
|
@Shadow private FeatureSet enabledFeatures;
|
||||||
@Shadow private CombinedDynamicRegistries<ClientDynamicRegistryType> combinedDynamicRegistries;
|
@Final
|
||||||
|
@Shadow private DynamicRegistryManager.Immutable combinedDynamicRegistries;
|
||||||
@Shadow private LastSeenMessagesCollector lastSeenMessagesCollector;
|
@Shadow private LastSeenMessagesCollector lastSeenMessagesCollector;
|
||||||
@Shadow private MessageChain.Packer messagePacker;
|
@Shadow private MessageChain.Packer messagePacker;
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public void sendPacket(Packet<?> packet) {}
|
|
||||||
|
|
||||||
@Inject(method = "<init>", at = @At("TAIL"))
|
|
||||||
private void init (MinecraftClient client, Screen screen, ClientConnection connection, ServerInfo serverInfo, GameProfile profile, WorldSession worldSession, CallbackInfo ci) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "onGameJoin", at = @At("TAIL"))
|
@Inject(method = "onGameJoin", at = @At("TAIL"))
|
||||||
private void onGameJoin (GameJoinS2CPacket packet, CallbackInfo ci) {
|
private void onGameJoin (GameJoinS2CPacket packet, CallbackInfo ci) {
|
||||||
final CommandRegistryAccess commandRegistryAccess = CommandRegistryAccess.of(this.combinedDynamicRegistries.getCombinedRegistryManager(), this.enabledFeatures);
|
final CommandRegistryAccess commandRegistryAccess = CommandRegistryAccess.of(this.combinedDynamicRegistries, this.enabledFeatures);
|
||||||
|
|
||||||
KaboomCheck.INSTANCE.onJoin();
|
KaboomCheck.INSTANCE.onJoin();
|
||||||
CommandManager.INSTANCE = new CommandManager(ChipmunkMod.CONFIG.commands.prefix, commandRegistryAccess);
|
CommandManager.INSTANCE = new CommandManager(ChipmunkMod.CONFIG.commands.prefix, commandRegistryAccess);
|
||||||
|
@ -69,7 +57,6 @@ public class ClientPlayNetworkHandlerMixin {
|
||||||
@Inject(method = "onPlayerRemove", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "onPlayerRemove", at = @At("HEAD"), cancellable = true)
|
||||||
private void onPlayerRemove (PlayerRemoveS2CPacket packet, CallbackInfo ci) { ci.cancel(); }
|
private void onPlayerRemove (PlayerRemoveS2CPacket packet, CallbackInfo ci) { ci.cancel(); }
|
||||||
|
|
||||||
|
|
||||||
@Inject(method = "onGameMessage", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "onGameMessage", at = @At("HEAD"), cancellable = true)
|
||||||
private void onGameMessage (GameMessageS2CPacket packet, CallbackInfo ci) {
|
private void onGameMessage (GameMessageS2CPacket packet, CallbackInfo ci) {
|
||||||
final Text message = packet.content();
|
final Text message = packet.content();
|
||||||
|
@ -129,7 +116,7 @@ public class ClientPlayNetworkHandlerMixin {
|
||||||
long l = NetworkEncryptionUtils.SecureRandomUtil.nextLong();
|
long l = NetworkEncryptionUtils.SecureRandomUtil.nextLong();
|
||||||
LastSeenMessagesCollector.LastSeenMessages lastSeenMessages = this.lastSeenMessagesCollector.collect();
|
LastSeenMessagesCollector.LastSeenMessages lastSeenMessages = this.lastSeenMessagesCollector.collect();
|
||||||
MessageSignatureData messageSignatureData = this.messagePacker.pack(new MessageBody(content, instant, l, lastSeenMessages.lastSeen()));
|
MessageSignatureData messageSignatureData = this.messagePacker.pack(new MessageBody(content, instant, l, lastSeenMessages.lastSeen()));
|
||||||
this.sendPacket(new ChatMessageC2SPacket(content, instant, l, messageSignatureData, lastSeenMessages.update()));
|
MinecraftClient.getInstance().getNetworkHandler().sendPacket(new ChatMessageC2SPacket(content, instant, l, messageSignatureData, lastSeenMessages.update()));
|
||||||
|
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
package land.chipmunk.chipmunkmod.mixin;
|
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import net.minecraft.network.*;
|
|
||||||
import net.minecraft.network.packet.Packet;
|
|
||||||
import net.minecraft.util.profiling.jfr.FlightProfiler;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Mutable;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static land.chipmunk.chipmunkmod.ChipmunkMod.LOGGER;
|
|
||||||
|
|
||||||
@Mixin(DecoderHandler.class)
|
|
||||||
public class DecoderHandlerMixin {
|
|
||||||
@Final @Mutable @Shadow private final NetworkSide side;
|
|
||||||
|
|
||||||
public DecoderHandlerMixin(NetworkSide side) {
|
|
||||||
this.side = side;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "decode", at = @At("HEAD"), cancellable = true)
|
|
||||||
private void decode (ChannelHandlerContext ctx, ByteBuf buf, List<Object> objects, CallbackInfo ci) {
|
|
||||||
int i = buf.readableBytes();
|
|
||||||
if (i != 0) {
|
|
||||||
PacketByteBuf packetByteBuf = new PacketByteBuf(buf);
|
|
||||||
int j = packetByteBuf.readVarInt();
|
|
||||||
Packet<?> packet = ctx.channel().attr(ClientConnection.PROTOCOL_ATTRIBUTE_KEY).get().getPacketHandler(this.side, j, packetByteBuf);
|
|
||||||
if (packet != null) {
|
|
||||||
int k = ctx.channel().attr(ClientConnection.PROTOCOL_ATTRIBUTE_KEY).get().getId();
|
|
||||||
FlightProfiler.INSTANCE.onPacketReceived(k, j, ctx.channel().remoteAddress(), i);
|
|
||||||
objects.add(packet);
|
|
||||||
if (LOGGER.isDebugEnabled()) {
|
|
||||||
LOGGER.debug(ClientConnection.PACKET_RECEIVED_MARKER, " IN: [{}:{}] {}", ctx.channel().attr(ClientConnection.PROTOCOL_ATTRIBUTE_KEY).get(), j, packet.getClass().getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
// https://github.com/LunaWasFlaggedAgain/Mojang-ResourceLocation-Challenge/blob/main/src/main/java/com/github/lunawasflaggedagain/mojangresourcelocationchallenge/mixin/DecoratedPotBlockEntitySherdsMixin.java
|
// https://github.com/LunaWasFlaggedAgain/Mojang-ResourceLocation-Challenge/blob/main/src/main/java/com/github/lunawasflaggedagain/mojangresourcelocationchallenge/mixin/DecoratedPotBlockEntitySherdsMixin.java
|
||||||
@Mixin(DecoratedPotBlockEntity.Sherds.class)
|
@Mixin(DecoratedPotBlockEntity.Sherds.class)
|
||||||
public class DecoratedPotBlockEntitySherdsMixin {
|
public class DecoratedPotBlockEntitySherdsMixin {
|
||||||
@Inject(method = "getSherd(Lnet/minecraft/nbt/NbtList;I)Lnet/minecraft/item/Item;", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;<init>(Ljava/lang/String;)V"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
|
@Inject(method = "getSherd", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;tryParse(Ljava/lang/String;)Lnet/minecraft/util/Identifier;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
|
||||||
private static void getSherd(NbtList list, int index, CallbackInfoReturnable<Item> cir, NbtElement nbtElement) {
|
private static void getSherd(NbtList list, int index, CallbackInfoReturnable<Item> cir, NbtElement nbtElement) {
|
||||||
if (!Identifier.isValid(nbtElement.asString())) cir.setReturnValue(Items.BRICK);
|
if (!Identifier.isValid(nbtElement.asString())) cir.setReturnValue(Items.BRICK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package land.chipmunk.chipmunkmod.mixin;
|
package land.chipmunk.chipmunkmod.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.session.Session;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Mutable;
|
import org.spongepowered.asm.mixin.Mutable;
|
||||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||||
import net.minecraft.client.util.Session;
|
|
||||||
|
|
||||||
@Mixin(net.minecraft.client.MinecraftClient.class)
|
@Mixin(net.minecraft.client.MinecraftClient.class)
|
||||||
public interface MinecraftClientAccessor {
|
public interface MinecraftClientAccessor {
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package land.chipmunk.chipmunkmod.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.nbt.*;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Mixin(NbtIo.class)
|
|
||||||
public class NbtIoMixin {
|
|
||||||
@Inject(method = "read(Ljava/io/DataInput;ILnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtElement;", at = @At("HEAD"), cancellable = true)
|
|
||||||
private static void read(DataInput input, int depth, NbtTagSizeTracker tracker, CallbackInfoReturnable<NbtElement> cir) {
|
|
||||||
try {
|
|
||||||
byte b = input.readByte();
|
|
||||||
if (b == 0) {
|
|
||||||
cir.setReturnValue(NbtEnd.INSTANCE);
|
|
||||||
}
|
|
||||||
|
|
||||||
NbtString.skip(input);
|
|
||||||
cir.setReturnValue(NbtTypes.byId(b).read(input, depth, tracker));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -131,7 +131,7 @@ public class SelfCare extends Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetReceived(GameJoinS2CPacket packet) {
|
public void packetReceived(GameJoinS2CPacket packet) {
|
||||||
gameMode = packet.gameMode().getId();
|
gameMode = packet.commonPlayerSpawnInfo().gameMode().getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetReceived(GameStateChangeS2CPacket packet) {
|
public void packetReceived(GameStateChangeS2CPacket packet) {
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package land.chipmunk.chipmunkmod.modules;
|
package land.chipmunk.chipmunkmod.modules;
|
||||||
|
|
||||||
import land.chipmunk.chipmunkmod.mixin.ClientConnectionAccessor;
|
|
||||||
import land.chipmunk.chipmunkmod.mixin.ClientConnectionInvoker;
|
|
||||||
import land.chipmunk.chipmunkmod.mixin.ClientPlayNetworkHandlerAccessor;
|
|
||||||
import land.chipmunk.chipmunkmod.song.Note;
|
import land.chipmunk.chipmunkmod.song.Note;
|
||||||
import land.chipmunk.chipmunkmod.song.Song;
|
import land.chipmunk.chipmunkmod.song.Song;
|
||||||
import land.chipmunk.chipmunkmod.song.SongLoaderException;
|
import land.chipmunk.chipmunkmod.song.SongLoaderException;
|
||||||
|
@ -14,13 +11,10 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
|
|
||||||
import net.minecraft.registry.entry.RegistryEntry;
|
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.random.Random;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -220,23 +214,16 @@ public class SongPlayer {
|
||||||
|
|
||||||
if (thing[1] == null) return; // idk if this can be null but ill just protect it for now i guess
|
if (thing[1] == null) return; // idk if this can be null but ill just protect it for now i guess
|
||||||
|
|
||||||
final ClientPlayNetworkHandlerAccessor networkHandlerAccessor = (ClientPlayNetworkHandlerAccessor) client.getNetworkHandler();
|
client.submit(() -> client.world.playSound(
|
||||||
|
|
||||||
final ClientConnectionAccessor clientConnectionAccessor = (ClientConnectionAccessor) networkHandlerAccessor.connection();
|
|
||||||
|
|
||||||
ClientConnectionInvoker.handlePacket(
|
|
||||||
new PlaySoundS2CPacket(
|
|
||||||
RegistryEntry.of(SoundEvent.of(Identifier.of(thing[0], thing[1]))),
|
|
||||||
SoundCategory.RECORDS,
|
|
||||||
client.player.getX(),
|
client.player.getX(),
|
||||||
client.player.getY(),
|
client.player.getY(),
|
||||||
client.player.getZ(),
|
client.player.getZ(),
|
||||||
|
SoundEvent.of(Identifier.of(thing[0], thing[1])),
|
||||||
|
SoundCategory.RECORDS,
|
||||||
note.volume,
|
note.volume,
|
||||||
floatingPitch,
|
floatingPitch,
|
||||||
Random.create().nextLong()
|
true
|
||||||
),
|
));
|
||||||
clientConnectionAccessor.packetListener()
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
final float floatingPitch = MathUtilities.clamp((float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12)))), 0F, 2F);
|
final float floatingPitch = MathUtilities.clamp((float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12)))), 0F, 2F);
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,7 @@
|
||||||
"ClientPlayNetworkHandlerAccessor",
|
"ClientPlayNetworkHandlerAccessor",
|
||||||
"ClientPlayNetworkHandlerMixin",
|
"ClientPlayNetworkHandlerMixin",
|
||||||
"MinecraftClientAccessor",
|
"MinecraftClientAccessor",
|
||||||
"DecoderHandlerMixin",
|
|
||||||
"StringHelperMixin",
|
"StringHelperMixin",
|
||||||
"NbtIoMixin",
|
|
||||||
"ElderGuardianAppearanceParticleMixin",
|
"ElderGuardianAppearanceParticleMixin",
|
||||||
"IdentifierMixin",
|
"IdentifierMixin",
|
||||||
"DecoratedPotBlockEntitySherdsMixin",
|
"DecoratedPotBlockEntitySherdsMixin",
|
||||||
|
|
Loading…
Reference in a new issue