]> git.lizzy.rs Git - LightOverlay.git/commitdiff
Update to 1.18.2
authorshedaniel <daniel@shedaniel.me>
Tue, 1 Mar 2022 04:27:31 +0000 (12:27 +0800)
committershedaniel <daniel@shedaniel.me>
Tue, 1 Mar 2022 04:27:31 +0000 (12:27 +0800)
build.gradle
common/build.gradle
common/src/main/java/me/shedaniel/lightoverlay/common/LightOverlayTicker.java
fabric/build.gradle
fabric/src/main/java/me/shedaniel/lightoverlay/common/fabric/LightOverlayTickerImpl.java [new file with mode: 0644]
fabric/src/main/resources/lightoverlay.accesswidener
forge/build.gradle
gradle.properties
settings.gradle

index 173399828d80ca37b449310c521389ee879c0add..20d4c3b574d2302a434778271183c563a172e6c5 100644 (file)
@@ -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 {
index 8d4e31d998896c93dbde3c337b2d3108eab8f68d..9a0b77118fecf9ea0a40bb29db067c4e8a97ab7d 100644 (file)
@@ -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 {
index 8cf2275ecf76cf863615de10b4ce2c159734e8a1..f9710156c3d90c553af23f8c33fafacb4a7981e3 100644 (file)
@@ -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<CubicChunkPos> POS = Collections.synchronizedSet(new HashSet<>());
     public final Set<CubicChunkPos> CALCULATING_POS = Collections.synchronizedSet(new HashSet<>());
     public final Map<CubicChunkPos, Long2ByteMap> CHUNK_MAP = Maps.newConcurrentMap();
-    private static final Supplier<EntityType<Entity>> TESTING_ENTITY_TYPE = Suppliers.memoize(() ->
-            EntityType.Builder.createNothing(MobCategory.MONSTER).sized(0f, 0f).noSave().build(null));
+    private static final Supplier<EntityType<Entity>> 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<Entity> type = (EntityType<Entity>) unsafe.allocateInstance(EntityType.class);
+            return type;
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    });
+    
+    @ExpectPlatform
+    public static void populateEntityType(EntityType<Entity> 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> 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> 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> 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;
     }
     
index 3e74394e576976d6a706737d3e1498e49c2b47b1..328ef3a3f66294ae297c8ca848fb8f0e91039283 100755 (executable)
@@ -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 (file)
index 0000000..adadbd6
--- /dev/null
@@ -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<Entity> type) {
+        type.factory = (entityType, level) -> null;
+        type.category = MobCategory.MONSTER;
+        type.immuneTo = ImmutableSet.of();
+        type.dimensions = EntityDimensions.fixed(0.0F, 0.0F);
+    }
+}
index ee2fe740e06eaabb7a2c072bc9cfb46310ca726c..06097972e13e5eb3099ab8a368a2f66b0848b76d 100644 (file)
@@ -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
index de6d3df8cf57364b35017580ba065f2d8d443995..f60510c6ceab9e71e47488539b772e0210762861 100644 (file)
@@ -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}")
index 8a713e23c4484f54c6998f4e0c821c889018a121..16c0289e341a59738eb3ca5227fe1b18953cc5e3 100755 (executable)
@@ -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
index a232ac9e2b4c4f3bec988c1203a274ef8113264f..323a92b2c0469908ea2a4ed3fc34881b527abe6a 100644 (file)
@@ -11,5 +11,5 @@ rootProject.name = "light-overlay"
 
 include("common")
 include("fabric")
-include("forge")
+//include("forge")