From: shedaniel Date: Tue, 1 Mar 2022 04:27:31 +0000 (+0800) Subject: Update to 1.18.2 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=f1532db002ff819f8330339e5b4e5cad357a16f1;p=LightOverlay.git Update to 1.18.2 --- diff --git a/build.gradle b/build.gradle index 1733998..20d4c3b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false + id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false } architectury { diff --git a/common/build.gradle b/common/build.gradle index 8d4e31d..9a0b771 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,6 +1,6 @@ dependencies { minecraft "com.mojang:minecraft:${rootProject.architectury.minecraft}" - mappings minecraft.officialMojangMappings() + mappings loom.officialMojangMappings() modImplementation "dev.architectury:architectury:${rootProject.architectury_version}" modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" modCompileOnly("me.shedaniel.cloth:cloth-config:${rootProject.cloth_config_version}") { @@ -9,7 +9,7 @@ dependencies { } architectury { - common() + common(false) } configurations { diff --git a/common/src/main/java/me/shedaniel/lightoverlay/common/LightOverlayTicker.java b/common/src/main/java/me/shedaniel/lightoverlay/common/LightOverlayTicker.java index 8cf2275..f971015 100644 --- a/common/src/main/java/me/shedaniel/lightoverlay/common/LightOverlayTicker.java +++ b/common/src/main/java/me/shedaniel/lightoverlay/common/LightOverlayTicker.java @@ -2,6 +2,7 @@ package me.shedaniel.lightoverlay.common; import com.google.common.base.Suppliers; import com.google.common.collect.Maps; +import dev.architectury.injectables.annotations.ExpectPlatform; import it.unimi.dsi.fastutil.longs.Long2ByteMap; import it.unimi.dsi.fastutil.longs.Long2ByteOpenHashMap; import net.minecraft.client.Minecraft; @@ -9,11 +10,11 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.player.LocalPlayer; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.core.Holder; import net.minecraft.tags.BlockTags; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.MobCategory; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LightLayer; @@ -26,7 +27,9 @@ import net.minecraft.world.level.lighting.LayerLightEventListener; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import org.apache.logging.log4j.LogManager; +import sun.misc.Unsafe; +import java.lang.reflect.Field; import java.util.*; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; @@ -44,8 +47,25 @@ public class LightOverlayTicker { public final Set POS = Collections.synchronizedSet(new HashSet<>()); public final Set CALCULATING_POS = Collections.synchronizedSet(new HashSet<>()); public final Map CHUNK_MAP = Maps.newConcurrentMap(); - private static final Supplier> TESTING_ENTITY_TYPE = Suppliers.memoize(() -> - EntityType.Builder.createNothing(MobCategory.MONSTER).sized(0f, 0f).noSave().build(null)); + private static final Supplier> TESTING_ENTITY_TYPE = Suppliers.memoize(() -> { + // get unsafe + try { + Field f = Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + Unsafe unsafe = (Unsafe) f.get(null); + + // instantiate entity type + EntityType type = (EntityType) unsafe.allocateInstance(EntityType.class); + return type; + } catch (Exception e) { + throw new RuntimeException(e); + } + }); + + @ExpectPlatform + public static void populateEntityType(EntityType type) { + throw new AssertionError(); + } public void queueChunk(CubicChunkPos pos) { if (LightOverlay.enabled && LightOverlay.caching && !CALCULATING_POS.contains(pos)) { @@ -89,7 +109,7 @@ public class LightOverlayTicker { chunkData.put(blockPos.asLong(), (byte) level); } } else { - Biome biome = !LightOverlay.mushroom ? world.getBiome(blockPos) : null; + Holder biome = !LightOverlay.mushroom ? world.getBiome(blockPos) : null; byte type = getCrossType(blockPos, biome, downPos, world, block, sky, collisionContext); if (type != LightOverlay.CROSS_NONE) { chunkData.put(blockPos.asLong(), type); @@ -210,7 +230,7 @@ public class LightOverlayTicker { chunkData.put(pos.asLong(), (byte) level); } } else { - Biome biome = !LightOverlay.mushroom ? world.getBiome(pos) : null; + Holder biome = !LightOverlay.mushroom ? world.getBiome(pos) : null; byte type = getCrossType(pos, biome, down, chunk, block, sky, collisionContext); if (type != LightOverlay.CROSS_NONE) { chunkData.put(pos.asLong(), type); @@ -223,7 +243,7 @@ public class LightOverlayTicker { } } - public byte getCrossType(BlockPos pos, Biome biome, BlockPos down, BlockGetter world, LayerLightEventListener block, LayerLightEventListener sky, CollisionContext entityContext) { + public byte getCrossType(BlockPos pos, Holder biome, BlockPos down, BlockGetter world, LayerLightEventListener block, LayerLightEventListener sky, CollisionContext entityContext) { BlockState blockBelowState = world.getBlockState(down); BlockState blockUpperState = world.getBlockState(pos); VoxelShape upperCollisionShape = blockUpperState.getCollisionShape(world, pos, entityContext); @@ -243,7 +263,7 @@ public class LightOverlayTicker { // Check block state allow spawning (excludes bedrock and barriers automatically) if (!blockBelowState.isValidSpawn(world, down, TESTING_ENTITY_TYPE.get())) return LightOverlay.CROSS_NONE; - if (!LightOverlay.mushroom && Biome.BiomeCategory.MUSHROOM == biome.getBiomeCategory()) + if (!LightOverlay.mushroom && Biome.BiomeCategory.MUSHROOM == Biome.getBiomeCategory(biome)) return LightOverlay.CROSS_NONE; int blockLightLevel = block.getLightValue(pos); int skyLightLevel = sky.getLightValue(pos); @@ -251,7 +271,7 @@ public class LightOverlayTicker { return LightOverlay.CROSS_NONE; if (skyLightLevel > LightOverlay.higherCrossLevel) return LightOverlay.higherCross; - return LightOverlay.lowerCrossLevel >= 0 && blockLightLevel > LightOverlay.lowerCrossLevel ? + return LightOverlay.lowerCrossLevel >= 0 && blockLightLevel > LightOverlay.lowerCrossLevel ? LightOverlay.lowerCross : LightOverlay.CROSS_RED; } diff --git a/fabric/build.gradle b/fabric/build.gradle index 3e74394..328ef3a 100755 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -2,8 +2,8 @@ plugins { id "com.github.johnrengelman.shadow" version "7.0.0" } -minecraft { - accessWidener = file("src/main/resources/lightoverlay.accesswidener") +loom { + accessWidenerPath = file("src/main/resources/lightoverlay.accesswidener") } architectury { @@ -28,7 +28,7 @@ processResources { dependencies { minecraft "com.mojang:minecraft:${rootProject.architectury.minecraft}" - mappings minecraft.officialMojangMappings() + mappings loom.officialMojangMappings() modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}" diff --git a/fabric/src/main/java/me/shedaniel/lightoverlay/common/fabric/LightOverlayTickerImpl.java b/fabric/src/main/java/me/shedaniel/lightoverlay/common/fabric/LightOverlayTickerImpl.java new file mode 100644 index 0000000..adadbd6 --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/lightoverlay/common/fabric/LightOverlayTickerImpl.java @@ -0,0 +1,16 @@ +package me.shedaniel.lightoverlay.common.fabric; + +import com.google.common.collect.ImmutableSet; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.MobCategory; + +public class LightOverlayTickerImpl { + public static void populateEntityType(EntityType type) { + type.factory = (entityType, level) -> null; + type.category = MobCategory.MONSTER; + type.immuneTo = ImmutableSet.of(); + type.dimensions = EntityDimensions.fixed(0.0F, 0.0F); + } +} diff --git a/fabric/src/main/resources/lightoverlay.accesswidener b/fabric/src/main/resources/lightoverlay.accesswidener index ee2fe74..0609797 100644 --- a/fabric/src/main/resources/lightoverlay.accesswidener +++ b/fabric/src/main/resources/lightoverlay.accesswidener @@ -3,4 +3,12 @@ accessible field net/minecraft/network/protocol/game/ClientboundSectionBlocksUpd accessible field net/minecraft/client/renderer/culling/Frustum camX D accessible field net/minecraft/client/renderer/culling/Frustum camY D accessible field net/minecraft/client/renderer/culling/Frustum camZ D -accessible field net/minecraft/client/renderer/culling/Frustum frustumData [Lcom/mojang/math/Vector4f; \ No newline at end of file +accessible field net/minecraft/client/renderer/culling/Frustum frustumData [Lcom/mojang/math/Vector4f; +accessible field net/minecraft/world/entity/EntityType factory Lnet/minecraft/world/entity/EntityType$EntityFactory; +accessible field net/minecraft/world/entity/EntityType category Lnet/minecraft/world/entity/MobCategory; +accessible field net/minecraft/world/entity/EntityType immuneTo Lcom/google/common/collect/ImmutableSet; +accessible field net/minecraft/world/entity/EntityType dimensions Lnet/minecraft/world/entity/EntityDimensions; +mutable field net/minecraft/world/entity/EntityType factory Lnet/minecraft/world/entity/EntityType$EntityFactory; +mutable field net/minecraft/world/entity/EntityType category Lnet/minecraft/world/entity/MobCategory; +mutable field net/minecraft/world/entity/EntityType immuneTo Lcom/google/common/collect/ImmutableSet; +mutable field net/minecraft/world/entity/EntityType dimensions Lnet/minecraft/world/entity/EntityDimensions; \ No newline at end of file diff --git a/forge/build.gradle b/forge/build.gradle index de6d3df..f60510c 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -26,7 +26,7 @@ processResources { dependencies { minecraft("com.mojang:minecraft:${rootProject.architectury.minecraft}") - mappings(minecraft.officialMojangMappings()) + mappings(loom.officialMojangMappings()) forge("net.minecraftforge:forge:${rootProject.architectury.minecraft}-${project.forge_version}") modImplementation("me.shedaniel.cloth:cloth-config-forge:${rootProject.cloth_config_version}") modImplementation("dev.architectury:architectury-forge:${rootProject.architectury_version}") diff --git a/gradle.properties b/gradle.properties index 8a713e2..16c0289 100755 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,15 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -mod_version=6.0.4 -minecraft_version=1.18 +mod_version=6.0.5 +minecraft_version=1.18.2 -architectury_version=3.1.45 +architectury_version=4.0.25 # fabric -fabric_loader_version=0.12.5 -fabric_api_version=0.43.1+1.18 -cloth_config_version=6.0.45 +fabric_loader_version=0.13.3 +fabric_api_version=0.47.8+1.18.2 +cloth_config_version=6.2.57 modmenu_version=3.0.0 # forge diff --git a/settings.gradle b/settings.gradle index a232ac9..323a92b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,5 +11,5 @@ rootProject.name = "light-overlay" include("common") include("fabric") -include("forge") +//include("forge")