9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-21 07:49:18 +00:00

small bug fixes

This commit is contained in:
NONPLAYT
2025-03-26 01:43:31 +03:00
parent e9faa34e80
commit b307ae4fc3
14 changed files with 3 additions and 861 deletions

View File

@@ -1,33 +0,0 @@
package net.caffeinemc.mods.lithium.common.block.entity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.TickingBlockEntity;
import org.jetbrains.annotations.NotNull;
public record SleepUntilTimeBlockEntityTickInvoker(BlockEntity sleepingBlockEntity, long sleepUntilTickExclusive, TickingBlockEntity delegate) implements TickingBlockEntity {
@Override
public void tick() {
long tickTime = this.sleepingBlockEntity.getLevel().getGameTime();
if (tickTime >= this.sleepUntilTickExclusive) {
((SleepingBlockEntity) this.sleepingBlockEntity).setTicker(this.delegate);
this.delegate.tick();
}
}
@Override
public boolean isRemoved() {
return this.sleepingBlockEntity.isRemoved();
}
@Override
public @NotNull BlockPos getPos() {
return this.sleepingBlockEntity.getBlockPos();
}
@Override
public @NotNull String getType() {
return BlockEntityType.getKey(this.sleepingBlockEntity.getType()).toString();
}
}

View File

@@ -1,82 +0,0 @@
package net.caffeinemc.mods.lithium.common.block.entity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.TickingBlockEntity;
import net.minecraft.world.level.chunk.LevelChunk;
import org.jetbrains.annotations.NotNull;
import org.jspecify.annotations.Nullable;
public interface SleepingBlockEntity {
TickingBlockEntity SLEEPING_BLOCK_ENTITY_TICKER = new TickingBlockEntity() {
public void tick() {
}
public boolean isRemoved() {
return false;
}
public @Nullable BlockPos getPos() {
return null;
}
public @NotNull String getType() {
return "<lithium_sleeping>";
}
};
LevelChunk.RebindableTickingBlockEntityWrapper lithium$getTickWrapper();
void lithium$setTickWrapper(LevelChunk.RebindableTickingBlockEntityWrapper tickWrapper);
TickingBlockEntity lithium$getSleepingTicker();
void lithium$setSleepingTicker(TickingBlockEntity sleepingTicker);
default boolean lithium$startSleeping() {
if (this.isSleeping()) {
return false;
}
LevelChunk.RebindableTickingBlockEntityWrapper tickWrapper = this.lithium$getTickWrapper();
if (tickWrapper == null) {
return false;
}
this.lithium$setSleepingTicker(tickWrapper.ticker);
tickWrapper.rebind(SleepingBlockEntity.SLEEPING_BLOCK_ENTITY_TICKER);
return true;
}
default void sleepOnlyCurrentTick() {
TickingBlockEntity sleepingTicker = this.lithium$getSleepingTicker();
LevelChunk.RebindableTickingBlockEntityWrapper tickWrapper = this.lithium$getTickWrapper();
if (sleepingTicker == null) {
sleepingTicker = tickWrapper.ticker;
}
Level world = ((BlockEntity) this).getLevel();
tickWrapper.rebind(new SleepUntilTimeBlockEntityTickInvoker((BlockEntity) this, world.getGameTime() + 1, sleepingTicker));
this.lithium$setSleepingTicker(null);
}
default void wakeUpNow() {
TickingBlockEntity sleepingTicker = this.lithium$getSleepingTicker();
if (sleepingTicker == null) {
return;
}
this.setTicker(sleepingTicker);
this.lithium$setSleepingTicker(null);
}
default void setTicker(TickingBlockEntity delegate) {
LevelChunk.RebindableTickingBlockEntityWrapper tickWrapper = this.lithium$getTickWrapper();
if (tickWrapper == null) {
return;
}
tickWrapper.rebind(delegate);
}
default boolean isSleeping() {
return this.lithium$getSleepingTicker() != null;
}
}

View File

@@ -320,17 +320,11 @@ public class DivineConfig {
}
public static boolean disableDisconnectSpam = false;
public static boolean connectionFlushQueueRewrite = false;
public static boolean gracefulTeleportHandling = false;
public static boolean dontRespondPingBeforeStart = true;
private static void networkSettings() {
disableDisconnectSpam = getBoolean("settings.network.disable-disconnect-spam", disableDisconnectSpam,
"Prevents players being disconnected by 'disconnect.spam' when sending too many chat packets");
connectionFlushQueueRewrite = getBoolean("settings.network.connection-flush-queue-rewrite", connectionFlushQueueRewrite,
"Replaces ConcurrentLinkedQueue with ArrayDeque in Connection for better performance",
"and also uses the Netty event loop to ensure thread safety.",
"",
"Note: May increase the Netty thread usage");
gracefulTeleportHandling = getBoolean("settings.network.graceful-teleport-handling", gracefulTeleportHandling ,
"Disables being disconnected from 'multiplayer.disconnect.invalid_player_movement' (also declines the packet handling).");
dontRespondPingBeforeStart = getBoolean("settings.network.dont-respond-ping-before-start", dontRespondPingBeforeStart,