Update to 1.20.3
This commit is contained in:
parent
8fd31327b4
commit
6d2051d47d
8 changed files with 68 additions and 47 deletions
|
@ -4,15 +4,15 @@ org.gradle.parallel=true
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version=1.20.1
|
minecraft_version=1.20.3
|
||||||
yarn_mappings=1.20.1+build.2
|
yarn_mappings=1.20.3+build.1
|
||||||
loader_version=0.14.21
|
loader_version=0.15.0
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 3.1.1
|
mod_version = 3.1.2
|
||||||
maven_group = com.github.hhhzzzsss
|
maven_group = com.github.hhhzzzsss
|
||||||
archives_base_name = song-player
|
archives_base_name = song-player
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
fabric_version=0.83.1+1.20.1
|
fabric_version=0.91.1+1.20.3
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class FakePlayerEntity extends OtherClientPlayerEntity {
|
||||||
capeY = getY();
|
capeY = getY();
|
||||||
capeZ = getZ();
|
capeZ = getZ();
|
||||||
|
|
||||||
world.addEntity(getId(), this);
|
world.addEntity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetPlayerPosition() {
|
public void resetPlayerPosition() {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtList;
|
import net.minecraft.nbt.NbtList;
|
||||||
import net.minecraft.nbt.NbtString;
|
import net.minecraft.nbt.NbtString;
|
||||||
import net.minecraft.text.LiteralTextContent;
|
import net.minecraft.text.PlainTextContent;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Style;
|
import net.minecraft.text.Style;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
@ -216,19 +216,19 @@ public class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MutableText getStyledText(String str, Style style) {
|
public static MutableText getStyledText(String str, Style style) {
|
||||||
MutableText text = MutableText.of(new LiteralTextContent(str));
|
MutableText text = MutableText.of(PlainTextContent.of(str));
|
||||||
text.setStyle(style);
|
text.setStyle(style);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setItemName(ItemStack stack, Text text) {
|
public static void setItemName(ItemStack stack, Text text) {
|
||||||
stack.getOrCreateSubNbt(ItemStack.DISPLAY_KEY).putString(ItemStack.NAME_KEY, Text.Serializer.toJson(text));
|
stack.getOrCreateSubNbt(ItemStack.DISPLAY_KEY).putString(ItemStack.NAME_KEY, Text.Serialization.toJsonString(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setItemLore(ItemStack stack, Text... loreLines) {
|
public static void setItemLore(ItemStack stack, Text... loreLines) {
|
||||||
NbtList lore = new NbtList();
|
NbtList lore = new NbtList();
|
||||||
for (Text line : loreLines) {
|
for (Text line : loreLines) {
|
||||||
lore.add(NbtString.of(Text.Serializer.toJson(line)));
|
lore.add(NbtString.of(Text.Serialization.toJsonString(line)));
|
||||||
}
|
}
|
||||||
stack.getOrCreateSubNbt(ItemStack.DISPLAY_KEY).put(ItemStack.LORE_KEY, lore);
|
stack.getOrCreateSubNbt(ItemStack.DISPLAY_KEY).put(ItemStack.LORE_KEY, lore);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class SongItemConfirmationScreen extends Screen {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||||
this.renderBackground(context);
|
this.renderBackground(context, mouseX, mouseY, delta);
|
||||||
|
|
||||||
context.drawCenteredTextWithShadow(textRenderer, this.title, this.width / 2, 40, 0xFFFFFF);
|
context.drawCenteredTextWithShadow(textRenderer, this.title, this.width / 2, 40, 0xFFFFFF);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.github.hhhzzzsss.songplayer.mixin;
|
||||||
|
|
||||||
|
import com.github.hhhzzzsss.songplayer.Config;
|
||||||
|
import com.github.hhhzzzsss.songplayer.SongPlayer;
|
||||||
|
import com.github.hhhzzzsss.songplayer.playing.SongHandler;
|
||||||
|
import com.github.hhhzzzsss.songplayer.playing.Stage;
|
||||||
|
import net.minecraft.client.network.ClientCommonNetworkHandler;
|
||||||
|
import net.minecraft.entity.EntityPose;
|
||||||
|
import net.minecraft.network.ClientConnection;
|
||||||
|
import net.minecraft.network.packet.Packet;
|
||||||
|
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
|
||||||
|
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(ClientCommonNetworkHandler.class)
|
||||||
|
public class ClientCommonNetworkHandlerMixin {
|
||||||
|
@Shadow
|
||||||
|
private final ClientConnection connection;
|
||||||
|
|
||||||
|
public ClientCommonNetworkHandlerMixin() {
|
||||||
|
connection = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(at = @At("HEAD"), method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", cancellable = true)
|
||||||
|
private void onSendPacket(Packet<?> packet, CallbackInfo ci) {
|
||||||
|
Stage stage = SongHandler.getInstance().stage;
|
||||||
|
|
||||||
|
if (stage != null && packet instanceof PlayerMoveC2SPacket) {
|
||||||
|
if (!Config.getConfig().rotate) {
|
||||||
|
connection.send(new PlayerMoveC2SPacket.Full(stage.position.getX() + 0.5, stage.position.getY(), stage.position.getZ() + 0.5, SongPlayer.MC.player.getYaw(), SongPlayer.MC.player.getPitch(), true));
|
||||||
|
if (SongPlayer.fakePlayer != null) {
|
||||||
|
SongPlayer.fakePlayer.copyStagePosAndPlayerLook();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
else if (packet instanceof ClientCommandC2SPacket) {
|
||||||
|
ClientCommandC2SPacket.Mode mode = ((ClientCommandC2SPacket) packet).getMode();
|
||||||
|
if (SongPlayer.fakePlayer != null) {
|
||||||
|
if (mode == ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY) {
|
||||||
|
SongPlayer.fakePlayer.setSneaking(true);
|
||||||
|
SongPlayer.fakePlayer.setPose(EntityPose.CROUCHING);
|
||||||
|
}
|
||||||
|
else if (mode == ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY) {
|
||||||
|
SongPlayer.fakePlayer.setSneaking(false);
|
||||||
|
SongPlayer.fakePlayer.setPose(EntityPose.STANDING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,41 +23,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(ClientPlayNetworkHandler.class)
|
@Mixin(ClientPlayNetworkHandler.class)
|
||||||
public class ClientPlayNetworkHandlerMixin {
|
public class ClientPlayNetworkHandlerMixin {
|
||||||
@Shadow
|
|
||||||
private final ClientConnection connection;
|
|
||||||
|
|
||||||
public ClientPlayNetworkHandlerMixin() {
|
|
||||||
connection = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", cancellable = true)
|
|
||||||
private void onSendPacket(Packet<?> packet, CallbackInfo ci) {
|
|
||||||
Stage stage = SongHandler.getInstance().stage;
|
|
||||||
|
|
||||||
if (stage != null && packet instanceof PlayerMoveC2SPacket) {
|
|
||||||
if (!Config.getConfig().rotate) {
|
|
||||||
connection.send(new PlayerMoveC2SPacket.Full(stage.position.getX() + 0.5, stage.position.getY(), stage.position.getZ() + 0.5, SongPlayer.MC.player.getYaw(), SongPlayer.MC.player.getPitch(), true));
|
|
||||||
if (SongPlayer.fakePlayer != null) {
|
|
||||||
SongPlayer.fakePlayer.copyStagePosAndPlayerLook();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ci.cancel();
|
|
||||||
}
|
|
||||||
else if (packet instanceof ClientCommandC2SPacket) {
|
|
||||||
ClientCommandC2SPacket.Mode mode = ((ClientCommandC2SPacket) packet).getMode();
|
|
||||||
if (SongPlayer.fakePlayer != null) {
|
|
||||||
if (mode == ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY) {
|
|
||||||
SongPlayer.fakePlayer.setSneaking(true);
|
|
||||||
SongPlayer.fakePlayer.setPose(EntityPose.CROUCHING);
|
|
||||||
}
|
|
||||||
else if (mode == ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY) {
|
|
||||||
SongPlayer.fakePlayer.setSneaking(false);
|
|
||||||
SongPlayer.fakePlayer.setPose(EntityPose.STANDING);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "sendChatMessage(Ljava/lang/String;)V", cancellable=true)
|
@Inject(at = @At("HEAD"), method = "sendChatMessage(Ljava/lang/String;)V", cancellable=true)
|
||||||
private void onSendChatMessage(String content, CallbackInfo ci) {
|
private void onSendChatMessage(String content, CallbackInfo ci) {
|
||||||
boolean isCommand = CommandProcessor.processChatMessage(content);
|
boolean isCommand = CommandProcessor.processChatMessage(content);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.11",
|
"fabricloader": ">=0.14.11",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "1.20.x",
|
"minecraft": "1.20.3",
|
||||||
"java": ">=17"
|
"java": ">=17"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"ChatInputSuggestorMixin",
|
"ChatInputSuggestorMixin",
|
||||||
|
"ClientCommonNetworkHandlerMixin",
|
||||||
"ClientPlayerInteractionManagerAccessor",
|
"ClientPlayerInteractionManagerAccessor",
|
||||||
"ClientPlayNetworkHandlerAccessor",
|
"ClientPlayNetworkHandlerAccessor",
|
||||||
"ClientPlayNetworkHandlerMixin",
|
"ClientPlayNetworkHandlerMixin",
|
||||||
|
|
Loading…
Reference in a new issue