Skip to content

Commit

Permalink
smoothClientAnimations implementation
Browse files Browse the repository at this point in the history
tho nobody uses carpet client 1.13 but it must be there
  • Loading branch information
Fallen-Breath committed Nov 1, 2020
1 parent cdffd02 commit 3e9ceac
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
Expand All @@ -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
Expand All @@ -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());
Expand All @@ -41,7 +95,7 @@
}

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

public void handleCustomPayload(SPacketCustomPayload packetIn)
{
Expand Down
26 changes: 26 additions & 0 deletions patches/net/minecraft/util/Timer.java.patch
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 3e9ceac

Please sign in to comment.