From 69d65bf991831875096c985989485c80844a78b0 Mon Sep 17 00:00:00 2001 From: mckuhei Date: Wed, 29 Mar 2023 00:35:42 +0800 Subject: [PATCH] Use BigDecimal to store player position. --- src/minecraft/net/minecraft/src/EntityPlayer.java | 7 +++++++ src/minecraft/net/minecraft/src/NBTTagCompound.java | 11 +++++++++++ .../net/minecraft/src/ServerConfigurationManager.java | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/minecraft/net/minecraft/src/EntityPlayer.java b/src/minecraft/net/minecraft/src/EntityPlayer.java index 278888b..9e07aef 100644 --- a/src/minecraft/net/minecraft/src/EntityPlayer.java +++ b/src/minecraft/net/minecraft/src/EntityPlayer.java @@ -1020,6 +1020,11 @@ public abstract class EntityPlayer extends EntityLiving implements ICommandSende this.experience = par1NBTTagCompound.getFloat("XpP"); this.experienceLevel = par1NBTTagCompound.getInteger("XpLevel"); this.experienceTotal = par1NBTTagCompound.getInteger("XpTotal"); + if(par1NBTTagCompound.hasKey("PosXBig")) { + this.posXBig = par1NBTTagCompound.getBigDecimal("PosXBig"); + this.posXBig = par1NBTTagCompound.getBigDecimal("PosXBig"); + setPosition(posXBig, posY, posZBig); + } if (this.sleeping) { @@ -1055,6 +1060,8 @@ public abstract class EntityPlayer extends EntityLiving implements ICommandSende par1NBTTagCompound.setFloat("XpP", this.experience); par1NBTTagCompound.setInteger("XpLevel", this.experienceLevel); par1NBTTagCompound.setInteger("XpTotal", this.experienceTotal); + par1NBTTagCompound.setBigDecimal("PosXBig", posXBig); + par1NBTTagCompound.setBigDecimal("PosZBig", posZBig); if (this.spawnChunk != null) { diff --git a/src/minecraft/net/minecraft/src/NBTTagCompound.java b/src/minecraft/net/minecraft/src/NBTTagCompound.java index 7c7c09e..27cecf7 100644 --- a/src/minecraft/net/minecraft/src/NBTTagCompound.java +++ b/src/minecraft/net/minecraft/src/NBTTagCompound.java @@ -3,6 +3,8 @@ package net.minecraft.src; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; +import java.math.BigDecimal; + import org.mcmodule.math.BigInteger; import java.util.Collection; import java.util.HashMap; @@ -326,8 +328,17 @@ public class NBTTagCompound extends NBTBase if(value == null) value = BigInteger.ZERO; setString(key, value.toString()); } + + public void setBigDecimal(String key, BigDecimal value) { + if(value == null) value = BigDecimal.ZERO; + setString(key, value.toString()); + } public BigInteger getBigInteger(String key) { return new BigInteger(getString(key)); } + + public BigDecimal getBigDecimal(String key) { + return new BigDecimal(getString(key)); + } } diff --git a/src/minecraft/net/minecraft/src/ServerConfigurationManager.java b/src/minecraft/net/minecraft/src/ServerConfigurationManager.java index c5d48ac..04dbc8c 100644 --- a/src/minecraft/net/minecraft/src/ServerConfigurationManager.java +++ b/src/minecraft/net/minecraft/src/ServerConfigurationManager.java @@ -74,7 +74,7 @@ public abstract class ServerConfigurationManager this.sendTimeAndRainingToPlayer(par2EntityPlayerMP, var4); this.sendPacketToAllPlayers(new Packet3Chat("\u00a7e" + par2EntityPlayerMP.username + " joined the game.")); this.func_72377_c(par2EntityPlayerMP); - var6.setPlayerLocation(par2EntityPlayerMP.posX, par2EntityPlayerMP.posY, par2EntityPlayerMP.posZ, par2EntityPlayerMP.rotationYaw, par2EntityPlayerMP.rotationPitch); + var6.setPlayerLocation(par2EntityPlayerMP.posXBig, par2EntityPlayerMP.posY, par2EntityPlayerMP.posZBig, par2EntityPlayerMP.rotationYaw, par2EntityPlayerMP.rotationPitch); this.mcServer.getNetworkThread().func_71745_a(var6); var6.sendPacketToPlayer(new Packet4UpdateTime(var4.getWorldTime()));