Skip to content

Commit 3e9ceac

Browse files
committed
smoothClientAnimations implementation
tho nobody uses carpet client 1.13 but it must be there
1 parent cdffd02 commit 3e9ceac

2 files changed

Lines changed: 84 additions & 4 deletions

File tree

patches/net/minecraft/client/network/NetHandlerPlayClient.java.patch

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,43 @@
1010
import com.google.common.collect.Lists;
1111
import com.google.common.collect.Maps;
1212
import com.google.common.util.concurrent.FutureCallback;
13-
@@ -335,6 +339,9 @@
13+
@@ -23,6 +27,7 @@
14+
import javax.annotation.Nullable;
15+
import net.minecraft.advancements.Advancement;
16+
import net.minecraft.block.Block;
17+
+import net.minecraft.block.state.IBlockState;
18+
import net.minecraft.client.ClientBrandRetriever;
19+
import net.minecraft.client.GameSettings;
20+
import net.minecraft.client.Minecraft;
21+
@@ -117,6 +122,7 @@
22+
import net.minecraft.entity.projectile.EntityTippedArrow;
23+
import net.minecraft.entity.projectile.EntityTrident;
24+
import net.minecraft.entity.projectile.EntityWitherSkull;
25+
+import net.minecraft.init.Blocks;
26+
import net.minecraft.init.Items;
27+
import net.minecraft.init.Particles;
28+
import net.minecraft.init.SoundEvents;
29+
@@ -242,18 +248,7 @@
30+
import net.minecraft.tags.FluidTags;
31+
import net.minecraft.tags.ItemTags;
32+
import net.minecraft.tags.NetworkTagManager;
33+
-import net.minecraft.tileentity.TileEntity;
34+
-import net.minecraft.tileentity.TileEntityBanner;
35+
-import net.minecraft.tileentity.TileEntityBeacon;
36+
-import net.minecraft.tileentity.TileEntityBed;
37+
-import net.minecraft.tileentity.TileEntityCommandBlock;
38+
-import net.minecraft.tileentity.TileEntityConduit;
39+
-import net.minecraft.tileentity.TileEntityEndGateway;
40+
-import net.minecraft.tileentity.TileEntityMobSpawner;
41+
-import net.minecraft.tileentity.TileEntityShulkerBox;
42+
-import net.minecraft.tileentity.TileEntitySign;
43+
-import net.minecraft.tileentity.TileEntitySkull;
44+
-import net.minecraft.tileentity.TileEntityStructure;
45+
+import net.minecraft.tileentity.*;
46+
import net.minecraft.util.EnumFacing;
47+
import net.minecraft.util.EnumHand;
48+
import net.minecraft.util.ResourceLocation;
49+
@@ -335,6 +330,9 @@
1450
this.client.playerController.setGameType(packetIn.getGameType());
1551
this.client.gameSettings.sendSettingsToServer();
1652
this.netManager.sendPacket(new CPacketCustomPayload(CPacketCustomPayload.BRAND, (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName())));
@@ -20,9 +56,27 @@
2056
}
2157

2258
public void handleSpawnObject(SPacketSpawnObject packetIn)
23-
@@ -798,6 +805,10 @@
59+
@@ -797,7 +795,28 @@
60+
{
2461
tileentity.read(nbttagcompound);
2562
}
63+
+
64+
+ // Carpet smoothClientAnimations
65+
+ // fix as suggested by G4me4u
66+
+ if (CarpetSettings.smoothClientAnimations && tileentity == null)
67+
+ {
68+
+ if ("minecraft:piston".equals(nbttagcompound.getString("id")))
69+
+ {
70+
+ IBlockState blockState = world.getBlockState(blockpos);
71+
+ if (blockState.getBlock() == Blocks.MOVING_PISTON) {
72+
+ nbttagcompound.putFloat("progress", Math.min(nbttagcompound.getFloat("progress") + 0.5F, 1.0F));
73+
+ tileentity = new TileEntityPiston();
74+
+ tileentity.read(nbttagcompound);
75+
+ this.world.setTileEntity(blockpos, tileentity);
76+
+ tileentity.updateContainingBlockInfo();
77+
+ }
78+
+ }
79+
+ }
2680
}
2781
+
2882
+ // [TISCM] Newlight
@@ -31,7 +85,7 @@
3185
}
3286

3387
public void processChunkUnload(SPacketUnloadChunk packetIn)
34-
@@ -818,6 +829,9 @@
88+
@@ -818,6 +837,9 @@
3589
public void handleDisconnect(SPacketDisconnect packetIn)
3690
{
3791
this.netManager.closeChannel(packetIn.getReason());
@@ -41,7 +95,7 @@
4195
}
4296

4397
public void onDisconnect(ITextComponent reason)
44-
@@ -1954,6 +1968,14 @@
98+
@@ -1954,6 +1976,14 @@
4599

46100
public void handleCustomPayload(SPacketCustomPayload packetIn)
47101
{
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--- a/net/minecraft/util/Timer.java
2+
+++ b/net/minecraft/util/Timer.java
3+
@@ -1,5 +1,7 @@
4+
package net.minecraft.util;
5+
6+
+import carpet.helpers.TickSpeed;
7+
+import carpet.settings.CarpetSettings;
8+
import net.minecraftforge.api.distmarker.Dist;
9+
import net.minecraftforge.api.distmarker.OnlyIn;
10+
11+
@@ -20,7 +22,14 @@
12+
13+
public void updateTimer(long p_74275_1_)
14+
{
15+
- this.elapsedPartialTicks = (float)(p_74275_1_ - this.lastSyncSysClock) / this.tickLength;
16+
+ // Carpet smoothClientAnimations
17+
+ float tickLength = this.tickLength;
18+
+ if (CarpetSettings.smoothClientAnimations && TickSpeed.process_entities)
19+
+ {
20+
+ tickLength = Math.max(tickLength, TickSpeed.mspt);
21+
+ }
22+
+
23+
+ this.elapsedPartialTicks = (float)(p_74275_1_ - this.lastSyncSysClock) / tickLength;
24+
this.lastSyncSysClock = p_74275_1_;
25+
this.renderPartialTicks += this.elapsedPartialTicks;
26+
this.elapsedTicks = (int)this.renderPartialTicks;

0 commit comments

Comments
 (0)