Merge branch 'master' into 1.15
# Conflicts: # src/main/java/carpet/mixins/MinecraftServer_tickspeedMixin.java # src/main/resources/carpet.mixins.json
This commit is contained in:
commit
8bcb433f72
7 files changed
+147
-27
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.PistonBlockEntity;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.network.packet.ChunkDataS2CPacket;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
public class ClientPlayNetworkHandler_smoothClientAnimationsMixin
|
||||
{
|
||||
@Shadow private ClientWorld world;
|
||||
// fix as suggested by G4me4u
|
||||
@Inject( method = "onChunkData", locals = LocalCapture.CAPTURE_FAILHARD, require = 0, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/world/ClientWorld;getBlockEntity(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/entity/BlockEntity;",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void recreateMovingPistons(ChunkDataS2CPacket packet, CallbackInfo ci,
|
||||
Iterator var5, CompoundTag tag, BlockPos blockPos)
|
||||
{
|
||||
if (CarpetSettings.smoothClientAnimations)
|
||||
{
|
||||
BlockEntity blockEntity = world.getBlockEntity(blockPos);
|
||||
if (blockEntity == null && "minecraft:piston".equals(tag.getString("id")))
|
||||
{
|
||||
BlockState blockState = world.getBlockState(blockPos);
|
||||
if (blockState.getBlock() == Blocks.MOVING_PISTON) {
|
||||
tag.putFloat("progress", Math.min(tag.getFloat("progress") + 0.5F, 1.0F));
|
||||
blockEntity = new PistonBlockEntity();
|
||||
blockEntity.fromTag(tag);
|
||||
world.setBlockEntity(blockPos, blockEntity);
|
||||
blockEntity.resetBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,12 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
private float carpetMsptAccum = 0.0f;
|
||||
|
||||
/**
|
||||
* To ensure compatibility with other mods we should allow milliseconds
|
||||
*/
|
||||
|
||||
// Cancel a while statement
|
||||
@Redirect(method = "run", at = @At(value = "FIELD", target = "Lnet/minecraft/server/MinecraftServer;running:Z"))
|
||||
private boolean cancelRunLoop(MinecraftServer server)
|
||||
@@ -67,29 +73,38 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
{
|
||||
CarpetProfiler.start_tick_profiling();
|
||||
}
|
||||
long mspt = 0L;
|
||||
long msThisTick = 0L;
|
||||
long long_1 = 0L;
|
||||
if (TickSpeed.time_warp_start_time != 0 && TickSpeed.continueWarp())
|
||||
{
|
||||
//making sure server won't flop after the warp or if the warp is interrupted
|
||||
this.timeReference = this.field_4557 = Util.getMeasuringTimeMs();
|
||||
carpetMsptAccum = TickSpeed.mspt;
|
||||
}
|
||||
else
|
||||
{
|
||||
mspt = TickSpeed.mspt; // regular tick
|
||||
if (Math.abs(carpetMsptAccum - TickSpeed.mspt) > 1.0f)
|
||||
{
|
||||
// Tickrate changed. Ensure that we use the correct value.
|
||||
carpetMsptAccum = TickSpeed.mspt;
|
||||
}
|
||||
|
||||
msThisTick = (long)carpetMsptAccum; // regular tick
|
||||
carpetMsptAccum += TickSpeed.mspt - msThisTick;
|
||||
|
||||
long_1 = Util.getMeasuringTimeMs() - this.timeReference;
|
||||
}
|
||||
//end tick deciding
|
||||
//smoothed out delay to include mcpt component. With 50L gives defaults.
|
||||
if (long_1 > /*2000L*/1000L+20*mspt && this.timeReference - this.field_4557 >= /*15000L*/10000L+100*mspt)
|
||||
if (long_1 > /*2000L*/1000L+20*TickSpeed.mspt && this.timeReference - this.field_4557 >= /*15000L*/10000L+100*TickSpeed.mspt)
|
||||
{
|
||||
long long_2 = long_1 / mspt;//50L;
|
||||
long long_2 = (long)(long_1 / TickSpeed.mspt);//50L;
|
||||
LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", long_1, long_2);
|
||||
this.timeReference += long_2 * mspt;//50L;
|
||||
this.timeReference += (long)(long_2 * TickSpeed.mspt);//50L;
|
||||
this.field_4557 = this.timeReference;
|
||||
}
|
||||
|
||||
this.timeReference += mspt;//50L;
|
||||
this.timeReference += msThisTick;//50L;
|
||||
if (this.profilerStartQueued)
|
||||
{
|
||||
this.profilerStartQueued = false;
|
||||
@@ -101,7 +116,7 @@ public abstract class MinecraftServer_tickspeedMixin
|
||||
this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking);
|
||||
this.profiler.swap("nextTickWait");
|
||||
this.field_19249 = true;
|
||||
this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ mspt, this.timeReference);
|
||||
this.field_19248 = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
||||
this.method_16208();
|
||||
this.profiler.pop();
|
||||
this.profiler.endTick();
|
||||
|
||||
Reference in new issue
Block a user