From 9c90db3718a914d22aefd2385d697191289624b9 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 18 Dec 2022 21:01:18 +1030 Subject: [PATCH] Fixed the accesswidener and TextureAtlasSpriteWrapper, and found the Registries locations. --- .../wrappers/block/TextureAtlasSpriteWrapper.java | 9 ++++----- .../worldGeneration/mimicObject/ChunkLoader.java | 15 +++++++++++++++ .../worldGeneration/step/StepStructureStart.java | 1 - .../src/main/resources/1_19_3.lod.accesswidener | 13 +++++-------- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/block/TextureAtlasSpriteWrapper.java b/common/src/main/java/com/seibel/lod/common/wrappers/block/TextureAtlasSpriteWrapper.java index 379ca9ca9..b441bfec0 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/block/TextureAtlasSpriteWrapper.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/block/TextureAtlasSpriteWrapper.java @@ -48,12 +48,11 @@ public class TextureAtlasSpriteWrapper { } return sprite.mainImage[0].getPixelRGBA(x, y); #else - // FIXME[1.19.3]: Furthest I could get was this - if (sprite.contents().getUniqueFrames().sum() > 1) { - x += sprite.contents().getFrameX(frameIndex) * sprite.contents().width(); - y += sprite.contents().getFrameY(frameIndex) * sprite.contents().width(); + if (sprite.contents().animatedTexture != null) { + x += sprite.contents().animatedTexture.getFrameX(frameIndex) * sprite.contents().width(); + y += sprite.contents().animatedTexture.getFrameY(frameIndex) * sprite.contents().width(); } - return sprite.mainImage[0].getPixelRGBA(x, y); + return sprite.contents().originalImage.getPixelRGBA(x, y); #endif } } diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java index 30e4bb2bf..607a99832 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/mimicObject/ChunkLoader.java @@ -37,9 +37,13 @@ import java.util.Objects; import net.minecraft.core.Registry; import net.minecraft.core.SectionPos; +#if POST_MC_1_19_3 +import net.minecraft.core.registries.Registries; +#endif import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.NbtOps; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.*; import net.minecraft.world.level.biome.Biome; @@ -103,7 +107,11 @@ public class ChunkLoader private static LevelChunkSection[] readSections(LevelAccessor level, LevelLightEngine lightEngine, ChunkPos chunkPos, CompoundTag chunkData) { #if POST_MC_1_18_1 + #if PRE_MC_1_19_3 Registry biomes = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); + #else + Registry biomes = level.registryAccess().registryOrThrow(Registries.BIOME); + #endif #if PRE_MC_1_18_2 Codec> biomeCodec = PalettedContainer.codec( biomes, biomes.byNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomes.getOrThrow(Biomes.PLAINS)); @@ -265,10 +273,17 @@ public class ChunkLoader : new ProtoTickList(fluid -> (fluid == null || fluid == Fluids.EMPTY), chunkPos, tagLevel.getList("LiquidsToBeTicked", 9)#if POST_MC_1_17_1, level #endif); #else + #if PRE_MC_1_19_3 LevelChunkTicks blockTicks = LevelChunkTicks.load(tagLevel.getList(BLOCK_TICKS_TAG_18, 10), string -> Registry.BLOCK.getOptional(ResourceLocation.tryParse(string)), chunkPos); LevelChunkTicks fluidTicks = LevelChunkTicks.load(tagLevel.getList(FLUID_TICKS_TAG_18, 10), string -> Registry.FLUID.getOptional(ResourceLocation.tryParse(string)), chunkPos); + #else + LevelChunkTicks blockTicks = LevelChunkTicks.load(tagLevel.getList(BLOCK_TICKS_TAG_18, 10), + string -> Registries.BLOCK.cast(ResourceLocation.tryParse(string)), chunkPos); + LevelChunkTicks fluidTicks = LevelChunkTicks.load(tagLevel.getList(FLUID_TICKS_TAG_18, 10), + string -> Registries.FLUID.cast(ResourceLocation.tryParse(string)), chunkPos); + #endif #endif LevelChunkSection[] levelChunkSections = readSections(level, lightEngine, chunkPos, tagLevel); diff --git a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepStructureStart.java b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepStructureStart.java index 2d61fed3c..48db995b6 100644 --- a/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepStructureStart.java +++ b/common/src/main/java/com/seibel/lod/common/wrappers/worldGeneration/step/StepStructureStart.java @@ -83,7 +83,6 @@ public final class StepStructureStart { environment.params.generator.createStructures(environment.params.registry, environment.params.randomState, tParams.structFeat, chunk, environment.params.structures, environment.params.worldSeed); #else - // FIXME[1.19.3]: This is the furthest I got with porting this to 1.19.3 environment.params.generator.createStructures(environment.params.registry, environment.params.generator.createState( environment.params.level.holderLookup(), environment.params.randomState, environment.params.worldSeed), diff --git a/common/src/main/resources/1_19_3.lod.accesswidener b/common/src/main/resources/1_19_3.lod.accesswidener index d6232332f..f3a62f9bd 100644 --- a/common/src/main/resources/1_19_3.lod.accesswidener +++ b/common/src/main/resources/1_19_3.lod.accesswidener @@ -33,14 +33,11 @@ accessible field net/minecraft/server/level/ChunkMap mainThreadExecutor Lnet/min # 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;