From 10d73a80bc7f08fae88a8a28626e359b14c0ca31 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Thu, 14 Mar 2024 00:07:46 -0400 Subject: [PATCH 01/13] ISSUE-75 - Introduce some fields for logging in and joining with vehicle --- .../annoyancefix/mixin/PlayerBaseMixin.java | 176 +++++++++--------- .../mixin/ServerPacketHandlerMixin.java | 69 +++++++ 2 files changed, 157 insertions(+), 88 deletions(-) create mode 100644 src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index 5188d34..a7c0e07 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -1,88 +1,88 @@ -//package com.github.telvarost.annoyancefix.mixin; -// -//import net.minecraft.entity.EntityBase; -//import net.minecraft.entity.Living; -//import net.minecraft.entity.player.PlayerBase; -//import net.minecraft.entity.player.PlayerContainer; -//import net.minecraft.item.ItemInstance; -//import net.minecraft.util.io.CompoundTag; -//import org.objectweb.asm.Opcodes; -//import org.spongepowered.asm.mixin.Mixin; -//import org.spongepowered.asm.mixin.Unique; -//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; -// -//@Mixin(PlayerBase.class) -//public class PlayerBaseMixin { -// -// @Unique -// private String _vehicleName = null; -// @Unique -// private boolean _playerInVehicle = false; -// @Unique -// private double _vehicleX = 0; -// @Unique -// private double _vehicleY = 70; -// @Unique -// private double _vehicleZ = 0; -// -// @Redirect( -// method = "interactWith", -// at = @At( -// value = "INVOKE", -// target = "Lnet/minecraft/entity/EntityBase;interact(Lnet/minecraft/entity/player/PlayerBase;)Z" -// ) -// ) -// public boolean interactWith(EntityBase instance, PlayerBase playerBase) { -// boolean canInteract = instance.interact(playerBase); -// -// if (canInteract) { -// _playerInVehicle = (instance.passenger != null); -// -// if (instance.passenger != null) { -// _vehicleName = instance.getClass().toString(); -// _vehicleX = Math.floor(instance.x); -// _vehicleY = Math.floor(instance.y); -// _vehicleZ = Math.floor(instance.z); -// } -// } -// -// return canInteract; -// } -// -// -// -// @Inject(method = "writeCustomDataToTag", at = @At("HEAD")) -// private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) { -// if (!true) { -// return; -// } -// -// tag.put("PlayerInVehicle", _playerInVehicle); -// -// if (_playerInVehicle) { -// tag.put("VehicleName", _vehicleName); -// tag.put("VehicleX", _vehicleX); -// tag.put("VehicleY", _vehicleY); -// tag.put("VehicleZ", _vehicleZ); -// } -// } -// -// @Inject(method = "readCustomDataFromTag", at = @At("HEAD")) -// private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info) { -// if (!true) { -// return; -// } -// -// _playerInVehicle = tag.getBoolean("PlayerInVehicle"); -// -// if (_playerInVehicle) { -// _vehicleName = tag.getString("VehicleName"); -// _vehicleX = tag.getDouble("VehicleX"); -// _vehicleY = tag.getDouble("VehicleY"); -// _vehicleZ = tag.getDouble("VehicleZ"); -// } -// } -//} +package com.github.telvarost.annoyancefix.mixin; + +import net.minecraft.entity.EntityBase; +import net.minecraft.entity.Living; +import net.minecraft.entity.player.PlayerBase; +import net.minecraft.entity.player.PlayerContainer; +import net.minecraft.item.ItemInstance; +import net.minecraft.util.io.CompoundTag; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +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; + +@Mixin(PlayerBase.class) +public class PlayerBaseMixin { + + @Unique + private String _vehicleName = null; + @Unique + private boolean _playerInVehicle = false; + @Unique + private double _vehicleX = 0; + @Unique + private double _vehicleY = 70; + @Unique + private double _vehicleZ = 0; + + @Redirect( + method = "interactWith", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/EntityBase;interact(Lnet/minecraft/entity/player/PlayerBase;)Z" + ) + ) + public boolean interactWith(EntityBase instance, PlayerBase playerBase) { + boolean canInteract = instance.interact(playerBase); + + if (canInteract) { + _playerInVehicle = (instance.passenger != null); + + if (instance.passenger != null) { + _vehicleName = instance.getClass().toString(); + _vehicleX = Math.floor(instance.x); + _vehicleY = Math.floor(instance.y); + _vehicleZ = Math.floor(instance.z); + } + } + + return canInteract; + } + + + + @Inject(method = "writeCustomDataToTag", at = @At("HEAD")) + private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) { + if (!true) { + return; + } + + tag.put("PlayerInVehicle", _playerInVehicle); + + if (_playerInVehicle) { + tag.put("VehicleName", _vehicleName); + tag.put("VehicleX", _vehicleX); + tag.put("VehicleY", _vehicleY); + tag.put("VehicleZ", _vehicleZ); + } + } + + @Inject(method = "readCustomDataFromTag", at = @At("HEAD")) + private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info) { + if (!true) { + return; + } + + _playerInVehicle = tag.getBoolean("PlayerInVehicle"); + + if (_playerInVehicle) { + _vehicleName = tag.getString("VehicleName"); + _vehicleX = tag.getDouble("VehicleX"); + _vehicleY = tag.getDouble("VehicleY"); + _vehicleZ = tag.getDouble("VehicleZ"); + } + } +} diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java new file mode 100644 index 0000000..47f929f --- /dev/null +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -0,0 +1,69 @@ +package com.github.telvarost.annoyancefix.mixin; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.entity.player.ServerPlayer; +import net.minecraft.packet.login.LoginRequest0x1Packet; +import net.minecraft.packet.play.ChatMessage0x3Packet; +import net.minecraft.packet.play.SpawnPosition0x6S2CPacket; +import net.minecraft.packet.play.TimeUpdate0x4S2CPacket; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.network.ClientConnection; +import net.minecraft.server.network.ServerPacketHandler; +import net.minecraft.server.network.ServerPlayerPacketHandler; +import net.minecraft.util.Vec3i; +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; + +import java.util.logging.Logger; + +@Environment(EnvType.SERVER) +@Mixin(ServerPacketHandler.class) +public abstract class ServerPacketHandlerMixin { + + + @Shadow private MinecraftServer server; + + @Shadow public abstract String getUsernameAndIp(); + + @Shadow public static Logger logger; + + @Shadow public ClientConnection playNetworkHandler; + + @Shadow public boolean closed; + + @Inject( + method = "complete", + at = @At("HEAD"), + cancellable = true + ) + public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { + ServerPlayer var2 = this.server.serverPlayerConnectionManager.connectPlayer(((ServerPacketHandler) (Object)this), arg.username); + if (var2 != null) { + this.server.serverPlayerConnectionManager.method_566(var2); + var2.setLevel(this.server.getLevel(var2.dimensionId)); + logger.info(this.getUsernameAndIp() + " logged in with entity id " + var2.entityId + " at (" + var2.x + ", " + var2.y + ", " + var2.z + ")"); + ServerLevel var3 = this.server.getLevel(var2.dimensionId); + Vec3i var4 = var3.getSpawnPosition(); + ServerPlayerPacketHandler var5 = new ServerPlayerPacketHandler(this.server, this.playNetworkHandler, var2); + var5.send(new LoginRequest0x1Packet("", var2.entityId, var3.getSeed(), (byte)var3.dimension.id)); + var5.send(new SpawnPosition0x6S2CPacket(var4.x, var4.y, var4.z)); + + var2.startRiding(var2.vehicle); // <-- Add join vehicle here + + this.server.serverPlayerConnectionManager.sendPlayerTime(var2, var3); + this.server.serverPlayerConnectionManager.sendToAll(new ChatMessage0x3Packet("§e" + var2.name + " joined the game.")); + this.server.serverPlayerConnectionManager.method_569(var2); + var5.method_832(var2.x, var2.y, var2.z, var2.yaw, var2.pitch); + this.server.pendingConnectionManager.method_38(var5); + var5.send(new TimeUpdate0x4S2CPacket(var3.getLevelTime())); + var2.method_317(); + } + + this.closed = true; + } +} From c7db71b259cde8b4bf77331c310ac1f947f08676 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Thu, 14 Mar 2024 00:33:56 -0400 Subject: [PATCH 02/13] ISSUE-75 - Join servers with a boat --- .../annoyancefix/mixin/ServerPacketHandlerMixin.java | 10 +++++++--- src/main/resources/annoyancefix.mixins.json | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index 47f929f..9ceae2d 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -2,6 +2,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.entity.Boat; import net.minecraft.entity.player.ServerPlayer; import net.minecraft.packet.login.LoginRequest0x1Packet; import net.minecraft.packet.play.ChatMessage0x3Packet; @@ -52,9 +53,6 @@ public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { ServerPlayerPacketHandler var5 = new ServerPlayerPacketHandler(this.server, this.playNetworkHandler, var2); var5.send(new LoginRequest0x1Packet("", var2.entityId, var3.getSeed(), (byte)var3.dimension.id)); var5.send(new SpawnPosition0x6S2CPacket(var4.x, var4.y, var4.z)); - - var2.startRiding(var2.vehicle); // <-- Add join vehicle here - this.server.serverPlayerConnectionManager.sendPlayerTime(var2, var3); this.server.serverPlayerConnectionManager.sendToAll(new ChatMessage0x3Packet("§e" + var2.name + " joined the game.")); this.server.serverPlayerConnectionManager.method_569(var2); @@ -62,8 +60,14 @@ public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { this.server.pendingConnectionManager.method_38(var5); var5.send(new TimeUpdate0x4S2CPacket(var3.getLevelTime())); var2.method_317(); + + /** - For now just force spawn a boat */ + Boat spawnedBoat = new Boat(var2.level, var2.x, var2.y, var2.z); + var2.level.spawnEntity(spawnedBoat); + var2.startRiding(spawnedBoat); // <-- Add join vehicle here } this.closed = true; + ci.cancel(); } } diff --git a/src/main/resources/annoyancefix.mixins.json b/src/main/resources/annoyancefix.mixins.json index b035f16..af4e53e 100644 --- a/src/main/resources/annoyancefix.mixins.json +++ b/src/main/resources/annoyancefix.mixins.json @@ -20,6 +20,7 @@ "ToolBaseMixin" ], "server": [ + "ServerPacketHandlerMixin" ], "client": [ "PlayerInventoryMixin", From d72929d44502fa8e2ddcfdfe43d8a8f3398981de Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Thu, 14 Mar 2024 20:41:11 -0400 Subject: [PATCH 03/13] ISSUE-75 - Remove vehicle on log out --- .../ServerPlayerConnectionManagerMixin.java | 43 +++++++++++++++++++ src/main/resources/annoyancefix.mixins.json | 3 +- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java new file mode 100644 index 0000000..5b3a174 --- /dev/null +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java @@ -0,0 +1,43 @@ +package com.github.telvarost.annoyancefix.mixin; + +import net.minecraft.entity.player.ServerPlayer; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.PlayerHandler; +import net.minecraft.server.ServerPlayerConnectionManager; +import net.minecraft.server.ServerPlayerView; +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; + +import java.util.List; + +@Mixin(ServerPlayerConnectionManager.class) +public abstract class ServerPlayerConnectionManagerMixin { + + + @Shadow private PlayerHandler field_590; + + @Shadow private MinecraftServer server; + + @Shadow public List players; + + @Shadow protected abstract ServerPlayerView getPlayerView(int i); + + @Inject( + method = "updateDimension", + at = @At("HEAD"), + cancellable = true + ) + public void updateDimension(ServerPlayer arg, CallbackInfo ci) { + if (null != arg.vehicle) { + arg.level.removeEntity(arg.vehicle); + } + this.field_590.savePlayer(arg); + this.server.getLevel(arg.dimensionId).removeEntity(arg); + this.players.remove(arg); + this.getPlayerView(arg.dimensionId).addPlayer(arg); + ci.cancel(); + } +} diff --git a/src/main/resources/annoyancefix.mixins.json b/src/main/resources/annoyancefix.mixins.json index af4e53e..34485b7 100644 --- a/src/main/resources/annoyancefix.mixins.json +++ b/src/main/resources/annoyancefix.mixins.json @@ -20,7 +20,8 @@ "ToolBaseMixin" ], "server": [ - "ServerPacketHandlerMixin" + "ServerPacketHandlerMixin", + "ServerPlayerConnectionManagerMixin" ], "client": [ "PlayerInventoryMixin", From e7b227aab58c91798ef736fe9350521ca105d96e Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Thu, 14 Mar 2024 23:01:55 -0400 Subject: [PATCH 04/13] ISSUE-75 - Push up full code --- .../telvarost/annoyancefix/ModHelper.java | 14 ++++++ .../interfaces/VehicleInterface.java | 21 +++++++++ .../annoyancefix/mixin/PlayerBaseMixin.java | 47 ++++++++++++++++--- .../mixin/ServerPacketHandlerMixin.java | 14 ++++-- .../ServerPlayerConnectionManagerMixin.java | 2 + src/main/resources/annoyancefix.mixins.json | 1 + src/main/resources/fabric.mod.json | 8 ++++ 7 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java diff --git a/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java b/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java index 9d5ff85..67eb70d 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java +++ b/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java @@ -7,6 +7,18 @@ public enum BlockTypeEnum { SLAB_BLOCK_IS_WOODEN } + public static byte toByte(boolean value) { + return (byte) (value ? 1 : 0); + } + + public static boolean toBool(byte value) { + return value > 0; + } + + public static final int IS_RIDING_VEHICLE_ID = 20; + + public static final int VEHICLE_NAME_ID = 21; + public static class ModHelperFields { /** @brief - Special data for remembering block type */ @@ -14,5 +26,7 @@ public static class ModHelperFields { /** @brief - Special data for flint and steel fixes */ public static Boolean isFireLit = false; + + public static String vehicleName = ""; } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java b/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java new file mode 100644 index 0000000..2e2e01a --- /dev/null +++ b/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java @@ -0,0 +1,21 @@ +package com.github.telvarost.annoyancefix.interfaces; + +import net.modificationstation.stationapi.api.util.Util; + +public interface VehicleInterface { + default boolean vehicle_isRiding() { + return Util.assertImpl(); + } + + default void vehicle_setIsRiding(boolean creative) { + Util.assertImpl(); + } + + default String vehicle_getVehicleName() { + return Util.assertImpl(); + } + + default void vehicle_setVehicleName(String vehicleName) { + Util.assertImpl(); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index a7c0e07..36f9b60 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -1,11 +1,15 @@ package com.github.telvarost.annoyancefix.mixin; +import com.github.telvarost.annoyancefix.ModHelper; +import com.github.telvarost.annoyancefix.interfaces.VehicleInterface; import net.minecraft.entity.EntityBase; import net.minecraft.entity.Living; import net.minecraft.entity.player.PlayerBase; import net.minecraft.entity.player.PlayerContainer; import net.minecraft.item.ItemInstance; +import net.minecraft.level.Level; import net.minecraft.util.io.CompoundTag; +import net.modificationstation.stationapi.api.util.Util; import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -15,12 +19,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PlayerBase.class) -public class PlayerBaseMixin { +public class PlayerBaseMixin extends Living implements VehicleInterface { @Unique - private String _vehicleName = null; + public String _vehicleName = null; @Unique - private boolean _playerInVehicle = false; + public boolean _playerInVehicle = false; @Unique private double _vehicleX = 0; @Unique @@ -28,6 +32,31 @@ public class PlayerBaseMixin { @Unique private double _vehicleZ = 0; + public PlayerBaseMixin(Level arg) { + super(arg); + } + + + @Override + public boolean vehicle_isRiding() { + return ModHelper.toBool(dataTracker.getByte(ModHelper.IS_RIDING_VEHICLE_ID)); + } + + @Override + public void vehicle_setIsRiding(boolean isRiding) { + this.dataTracker.setInt(ModHelper.IS_RIDING_VEHICLE_ID, ModHelper.toByte(isRiding)); + } + + @Override + public String vehicle_getVehicleName() { + return dataTracker.getString(ModHelper.VEHICLE_NAME_ID); + } + + @Override + public void vehicle_setVehicleName(String vehicleName) { + this.dataTracker.setInt(ModHelper.VEHICLE_NAME_ID, vehicleName); + } + @Redirect( method = "interactWith", at = @At( @@ -40,12 +69,16 @@ public boolean interactWith(EntityBase instance, PlayerBase playerBase) { if (canInteract) { _playerInVehicle = (instance.passenger != null); + this.vehicle_setIsRiding(_playerInVehicle); if (instance.passenger != null) { - _vehicleName = instance.getClass().toString(); + this.vehicle_setVehicleName(instance.getClass().toString()); + ModHelper.ModHelperFields.vehicleName = instance.getClass().toString(); _vehicleX = Math.floor(instance.x); _vehicleY = Math.floor(instance.y); _vehicleZ = Math.floor(instance.z); + } else { + ModHelper.ModHelperFields.vehicleName = ""; } } @@ -63,7 +96,7 @@ private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) tag.put("PlayerInVehicle", _playerInVehicle); if (_playerInVehicle) { - tag.put("VehicleName", _vehicleName); + tag.put("VehicleName", ModHelper.ModHelperFields.vehicleName); tag.put("VehicleX", _vehicleX); tag.put("VehicleY", _vehicleY); tag.put("VehicleZ", _vehicleZ); @@ -77,9 +110,11 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info } _playerInVehicle = tag.getBoolean("PlayerInVehicle"); + vehicle_isRiding(_playerInVehicle); if (_playerInVehicle) { - _vehicleName = tag.getString("VehicleName"); + //this.vehicle_setVehicleName(instance.getClass().toString()); + ModHelper.ModHelperFields.vehicleName = tag.getString("VehicleName"); _vehicleX = tag.getDouble("VehicleX"); _vehicleY = tag.getDouble("VehicleY"); _vehicleZ = tag.getDouble("VehicleZ"); diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index 9ceae2d..efdd306 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -1,8 +1,11 @@ package com.github.telvarost.annoyancefix.mixin; +import com.github.telvarost.annoyancefix.ModHelper; +import com.github.telvarost.annoyancefix.interfaces.VehicleInterface; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.entity.Boat; +import net.minecraft.entity.player.PlayerBase; import net.minecraft.entity.player.ServerPlayer; import net.minecraft.packet.login.LoginRequest0x1Packet; import net.minecraft.packet.play.ChatMessage0x3Packet; @@ -20,6 +23,9 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; import java.util.logging.Logger; @Environment(EnvType.SERVER) @@ -62,9 +68,11 @@ public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { var2.method_317(); /** - For now just force spawn a boat */ - Boat spawnedBoat = new Boat(var2.level, var2.x, var2.y, var2.z); - var2.level.spawnEntity(spawnedBoat); - var2.startRiding(spawnedBoat); // <-- Add join vehicle here + if (var2.vehicle_isRiding()) { + Boat spawnedBoat = new Boat(var2.level, var2.x, var2.y, var2.z); + var2.level.spawnEntity(var2.vehicle); + var2.startRiding(var2.vehicle); // <-- Add join vehicle here + } } this.closed = true; diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java index 5b3a174..98f3e3f 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java @@ -11,6 +11,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.io.FileWriter; +import java.io.IOException; import java.util.List; @Mixin(ServerPlayerConnectionManager.class) diff --git a/src/main/resources/annoyancefix.mixins.json b/src/main/resources/annoyancefix.mixins.json index 34485b7..02806ef 100644 --- a/src/main/resources/annoyancefix.mixins.json +++ b/src/main/resources/annoyancefix.mixins.json @@ -16,6 +16,7 @@ "MinecraftMixin", "PickaxeMixin", "PigMixin", + "PlayerBaseMixin", "StairsMixin", "ToolBaseMixin" ], diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index dabd51d..4579d98 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -41,5 +41,13 @@ "depends": { "minecraft": "1.0.0-beta.7.3" + }, + + "custom": { + "loom:injected_interfaces": { + "net/minecraft/class_54": [ + "com/github/telvarost/annoyancefix/interfaces/VehicleInterface" + ] + } } } From 63ede04d4e5c6ea92b5631647a1efe357571a1d8 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Thu, 14 Mar 2024 23:03:49 -0400 Subject: [PATCH 05/13] ISSUE-75 - Clean up imports and make code runnable --- .../telvarost/annoyancefix/mixin/PlayerBaseMixin.java | 6 +----- .../annoyancefix/mixin/ServerPacketHandlerMixin.java | 6 ------ .../mixin/ServerPlayerConnectionManagerMixin.java | 2 -- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index 36f9b60..261adf6 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -5,12 +5,8 @@ import net.minecraft.entity.EntityBase; import net.minecraft.entity.Living; import net.minecraft.entity.player.PlayerBase; -import net.minecraft.entity.player.PlayerContainer; -import net.minecraft.item.ItemInstance; import net.minecraft.level.Level; import net.minecraft.util.io.CompoundTag; -import net.modificationstation.stationapi.api.util.Util; -import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -110,7 +106,7 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info } _playerInVehicle = tag.getBoolean("PlayerInVehicle"); - vehicle_isRiding(_playerInVehicle); + //this.vehicle_getIsRiding(_playerInVehicle); if (_playerInVehicle) { //this.vehicle_setVehicleName(instance.getClass().toString()); diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index efdd306..3f646a8 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -1,11 +1,8 @@ package com.github.telvarost.annoyancefix.mixin; -import com.github.telvarost.annoyancefix.ModHelper; -import com.github.telvarost.annoyancefix.interfaces.VehicleInterface; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.entity.Boat; -import net.minecraft.entity.player.PlayerBase; import net.minecraft.entity.player.ServerPlayer; import net.minecraft.packet.login.LoginRequest0x1Packet; import net.minecraft.packet.play.ChatMessage0x3Packet; @@ -23,9 +20,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; import java.util.logging.Logger; @Environment(EnvType.SERVER) diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java index 98f3e3f..5b3a174 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java @@ -11,8 +11,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import java.io.FileWriter; -import java.io.IOException; import java.util.List; @Mixin(ServerPlayerConnectionManager.class) From f582a174e431efad8eab269f13e58c85246934e3 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Thu, 14 Mar 2024 23:58:12 -0400 Subject: [PATCH 06/13] ISSUE-75 - Teachings of paulevs with silly telvarost code --- .../telvarost/annoyancefix/ModHelper.java | 2 +- .../interfaces/VehicleInterface.java | 5 +- .../annoyancefix/mixin/PlayerBaseMixin.java | 57 ++++++++++--------- .../mixin/ServerPacketHandlerMixin.java | 14 ++++- 4 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java b/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java index 67eb70d..ebdfe38 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java +++ b/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java @@ -17,7 +17,7 @@ public static boolean toBool(byte value) { public static final int IS_RIDING_VEHICLE_ID = 20; - public static final int VEHICLE_NAME_ID = 21; + public static final int VEHICLE_INFO_ID = 21; public static class ModHelperFields { diff --git a/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java b/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java index 2e2e01a..df7a975 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java +++ b/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java @@ -1,5 +1,6 @@ package com.github.telvarost.annoyancefix.interfaces; +import net.minecraft.util.io.CompoundTag; import net.modificationstation.stationapi.api.util.Util; public interface VehicleInterface { @@ -11,11 +12,11 @@ default void vehicle_setIsRiding(boolean creative) { Util.assertImpl(); } - default String vehicle_getVehicleName() { + default CompoundTag vehicle_getVehicle() { return Util.assertImpl(); } - default void vehicle_setVehicleName(String vehicleName) { + default void vehicle_setVehicle(CompoundTag vehicle) { Util.assertImpl(); } } \ No newline at end of file diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index 261adf6..136a4a8 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -8,6 +8,7 @@ import net.minecraft.level.Level; import net.minecraft.util.io.CompoundTag; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -15,24 +16,20 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PlayerBase.class) -public class PlayerBaseMixin extends Living implements VehicleInterface { +public abstract class PlayerBaseMixin extends Living implements VehicleInterface { + + @Shadow public abstract void readCustomDataFromTag(CompoundTag arg); - @Unique - public String _vehicleName = null; @Unique public boolean _playerInVehicle = false; + @Unique - private double _vehicleX = 0; - @Unique - private double _vehicleY = 70; - @Unique - private double _vehicleZ = 0; + public CompoundTag _vehicleTag = new CompoundTag(); public PlayerBaseMixin(Level arg) { super(arg); } - @Override public boolean vehicle_isRiding() { return ModHelper.toBool(dataTracker.getByte(ModHelper.IS_RIDING_VEHICLE_ID)); @@ -44,13 +41,13 @@ public void vehicle_setIsRiding(boolean isRiding) { } @Override - public String vehicle_getVehicleName() { - return dataTracker.getString(ModHelper.VEHICLE_NAME_ID); + public CompoundTag vehicle_getVehicle() { + return _vehicleTag; } @Override - public void vehicle_setVehicleName(String vehicleName) { - this.dataTracker.setInt(ModHelper.VEHICLE_NAME_ID, vehicleName); + public void vehicle_setVehicle(CompoundTag vehicleTag) { + _vehicleTag = vehicleTag; } @Redirect( @@ -68,11 +65,8 @@ public boolean interactWith(EntityBase instance, PlayerBase playerBase) { this.vehicle_setIsRiding(_playerInVehicle); if (instance.passenger != null) { - this.vehicle_setVehicleName(instance.getClass().toString()); + //this.vehicle_setVehicleName(instance.getClass().toString()); ModHelper.ModHelperFields.vehicleName = instance.getClass().toString(); - _vehicleX = Math.floor(instance.x); - _vehicleY = Math.floor(instance.y); - _vehicleZ = Math.floor(instance.z); } else { ModHelper.ModHelperFields.vehicleName = ""; } @@ -90,12 +84,13 @@ private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) } tag.put("PlayerInVehicle", _playerInVehicle); + vehicle_setIsRiding(_playerInVehicle); + if (_playerInVehicle) { - tag.put("VehicleName", ModHelper.ModHelperFields.vehicleName); - tag.put("VehicleX", _vehicleX); - tag.put("VehicleY", _vehicleY); - tag.put("VehicleZ", _vehicleZ); + this.vehicle.toTag(_vehicleTag); + tag.put("Vehicle", _vehicleTag); + vehicle_setVehicle(_vehicleTag); } } @@ -106,14 +101,22 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info } _playerInVehicle = tag.getBoolean("PlayerInVehicle"); - //this.vehicle_getIsRiding(_playerInVehicle); + this.vehicle_setIsRiding(_playerInVehicle); + if (_playerInVehicle) { - //this.vehicle_setVehicleName(instance.getClass().toString()); - ModHelper.ModHelperFields.vehicleName = tag.getString("VehicleName"); - _vehicleX = tag.getDouble("VehicleX"); - _vehicleY = tag.getDouble("VehicleY"); - _vehicleZ = tag.getDouble("VehicleZ"); + _vehicleTag = tag.getCompoundTag("Vehicle"); + vehicle_setVehicle(_vehicleTag); } } + + @Inject(method = "initDataTracker", at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/Living;initDataTracker()V", + shift = At.Shift.AFTER + )) + private void creative_trackData(CallbackInfo info) { + this.dataTracker.startTracking(ModHelper.IS_RIDING_VEHICLE_ID, (byte) 0); + this.dataTracker.startTracking(ModHelper.VEHICLE_INFO_ID, new CompoundTag()); + } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index 3f646a8..d5fc5ba 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -3,6 +3,8 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.entity.Boat; +import net.minecraft.entity.EntityBase; +import net.minecraft.entity.EntityRegistry; import net.minecraft.entity.player.ServerPlayer; import net.minecraft.packet.login.LoginRequest0x1Packet; import net.minecraft.packet.play.ChatMessage0x3Packet; @@ -14,6 +16,7 @@ import net.minecraft.server.network.ServerPacketHandler; import net.minecraft.server.network.ServerPlayerPacketHandler; import net.minecraft.util.Vec3i; +import net.minecraft.util.io.CompoundTag; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -63,9 +66,14 @@ public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { /** - For now just force spawn a boat */ if (var2.vehicle_isRiding()) { - Boat spawnedBoat = new Boat(var2.level, var2.x, var2.y, var2.z); - var2.level.spawnEntity(var2.vehicle); - var2.startRiding(var2.vehicle); // <-- Add join vehicle here + //if (level.isRemote) return; // We are client connected to server, server do all the job + CompoundTag vehicleTag = var2.vehicle_getVehicle(); + if (vehicleTag != null) { + String vehicleName = vehicleTag.getString("vehicleName"); // Or in any other way that you store that data + EntityBase vehicle = EntityRegistry.create(vehicleName, var2.level); + vehicle.fromTag(vehicleTag); + var2.startRiding(vehicle); + } } } From 23c40ef859819f501bd2f35e86b43573ab4465c8 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Fri, 15 Mar 2024 00:17:01 -0400 Subject: [PATCH 07/13] ISSUE-75 - Current iterations understanding of NBT and such --- .../annoyancefix/mixin/PlayerBaseMixin.java | 25 ++++- .../mixin/ServerPacketHandlerMixin.java | 96 ++++++++----------- 2 files changed, 62 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index 136a4a8..3bed332 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -3,6 +3,7 @@ import com.github.telvarost.annoyancefix.ModHelper; import com.github.telvarost.annoyancefix.interfaces.VehicleInterface; import net.minecraft.entity.EntityBase; +import net.minecraft.entity.EntityRegistry; import net.minecraft.entity.Living; import net.minecraft.entity.player.PlayerBase; import net.minecraft.level.Level; @@ -65,6 +66,8 @@ public boolean interactWith(EntityBase instance, PlayerBase playerBase) { this.vehicle_setIsRiding(_playerInVehicle); if (instance.passenger != null) { + this.vehicle.toTag(_vehicleTag); + vehicle_setVehicle(_vehicleTag); //this.vehicle_setVehicleName(instance.getClass().toString()); ModHelper.ModHelperFields.vehicleName = instance.getClass().toString(); } else { @@ -88,9 +91,11 @@ private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) if (_playerInVehicle) { - this.vehicle.toTag(_vehicleTag); - tag.put("Vehicle", _vehicleTag); - vehicle_setVehicle(_vehicleTag); + if (null != this.vehicle) { + this.vehicle.toTag(_vehicleTag); + tag.put("Vehicle", _vehicleTag); + vehicle_setVehicle(_vehicleTag); + } } } @@ -108,6 +113,18 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info _vehicleTag = tag.getCompoundTag("Vehicle"); vehicle_setVehicle(_vehicleTag); } + + if (level.isServerSide) return; // We are client connected to server, server do all the job + _vehicleTag = vehicle_getVehicle(); + if (_vehicleTag == null) return; // Not riding anything + String vehicleName = _vehicleTag.getString("vehicleName"); // Or in any other way that you store that data + EntityBase vehicle = EntityRegistry.create(vehicleName, level); + if (null != vehicle) { + vehicle.setPositionAndAngles(x, y, z, yaw, pitch); + vehicle.fromTag(_vehicleTag); + level.spawnEntity(vehicle); + startRiding(vehicle); + } } @Inject(method = "initDataTracker", at = @At( @@ -117,6 +134,6 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info )) private void creative_trackData(CallbackInfo info) { this.dataTracker.startTracking(ModHelper.IS_RIDING_VEHICLE_ID, (byte) 0); - this.dataTracker.startTracking(ModHelper.VEHICLE_INFO_ID, new CompoundTag()); + //this.dataTracker.startTracking(ModHelper.VEHICLE_INFO_ID, new CompoundTag()); } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index d5fc5ba..a372e68 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -2,26 +2,11 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.entity.Boat; -import net.minecraft.entity.EntityBase; -import net.minecraft.entity.EntityRegistry; -import net.minecraft.entity.player.ServerPlayer; -import net.minecraft.packet.login.LoginRequest0x1Packet; -import net.minecraft.packet.play.ChatMessage0x3Packet; -import net.minecraft.packet.play.SpawnPosition0x6S2CPacket; -import net.minecraft.packet.play.TimeUpdate0x4S2CPacket; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; import net.minecraft.server.network.ClientConnection; import net.minecraft.server.network.ServerPacketHandler; -import net.minecraft.server.network.ServerPlayerPacketHandler; -import net.minecraft.util.Vec3i; -import net.minecraft.util.io.CompoundTag; 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; import java.util.logging.Logger; @@ -40,44 +25,45 @@ public abstract class ServerPacketHandlerMixin { @Shadow public boolean closed; - @Inject( - method = "complete", - at = @At("HEAD"), - cancellable = true - ) - public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { - ServerPlayer var2 = this.server.serverPlayerConnectionManager.connectPlayer(((ServerPacketHandler) (Object)this), arg.username); - if (var2 != null) { - this.server.serverPlayerConnectionManager.method_566(var2); - var2.setLevel(this.server.getLevel(var2.dimensionId)); - logger.info(this.getUsernameAndIp() + " logged in with entity id " + var2.entityId + " at (" + var2.x + ", " + var2.y + ", " + var2.z + ")"); - ServerLevel var3 = this.server.getLevel(var2.dimensionId); - Vec3i var4 = var3.getSpawnPosition(); - ServerPlayerPacketHandler var5 = new ServerPlayerPacketHandler(this.server, this.playNetworkHandler, var2); - var5.send(new LoginRequest0x1Packet("", var2.entityId, var3.getSeed(), (byte)var3.dimension.id)); - var5.send(new SpawnPosition0x6S2CPacket(var4.x, var4.y, var4.z)); - this.server.serverPlayerConnectionManager.sendPlayerTime(var2, var3); - this.server.serverPlayerConnectionManager.sendToAll(new ChatMessage0x3Packet("§e" + var2.name + " joined the game.")); - this.server.serverPlayerConnectionManager.method_569(var2); - var5.method_832(var2.x, var2.y, var2.z, var2.yaw, var2.pitch); - this.server.pendingConnectionManager.method_38(var5); - var5.send(new TimeUpdate0x4S2CPacket(var3.getLevelTime())); - var2.method_317(); - - /** - For now just force spawn a boat */ - if (var2.vehicle_isRiding()) { - //if (level.isRemote) return; // We are client connected to server, server do all the job - CompoundTag vehicleTag = var2.vehicle_getVehicle(); - if (vehicleTag != null) { - String vehicleName = vehicleTag.getString("vehicleName"); // Or in any other way that you store that data - EntityBase vehicle = EntityRegistry.create(vehicleName, var2.level); - vehicle.fromTag(vehicleTag); - var2.startRiding(vehicle); - } - } - } - - this.closed = true; - ci.cancel(); - } +// @Inject( +// method = "complete", +// at = @At("HEAD"), +// cancellable = true +// ) +// public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { +// ServerPlayer var2 = this.server.serverPlayerConnectionManager.connectPlayer(((ServerPacketHandler) (Object)this), arg.username); +// if (var2 != null) { +// this.server.serverPlayerConnectionManager.method_566(var2); +// var2.setLevel(this.server.getLevel(var2.dimensionId)); +// logger.info(this.getUsernameAndIp() + " logged in with entity id " + var2.entityId + " at (" + var2.x + ", " + var2.y + ", " + var2.z + ")"); +// ServerLevel var3 = this.server.getLevel(var2.dimensionId); +// Vec3i var4 = var3.getSpawnPosition(); +// ServerPlayerPacketHandler var5 = new ServerPlayerPacketHandler(this.server, this.playNetworkHandler, var2); +// var5.send(new LoginRequest0x1Packet("", var2.entityId, var3.getSeed(), (byte)var3.dimension.id)); +// var5.send(new SpawnPosition0x6S2CPacket(var4.x, var4.y, var4.z)); +// this.server.serverPlayerConnectionManager.sendPlayerTime(var2, var3); +// this.server.serverPlayerConnectionManager.sendToAll(new ChatMessage0x3Packet("§e" + var2.name + " joined the game.")); +// this.server.serverPlayerConnectionManager.method_569(var2); +// var5.method_832(var2.x, var2.y, var2.z, var2.yaw, var2.pitch); +// this.server.pendingConnectionManager.method_38(var5); +// var5.send(new TimeUpdate0x4S2CPacket(var3.getLevelTime())); +// var2.method_317(); +// +// /** - For now just force spawn a boat */ +// if (var2.vehicle_isRiding()) { +// //if (level.isRemote) return; // We are client connected to server, server do all the job +// CompoundTag vehicleTag = var2.vehicle_getVehicle(); +// if (vehicleTag != null) { +// String vehicleName = vehicleTag.getString("Vehicle"); // Or in any other way that you store that data +// EntityBase vehicle = EntityRegistry.create(vehicleName, var2.level); +// vehicle.fromTag(vehicleTag); +// var2.level.spawnEntity(vehicle); +// var2.startRiding(vehicle); +// } +// } +// } +// +// this.closed = true; +// ci.cancel(); +// } } From d50bc6159c1879521174aeab4a7ea898ecbf41a9 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:32:50 -0400 Subject: [PATCH 08/13] ISSUE-75 - Fully functional system for remaining in vehicle upon log out and re-log in --- gradle.properties | 2 +- .../telvarost/annoyancefix/ModHelper.java | 6 +- .../interfaces/VehicleInterface.java | 8 +- .../annoyancefix/mixin/PlayerBaseMixin.java | 109 ++++++++++++------ .../mixin/ServerPacketHandlerMixin.java | 103 ++++++++++------- .../ServerPlayerConnectionManagerMixin.java | 2 + 6 files changed, 144 insertions(+), 86 deletions(-) diff --git a/gradle.properties b/gradle.properties index e08ce47..ea5ffc4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=b1.7.3-build.2 loader_version=0.14.24-babric.1 # Mod Properties -mod_version=2.3.0 +mod_version=2.4.0 maven_group=com.github.telvarost archives_base_name=AnnoyanceFix diff --git a/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java b/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java index ebdfe38..bfca5df 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java +++ b/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java @@ -15,9 +15,9 @@ public static boolean toBool(byte value) { return value > 0; } - public static final int IS_RIDING_VEHICLE_ID = 20; + public static final int VEHICLE_NAME_ID = 20; - public static final int VEHICLE_INFO_ID = 21; + //public static final int VEHICLE_INFO_ID = 21; public static class ModHelperFields { @@ -26,7 +26,5 @@ public static class ModHelperFields { /** @brief - Special data for flint and steel fixes */ public static Boolean isFireLit = false; - - public static String vehicleName = ""; } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java b/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java index df7a975..9bc49b3 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java +++ b/src/main/java/com/github/telvarost/annoyancefix/interfaces/VehicleInterface.java @@ -4,19 +4,19 @@ import net.modificationstation.stationapi.api.util.Util; public interface VehicleInterface { - default boolean vehicle_isRiding() { + default String vehicle_getVehicleName() { return Util.assertImpl(); } - default void vehicle_setIsRiding(boolean creative) { + default void vehicle_setVehicleName(String vehicleName) { Util.assertImpl(); } - default CompoundTag vehicle_getVehicle() { + default CompoundTag vehicle_getVehicleTag() { return Util.assertImpl(); } - default void vehicle_setVehicle(CompoundTag vehicle) { + default void vehicle_setVehicleTag(CompoundTag vehicleTag) { Util.assertImpl(); } } \ No newline at end of file diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index 3bed332..f8636ff 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -2,12 +2,14 @@ import com.github.telvarost.annoyancefix.ModHelper; import com.github.telvarost.annoyancefix.interfaces.VehicleInterface; +import net.minecraft.entity.Boat; import net.minecraft.entity.EntityBase; import net.minecraft.entity.EntityRegistry; import net.minecraft.entity.Living; import net.minecraft.entity.player.PlayerBase; import net.minecraft.level.Level; import net.minecraft.util.io.CompoundTag; +import net.modificationstation.stationapi.api.entity.player.PlayerHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -21,8 +23,14 @@ public abstract class PlayerBaseMixin extends Living implements VehicleInterface @Shadow public abstract void readCustomDataFromTag(CompoundTag arg); +// @Unique +// public boolean _playerInVehicle = false; + + @Unique + private static String NULL_AS_STRING = "null"; + @Unique - public boolean _playerInVehicle = false; + public String _vehicleName = NULL_AS_STRING; @Unique public CompoundTag _vehicleTag = new CompoundTag(); @@ -32,22 +40,22 @@ public PlayerBaseMixin(Level arg) { } @Override - public boolean vehicle_isRiding() { - return ModHelper.toBool(dataTracker.getByte(ModHelper.IS_RIDING_VEHICLE_ID)); + public String vehicle_getVehicleName() { + return _vehicleName; //ModHelper.toBool(dataTracker.getByte(ModHelper.IS_RIDING_VEHICLE_ID)); } @Override - public void vehicle_setIsRiding(boolean isRiding) { - this.dataTracker.setInt(ModHelper.IS_RIDING_VEHICLE_ID, ModHelper.toByte(isRiding)); + public void vehicle_setVehicleName(String vehicleName) { + _vehicleName = vehicleName;//this.dataTracker.setInt(ModHelper.IS_RIDING_VEHICLE_ID, ModHelper.toByte(isRiding)); } @Override - public CompoundTag vehicle_getVehicle() { + public CompoundTag vehicle_getVehicleTag() { return _vehicleTag; } @Override - public void vehicle_setVehicle(CompoundTag vehicleTag) { + public void vehicle_setVehicleTag(CompoundTag vehicleTag) { _vehicleTag = vehicleTag; } @@ -62,17 +70,18 @@ public boolean interactWith(EntityBase instance, PlayerBase playerBase) { boolean canInteract = instance.interact(playerBase); if (canInteract) { - _playerInVehicle = (instance.passenger != null); - this.vehicle_setIsRiding(_playerInVehicle); - - if (instance.passenger != null) { - this.vehicle.toTag(_vehicleTag); - vehicle_setVehicle(_vehicleTag); - //this.vehicle_setVehicleName(instance.getClass().toString()); - ModHelper.ModHelperFields.vehicleName = instance.getClass().toString(); - } else { - ModHelper.ModHelperFields.vehicleName = ""; + _vehicleName = (instance.passenger != null) ? EntityRegistry.getStringId(instance) : NULL_AS_STRING; + //this.vehicle_setIsRiding(_playerInVehicle); + + if (!_vehicleName.equals(NULL_AS_STRING)) { + //_vehicleName = EntityRegistry.getStringId(instance); + instance.toTag(_vehicleTag); + //vehicle_setVehicle(_vehicleTag); } +// else { +// _vehicleTag = null; +// ModHelper.ModHelperFields.vehicleName = ""; +// } } return canInteract; @@ -86,16 +95,18 @@ private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) return; } - tag.put("PlayerInVehicle", _playerInVehicle); - vehicle_setIsRiding(_playerInVehicle); + //tag.put("PlayerInVehicle", _playerInVehicle); + //vehicle_setIsRiding(_playerInVehicle); + _vehicleName = (this.vehicle != null) ? EntityRegistry.getStringId(this.vehicle) : NULL_AS_STRING; + tag.put("VehicleName", _vehicleName); - if (_playerInVehicle) { - if (null != this.vehicle) { - this.vehicle.toTag(_vehicleTag); - tag.put("Vehicle", _vehicleTag); - vehicle_setVehicle(_vehicleTag); - } + if (!_vehicleName.equals(NULL_AS_STRING)) { + //if (null != this.vehicle) { + //this.vehicle.toTag(_vehicleTag); + tag.put("VehicleTag", _vehicleTag); + //vehicle_setVehicle(_vehicleTag); + //} } } @@ -105,23 +116,49 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info return; } - _playerInVehicle = tag.getBoolean("PlayerInVehicle"); - this.vehicle_setIsRiding(_playerInVehicle); + //_playerInVehicle = tag.getBoolean("PlayerInVehicle"); + //this.vehicle_setIsRiding(_playerInVehicle); + _vehicleName = tag.getString("VehicleName"); - if (_playerInVehicle) { - _vehicleTag = tag.getCompoundTag("Vehicle"); - vehicle_setVehicle(_vehicleTag); + if (!_vehicleName.equals(NULL_AS_STRING)) { + _vehicleTag = tag.getCompoundTag("VehicleTag"); + //vehicle_setVehicle(_vehicleTag); } + if (level.isServerSide) return; // We are client connected to server, server do all the job - _vehicleTag = vehicle_getVehicle(); + PlayerBase singlePlayer = PlayerHelper.getPlayerFromGame(); + if (null == singlePlayer) return; + //if () + //_vehicleTag = vehicle_getVehicle(); + if (_vehicleName.equals(NULL_AS_STRING)) return; // Not riding anything if (_vehicleTag == null) return; // Not riding anything - String vehicleName = _vehicleTag.getString("vehicleName"); // Or in any other way that you store that data - EntityBase vehicle = EntityRegistry.create(vehicleName, level); + //String vehicleName = _vehicleTag.getString("Vehicle"); // Or in any other way that you store that data + EntityBase vehicle = EntityRegistry.create(_vehicleName, level); if (null != vehicle) { - vehicle.setPositionAndAngles(x, y, z, yaw, pitch); - vehicle.fromTag(_vehicleTag); + + try { + vehicle.fromTag(_vehicleTag); + } catch(Exception ex) { + vehicle.setPositionAndAngles(x, y, z, yaw, pitch); + System.out.println("Failed to read vehicle data"); + } + + /** - Remove old entity if there is one */ + for (int entityIndex = 0; entityIndex < level.entities.size(); entityIndex++) { + EntityBase entityToCheck = (EntityBase)level.entities.get(entityIndex); + + if ( (entityToCheck.getClass().equals(vehicle.getClass())) + && (entityToCheck.x == vehicle.x) + && (entityToCheck.y == vehicle.y) + && (entityToCheck.z == vehicle.z) + ) { + //System.out.println("Found: " + entityToCheck.getClass()); + level.removeEntity(entityToCheck); + } + } + level.spawnEntity(vehicle); startRiding(vehicle); } @@ -133,7 +170,7 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info shift = At.Shift.AFTER )) private void creative_trackData(CallbackInfo info) { - this.dataTracker.startTracking(ModHelper.IS_RIDING_VEHICLE_ID, (byte) 0); + //this.dataTracker.startTracking(ModHelper.IS_RIDING_VEHICLE_ID, (byte) 0); //this.dataTracker.startTracking(ModHelper.VEHICLE_INFO_ID, new CompoundTag()); } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index a372e68..5ba8704 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -2,11 +2,25 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.entity.EntityBase; +import net.minecraft.entity.EntityRegistry; +import net.minecraft.entity.player.ServerPlayer; +import net.minecraft.packet.login.LoginRequest0x1Packet; +import net.minecraft.packet.play.ChatMessage0x3Packet; +import net.minecraft.packet.play.SpawnPosition0x6S2CPacket; +import net.minecraft.packet.play.TimeUpdate0x4S2CPacket; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.network.ClientConnection; import net.minecraft.server.network.ServerPacketHandler; +import net.minecraft.server.network.ServerPlayerPacketHandler; +import net.minecraft.util.Vec3i; +import net.minecraft.util.io.CompoundTag; 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; import java.util.logging.Logger; @@ -25,45 +39,52 @@ public abstract class ServerPacketHandlerMixin { @Shadow public boolean closed; -// @Inject( -// method = "complete", -// at = @At("HEAD"), -// cancellable = true -// ) -// public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { -// ServerPlayer var2 = this.server.serverPlayerConnectionManager.connectPlayer(((ServerPacketHandler) (Object)this), arg.username); -// if (var2 != null) { -// this.server.serverPlayerConnectionManager.method_566(var2); -// var2.setLevel(this.server.getLevel(var2.dimensionId)); -// logger.info(this.getUsernameAndIp() + " logged in with entity id " + var2.entityId + " at (" + var2.x + ", " + var2.y + ", " + var2.z + ")"); -// ServerLevel var3 = this.server.getLevel(var2.dimensionId); -// Vec3i var4 = var3.getSpawnPosition(); -// ServerPlayerPacketHandler var5 = new ServerPlayerPacketHandler(this.server, this.playNetworkHandler, var2); -// var5.send(new LoginRequest0x1Packet("", var2.entityId, var3.getSeed(), (byte)var3.dimension.id)); -// var5.send(new SpawnPosition0x6S2CPacket(var4.x, var4.y, var4.z)); -// this.server.serverPlayerConnectionManager.sendPlayerTime(var2, var3); -// this.server.serverPlayerConnectionManager.sendToAll(new ChatMessage0x3Packet("§e" + var2.name + " joined the game.")); -// this.server.serverPlayerConnectionManager.method_569(var2); -// var5.method_832(var2.x, var2.y, var2.z, var2.yaw, var2.pitch); -// this.server.pendingConnectionManager.method_38(var5); -// var5.send(new TimeUpdate0x4S2CPacket(var3.getLevelTime())); -// var2.method_317(); -// -// /** - For now just force spawn a boat */ -// if (var2.vehicle_isRiding()) { -// //if (level.isRemote) return; // We are client connected to server, server do all the job -// CompoundTag vehicleTag = var2.vehicle_getVehicle(); -// if (vehicleTag != null) { -// String vehicleName = vehicleTag.getString("Vehicle"); // Or in any other way that you store that data -// EntityBase vehicle = EntityRegistry.create(vehicleName, var2.level); -// vehicle.fromTag(vehicleTag); -// var2.level.spawnEntity(vehicle); -// var2.startRiding(vehicle); -// } -// } -// } -// -// this.closed = true; -// ci.cancel(); -// } + @Inject( + method = "complete", + at = @At("HEAD"), + cancellable = true + ) + public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { + ServerPlayer var2 = this.server.serverPlayerConnectionManager.connectPlayer(((ServerPacketHandler) (Object)this), arg.username); + if (var2 != null) { + this.server.serverPlayerConnectionManager.method_566(var2); + var2.setLevel(this.server.getLevel(var2.dimensionId)); + logger.info(this.getUsernameAndIp() + " logged in with entity id " + var2.entityId + " at (" + var2.x + ", " + var2.y + ", " + var2.z + ")"); + ServerLevel var3 = this.server.getLevel(var2.dimensionId); + Vec3i var4 = var3.getSpawnPosition(); + ServerPlayerPacketHandler var5 = new ServerPlayerPacketHandler(this.server, this.playNetworkHandler, var2); + var5.send(new LoginRequest0x1Packet("", var2.entityId, var3.getSeed(), (byte)var3.dimension.id)); + var5.send(new SpawnPosition0x6S2CPacket(var4.x, var4.y, var4.z)); + this.server.serverPlayerConnectionManager.sendPlayerTime(var2, var3); + this.server.serverPlayerConnectionManager.sendToAll(new ChatMessage0x3Packet("§e" + var2.name + " joined the game.")); + this.server.serverPlayerConnectionManager.method_569(var2); + var5.method_832(var2.x, var2.y, var2.z, var2.yaw, var2.pitch); + this.server.pendingConnectionManager.method_38(var5); + var5.send(new TimeUpdate0x4S2CPacket(var3.getLevelTime())); + var2.method_317(); + + /** - For now just force spawn a boat */ + String vehicleName = var2.vehicle_getVehicleName(); + if (!vehicleName.equals("null")) { + //if (level.isRemote) return; // We are client connected to server, server do all the job + CompoundTag vehicleTag = var2.vehicle_getVehicleTag(); + if (vehicleTag != null) { + EntityBase vehicle = EntityRegistry.create(vehicleName, var2.level); + if (null != vehicle) { + try { + vehicle.fromTag(vehicleTag); + } catch(Exception ex) { + vehicle.setPositionAndAngles(var2.x, var2.y, var2.z, var2.yaw, var2.pitch); + System.out.println("Failed to read vehicle data"); + } + var2.level.spawnEntity(vehicle); + var2.startRiding(vehicle); + } + } + } + } + + this.closed = true; + ci.cancel(); + } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java index 5b3a174..d2174d6 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java @@ -33,6 +33,8 @@ public abstract class ServerPlayerConnectionManagerMixin { public void updateDimension(ServerPlayer arg, CallbackInfo ci) { if (null != arg.vehicle) { arg.level.removeEntity(arg.vehicle); + } else { + arg.vehicle_setVehicleName("null"); } this.field_590.savePlayer(arg); this.server.getLevel(arg.dimensionId).removeEntity(arg); From f6d113069c301b642dd87308fa9fd68c013d03eb Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Sat, 16 Mar 2024 10:48:25 -0400 Subject: [PATCH 09/13] ISSUE-75 - Remove some disused code and add some comments --- .../telvarost/annoyancefix/ModHelper.java | 4 -- .../annoyancefix/mixin/PlayerBaseMixin.java | 57 ++++--------------- .../mixin/ServerPacketHandlerMixin.java | 1 - 3 files changed, 10 insertions(+), 52 deletions(-) diff --git a/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java b/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java index bfca5df..ea76870 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java +++ b/src/main/java/com/github/telvarost/annoyancefix/ModHelper.java @@ -15,10 +15,6 @@ public static boolean toBool(byte value) { return value > 0; } - public static final int VEHICLE_NAME_ID = 20; - - //public static final int VEHICLE_INFO_ID = 21; - public static class ModHelperFields { /** @brief - Special data for remembering block type */ diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index f8636ff..b50759e 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -21,11 +21,6 @@ @Mixin(PlayerBase.class) public abstract class PlayerBaseMixin extends Living implements VehicleInterface { - @Shadow public abstract void readCustomDataFromTag(CompoundTag arg); - -// @Unique -// public boolean _playerInVehicle = false; - @Unique private static String NULL_AS_STRING = "null"; @@ -41,12 +36,12 @@ public PlayerBaseMixin(Level arg) { @Override public String vehicle_getVehicleName() { - return _vehicleName; //ModHelper.toBool(dataTracker.getByte(ModHelper.IS_RIDING_VEHICLE_ID)); + return _vehicleName; } @Override public void vehicle_setVehicleName(String vehicleName) { - _vehicleName = vehicleName;//this.dataTracker.setInt(ModHelper.IS_RIDING_VEHICLE_ID, ModHelper.toByte(isRiding)); + _vehicleName = vehicleName; } @Override @@ -70,18 +65,11 @@ public boolean interactWith(EntityBase instance, PlayerBase playerBase) { boolean canInteract = instance.interact(playerBase); if (canInteract) { + /** - Set vehicle data */ _vehicleName = (instance.passenger != null) ? EntityRegistry.getStringId(instance) : NULL_AS_STRING; - //this.vehicle_setIsRiding(_playerInVehicle); - if (!_vehicleName.equals(NULL_AS_STRING)) { - //_vehicleName = EntityRegistry.getStringId(instance); instance.toTag(_vehicleTag); - //vehicle_setVehicle(_vehicleTag); } -// else { -// _vehicleTag = null; -// ModHelper.ModHelperFields.vehicleName = ""; -// } } return canInteract; @@ -95,18 +83,11 @@ private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) return; } - //tag.put("PlayerInVehicle", _playerInVehicle); - //vehicle_setIsRiding(_playerInVehicle); - + /** - Save vehicle data */ _vehicleName = (this.vehicle != null) ? EntityRegistry.getStringId(this.vehicle) : NULL_AS_STRING; tag.put("VehicleName", _vehicleName); - if (!_vehicleName.equals(NULL_AS_STRING)) { - //if (null != this.vehicle) { - //this.vehicle.toTag(_vehicleTag); - tag.put("VehicleTag", _vehicleTag); - //vehicle_setVehicle(_vehicleTag); - //} + tag.put("VehicleTag", _vehicleTag); } } @@ -116,25 +97,18 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info return; } - //_playerInVehicle = tag.getBoolean("PlayerInVehicle"); - //this.vehicle_setIsRiding(_playerInVehicle); - + /** - Get vehicle data */ _vehicleName = tag.getString("VehicleName"); - if (!_vehicleName.equals(NULL_AS_STRING)) { _vehicleTag = tag.getCompoundTag("VehicleTag"); - //vehicle_setVehicle(_vehicleTag); } - - if (level.isServerSide) return; // We are client connected to server, server do all the job + /** - Spawn vehicle if on single player (and remove old vehicle) */ + if (level.isServerSide) return; PlayerBase singlePlayer = PlayerHelper.getPlayerFromGame(); if (null == singlePlayer) return; - //if () - //_vehicleTag = vehicle_getVehicle(); - if (_vehicleName.equals(NULL_AS_STRING)) return; // Not riding anything - if (_vehicleTag == null) return; // Not riding anything - //String vehicleName = _vehicleTag.getString("Vehicle"); // Or in any other way that you store that data + if (null == _vehicleTag) return; + if (_vehicleName.equals(NULL_AS_STRING)) return; EntityBase vehicle = EntityRegistry.create(_vehicleName, level); if (null != vehicle) { @@ -154,7 +128,6 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info && (entityToCheck.y == vehicle.y) && (entityToCheck.z == vehicle.z) ) { - //System.out.println("Found: " + entityToCheck.getClass()); level.removeEntity(entityToCheck); } } @@ -163,14 +136,4 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info startRiding(vehicle); } } - - @Inject(method = "initDataTracker", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/entity/Living;initDataTracker()V", - shift = At.Shift.AFTER - )) - private void creative_trackData(CallbackInfo info) { - //this.dataTracker.startTracking(ModHelper.IS_RIDING_VEHICLE_ID, (byte) 0); - //this.dataTracker.startTracking(ModHelper.VEHICLE_INFO_ID, new CompoundTag()); - } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index 5ba8704..30d9a48 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -66,7 +66,6 @@ public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { /** - For now just force spawn a boat */ String vehicleName = var2.vehicle_getVehicleName(); if (!vehicleName.equals("null")) { - //if (level.isRemote) return; // We are client connected to server, server do all the job CompoundTag vehicleTag = var2.vehicle_getVehicleTag(); if (vehicleTag != null) { EntityBase vehicle = EntityRegistry.create(vehicleName, var2.level); From 1c500f6bceb7250122ccea4d10c952f6797f47b6 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:02:44 -0400 Subject: [PATCH 10/13] ISSUE-75 - Add config toggle for boat logout/login fixes --- .../com/github/telvarost/annoyancefix/Config.java | 11 ++++++++--- .../telvarost/annoyancefix/mixin/PlayerBaseMixin.java | 10 ++++------ .../annoyancefix/mixin/ServerPacketHandlerMixin.java | 5 +++++ .../mixin/ServerPlayerConnectionManagerMixin.java | 5 +++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/telvarost/annoyancefix/Config.java b/src/main/java/com/github/telvarost/annoyancefix/Config.java index d48f092..535061c 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/Config.java +++ b/src/main/java/com/github/telvarost/annoyancefix/Config.java @@ -177,15 +177,20 @@ public static class ConfigFields { @Comment("Options here require restart to take effect") public final RecipesConfig RECIPES_CONFIG = new RecipesConfig(); + @ConfigName("Boat Collision Behavior") + @MultiplayerSynced + @ValueOnVanillaServer(integerValue = 0) + public BoatCollisionEnum boatCollisionBehavior = BoatCollisionEnum.INVINCIBLE; + @ConfigName("Boat Drop Fixes Enabled") @MultiplayerSynced @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) public Boolean boatDropFixesEnabled = true; - @ConfigName("Boat Speed Collision Behavior") + @ConfigName("Boat Logout/Login Fixes Enabled") @MultiplayerSynced - @ValueOnVanillaServer(integerValue = 0) - public BoatCollisionEnum boatCollisionBehavior = BoatCollisionEnum.INVINCIBLE; + @ValueOnVanillaServer(booleanValue = TriBoolean.FALSE) + public Boolean boatLogoutLoginFixesEnabled = true; @ConfigName("Bookshelf Fixes Enabled") @MultiplayerSynced diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index b50759e..7eb6c12 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -1,8 +1,7 @@ package com.github.telvarost.annoyancefix.mixin; -import com.github.telvarost.annoyancefix.ModHelper; +import com.github.telvarost.annoyancefix.Config; import com.github.telvarost.annoyancefix.interfaces.VehicleInterface; -import net.minecraft.entity.Boat; import net.minecraft.entity.EntityBase; import net.minecraft.entity.EntityRegistry; import net.minecraft.entity.Living; @@ -11,7 +10,6 @@ import net.minecraft.util.io.CompoundTag; import net.modificationstation.stationapi.api.entity.player.PlayerHelper; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -64,7 +62,7 @@ public void vehicle_setVehicleTag(CompoundTag vehicleTag) { public boolean interactWith(EntityBase instance, PlayerBase playerBase) { boolean canInteract = instance.interact(playerBase); - if (canInteract) { + if (Config.config.boatLogoutLoginFixesEnabled && canInteract) { /** - Set vehicle data */ _vehicleName = (instance.passenger != null) ? EntityRegistry.getStringId(instance) : NULL_AS_STRING; if (!_vehicleName.equals(NULL_AS_STRING)) { @@ -79,7 +77,7 @@ public boolean interactWith(EntityBase instance, PlayerBase playerBase) { @Inject(method = "writeCustomDataToTag", at = @At("HEAD")) private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) { - if (!true) { + if (!Config.config.boatLogoutLoginFixesEnabled) { return; } @@ -93,7 +91,7 @@ private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) @Inject(method = "readCustomDataFromTag", at = @At("HEAD")) private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info) { - if (!true) { + if (!Config.config.boatLogoutLoginFixesEnabled) { return; } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index 30d9a48..c00d14d 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -1,5 +1,6 @@ package com.github.telvarost.annoyancefix.mixin; +import com.github.telvarost.annoyancefix.Config; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.entity.EntityBase; @@ -45,6 +46,10 @@ public abstract class ServerPacketHandlerMixin { cancellable = true ) public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { + if (!Config.config.boatLogoutLoginFixesEnabled) { + return; + } + ServerPlayer var2 = this.server.serverPlayerConnectionManager.connectPlayer(((ServerPacketHandler) (Object)this), arg.username); if (var2 != null) { this.server.serverPlayerConnectionManager.method_566(var2); diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java index d2174d6..9ac35fd 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java @@ -1,5 +1,6 @@ package com.github.telvarost.annoyancefix.mixin; +import com.github.telvarost.annoyancefix.Config; import net.minecraft.entity.player.ServerPlayer; import net.minecraft.server.MinecraftServer; import net.minecraft.server.PlayerHandler; @@ -31,6 +32,10 @@ public abstract class ServerPlayerConnectionManagerMixin { cancellable = true ) public void updateDimension(ServerPlayer arg, CallbackInfo ci) { + if (!Config.config.boatLogoutLoginFixesEnabled) { + return; + } + if (null != arg.vehicle) { arg.level.removeEntity(arg.vehicle); } else { From d6d15c53c58b44fc3f488f55d8d4ab7b693d98f0 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:19:13 -0400 Subject: [PATCH 11/13] ISSUE-75 - Improve mixins to be less intrusive and fix server bug with vehicle saving --- .../annoyancefix/mixin/PlayerBaseMixin.java | 2 +- .../mixin/ServerPacketHandlerMixin.java | 89 +++++-------------- .../ServerPlayerConnectionManagerMixin.java | 48 ++++------ 3 files changed, 43 insertions(+), 96 deletions(-) diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index 7eb6c12..71d56a5 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -101,7 +101,7 @@ private void betaTweaks_readCustomDataFromTag(CompoundTag tag, CallbackInfo info _vehicleTag = tag.getCompoundTag("VehicleTag"); } - /** - Spawn vehicle if on single player (and remove old vehicle) */ + /** - Spawn saved vehicle if on single player (and remove old vehicle) */ if (level.isServerSide) return; PlayerBase singlePlayer = PlayerHelper.getPlayerFromGame(); if (null == singlePlayer) return; diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index c00d14d..45173c5 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -6,89 +6,48 @@ import net.minecraft.entity.EntityBase; import net.minecraft.entity.EntityRegistry; import net.minecraft.entity.player.ServerPlayer; -import net.minecraft.packet.login.LoginRequest0x1Packet; -import net.minecraft.packet.play.ChatMessage0x3Packet; -import net.minecraft.packet.play.SpawnPosition0x6S2CPacket; -import net.minecraft.packet.play.TimeUpdate0x4S2CPacket; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.network.ClientConnection; import net.minecraft.server.network.ServerPacketHandler; -import net.minecraft.server.network.ServerPlayerPacketHandler; -import net.minecraft.util.Vec3i; import net.minecraft.util.io.CompoundTag; 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; - -import java.util.logging.Logger; +import org.spongepowered.asm.mixin.injection.Redirect; @Environment(EnvType.SERVER) @Mixin(ServerPacketHandler.class) public abstract class ServerPacketHandlerMixin { - - @Shadow private MinecraftServer server; - - @Shadow public abstract String getUsernameAndIp(); - - @Shadow public static Logger logger; - - @Shadow public ClientConnection playNetworkHandler; - - @Shadow public boolean closed; - - @Inject( + @Redirect( method = "complete", - at = @At("HEAD"), - cancellable = true + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/player/ServerPlayer;method_317()V" + ) ) - public void complete(LoginRequest0x1Packet arg, CallbackInfo ci) { + public void annoyanceFix_completeLoadVehicle(ServerPlayer instance) { if (!Config.config.boatLogoutLoginFixesEnabled) { return; } - ServerPlayer var2 = this.server.serverPlayerConnectionManager.connectPlayer(((ServerPacketHandler) (Object)this), arg.username); - if (var2 != null) { - this.server.serverPlayerConnectionManager.method_566(var2); - var2.setLevel(this.server.getLevel(var2.dimensionId)); - logger.info(this.getUsernameAndIp() + " logged in with entity id " + var2.entityId + " at (" + var2.x + ", " + var2.y + ", " + var2.z + ")"); - ServerLevel var3 = this.server.getLevel(var2.dimensionId); - Vec3i var4 = var3.getSpawnPosition(); - ServerPlayerPacketHandler var5 = new ServerPlayerPacketHandler(this.server, this.playNetworkHandler, var2); - var5.send(new LoginRequest0x1Packet("", var2.entityId, var3.getSeed(), (byte)var3.dimension.id)); - var5.send(new SpawnPosition0x6S2CPacket(var4.x, var4.y, var4.z)); - this.server.serverPlayerConnectionManager.sendPlayerTime(var2, var3); - this.server.serverPlayerConnectionManager.sendToAll(new ChatMessage0x3Packet("§e" + var2.name + " joined the game.")); - this.server.serverPlayerConnectionManager.method_569(var2); - var5.method_832(var2.x, var2.y, var2.z, var2.yaw, var2.pitch); - this.server.pendingConnectionManager.method_38(var5); - var5.send(new TimeUpdate0x4S2CPacket(var3.getLevelTime())); - var2.method_317(); - - /** - For now just force spawn a boat */ - String vehicleName = var2.vehicle_getVehicleName(); - if (!vehicleName.equals("null")) { - CompoundTag vehicleTag = var2.vehicle_getVehicleTag(); - if (vehicleTag != null) { - EntityBase vehicle = EntityRegistry.create(vehicleName, var2.level); - if (null != vehicle) { - try { - vehicle.fromTag(vehicleTag); - } catch(Exception ex) { - vehicle.setPositionAndAngles(var2.x, var2.y, var2.z, var2.yaw, var2.pitch); - System.out.println("Failed to read vehicle data"); - } - var2.level.spawnEntity(vehicle); - var2.startRiding(vehicle); + instance.method_317(); + + /** - Spawn saved vehicle if on multiplayer */ + String vehicleName = instance.vehicle_getVehicleName(); + if (!vehicleName.equals("null")) { + CompoundTag vehicleTag = instance.vehicle_getVehicleTag(); + if (vehicleTag != null) { + EntityBase vehicle = EntityRegistry.create(vehicleName, instance.level); + if (null != vehicle) { + try { + vehicle.fromTag(vehicleTag); + } catch(Exception ex) { + vehicle.setPositionAndAngles(instance.x, instance.y, instance.z, instance.yaw, instance.pitch); + System.out.println("Failed to read vehicle data"); } + instance.level.spawnEntity(vehicle); + instance.startRiding(vehicle); } } } - - this.closed = true; - ci.cancel(); } + } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java index 9ac35fd..af39bbd 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java @@ -1,50 +1,38 @@ package com.github.telvarost.annoyancefix.mixin; import com.github.telvarost.annoyancefix.Config; -import net.minecraft.entity.player.ServerPlayer; -import net.minecraft.server.MinecraftServer; +import net.minecraft.entity.player.PlayerBase; import net.minecraft.server.PlayerHandler; import net.minecraft.server.ServerPlayerConnectionManager; -import net.minecraft.server.ServerPlayerView; 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; - -import java.util.List; +import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(ServerPlayerConnectionManager.class) public abstract class ServerPlayerConnectionManagerMixin { - - @Shadow private PlayerHandler field_590; - - @Shadow private MinecraftServer server; - - @Shadow public List players; - - @Shadow protected abstract ServerPlayerView getPlayerView(int i); - - @Inject( + @Redirect( method = "updateDimension", - at = @At("HEAD"), - cancellable = true + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/server/PlayerHandler;savePlayer(Lnet/minecraft/entity/player/PlayerBase;)V" + ) ) - public void updateDimension(ServerPlayer arg, CallbackInfo ci) { + public void updateDimension(PlayerHandler instance, PlayerBase playerBase) { if (!Config.config.boatLogoutLoginFixesEnabled) { return; } - if (null != arg.vehicle) { - arg.level.removeEntity(arg.vehicle); - } else { - arg.vehicle_setVehicleName("null"); + /** - Save vehicle on logout */ + if (null == playerBase.vehicle) { + playerBase.vehicle_setVehicleName("null"); + } + + instance.savePlayer(playerBase); + + /** - Remove vehicle on logout */ + if (null != playerBase.vehicle) { + playerBase.level.removeEntity(playerBase.vehicle); } - this.field_590.savePlayer(arg); - this.server.getLevel(arg.dimensionId).removeEntity(arg); - this.players.remove(arg); - this.getPlayerView(arg.dimensionId).addPlayer(arg); - ci.cancel(); } } From a4f11c21393dca39852526bae7eec319ae5b78a5 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:28:15 -0400 Subject: [PATCH 12/13] ISSUE-75 - Fix up some bugs --- .../annoyancefix/mixin/PlayerBaseMixin.java | 1 + .../mixin/ServerPacketHandlerMixin.java | 34 +++++++++---------- .../ServerPlayerConnectionManagerMixin.java | 17 +++------- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java index 71d56a5..1e721be 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/PlayerBaseMixin.java @@ -85,6 +85,7 @@ private void betaTweaks_writeCustomDataToTag(CompoundTag tag, CallbackInfo info) _vehicleName = (this.vehicle != null) ? EntityRegistry.getStringId(this.vehicle) : NULL_AS_STRING; tag.put("VehicleName", _vehicleName); if (!_vehicleName.equals(NULL_AS_STRING)) { + this.vehicle.toTag(_vehicleTag); tag.put("VehicleTag", _vehicleTag); } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java index 45173c5..e95f1da 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPacketHandlerMixin.java @@ -24,27 +24,25 @@ public abstract class ServerPacketHandlerMixin { ) ) public void annoyanceFix_completeLoadVehicle(ServerPlayer instance) { - if (!Config.config.boatLogoutLoginFixesEnabled) { - return; - } - instance.method_317(); - /** - Spawn saved vehicle if on multiplayer */ - String vehicleName = instance.vehicle_getVehicleName(); - if (!vehicleName.equals("null")) { - CompoundTag vehicleTag = instance.vehicle_getVehicleTag(); - if (vehicleTag != null) { - EntityBase vehicle = EntityRegistry.create(vehicleName, instance.level); - if (null != vehicle) { - try { - vehicle.fromTag(vehicleTag); - } catch(Exception ex) { - vehicle.setPositionAndAngles(instance.x, instance.y, instance.z, instance.yaw, instance.pitch); - System.out.println("Failed to read vehicle data"); + if (Config.config.boatLogoutLoginFixesEnabled) { + /** - Spawn saved vehicle if on multiplayer */ + String vehicleName = instance.vehicle_getVehicleName(); + if (!vehicleName.equals("null")) { + CompoundTag vehicleTag = instance.vehicle_getVehicleTag(); + if (vehicleTag != null) { + EntityBase vehicle = EntityRegistry.create(vehicleName, instance.level); + if (null != vehicle) { + try { + vehicle.fromTag(vehicleTag); + } catch(Exception ex) { + vehicle.setPositionAndAngles(instance.x, instance.y, instance.z, instance.yaw, instance.pitch); + System.out.println("Failed to read vehicle data"); + } + instance.level.spawnEntity(vehicle); + instance.startRiding(vehicle); } - instance.level.spawnEntity(vehicle); - instance.startRiding(vehicle); } } } diff --git a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java index af39bbd..cf8301e 100644 --- a/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java +++ b/src/main/java/com/github/telvarost/annoyancefix/mixin/ServerPlayerConnectionManagerMixin.java @@ -19,20 +19,13 @@ public abstract class ServerPlayerConnectionManagerMixin { ) ) public void updateDimension(PlayerHandler instance, PlayerBase playerBase) { - if (!Config.config.boatLogoutLoginFixesEnabled) { - return; - } - - /** - Save vehicle on logout */ - if (null == playerBase.vehicle) { - playerBase.vehicle_setVehicleName("null"); - } - instance.savePlayer(playerBase); - /** - Remove vehicle on logout */ - if (null != playerBase.vehicle) { - playerBase.level.removeEntity(playerBase.vehicle); + if (Config.config.boatLogoutLoginFixesEnabled) { + /** - Remove vehicle on logout */ + if (null != playerBase.vehicle) { + playerBase.level.removeEntity(playerBase.vehicle); + } } } } From 6f896121d74155d682d645a1e5500a9095c918f3 Mon Sep 17 00:00:00 2001 From: telvarost <132113523+telvarost@users.noreply.github.com> Date: Sat, 16 Mar 2024 12:35:41 -0400 Subject: [PATCH 13/13] ISSUE-75 - Update readme --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 26dd9f7..c91e7df 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,12 @@ The aim of this mod is to fix (major) annoyances or backport useful features tha - Axes are also effective against: crafting tables, wooden slabs (experimental), wooden stairs, fences, wooden doors, ladders, signs, pumpkins, wooden pressure plates, jukeboxes, and noteblocks - Fences are placeable like normal and bounding box was minimized when appropriate - Stairs drop themselves -- Boats drop themselves -- Pigs drop their saddles if they have a saddle equipped - Bookshelves drop three books -- Boats don't break due to high velocity +- Pigs drop their saddles if they have a saddle equipped +- Boats drop themselves +- Boats don't break due to high velocity (or drop boat, or vanilla, toggle with config) - Never fall through boats anymore when getting out +- Logout/login with vehicle (no longer exit vehicle upon logout) - Pick block (middle mouse button click) works for blocks that are in the player's inventory, but not in their hotbar - Pick block also works on: paintings, minecarts (all three types), wooden doors, iron doors, signs, crops, redstone repeaters, redstone wire, beds, piston heads and cake - Add missing wooden items as fuel sources in furnace: wooden tools, wooden doors, boats, bowls, signs, and ladders