Public Access
Add Flooded pages across Minecraft versions and fix 1.21.1 workstations
Build and smoke / changes (push) Waiting to run
Build and smoke / changes (push) Waiting to run
This commit is contained in:
1 parent
4a59fb5d02
commit
441f2896d7
40 files changed
+1018
-64
No files matched your search
@@ -1,5 +1,7 @@
|
||||
package net.dnorberg.rivencraft.age;
|
||||
|
||||
import net.dnorberg.rivencraft.shared.FloodingRules;
|
||||
|
||||
import java.util.Set;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -76,14 +78,18 @@ public final class PortAgeTravel {
|
||||
}
|
||||
}
|
||||
}
|
||||
return generatePlatform ? makePlatform(target, new BlockPos(0, 64, 0)) : null;
|
||||
return generatePlatform ? makePlatform(target, new BlockPos(0, fallbackFeet(target), 0)) : null;
|
||||
}
|
||||
BlockPos surface = findSurfaceLanding(target, 0, 0);
|
||||
if (surface != null) return surface;
|
||||
// Only build above the actual highest obstruction, never in a pocket
|
||||
// beneath it. Void Ages retain the usual platform floor at Y=63.
|
||||
BlockPos obstruction = highestObstruction(target, 0, 0);
|
||||
int y = obstruction == null ? 64 : Math.max(64, obstruction.getY() + 3);
|
||||
boolean flooded = target.getChunkSource().getGenerator() instanceof PortFeatureChunkGenerator features
|
||||
&& features.floodSurface() != FloodingRules.NONE;
|
||||
int clearance = flooded && obstruction != null && !target.getFluidState(obstruction).isEmpty() ? 2 : 3;
|
||||
int y = obstruction == null ? fallbackFeet(target)
|
||||
: Math.max(fallbackFeet(target), obstruction.getY() + clearance);
|
||||
return generatePlatform ? makePlatform(target, new BlockPos(0, y, 0)) : null;
|
||||
}
|
||||
|
||||
@@ -124,6 +130,12 @@ public final class PortAgeTravel {
|
||||
.value().noiseSettings());
|
||||
}
|
||||
|
||||
private static int fallbackFeet(ServerLevel target) {
|
||||
int requested = target.getChunkSource().getGenerator() instanceof PortFeatureChunkGenerator features
|
||||
? features.floodSurface() : FloodingRules.NONE;
|
||||
return FloodingRules.platformFloor(requested, target.getMinY(), target.getMaxY()) + 1;
|
||||
}
|
||||
|
||||
private static BlockPos makePlatform(ServerLevel target, BlockPos foot) {
|
||||
if (foot.getY() <= target.getMinY() || foot.getY() + 2 >= target.getMaxY()) return null;
|
||||
// A carved pocket inside a flooded cave immediately refills. Refuse
|
||||
|
||||
@@ -86,6 +86,7 @@ public final class PortFeatureChunkGenerator extends ChunkGenerator {
|
||||
private final long ageSeed;
|
||||
private final boolean libraries;
|
||||
private final List<Identifier> librarySymbols;
|
||||
private final int floodSurface;
|
||||
|
||||
public PortFeatureChunkGenerator(ChunkGenerator base, PortRockPlan rocks,
|
||||
PortVegetationPlan vegetation, int dungeons, PortLakePlan lakes,
|
||||
@@ -107,8 +108,10 @@ public final class PortFeatureChunkGenerator extends ChunkGenerator {
|
||||
this.ageSeed = ageSeed;
|
||||
this.libraries = libraries;
|
||||
this.librarySymbols = List.copyOf(librarySymbols);
|
||||
this.floodSurface = PortFlooding.requested(librarySymbols);
|
||||
}
|
||||
|
||||
public int floodSurface() { return floodSurface; }
|
||||
public ChunkGenerator base() { return base; }
|
||||
public PortRockPlan rocks() { return rocks; }
|
||||
public PortVegetationPlan vegetation() { return vegetation; }
|
||||
@@ -300,5 +303,6 @@ public final class PortFeatureChunkGenerator extends ChunkGenerator {
|
||||
}
|
||||
}
|
||||
if (libraries) PortLibraryFeature.generate(level, chunk, ageSeed, librarySymbols);
|
||||
PortFlooding.apply(chunk, floodSurface);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package net.dnorberg.rivencraft.age;
|
||||
|
||||
import java.util.List;
|
||||
import net.dnorberg.rivencraft.shared.FloodingRules;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
|
||||
public final class PortFlooding {
|
||||
public static final Identifier PAGE = Identifier.fromNamespaceAndPath("rivencraft", "environment/flooded");
|
||||
private PortFlooding() {}
|
||||
public static int requested(List<Identifier> pages) {
|
||||
return FloodingRules.requested(pages.stream().map(page -> {
|
||||
if (page.equals(PAGE)) return FloodingRules.FLOODED;
|
||||
if (page.getNamespace().equals("rivencraft") && page.getPath().startsWith("number/")) {
|
||||
try {
|
||||
int digit = Integer.parseInt(page.getPath().substring(7));
|
||||
if (digit >= 0 && digit <= 24) return digit;
|
||||
} catch (NumberFormatException ignored) { }
|
||||
}
|
||||
return FloodingRules.OTHER;
|
||||
}).toList());
|
||||
}
|
||||
public static void apply(ChunkAccess chunk, int requested) {
|
||||
int surface = FloodingRules.surface(requested, chunk.getMinY(), chunk.getMaxY());
|
||||
if (surface == FloodingRules.NONE) return;
|
||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
|
||||
int startX = chunk.getPos().getMinBlockX(), startZ = chunk.getPos().getMinBlockZ();
|
||||
for (int x = 0; x < 16; x++) for (int z = 0; z < 16; z++) {
|
||||
for (int y = chunk.getMinY(); y < chunk.getMaxY(); y++) {
|
||||
pos.set(startX + x, y, startZ + z);
|
||||
var state = chunk.getBlockState(pos);
|
||||
if (y <= surface && state.isAir())
|
||||
chunk.setBlockState(pos, Blocks.WATER.defaultBlockState());
|
||||
else if (state.hasProperty(BlockStateProperties.WATERLOGGED))
|
||||
chunk.setBlockState(pos, state.setValue(BlockStateProperties.WATERLOGGED, y <= surface));
|
||||
else if (y > surface && state.getFluidState().is(FluidTags.WATER))
|
||||
chunk.setBlockState(pos, Blocks.AIR.defaultBlockState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.dnorberg.rivencraft.client;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import qouteall.imm_ptl.core.ClientWorldLoader;
|
||||
|
||||
/** Reborn's world map is briefly unavailable during vanilla dimension replacement. */
|
||||
public final class RebornPredictionAcks {
|
||||
private RebornPredictionAcks() {}
|
||||
|
||||
public static boolean handleDuringWorldReset(ClientLevel packetLevel, int sequence) {
|
||||
if (ClientWorldLoader.getIsInitialized()) return false;
|
||||
// The old remote worlds have been discarded. Preserve the vanilla ack for
|
||||
// the packet listener's live world until Reborn rebuilds its multiworld map.
|
||||
if (packetLevel != null) packetLevel.handleBlockChangedAck(sequence);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package net.dnorberg.rivencraft.mixin;
|
||||
|
||||
import net.dnorberg.rivencraft.client.RebornPredictionAcks;
|
||||
import net.dnorberg.rivencraft.compat.RebornBookPreviews;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockChangedAckPacket;
|
||||
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;
|
||||
|
||||
/** Keep transitional acks out of Reborn's initialized-world assertion. */
|
||||
@Mixin(value = ClientPacketListener.class, priority = 2000)
|
||||
public abstract class RebornBlockAckMixin {
|
||||
@Shadow private ClientLevel level;
|
||||
|
||||
@Inject(method = "handleBlockChangedAck", at = @At("HEAD"), cancellable = true)
|
||||
private void rivencraft$ackDuringWorldReset(ClientboundBlockChangedAckPacket packet, CallbackInfo callback) {
|
||||
// Off-thread packets must reach vanilla's normal scheduling path first.
|
||||
if (Minecraft.getInstance().isSameThread() && RebornBookPreviews.available()
|
||||
&& RebornPredictionAcks.handleDuringWorldReset(level, packet.sequence())) callback.cancel();
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,8 @@ public final class PortAuthoredWriting {
|
||||
|| net.dnorberg.rivencraft.compat.SereneSeasonsCompatibility.available();
|
||||
if (net.dnorberg.rivencraft.age.PortAgeColors.isModifier(page)
|
||||
|| net.dnorberg.rivencraft.age.PortDayCycle.supports(page)) return true;
|
||||
if (page.equals(net.dnorberg.rivencraft.age.PortAcceleratedTicks.PAGE)
|
||||
if (page.equals(net.dnorberg.rivencraft.age.PortFlooding.PAGE)
|
||||
|| page.equals(net.dnorberg.rivencraft.age.PortAcceleratedTicks.PAGE)
|
||||
|| net.dnorberg.rivencraft.age.PortInstabilityData.isCorrupted(page)) return true;
|
||||
if (isTerrain(page) || controller(page) != null || PortWeatherMode.forPage(page) != null
|
||||
|| PortLighting.forPage(page) != null || PortSkyStyle.forPage(page) != null) return true;
|
||||
@@ -135,7 +136,8 @@ public final class PortAuthoredWriting {
|
||||
if (pendingMaterial != null && !(pendingMaterial.equals("rivencraft:block")
|
||||
&& (page.equals(ROCKS) || PortTerrainFeaturePlan.acceptsMaterial(page))
|
||||
|| pendingMaterial.equals("rivencraft:fluid") && PortLakePlan.isLake(page))) return false;
|
||||
if (net.dnorberg.rivencraft.age.PortAgeColors.isModifier(page)
|
||||
if (page.equals(net.dnorberg.rivencraft.age.PortFlooding.PAGE)
|
||||
|| net.dnorberg.rivencraft.age.PortAgeColors.isModifier(page)
|
||||
|| net.dnorberg.rivencraft.age.PortDayCycle.supports(page)) {
|
||||
// Shared colors target Sky, Ambient Light Color or Normal Time; trailing colors tint the sky.
|
||||
} else if (net.dnorberg.rivencraft.age.PortInstabilityData.isCorrupted(page)) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.resources.Identifier;
|
||||
|
||||
/** 1.21.1 grammar diagnostics and singular-controller recovery; preserve ordered modifier chains. */
|
||||
public final class PortWritingRecovery {
|
||||
private static final Set<String> SINGULAR = Set.of("terrain", "biome_controller", "weather", "season", "lighting", "sky");
|
||||
private static final Set<String> SINGULAR = Set.of("terrain", "biome_controller", "weather", "season", "lighting", "sky", "flooding");
|
||||
private static final Set<String> MODIFIERS = Set.of("period_modifier", "angle_modifier", "phase_modifier", "size_modifier",
|
||||
"celestial_color", "direction_modifier");
|
||||
public record Diagnostic(String code, int index, int points) {}
|
||||
@@ -29,7 +29,8 @@ public final class PortWritingRecovery {
|
||||
var entry = PortSymbolPages.find(page);
|
||||
if (entry == null || !PortAuthoredWriting.isPageImplemented(page)) { implemented = false; continue; }
|
||||
String role = entry.role();
|
||||
if (pendingNumber != null && !numberTarget(role)) {
|
||||
if (pendingNumber != null && !numberTarget(role)
|
||||
&& !(role.equals("color_number") && numberRunTargetsFlooded(pages, index))) {
|
||||
diagnostics.add(new Diagnostic("misplaced_modifier", pendingNumber, 100));
|
||||
pendingNumber = null;
|
||||
}
|
||||
@@ -78,9 +79,18 @@ public final class PortWritingRecovery {
|
||||
// The port's category compilers select by role, so no physical resort is necessary.
|
||||
return new Result(active, diagnostics, implemented);
|
||||
}
|
||||
private static boolean numberRunTargetsFlooded(List<Identifier> pages, int index) {
|
||||
for (int next = index + 1; next < pages.size(); next++) {
|
||||
var entry = PortSymbolPages.find(pages.get(next));
|
||||
if (entry == null) return false;
|
||||
if (!entry.role().equals("color_number")) return entry.role().equals("flooding");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean numberTarget(String role) {
|
||||
return role.equals("color") || role.equals("period_modifier") || role.equals("angle_modifier")
|
||||
|| role.equals("phase_modifier") || role.equals("size_modifier");
|
||||
|| role.equals("phase_modifier") || role.equals("size_modifier") || role.equals("flooding");
|
||||
}
|
||||
private static int stage(String role) {
|
||||
return switch (role) {
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
"StaticSkyStateMixin",
|
||||
"StaticSkyRendererMixin",
|
||||
"RebornGuiRenderingMixin",
|
||||
"ClientLevelSoundMixin"
|
||||
"ClientLevelSoundMixin",
|
||||
"RebornBlockAckMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in new issue
Block a user