From 3e9ceac24254842692343439b503cddeeacec30b Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Sun, 1 Nov 2020 22:32:53 +0800 Subject: [PATCH] smoothClientAnimations implementation tho nobody uses carpet client 1.13 but it must be there --- .../network/NetHandlerPlayClient.java.patch | 62 +++++++++++++++++-- patches/net/minecraft/util/Timer.java.patch | 26 ++++++++ 2 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 patches/net/minecraft/util/Timer.java.patch diff --git a/patches/net/minecraft/client/network/NetHandlerPlayClient.java.patch b/patches/net/minecraft/client/network/NetHandlerPlayClient.java.patch index a3e4e258..8d38fe93 100644 --- a/patches/net/minecraft/client/network/NetHandlerPlayClient.java.patch +++ b/patches/net/minecraft/client/network/NetHandlerPlayClient.java.patch @@ -10,7 +10,43 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.util.concurrent.FutureCallback; -@@ -335,6 +339,9 @@ +@@ -23,6 +27,7 @@ + import javax.annotation.Nullable; + import net.minecraft.advancements.Advancement; + import net.minecraft.block.Block; ++import net.minecraft.block.state.IBlockState; + import net.minecraft.client.ClientBrandRetriever; + import net.minecraft.client.GameSettings; + import net.minecraft.client.Minecraft; +@@ -117,6 +122,7 @@ + import net.minecraft.entity.projectile.EntityTippedArrow; + import net.minecraft.entity.projectile.EntityTrident; + import net.minecraft.entity.projectile.EntityWitherSkull; ++import net.minecraft.init.Blocks; + import net.minecraft.init.Items; + import net.minecraft.init.Particles; + import net.minecraft.init.SoundEvents; +@@ -242,18 +248,7 @@ + import net.minecraft.tags.FluidTags; + import net.minecraft.tags.ItemTags; + import net.minecraft.tags.NetworkTagManager; +-import net.minecraft.tileentity.TileEntity; +-import net.minecraft.tileentity.TileEntityBanner; +-import net.minecraft.tileentity.TileEntityBeacon; +-import net.minecraft.tileentity.TileEntityBed; +-import net.minecraft.tileentity.TileEntityCommandBlock; +-import net.minecraft.tileentity.TileEntityConduit; +-import net.minecraft.tileentity.TileEntityEndGateway; +-import net.minecraft.tileentity.TileEntityMobSpawner; +-import net.minecraft.tileentity.TileEntityShulkerBox; +-import net.minecraft.tileentity.TileEntitySign; +-import net.minecraft.tileentity.TileEntitySkull; +-import net.minecraft.tileentity.TileEntityStructure; ++import net.minecraft.tileentity.*; + import net.minecraft.util.EnumFacing; + import net.minecraft.util.EnumHand; + import net.minecraft.util.ResourceLocation; +@@ -335,6 +330,9 @@ this.client.playerController.setGameType(packetIn.getGameType()); this.client.gameSettings.sendSettingsToServer(); this.netManager.sendPacket(new CPacketCustomPayload(CPacketCustomPayload.BRAND, (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName()))); @@ -20,9 +56,27 @@ } public void handleSpawnObject(SPacketSpawnObject packetIn) -@@ -798,6 +805,10 @@ +@@ -797,7 +795,28 @@ + { tileentity.read(nbttagcompound); } ++ ++ // Carpet smoothClientAnimations ++ // fix as suggested by G4me4u ++ if (CarpetSettings.smoothClientAnimations && tileentity == null) ++ { ++ if ("minecraft:piston".equals(nbttagcompound.getString("id"))) ++ { ++ IBlockState blockState = world.getBlockState(blockpos); ++ if (blockState.getBlock() == Blocks.MOVING_PISTON) { ++ nbttagcompound.putFloat("progress", Math.min(nbttagcompound.getFloat("progress") + 0.5F, 1.0F)); ++ tileentity = new TileEntityPiston(); ++ tileentity.read(nbttagcompound); ++ this.world.setTileEntity(blockpos, tileentity); ++ tileentity.updateContainingBlockInfo(); ++ } ++ } ++ } } + + // [TISCM] Newlight @@ -31,7 +85,7 @@ } public void processChunkUnload(SPacketUnloadChunk packetIn) -@@ -818,6 +829,9 @@ +@@ -818,6 +837,9 @@ public void handleDisconnect(SPacketDisconnect packetIn) { this.netManager.closeChannel(packetIn.getReason()); @@ -41,7 +95,7 @@ } public void onDisconnect(ITextComponent reason) -@@ -1954,6 +1968,14 @@ +@@ -1954,6 +1976,14 @@ public void handleCustomPayload(SPacketCustomPayload packetIn) { diff --git a/patches/net/minecraft/util/Timer.java.patch b/patches/net/minecraft/util/Timer.java.patch new file mode 100644 index 00000000..e123d3cb --- /dev/null +++ b/patches/net/minecraft/util/Timer.java.patch @@ -0,0 +1,26 @@ +--- a/net/minecraft/util/Timer.java ++++ b/net/minecraft/util/Timer.java +@@ -1,5 +1,7 @@ + package net.minecraft.util; + ++import carpet.helpers.TickSpeed; ++import carpet.settings.CarpetSettings; + import net.minecraftforge.api.distmarker.Dist; + import net.minecraftforge.api.distmarker.OnlyIn; + +@@ -20,7 +22,14 @@ + + public void updateTimer(long p_74275_1_) + { +- this.elapsedPartialTicks = (float)(p_74275_1_ - this.lastSyncSysClock) / this.tickLength; ++ // Carpet smoothClientAnimations ++ float tickLength = this.tickLength; ++ if (CarpetSettings.smoothClientAnimations && TickSpeed.process_entities) ++ { ++ tickLength = Math.max(tickLength, TickSpeed.mspt); ++ } ++ ++ this.elapsedPartialTicks = (float)(p_74275_1_ - this.lastSyncSysClock) / tickLength; + this.lastSyncSysClock = p_74275_1_; + this.renderPartialTicks += this.elapsedPartialTicks; + this.elapsedTicks = (int)this.renderPartialTicks;