Port uncommited changes from chunk system 1.20.4 branch
This commit is contained in:
@@ -2,6 +2,9 @@ package ca.spottedleaf.moonrise.mixin.collisions;
|
||||
|
||||
import ca.spottedleaf.moonrise.patches.collisions.CollisionUtil;
|
||||
import ca.spottedleaf.moonrise.patches.collisions.world.CollisionLevelChunkSection;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import net.minecraft.util.BitStorage;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.Palette;
|
||||
@@ -16,6 +19,7 @@ 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.CallbackInfoReturnable;
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Mixin(LevelChunkSection.class)
|
||||
@@ -74,20 +78,35 @@ public abstract class LevelChunkSectionMixin implements CollisionLevelChunkSecti
|
||||
if (this.maybeHas((final BlockState state) -> !state.isAir())) {
|
||||
final PalettedContainer.Data<BlockState> data = this.states.data;
|
||||
final Palette<BlockState> palette = data.palette;
|
||||
final int paletteSize = palette.getSize();
|
||||
final BitStorage storage = data.storage;
|
||||
|
||||
final Int2IntOpenHashMap counts = new Int2IntOpenHashMap(paletteSize);
|
||||
if (paletteSize == 1) {
|
||||
counts.addTo(0, storage.getSize());
|
||||
} else {
|
||||
storage.getAll((final int paletteIdx) -> {
|
||||
counts.addTo(paletteIdx, 1);
|
||||
});
|
||||
}
|
||||
|
||||
for (final Iterator<Int2IntMap.Entry> iterator = counts.int2IntEntrySet().fastIterator(); iterator.hasNext();) {
|
||||
final Int2IntMap.Entry entry = iterator.next();
|
||||
final int paletteIdx = entry.getIntKey();
|
||||
final int paletteCount = entry.getIntValue();
|
||||
|
||||
data.storage.getAll((final int paletteIdx) -> {
|
||||
final BlockState state = palette.valueFor(paletteIdx);
|
||||
|
||||
if (state.isAir()) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CollisionUtil.isSpecialCollidingBlock(state)) {
|
||||
++this.specialCollidingBlocks;
|
||||
this.specialCollidingBlocks += paletteCount;
|
||||
}
|
||||
this.nonEmptyBlockCount += 1;
|
||||
this.nonEmptyBlockCount += paletteCount;
|
||||
if (state.isRandomlyTicking()) {
|
||||
this.tickingBlockCount += 1;
|
||||
this.tickingBlockCount += paletteCount;
|
||||
}
|
||||
|
||||
final FluidState fluid = state.getFluidState();
|
||||
@@ -95,10 +114,10 @@ public abstract class LevelChunkSectionMixin implements CollisionLevelChunkSecti
|
||||
if (!fluid.isEmpty()) {
|
||||
//this.nonEmptyBlockCount += count; // fix vanilla bug: make non empty block count correct
|
||||
if (fluid.isRandomlyTicking()) {
|
||||
this.tickingFluidCount += 1;
|
||||
this.tickingFluidCount += paletteCount;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ public abstract class LivingEntityMixin extends Entity implements Attackable {
|
||||
@Overwrite
|
||||
public void pushEntities() {
|
||||
if (this.level().isClientSide()) {
|
||||
final List<Player> players = new ArrayList<>();
|
||||
((CollisionLevel)this.level()).moonrise$getCollisionLookup().getEntities(Player.class, this, this.getBoundingBox(), players, EntitySelector.pushableBy(this));
|
||||
final List<Player> players = this.level().getEntitiesOfClass(Player.class, this.getBoundingBox(), EntitySelector.pushableBy(this));
|
||||
for (int i = 0, len = players.size(); i < len; ++i) {
|
||||
this.doPush(players.get(i));
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class ServerGamePacketListenerImplMixin implements ServerCommonP
|
||||
)
|
||||
)
|
||||
private void refuseSPKick(final ServerCommonPacketListenerImpl instance, final Component component) {
|
||||
if (Component.translatable("disconnect.timeout").equals(component) && this.isSingleplayerOwner()) {
|
||||
if (this.isSingleplayerOwner() && Component.translatable("disconnect.timeout").equals(component)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,10 @@ package ca.spottedleaf.moonrise.mixin.serverlist;
|
||||
|
||||
import ca.spottedleaf.moonrise.patches.serverlist.ServerListConnection;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||
import net.minecraft.client.multiplayer.ServerStatusPinger;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -15,9 +13,7 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@Mixin(Connection.class)
|
||||
public abstract class ConnectionMixin extends SimpleChannelInboundHandler<Packet<?>> implements ServerListConnection {
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class UtilMixin {
|
||||
// [5, 8]
|
||||
value = cpus <= 6 ? 3 : 4;
|
||||
} else {
|
||||
value = Math.min(8, cpus / 2);
|
||||
value = (cpus - 4) / 2;
|
||||
}
|
||||
|
||||
return Mth.clamp(value, min, max);
|
||||
|
||||
@@ -13,12 +13,12 @@ public final class ZeroCollidingReferenceStateTable {
|
||||
|
||||
// upper 32 bits: starting index
|
||||
// lower 32 bits: bitset for contained ids
|
||||
protected final long[] this_index_table;
|
||||
protected final Comparable<?>[] this_table;
|
||||
protected final StateHolder<?, ?> this_state;
|
||||
private final long[] this_index_table;
|
||||
private final Comparable<?>[] this_table;
|
||||
private final StateHolder<?, ?> this_state;
|
||||
|
||||
protected long[] index_table;
|
||||
protected StateHolder<?, ?>[][] value_table;
|
||||
private long[] index_table;
|
||||
private StateHolder<?, ?>[][] value_table;
|
||||
|
||||
private boolean inited;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user