Add in 1.20.1 builds! But, sky light for world gen isn't working...?

This commit is contained in:
TomTheFurry
2023-06-25 14:56:50 +08:00
committed by s809
parent b2ba94f6e5
commit 16bcf30092
20 changed files with 347 additions and 111 deletions
+34
View File
@@ -8,6 +8,7 @@ stages:
# TODO: Make stages depending on what is in versionProperties
- build_1_18_2
- build_1_19_4
- build_1_20_1
variables:
# Pull core when building
@@ -84,6 +85,39 @@ build_1_19_4:
allow_failure: true
# 1.20.1 build
build_1.20.1:
stage: build_1.20.1
script:
# this both runs the unit tests and assembles the code
- ./gradlew clean -PmcVer="1.20.1" --gradle-user-home cache/;
- ./gradlew build -PmcVer="1.20.1" --gradle-user-home cache/;
- ./gradlew mergeJars -PmcVer="1.20.1" --gradle-user-home cache/;
image: eclipse-temurin:17
artifacts:
name: "NightlyBuild_1.20.1-${CI_COMMIT_SHORT_SHA}-${CI_COMMIT_TIMESTAMP}"
paths:
- Merged/*.jar
- fabric/build/libs/*.jar
- forge/build/libs/*.jar
- quilt/build/libs/*.jar
exclude:
# TODO: There is a lot of duplicate stuff here, fix it later to be smaller
- fabric/build/libs/*-all.jar
- fabric/build/libs/*-sources.jar
- forge/build/libs/*-all.jar
- forge/build/libs/*-sources.jar
- quilt/build/libs/*-all.jar
- quilt/build/libs/*-sources.jar
expire_in: 1 day
when: always
cache:
key: "gradleCache"
policy: pull-push
paths:
- .gradle
- cache/
allow_failure: true
@@ -95,7 +95,7 @@ public class WrapperFactory implements IWrapperFactory
}
// MC 1.18
#if POST_MC_1_17_1 && PRE_MC_1_20_1
#if POST_MC_1_17_1
else if (objectArray.length == 2)
{
// correct number of parameters from the API
@@ -138,7 +138,7 @@ public class WrapperFactory implements IWrapperFactory
"Expected parameters: \n");
// MC 1.18
#if POST_MC_1_17_1 && PRE_MC_1_20_1
#if POST_MC_1_17_1
message.append("["+ChunkAccess.class.getName()+"], \n");
message.append("["+LevelReader.class.getName()+"]. \n");
#else
@@ -4,6 +4,9 @@ import com.google.gson.JsonParser;
import com.mojang.serialization.JsonOps;
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import org.apache.logging.log4j.Logger;
@@ -81,10 +84,22 @@ public class BlockStateWrapper implements IBlockStateWrapper
public boolean isAir(BlockState blockState) { return blockState == null || blockState.isAir(); }
@Override
public boolean isSolid() { return this.blockState.getMaterial().isSolid(); }
public boolean isSolid() {
#if PRE_MC_1_20_1
return this.blockState.getMaterial().isSolid();
#else
return !this.blockState.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO).isEmpty();
#endif
}
@Override
public boolean isLiquid() { return this.blockState.getMaterial().isLiquid(); }
public boolean isLiquid() {
#if PRE_MC_1_20_1
return this.blockState.getMaterial().isLiquid();
#else
return !this.blockState.getFluidState().isEmpty();
#endif
}
@@ -39,15 +39,22 @@ import net.minecraft.core.BlockPos;
#if POST_MC_1_17_1
import net.minecraft.core.QuartPos;
#endif
import net.minecraft.core.SectionPos;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.levelgen.Heightmap;
// Which nullable should be used???
import net.minecraft.world.level.lighting.LevelLightEngine;
#if POST_MC_1_20_1
import net.minecraft.world.level.lighting.LightEngine;
#endif
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
@@ -357,13 +364,32 @@ public class ChunkWrapper implements IChunkWrapper
@Override
public boolean isStillValid() { return this.wrappedLevel == null || this.wrappedLevel.tryGetChunk(this.chunkPos) == this; }
#if POST_MC_1_20_1
private static boolean checkLightSectionsOnChunk(LevelChunk chunk, LevelLightEngine engine) {
LevelChunkSection[] sections = chunk.getSections();
int minY = chunk.getMinSection();
int maxY = chunk.getMaxSection();
for (int y = minY; y < maxY; ++y) {
LevelChunkSection section = sections[chunk.getSectionIndexFromSectionY(y)];
if (section.hasOnlyAir()) continue;
if (!engine.lightOnInSection(SectionPos.of(chunk.getPos(), y))) {
return false;
}
}
return true;
}
#endif
// Should be called after client light updates are triggered.
private static boolean updateClientLightReady(ChunkAccess chunk, boolean oldValue) {
if (chunk instanceof LevelChunk && ((LevelChunk)chunk).getLevel() instanceof ClientLevel)
{
LevelChunk levelChunk = (LevelChunk)chunk;
ClientChunkCache clientChunkCache = ((ClientLevel)levelChunk.getLevel()).getChunkSource();
return clientChunkCache.getChunkForLighting(chunk.getPos().x, chunk.getPos().z) != null && levelChunk.isClientLightReady();
return clientChunkCache.getChunkForLighting(chunk.getPos().x, chunk.getPos().z) != null &&
#if PRE_MC_1_20_1 levelChunk.isClientLightReady()
#else checkLightSectionsOnChunk(levelChunk, levelChunk.getLevel().getLightEngine())
#endif;
}
else
{
@@ -36,7 +36,11 @@ import com.seibel.distanthorizons.coreapi.ModInfo;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
#if PRE_MC_1_20_1
import net.minecraft.client.gui.GuiComponent;
#else
import net.minecraft.client.gui.GuiGraphics;
#endif
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
@@ -165,7 +169,7 @@ public class ClassicConfigGUI
/**
* Pain
*/
private static class ConfigScreen extends Screen {
private static class ConfigScreen extends DhScreen {
protected ConfigScreen(ConfigBase configBase, Screen parent, String category) {
super(Translatable(
I18n.exists(configBase.modID + ".config" + (category.isEmpty() ? "." + category : "") + ".title") ?
@@ -203,17 +207,6 @@ public class ClassicConfigGUI
Objects.requireNonNull(minecraft).setScreen(this.parent);
}
// addRenderableWidget in 1.17 and over
// addButton in 1.16 and below
private Button addBtn(Button button) {
#if PRE_MC_1_17_1
this.addButton(button);
#else
this.addRenderableWidget(button);
#endif
return button;
}
@Override
protected void init() {
super.init();
@@ -314,14 +307,20 @@ public class ClassicConfigGUI
}
@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
#if PRE_MC_1_20_1
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
#else
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
#endif
{
this.renderBackground(matrices); // Renders background
this.list.render(matrices, mouseX, mouseY, delta); // Render buttons
drawCenteredString(matrices, font, title, width / 2, 15, 0xFFFFFF); // Render title
DhDrawCenteredString(matrices, font, title, width / 2, 15, 0xFFFFFF); // Render title
// If the update is pending, display this message to inform the user that it will apply when the game restarts
if (SelfUpdater.deleteOldOnClose)
drawString(matrices, font, Translatable(configBase.modID + ".updater.waitingForClose"), 4, height-38, 0xFFFFFF);
DhDrawString(matrices, font, Translatable(configBase.modID + ".updater.waitingForClose"), 4, height-38, 0xFFFFFF);
// Render the tooltip only if it can find a tooltip in the language file
@@ -339,13 +338,13 @@ public class ClassicConfigGUI
String key = translationPrefix + (newInfo.category.isEmpty() ? "" : newInfo.category + ".") + newInfo.getName() + ".@tooltip";
if (((EntryInfo) newInfo.guiValue).error != null && text.equals(name))
renderTooltip(matrices, (Component) ((EntryInfo) newInfo.guiValue).error.getValue(), mouseX, mouseY);
DhRenderTooltip(matrices, font, ((EntryInfo) newInfo.guiValue).error.getValue(), mouseX, mouseY);
else if (I18n.exists(key) && (text != null && text.equals(name))) {
List<Component> list = new ArrayList<>();
for (String str : I18n.get(key).split("\n")) {
list.add(TextOrTranslatable(str));
}
renderComponentTooltip(matrices, list, mouseX, mouseY);
DhRenderComponentTooltip(matrices, font, list, mouseX, mouseY);
}
}
}
@@ -485,7 +484,12 @@ public class ClassicConfigGUI
}
@Override
public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
#if PRE_MC_1_20_1
public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
#else
public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta)
#endif
{
if (button != null) {
SetY(button, y);
button.render(matrices, mouseX, mouseY, tickDelta);
@@ -499,7 +503,11 @@ public class ClassicConfigGUI
indexButton.render(matrices, mouseX, mouseY, tickDelta);
}
if (text != null && (!text.getString().contains("spacer") || button != null))
GuiComponent.drawString(matrices, textRenderer, text, 12, y + 5, 0xFFFFFF);
#if PRE_MC_1_20_1
GuiComponent.drawString(matrices, textRenderer, text, 12, y + 5, 0xFFFFFF);
#else
matrices.drawString(textRenderer, text, 12, y + 5, 0xFFFFFF);
#endif
}
@Override
@@ -1,9 +1,17 @@
package com.seibel.distanthorizons.common.wrappers.gui;
import net.minecraft.client.gui.Font;
#if PRE_MC_1_20_1
import com.mojang.blaze3d.vertex.PoseStack;
#else
import net.minecraft.client.gui.GuiGraphics;
#endif
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import java.util.List;
public class DhScreen extends Screen {
protected DhScreen(Component $$0) {
@@ -12,11 +20,45 @@ public class DhScreen extends Screen {
// addRenderableWidget in 1.17 and over
// addButton in 1.16 and below
protected void addBtn(Button button) {
protected Button addBtn(Button button) {
#if PRE_MC_1_17_1
this.addButton(button);
return this.addButton(button);
#else
this.addRenderableWidget(button);
return this.addRenderableWidget(button);
#endif
}
#if PRE_MC_1_20_1
protected void DhDrawCenteredString(PoseStack guiStack, Font font, Component text, int x, int y, int color) {
drawCenteredString(guiStack, font, text, x, y, color);
}
protected void DhDrawString(PoseStack guiStack, Font font, Component text, int x, int y, int color) {
drawString(guiStack, font, text, x, y, color);
}
protected void DhRenderTooltip(PoseStack guiStack, Font font, List<? extends net.minecraft.util.FormattedCharSequence> text, int x, int y) {
renderTooltip(guiStack, text, x, y);
}
protected void DhRenderComponentTooltip(PoseStack guiStack, Font font, List<Component> comp, int x, int y) {
renderComponentTooltip(guiStack, comp, x, y);
}
protected void DhRenderTooltip(PoseStack guiStack, Font font, Component comp, int x, int y) {
renderTooltip(guiStack, comp, x, y);
}
#else
protected void DhDrawCenteredString(GuiGraphics guiStack, Font font, Component text, int x, int y, int color) {
guiStack.drawCenteredString(font, text, x, y, color);
}
protected void DhDrawString(GuiGraphics guiStack, Font font, Component text, int x, int y, int color) {
guiStack.drawString(font, text, x, y, color);
}
protected void DhRenderTooltip(GuiGraphics guiStack, Font font, List<? extends net.minecraft.util.FormattedCharSequence> text, int x, int y) {
guiStack.renderTooltip(font, text, x, y);
}
protected void DhRenderComponentTooltip(GuiGraphics guiStack, Font font, List<Component> comp, int x, int y) {
guiStack.renderComponentTooltip(font, comp, x, y);
}
protected void DhRenderTooltip(GuiGraphics guiStack, Font font, Component text, int x, int y) {
guiStack.renderTooltip(font, text, x, y);
}
#endif
}
@@ -4,6 +4,9 @@ import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.vertex.PoseStack;
import com.seibel.distanthorizons.core.config.gui.AbstractScreen;
import net.minecraft.client.Minecraft;
#if POST_MC_1_20_1
import net.minecraft.client.gui.GuiGraphics;
#endif
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
import net.minecraft.client.gui.screens.Screen;
import org.jetbrains.annotations.NotNull;
@@ -16,7 +19,7 @@ public class MinecraftScreen {
return new ConfigScreenRenderer(parent, screen, translationName);
}
private static class ConfigScreenRenderer extends Screen {
private static class ConfigScreenRenderer extends DhScreen {
private final Screen parent;
private ConfigListWidget list;
private AbstractScreen screen;
@@ -56,7 +59,12 @@ public class MinecraftScreen {
}
@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
#if PRE_MC_1_20_1
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
#else
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
#endif
{
this.renderBackground(matrices); // Render background
this.list.render(matrices, mouseX, mouseY, delta); // Renders the items in the render list (currently only used to tint background darker)
@@ -9,7 +9,11 @@ import com.seibel.distanthorizons.core.jar.installer.MarkdownFormatter;
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
#if PRE_MC_1_20_1
import net.minecraft.client.gui.GuiComponent;
#else
import net.minecraft.client.gui.GuiGraphics;
#endif
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
@@ -104,7 +108,12 @@ public class ChangelogScreen extends DhScreen {
}
@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
#if PRE_MC_1_20_1
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
#else
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
#endif
{
this.renderBackground(matrices); // Render background
// Set the scroll position to the mouse height relative to the screen
@@ -115,7 +124,7 @@ public class ChangelogScreen extends DhScreen {
super.render(matrices, mouseX, mouseY, delta); // Render the buttons
drawCenteredString(matrices, font, title, width / 2, 15, 0xFFFFFF); // Render title
DhDrawCenteredString(matrices, font, title, width / 2, 15, 0xFFFFFF); // Render title
}
@Override
@@ -155,10 +164,17 @@ public class ChangelogScreen extends DhScreen {
return new ButtonEntry(text);
}
#if PRE_MC_1_20_1
@Override
public void render(PoseStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
GuiComponent.drawString(matrices, textRenderer, text, 12, y + 5, 0xFFFFFF);
}
#else
@Override
public void render(GuiGraphics matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
matrices.drawString(textRenderer, text, 12, y + 5, 0xFFFFFF);
}
#endif
@Override
public List<? extends GuiEventListener> children() {
@@ -10,6 +10,9 @@ import com.seibel.distanthorizons.core.jar.JarUtils;
import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
import net.minecraft.client.Minecraft;
#if POST_MC_1_20_1
import net.minecraft.client.gui.GuiGraphics;
#endif
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.screens.Screen;
@@ -117,13 +120,18 @@ public class UpdateModScreen extends DhScreen {
}
@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
#if PRE_MC_1_20_1
public void render(PoseStack matrices, int mouseX, int mouseY, float delta)
#else
public void render(GuiGraphics matrices, int mouseX, int mouseY, float delta)
#endif
{
this.renderBackground(matrices); // Render background
// Render the text's
drawCenteredString(matrices, this.font, Translatable(ModInfo.ID + ".updater.text1"), this.width / 2, this.height / 2 - 35, 0xFFFFFF);
drawCenteredString(matrices, this.font, Translatable(ModInfo.ID + ".updater.text2", ModInfo.VERSION, ModrinthGetter.releaseNames.get(this.newVersionID)), this.width / 2, this.height / 2 -20, 0x52FD52);
DhDrawCenteredString(matrices, this.font, Translatable(ModInfo.ID + ".updater.text1"), this.width / 2, this.height / 2 - 35, 0xFFFFFF);
DhDrawCenteredString(matrices, this.font, Translatable(ModInfo.ID + ".updater.text2", ModInfo.VERSION, ModrinthGetter.releaseNames.get(this.newVersionID)), this.width / 2, this.height / 2 -20, 0x52FD52);
// TODO: add the tooltips for the buttons
super.render(matrices, mouseX, mouseY, delta); // Render the buttons
@@ -587,7 +587,9 @@ public final class BatchGenerationEnvironment extends AbstractBatchGenerationEnv
{
LevelChunk levelChunk = (LevelChunk) chunk;
levelChunk.setLightCorrect(true);
#if PRE_MC_1_20_1
levelChunk.setClientLightReady(true);
#endif
levelChunk.loaded = true;
}
#endif
@@ -28,6 +28,9 @@ import net.minecraft.world.level.LevelHeightAccessor;
#endif
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LightChunkGetter;
#if POST_MC_1_20_1
import net.minecraft.world.level.chunk.LightChunk;
#endif
public class LightGetterAdaptor implements LightChunkGetter {
private final BlockGetter heightGetter;
@@ -44,7 +47,7 @@ public class LightGetterAdaptor implements LightChunkGetter {
}
@Override
public BlockGetter getChunkForLighting(int chunkX, int chunkZ) {
public #if PRE_MC_1_20_1 BlockGetter #else LightChunk #endif getChunkForLighting(int chunkX, int chunkZ) {
if (genRegion == null)
throw new IllegalStateException("World Gen region has not been set!");
// May be null
@@ -19,6 +19,7 @@
package com.seibel.distanthorizons.common.wrappers.worldGeneration.mimicObject;
import net.minecraft.world.level.lighting.*;
import org.jetbrains.annotations.Nullable;
import net.minecraft.core.BlockPos;
@@ -31,10 +32,7 @@ import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.DataLayer;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.lighting.BlockLightEngine;
import net.minecraft.world.level.lighting.LayerLightEventListener;
import net.minecraft.world.level.lighting.LevelLightEngine;
import net.minecraft.world.level.lighting.SkyLightEngine;
import org.jetbrains.annotations.PropertyKey;
public class WorldGenLevelLightEngine extends LevelLightEngine {
public static final int MAX_SOURCE_LEVEL = 15;
@@ -42,10 +40,19 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
#if POST_MC_1_17_1
protected final LevelHeightAccessor levelHeightAccessor;
#endif
#if PRE_MC_1_20_1
@Nullable
public final BlockLightEngine blockEngine;
@Nullable
public final SkyLightEngine skyEngine;
#else
@Nullable
public final LightEngine<?, ?> blockEngine;
@Nullable
public final LightEngine<?, ?> skyEngine;
#endif
public WorldGenLevelLightEngine(LightGetterAdaptor genRegion) {
super(genRegion, false, false);
@@ -56,16 +63,7 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
this.skyEngine = new SkyLightEngine(genRegion);
}
@Override
public void checkBlock(BlockPos blockPos) {
if (this.blockEngine != null) {
this.blockEngine.checkBlock(blockPos);
}
if (this.skyEngine != null) {
this.skyEngine.checkBlock(blockPos);
}
}
#if PRE_MC_1_20_1
@Override
public void onBlockEmissionIncrease(BlockPos blockPos, int i) {
if (this.blockEngine != null) {
@@ -73,14 +71,6 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
}
}
@Override
public boolean hasLightWork() {
if (this.skyEngine != null && this.skyEngine.hasLightWork()) {
return true;
}
return this.blockEngine != null && this.blockEngine.hasLightWork();
}
@Override
public int runUpdates(int i, boolean bl, boolean bl2) {
if (this.blockEngine != null && this.skyEngine != null) {
@@ -102,16 +92,6 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
return i;
}
@Override
public void updateSectionStatus(SectionPos sectionPos, boolean bl) {
if (this.blockEngine != null) {
this.blockEngine.updateSectionStatus(sectionPos, bl);
}
if (this.skyEngine != null) {
this.skyEngine.updateSectionStatus(sectionPos, bl);
}
}
@Override
public void enableLightSources(ChunkPos chunkPos, boolean bl) {
if (this.blockEngine != null) {
@@ -122,6 +102,87 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
}
}
#else
@Override
public int runLightUpdates() {
int $$0 = 0;
if (this.blockEngine != null) {
$$0 += this.blockEngine.runLightUpdates();
}
if (this.skyEngine != null) {
$$0 += this.skyEngine.runLightUpdates();
}
return $$0;
}
@Override
public void setLightEnabled(ChunkPos $$0, boolean $$1) {
if (this.blockEngine != null) {
this.blockEngine.setLightEnabled($$0, $$1);
}
if (this.skyEngine != null) {
this.skyEngine.setLightEnabled($$0, $$1);
}
}
@Override
public void propagateLightSources(ChunkPos arg) {
if (this.skyEngine != null) {
this.skyEngine.propagateLightSources(arg);
}
if (this.blockEngine != null) {
this.blockEngine.propagateLightSources(arg);
}
}
public boolean lightOnInSection(SectionPos $$0) {
long $$1 = $$0.asLong();
return this.blockEngine == null
/*Note: Somehow vanilla access the protected 'storage' field from the LevelLightEngine class... we're using mixin to do this.*/
|| this.blockEngine.storage.lightOnInSection($$1) && (this.skyEngine == null || this.skyEngine.storage.lightOnInSection($$1));
}
#endif
@Override
public void queueSectionData(LightLayer lightLayer, SectionPos sectionPos, @Nullable DataLayer dataLayer #if PRE_MC_1_20_1, boolean bl #endif) {
if (lightLayer == LightLayer.BLOCK) {
if (this.blockEngine != null) {
this.blockEngine.queueSectionData(sectionPos.asLong(), dataLayer #if PRE_MC_1_20_1, bl #endif);
}
} else if (this.skyEngine != null) {
this.skyEngine.queueSectionData(sectionPos.asLong(), dataLayer #if PRE_MC_1_20_1, bl #endif);
}
}
@Override
public void checkBlock(BlockPos blockPos) {
if (this.blockEngine != null) {
this.blockEngine.checkBlock(blockPos);
}
if (this.skyEngine != null) {
this.skyEngine.checkBlock(blockPos);
}
}
@Override
public boolean hasLightWork() {
if (this.skyEngine != null && this.skyEngine.hasLightWork()) {
return true;
}
return this.blockEngine != null && this.blockEngine.hasLightWork();
}
@Override
public void updateSectionStatus(SectionPos sectionPos, boolean bl) {
if (this.blockEngine != null) {
this.blockEngine.updateSectionStatus(sectionPos, bl);
}
if (this.skyEngine != null) {
this.skyEngine.updateSectionStatus(sectionPos, bl);
}
}
@Override
public LayerLightEventListener getLayerListener(LightLayer lightLayer) {
if (lightLayer == LightLayer.BLOCK) {
@@ -168,15 +229,25 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
#else
if (levelChunkSection.hasOnlyAir()) continue;
int j = this.levelHeightAccessor.getSectionYFromSectionIndex(i);
#if POST_MC_1_20_1
queueSectionData(LightLayer.BLOCK, SectionPos.of(chunkPos, i), null);
queueSectionData(LightLayer.SKY, SectionPos.of(chunkPos, i), null);
#endif
updateSectionStatus(SectionPos.of(chunkPos, j), false);
#endif
}
#if PRE_MC_1_20_1
enableLightSources(chunkPos, true);
if (needLightBlockUpdate) {
chunkAccess.getLights().forEach(blockPos ->
onBlockEmissionIncrease(blockPos, chunkAccess.getLightEmission(blockPos)));
}
#else
//runLightUpdates();
propagateLightSources(chunkPos);
//runLightUpdates();
#endif
chunkAccess.setLightCorrect(true);
}
@@ -185,16 +256,6 @@ public class WorldGenLevelLightEngine extends LevelLightEngine {
throw new UnsupportedOperationException("This should never be used!");
}
@Override
public void queueSectionData(LightLayer lightLayer, SectionPos sectionPos, @Nullable DataLayer dataLayer, boolean bl) {
if (lightLayer == LightLayer.BLOCK) {
if (this.blockEngine != null) {
this.blockEngine.queueSectionData(sectionPos.asLong(), dataLayer, bl);
}
} else if (this.skyEngine != null) {
this.skyEngine.queueSectionData(sectionPos.asLong(), dataLayer, bl);
}
}
@Override
public void retainData(ChunkPos chunkPos, boolean bl) {
if (this.blockEngine != null) {
this.blockEngine.retainData(chunkPos, bl);
@@ -64,12 +64,12 @@ public final class StepFeatures {
try {
#if PRE_MC_1_18_1
worldGenRegion.setOverrideCenter(chunk.getPos());
Heightmap.primeHeightmaps(chunk, STATUS.heightmapsAfter());
environment.params.generator.applyBiomeDecoration(worldGenRegion, tParams.structFeat);
#else
Heightmap.primeHeightmaps(chunk, STATUS.heightmapsAfter());
#else
environment.params.generator.applyBiomeDecoration(worldGenRegion, chunk,
tParams.structFeat.forWorldGenRegion(worldGenRegion));
Heightmap.primeHeightmaps(chunk, STATUS.heightmapsAfter());
#endif
} catch (ReportedException e) {
e.printStackTrace();
@@ -72,11 +72,19 @@ public final class StepLight {
} catch (Exception e) {
e.printStackTrace();
}
#if POST_MC_1_18_1
#if POST_MC_1_18_1 && PRE_MC_1_20_1
if (chunk instanceof LevelChunk) ((LevelChunk)chunk).setClientLightReady(true);
#elif POST_MC_1_20_1
lightEngine.setLightEnabled(chunk.getPos(), true);
#endif
chunk.setLightCorrect(true);
}
#if PRE_MC_1_20_1
lightEngine.runUpdates(Integer.MAX_VALUE, true, true);
#else
lightEngine.runLightUpdates();
#endif
}
}
@@ -1,12 +1,9 @@
accessWidener v1 named
# used when determining where to save files to
accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/io/File;
# used when rendering
accessible field com/mojang/blaze3d/vertex/VertexBuffer indexCount I
accessible field com/mojang/blaze3d/vertex/VertexBuffer vertextBufferId I
accessible method net/minecraft/client/renderer/GameRenderer getFov (Lnet/minecraft/client/Camera;FZ)D
# used for grabbing vanilla rendered chunks
@@ -15,39 +12,24 @@ accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkStorage
accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo
accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk;
# lighting
accessible field net/minecraft/client/renderer/LightTexture lightPixels Lcom/mojang/blaze3d/platform/NativeImage;
accessible field net/minecraft/client/renderer/LightTexture lightTexture Lnet/minecraft/client/renderer/texture/DynamicTexture;
accessible field net/minecraft/world/level/lighting/LevelLightEngine blockEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
accessible field net/minecraft/world/level/lighting/LevelLightEngine skyEngine Lnet/minecraft/world/level/lighting/LayerLightEngine;
# world generation
accessible method net/minecraft/world/level/levelgen/Heightmap setHeight (III)V
accessible field net/minecraft/world/level/biome/Biome generationSettings Lnet/minecraft/world/level/biome/BiomeGenerationSettings;
accessible field net/minecraft/world/level/biome/Biome biomeCategory Lnet/minecraft/world/level/biome/Biome$BiomeCategory;
# accessible field net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator settings Lnet/minecraft/core/Holder;
accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doFill (Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;II)Lnet/minecraft/world/level/chunk/ChunkAccess;
#accessible method net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator doCreateBiomes (Lnet/minecraft/core/Registry;Lnet/minecraft/world/level/levelgen/blending/Blender;Lnet/minecraft/world/level/StructureFeatureManager;Lnet/minecraft/world/level/chunk/ChunkAccess;)V
accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
# accessible method net/minecraft/world/level/lighting/LayerLightEngine queueSectionData (JLnet/minecraft/world/level/chunk/DataLayer;Z)V
accessible field net/minecraft/world/level/chunk/LevelChunk loaded Z
accessible field net/minecraft/world/level/lighting/LightEngine storage Lnet/minecraft/world/level/lighting/LayerLightSectionStorage;
accessible method net/minecraft/world/level/lighting/LayerLightSectionStorage lightOnInSection (J)Z
# lod generation from save file
accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/minecraft/util/thread/BlockableEventLoop;
accessible method net/minecraft/server/level/ChunkMap readChunk (Lnet/minecraft/world/level/ChunkPos;)Lnet/minecraft/nbt/CompoundTag;
accessible field net/minecraft/world/level/chunk/storage/ChunkStorage worker Lnet/minecraft/world/level/chunk/storage/IOWorker;
accessible field net/minecraft/world/level/chunk/storage/IOWorker storage Lnet/minecraft/world/level/chunk/storage/RegionFileStorage;
accessible field net/minecraft/world/level/chunk/storage/RegionFileStorage regionCache Lit/unimi/dsi/fastutil/longs/Long2ObjectLinkedOpenHashMap;
accessible field net/minecraft/world/level/chunk/storage/RegionFileStorage folder Ljava/nio/file/Path;
# grabbing textures
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite animatedTexture Lnet/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture;
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite width I
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite height I
accessible field net/minecraft/client/renderer/texture/TextureAtlasSprite mainImage [Lcom/mojang/blaze3d/platform/NativeImage;
accessible class net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameX (I)I
accessible method net/minecraft/client/renderer/texture/TextureAtlasSprite$AnimatedTexture getFrameY (I)I
extendable class com/mojang/math/Matrix4f
accessible class net/minecraft/client/renderer/texture/SpriteContents$AnimatedTexture
accessible method net/minecraft/client/renderer/texture/SpriteContents$AnimatedTexture getFrameX (I)I
accessible method net/minecraft/client/renderer/texture/SpriteContents$AnimatedTexture getFrameY (I)I
accessible field net/minecraft/client/renderer/texture/SpriteContents animatedTexture Lnet/minecraft/client/renderer/texture/SpriteContents$AnimatedTexture;
accessible field net/minecraft/client/renderer/texture/SpriteContents originalImage Lcom/mojang/blaze3d/platform/NativeImage;
# hacky stuff
accessible field net/minecraft/util/ThreadingDetector lock Ljava/util/concurrent/Semaphore;
@@ -48,8 +48,9 @@ public class MixinClientLevel
// {
// ClientApi.INSTANCE.clientLevelLoadEvent(WorldWrapper.getWorldWrapper((ClientLevel)(Object)this));
// }
#if POST_MC_1_18_1 // Only the setLightReady is only available after 1.18. This ensures the light data is ready.
// Moved to overriding the enableChunkLight(...) method over at ClientPacketListener for 1.20+
#if POST_MC_1_18_1 && PRE_MC_1_20_1 // Only the setLightReady is only available after 1.18. This ensures the light data is ready.
@Inject(method = "setLightReady", at = @At("HEAD"))
private void onChunkLightReady(int x, int z, CallbackInfo ci)
{
@@ -1,9 +1,11 @@
package com.seibel.distanthorizons.fabric.mixins.client;
import com.seibel.distanthorizons.common.wrappers.chunk.ChunkWrapper;
import com.seibel.distanthorizons.common.wrappers.world.ClientLevelWrapper;
import com.seibel.distanthorizons.core.api.internal.ClientApi;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.world.level.chunk.LevelChunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -51,5 +53,15 @@ public class MixinClientPacketListener
ClientApi.INSTANCE.clientLevelUnloadEvent(ClientLevelWrapper.getWrapper(level));
}
}
#if POST_MC_1_20_1
@Inject(method = "enableChunkLight", at = @At("TAIL"))
void onEnableChunkLight(LevelChunk chunk, int x, int z, CallbackInfo ci)
{
ClientLevelWrapper clientLevel = ClientLevelWrapper.getWrapper((ClientLevel) chunk.getLevel());
ClientApi.INSTANCE.clientChunkLoadEvent(new ChunkWrapper(chunk, chunk.getLevel(), clientLevel), clientLevel);
}
#endif
}
@@ -116,11 +116,19 @@ public class MixinLevelRenderer
,
at = @At(
value = "INVOKE",
#if PRE_MC_1_20_1
target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runUpdates(IZZ)I"
#else
target = "Lnet/minecraft/world/level/lighting/LevelLightEngine;runLightUpdates()I"
#endif
))
private int callAfterRunUpdates(LevelLightEngine light, int pos, boolean isQueueEmpty, boolean updateBlockLight)
private int callAfterRunUpdates(LevelLightEngine light #if PRE_MC_1_20_1 , int pos, boolean isQueueEmpty, boolean updateBlockLight #endif)
{
#if PRE_MC_1_20_1
int r = light.runUpdates(pos, isQueueEmpty, updateBlockLight);
#else
int r = light.runLightUpdates();
#endif
ChunkWrapper.syncedUpdateClientLightStatus();
return r;
}
@@ -12,6 +12,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
*
* @author coolGi
*/
#if PRE_MC_1_20_1 // FIXME: Forge seems to be missing the mapping for this ,and remap=false doesn't work... Help
@Mixin(TextureUtil.class)
public class MixinTextureUtil {
@Redirect(method = "Lcom/mojang/blaze3d/platform/TextureUtil;prepareImage(Lcom/mojang/blaze3d/platform/NativeImage$InternalGlFormat;IIII)V",
@@ -26,3 +27,4 @@ public class MixinTextureUtil {
}
}
}
#endif
+1 -1
View File
@@ -33,4 +33,4 @@ versionStr=
# This defines what MC version Intellij will use for the preprocessor
# and what version is used automatically by build and run commands
mcVer=1.19.4
mcVer=1.18.2