24w20a, disable reset_chunk, relight, and chunk load events
This commit is contained in:
1 parent
9fd313a672
commit
c4f8c86520
13 files changed
+60
-32
No files matched your search
@@ -20,8 +20,8 @@ public abstract class AbstractArrowMixin extends Entity
|
||||
private TrajectoryLogHelper logHelper;
|
||||
public AbstractArrowMixin(EntityType<?> entityType_1, Level world_1) { super(entityType_1, world_1); }
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN"))
|
||||
private void addLogger(final EntityType entityType, final Level level, final ItemStack itemStack, final ItemStack weapon, final CallbackInfo ci)
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;DDDLnet/minecraft/world/level/Level;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN"))
|
||||
private void addLogger(final EntityType entityType, final double x, final double y, final double z, final Level level, final ItemStack itemStack, final ItemStack weapon, final CallbackInfo ci)
|
||||
{
|
||||
if (LoggerRegistry.__projectiles && !level.isClientSide)
|
||||
logHelper = new TrajectoryLogHelper("projectiles");
|
||||
|
||||
@@ -21,10 +21,11 @@ import net.minecraft.world.level.chunk.UpgradeData;
|
||||
@Mixin(ChunkHolder.class)
|
||||
public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHolderInterface
|
||||
{
|
||||
@Shadow protected abstract void updateChunkToSave(CompletableFuture<? extends ChunkResult<? extends ChunkAccess>> newChunkFuture, String type);
|
||||
//@Shadow protected abstract void updateChunkToSave(CompletableFuture<? extends ChunkResult<? extends ChunkAccess>> newChunkFuture, String type);
|
||||
|
||||
@Shadow @Final private AtomicReferenceArray<CompletableFuture<ChunkResult<ChunkAccess>>> futures;
|
||||
//@Shadow @Final private AtomicReferenceArray<CompletableFuture<ChunkResult<ChunkAccess>>> futures;
|
||||
|
||||
/*
|
||||
@Override
|
||||
public CompletableFuture<ChunkResult<ChunkAccess>> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop<Runnable> executor, ServerLevel world)
|
||||
{
|
||||
@@ -37,4 +38,5 @@ public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHold
|
||||
futures.set(i, completableFuture2);
|
||||
return completableFuture2;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.TickTask;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.ChunkLevel;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ChunkMap.DistanceManager;
|
||||
import net.minecraft.server.level.ChunkResult;
|
||||
@@ -64,10 +65,6 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
@Final
|
||||
private ServerLevel level;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private LongSet entitiesInLevel;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Long2ObjectLinkedOpenHashMap<ChunkHolder> updatingChunkMap;
|
||||
@@ -111,6 +108,10 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
|
||||
// in protoChunkToFullChunk
|
||||
// fancier version of the one below, ensuring that the event is triggered when the chunk is actually loaded.
|
||||
|
||||
/*
|
||||
|
||||
|
||||
@Inject(method = "method_17227", at = @At("HEAD"), remap = false)
|
||||
private void onChunkGeneratedStart(ChunkHolder chunkHolder, ChunkAccess chunkAccess, CallbackInfoReturnable<ChunkAccess> cir)
|
||||
{
|
||||
@@ -146,6 +147,8 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/* simple but a version that doesn't guarantee that the chunk is actually loaded
|
||||
@Inject(method = "convertToFullChunk", at = @At("HEAD"))
|
||||
private void onChunkGeneratedEnd(ChunkHolder chunkHolder, CallbackInfoReturnable<CompletableFuture<ChunkResult<ChunkAccess>>> cir)
|
||||
@@ -167,7 +170,7 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
@Unique
|
||||
private void addTicket(ChunkPos pos, ChunkStatus status)
|
||||
{ // UNKNOWN
|
||||
this.distanceManager.addTicket(TicketType.UNKNOWN, pos, 33 + ChunkStatus.getDistance(status), pos);
|
||||
this.distanceManager.addTicket(TicketType.UNKNOWN, pos, 33 + ChunkLevel.byStatus(status), pos);
|
||||
}
|
||||
|
||||
@Unique
|
||||
@@ -176,6 +179,8 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
this.addTicket(pos, ChunkStatus.EMPTY);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Unique
|
||||
private void addRelightTicket(ChunkPos pos)
|
||||
{
|
||||
@@ -190,7 +195,7 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
() -> "release relight ticket " + pos
|
||||
));
|
||||
}
|
||||
|
||||
*/
|
||||
@Unique
|
||||
private void tickTicketManager()
|
||||
{
|
||||
@@ -214,6 +219,8 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@Unique
|
||||
private Set<ChunkPos> loadExistingChunksFromDisk(Set<ChunkPos> requestedChunks)
|
||||
{
|
||||
@@ -329,6 +336,8 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
this.waitFor(lightFuture);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> regenerateChunkRegion(List<ChunkPos> requestedChunksList)
|
||||
{
|
||||
@@ -385,7 +394,7 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
{
|
||||
ChunkAccess chunk = this.getCurrentChunk(pos);
|
||||
|
||||
if (chunk.getStatus().isOrAfter(ChunkStatus.LIGHT.getParent()))
|
||||
if (chunk.getPersistedStatus().isOrAfter(ChunkStatus.LIGHT.getParent()))
|
||||
{
|
||||
affectedNeighbors.add(chunk);
|
||||
}
|
||||
@@ -399,7 +408,7 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
|
||||
// remove entities
|
||||
long longPos = pos.toLong();
|
||||
if (this.entitiesInLevel.contains(longPos) && chunk instanceof LevelChunk)
|
||||
if (chunk instanceof LevelChunk)
|
||||
{
|
||||
((SimpleEntityLookupInterface<Entity>) ((ServerWorldInterface) level).getEntityLookupCMPublic()).getChunkEntities(pos).forEach(entity -> {
|
||||
if (!(entity instanceof Player))
|
||||
@@ -415,7 +424,7 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
((LevelChunk) chunk).setLoaded(false);
|
||||
}
|
||||
|
||||
if (this.entitiesInLevel.remove(pos.toLong()) && chunk instanceof LevelChunk)
|
||||
if (chunk instanceof LevelChunk)
|
||||
{
|
||||
this.level.unload((LevelChunk) chunk); // block entities only
|
||||
}
|
||||
@@ -450,7 +459,7 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
// Also, this is needed to ensure chunks are saved to disk
|
||||
|
||||
Map<ChunkPos, ChunkStatus> targetGenerationStatus = affectedChunks.stream().collect(
|
||||
Collectors.toMap(ChunkAccess::getPos, ChunkAccess::getStatus)
|
||||
Collectors.toMap(ChunkAccess::getPos, ChunkAccess::getPersistedStatus)
|
||||
);
|
||||
|
||||
for (Entry<ChunkPos, ChunkStatus> entry : targetGenerationStatus.entrySet())
|
||||
@@ -548,9 +557,13 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
|
||||
return report;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<ChunkHolder> getChunksCM()
|
||||
{
|
||||
return getChunks();
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import carpet.network.CarpetClient;
|
||||
import carpet.script.utils.ShapesRenderer;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
@@ -36,14 +37,14 @@ public class LevelRenderer_scarpetRenderMixin
|
||||
//target = "Lnet/minecraft/client/render/BufferBuilderStorage;getEntityVertexConsumers()Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;", shift = At.Shift.AFTER
|
||||
//target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.AFTER // before return
|
||||
))
|
||||
private void renderScarpetThings(float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f modelViewMatrix, Matrix4f matrix4f, CallbackInfo ci)
|
||||
private void renderScarpetThings(final DeltaTracker deltaTracker, final boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f modelViewMatrix, Matrix4f matrix4f, CallbackInfo ci)
|
||||
{
|
||||
// in normal circumstances we want to render shapes at the very end so it appears correctly behind stuff.
|
||||
// we might actually not need to play with render hooks here.
|
||||
//if (!FabricAPIHooks.WORLD_RENDER_EVENTS && CarpetClient.shapes != null )
|
||||
if (CarpetClient.shapes != null)
|
||||
{
|
||||
CarpetClient.shapes.render(modelViewMatrix, camera, tickDelta);
|
||||
CarpetClient.shapes.render(modelViewMatrix, camera, deltaTracker.getGameTimeDeltaPartialTick(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -24,9 +25,9 @@ public class PlayerList_scarpetEventsMixin
|
||||
@Shadow @Final private MinecraftServer server;
|
||||
|
||||
@Inject(method = "respawn", at = @At("HEAD"))
|
||||
private void onRespawn(ServerPlayer player, boolean olive, CallbackInfoReturnable<ServerPlayer> cir)
|
||||
private void onResp(ServerPlayer serverPlayer, boolean olive, Entity.RemovalReason removalReason, CallbackInfoReturnable<ServerPlayer> cir)
|
||||
{
|
||||
PLAYER_RESPAWNS.onPlayerEvent(player);
|
||||
PLAYER_RESPAWNS.onPlayerEvent(serverPlayer);
|
||||
}
|
||||
|
||||
@Inject(method = "broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatType$Bound;)V",
|
||||
@@ -44,7 +45,7 @@ public class PlayerList_scarpetEventsMixin
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;initInventoryMenu()V"
|
||||
))
|
||||
private void invalidatePreviousInstance(ServerPlayer player, boolean alive, CallbackInfoReturnable<ServerPlayer> cir)
|
||||
private void invalidatePreviousInstance(ServerPlayer player, boolean alive, Entity.RemovalReason removalReason, CallbackInfoReturnable<ServerPlayer> cir)
|
||||
{
|
||||
((ServerPlayerInterface)player).invalidateEntityObjectReference();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.portal.DimensionTransition;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -96,18 +97,20 @@ public abstract class ServerPlayer_scarpetEventMixin extends Player implements S
|
||||
private ResourceKey<Level> previousDimension;
|
||||
|
||||
@Inject(method = "changeDimension", at = @At("HEAD"))
|
||||
private void logPreviousCoordinates(ServerLevel serverWorld, CallbackInfoReturnable<Entity> cir)
|
||||
private void logPreviousCoordinates(DimensionTransitionSupplier serverWorld, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
previousLocation = position();
|
||||
previousDimension = level().dimension(); //dimension type
|
||||
}
|
||||
|
||||
@Inject(method = "changeDimension", at = @At("RETURN"))
|
||||
private void atChangeDimension(ServerLevel destination, CallbackInfoReturnable<Entity> cir)
|
||||
private void atChangeDimension(DimensionTransitionSupplier destinationP, CallbackInfoReturnable<Entity> cir)
|
||||
{
|
||||
if (PLAYER_CHANGES_DIMENSION.isNeeded())
|
||||
{
|
||||
ServerPlayer player = (ServerPlayer) (Object)this;
|
||||
DimensionTransition destinationTransition = destinationP.get();
|
||||
ServerLevel destination = destinationTransition.newDimension();
|
||||
Vec3 to = null;
|
||||
if (!wonGame || previousDimension != Level.END || destination.dimension() != Level.OVERWORLD)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user