소스 검색

Initial move to Architectury

malte0811 4 년 전
부모
커밋
e65d4f1dd6
69개의 변경된 파일666개의 추가작업 그리고 587개의 파일을 삭제
  1. 15 24
      .gitignore
  2. 24 151
      build.gradle
  3. 16 0
      common/build.gradle
  4. 5 0
      common/src/main/java/malte0811/ferritecore/ModMain.java
  5. 1 1
      common/src/main/java/malte0811/ferritecore/ducks/FastMapStateHolder.java
  6. 0 0
      common/src/main/java/malte0811/ferritecore/ducks/NoPropertyStateHolder.java
  7. 2 2
      common/src/main/java/malte0811/ferritecore/fastmap/FastMap.java
  8. 2 2
      common/src/main/java/malte0811/ferritecore/fastmap/FastMapKey.java
  9. 1 1
      common/src/main/java/malte0811/ferritecore/fastmap/FastSubMap.java
  10. 1 1
      common/src/main/java/malte0811/ferritecore/fastmap/FastSubMapEntrySet.java
  11. 13 13
      common/src/main/java/malte0811/ferritecore/hash/VoxelShapeArrayHash.java
  12. 47 0
      common/src/main/java/malte0811/ferritecore/hash/VoxelShapeHash.java
  13. 84 0
      common/src/main/java/malte0811/ferritecore/hash/VoxelShapePartHash.java
  14. 11 11
      common/src/main/java/malte0811/ferritecore/hash/VoxelShapeSplitHash.java
  15. 34 39
      common/src/main/java/malte0811/ferritecore/impl/BlockStateCacheImpl.java
  16. 16 21
      common/src/main/java/malte0811/ferritecore/impl/Deduplicator.java
  17. 8 8
      common/src/main/java/malte0811/ferritecore/impl/PropertyValueConditionImpl.java
  18. 1 1
      common/src/main/java/malte0811/ferritecore/impl/StateHolderImpl.java
  19. 41 0
      common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/BlockStateCacheMixin.java
  20. 0 0
      common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/Config.java
  21. 8 8
      common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSArrayAccess.java
  22. 9 9
      common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSPBitSetAccess.java
  23. 4 4
      common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSPSplitAccess.java
  24. 6 6
      common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSSplitAccess.java
  25. 6 6
      common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VoxelShapeAccess.java
  26. 1 4
      common/src/main/java/malte0811/ferritecore/mixin/config/FerriteConfig.java
  27. 0 0
      common/src/main/java/malte0811/ferritecore/mixin/config/FerriteMixinConfig.java
  28. 0 0
      common/src/main/java/malte0811/ferritecore/mixin/dedupmultipart/Config.java
  29. 6 6
      common/src/main/java/malte0811/ferritecore/mixin/dedupmultipart/MixinMultipartBuilder.java
  30. 0 0
      common/src/main/java/malte0811/ferritecore/mixin/fastmap/Config.java
  31. 7 7
      common/src/main/java/malte0811/ferritecore/mixin/fastmap/FastMapStateHolderMixin.java
  32. 0 0
      common/src/main/java/malte0811/ferritecore/mixin/mrl/Config.java
  33. 3 3
      common/src/main/java/malte0811/ferritecore/mixin/mrl/ModelResourceLocationMixin.java
  34. 1 1
      common/src/main/java/malte0811/ferritecore/mixin/mrl/ResourceLocationAccess.java
  35. 0 0
      common/src/main/java/malte0811/ferritecore/mixin/nopropertymap/Config.java
  36. 2 2
      common/src/main/java/malte0811/ferritecore/mixin/nopropertymap/DummyFerriteValuesMixin.java
  37. 3 3
      common/src/main/java/malte0811/ferritecore/mixin/nopropertymap/NoPropertyStateHolderMixin.java
  38. 7 7
      common/src/main/java/malte0811/ferritecore/mixin/predicates/AndConditionMixin.java
  39. 0 0
      common/src/main/java/malte0811/ferritecore/mixin/predicates/Config.java
  40. 7 7
      common/src/main/java/malte0811/ferritecore/mixin/predicates/OrConditionMixin.java
  41. 8 8
      common/src/main/java/malte0811/ferritecore/mixin/predicates/PropertyValueConditionMixin.java
  42. 0 0
      common/src/main/java/malte0811/ferritecore/util/LastAccessedCache.java
  43. 6 6
      common/src/main/java/malte0811/ferritecore/util/PredicateHelper.java
  44. 0 0
      common/src/main/resources/META-INF/coremods.json
  45. 0 0
      common/src/main/resources/META-INF/mods.toml
  46. 0 0
      common/src/main/resources/asm/immutable_to_plain_map.js
  47. 0 0
      common/src/main/resources/ferritecore.blockstatecache.mixin.json
  48. 0 0
      common/src/main/resources/ferritecore.dedupmultipart.mixin.json
  49. 0 0
      common/src/main/resources/ferritecore.fastmap.mixin.json
  50. 0 0
      common/src/main/resources/ferritecore.mrl.mixin.json
  51. 0 0
      common/src/main/resources/ferritecore.nopropertymap.mixin.json
  52. 0 0
      common/src/main/resources/ferritecore.predicates.mixin.json
  53. 0 0
      common/src/main/resources/pack.mcmeta
  54. 60 0
      fabric/build.gradle
  55. 29 0
      fabric/src/main/resources/fabric.mod.json
  56. 52 0
      forge/build.gradle
  57. 1 0
      forge/gradle.properties
  58. 1 2
      forge/src/main/java/malte0811/ferritecore/ModMainForge.java
  59. 24 0
      forge/src/main/resources/META-INF/mods.toml
  60. 6 0
      forge/src/main/resources/pack.mcmeta
  61. 14 10
      gradle.properties
  62. BIN
      gradle/wrapper/gradle-wrapper.jar
  63. 1 1
      gradle/wrapper/gradle-wrapper.properties
  64. 33 20
      gradlew
  65. 24 19
      gradlew.bat
  66. 15 0
      settings.gradle
  67. 0 48
      src/main/java/malte0811/ferritecore/hash/VoxelShapeHash.java
  68. 0 84
      src/main/java/malte0811/ferritecore/hash/VoxelShapePartHash.java
  69. 0 41
      src/main/java/malte0811/ferritecore/mixin/blockstatecache/BlockStateCacheMixin.java

+ 15 - 24
.gitignore

@@ -1,28 +1,19 @@
-# eclipse
-bin
-*.launch
-.settings
-.metadata
-.classpath
-.project
-
-# idea
-out
+build/
 *.ipr
+run/
 *.iws
+out/
 *.iml
-.idea
-
-# gradle
-build
-.gradle
+.gradle/
+output/
+bin/
+libs/
 
-# other
-eclipse
-run
-classes
-
-# Files from Forge MDK
-forge*changelog.txt
-
-custom.gradle
+.classpath
+.project
+.idea/
+classes/
+.metadata
+.vscode
+.settings
+*.launch

+ 24 - 151
build.gradle

@@ -1,164 +1,37 @@
-import java.util.stream.Collectors
-import net.minecraftforge.gradle.common.task.SignJar
-
-buildscript {
-    repositories {
-        maven { url = 'https://files.minecraftforge.net/maven' }
-        jcenter()
-        mavenCentral()
-        maven {url='https://dist.creeper.host/Sponge/maven'}
-
-    }
-    dependencies {
-        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
-        classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
-    }
+plugins {
+    id "architectury-plugin" version "2.0.65"
+    id "forgified-fabric-loom" version "0.6.54" apply false
 }
-apply plugin: 'net.minecraftforge.gradle'
-// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
-apply plugin: 'eclipse'
-apply plugin: 'maven-publish'
-
-version = "${mod_version}"
-group = "malte0811.${modid}" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
-archivesBaseName = "${modid}"
-
-def mixinConfigs = ["predicates", "fastmap", "nopropertymap", "mrl", "dedupmultipart", "blockstatecache"].stream()
-        .map({s -> archivesBaseName+"."+s+".mixin.json"})
-        .collect(Collectors.toList())
-
-def mixinConfigArg = mixinConfigs.stream()
-    .map({s -> "-mixin.config="+s})
-        .collect(Collectors.toList())
-
-def mixinConfigManifestEntry = mixinConfigs.join(",");
-
-sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
-
-minecraft {
-    // The mappings can be changed at any time, and must be in the following format.
-    // snapshot_YYYYMMDD   Snapshot are built nightly.
-    // stable_#            Stables are built at the discretion of the MCP team.
-    // Use non-default mappings at your own risk. they may not always work.
-    // Simply re-run your setup task after changing the mappings to update your workspace.
-    mappings channel: "snapshot", version: "${mapping}-${mcp_version}"
-    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
-
-    //accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
-
-    // Default run configurations.
-    // These can be tweaked, removed, or duplicated as needed.
-    runs {
-        client {
-            workingDirectory project.file('run')
-            args mixinConfigArg
-            property 'mixin.env.disableRefMap', 'true'
-            property 'mixin.debug.export', 'true'
-
-
-            // Recommended logging level for the console
-            property 'forge.logging.console.level', 'debug'
-
-            mods {
-                examplemod {
-                    source sourceSets.main
-                }
-            }
-        }
-
-        server {
-            workingDirectory project.file('run')
-            args mixinConfigArg
-            arg "-nogui"
-            property 'mixin.env.disableRefMap', 'true'
-
-
-            // Recommended logging level for the console
-            property 'forge.logging.console.level', 'debug'
 
-            mods {
-                examplemod {
-                    source sourceSets.main
-                }
-            }
-        }
-    }
+architectury {
+    minecraft = rootProject.minecraft_version
 }
 
-def customGradle = rootProject.file('custom.gradle');
-if (customGradle.exists()) {
-    apply from: customGradle;
+subprojects {
+    apply plugin: "forgified-fabric-loom"
 }
 
-repositories{
-    maven {
-        // location of the maven that hosts JEI files
-        name = "Progwml6 maven"
-        url = "https://dvs1.progwml6.com/files/maven/"
-    }
-    maven {
-        // location of a maven mirror for JEI files, as a fallback
-        name = "ModMaven"
-        url = "https://modmaven.k-4u.nl"
-    }
-    maven {
-        name = "BlameJared"
-        url = "https://maven.blamejared.com/"
-    }
-    jcenter()
-    mavenCentral()
-
-}
-
-dependencies {
-    minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
-    annotationProcessor 'org.spongepowered:mixin:0.8.2:processor'
-}
+allprojects {
+    apply plugin: "java"
+    apply plugin: "architectury-plugin"
 
-// Example for how to get properties into the manifest for reading by the runtime..
-jar {
-    manifest {
-        attributes([
-                "Specification-Title": "${modid}",
-                "Specification-Version": "1", // We are version 1 of ourselves
-                "Implementation-Title": project.name,
-                "Implementation-Version": "${version}",
-                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
-                "MixinConfigs": mixinConfigManifestEntry
-        ])
-    }
-}
+    archivesBaseName = rootProject.archives_base_name
+    version = rootProject.mod_version
+    group = rootProject.maven_group
 
-apply plugin: 'org.spongepowered.mixin'
+    tasks.withType(JavaCompile) {
+        options.encoding = "UTF-8"
 
-task signJar(type: SignJar, dependsOn: jar) {
-    onlyIf {
-        project.hasProperty('keyStore')
-    }
-    if (project.hasProperty('keyStore')) {
-        keyStore = project.keyStore
-        alias = project.storeAlias
-        storePass = project.storePass
-        keyPass = project.storePass
-        inputFile = jar.archivePath
-        outputFile = jar.archivePath
-    } else {
-        logger.warn("No key store found, not signing the output jar\n")
+        // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
+        // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
+        // We'll use that if it's available, but otherwise we'll use the older option.
+        def targetVersion = 8
+        if (JavaVersion.current().isJava9Compatible()) {
+            options.release = targetVersion
+        }
     }
-}
 
-build.dependsOn signJar
-
-mixin {
-    add sourceSets.main, "${modid}.refmap.json"
-}
-
-// Prevent Mixin annotation processor from getting into IDEA's annotation processor settings
-// Copied from Botania
-if (System.getProperty("idea.sync.active") == "true") {
-    afterEvaluate {
-        tasks.withType(JavaCompile).all {
-            it.options.annotationProcessorPath = files()
-        }
+    java {
+        withSourcesJar()
     }
 }

+ 16 - 0
common/build.gradle

@@ -0,0 +1,16 @@
+import java.util.stream.Collectors
+
+dependencies {
+    minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
+    mappings minecraft.officialMojangMappings()
+    compileOnly "com.google.code.findbugs:jsr305:3.+"
+    // We depend on fabric loader here to use the fabric @Environment annotations
+    // Do NOT use other classes from fabric loader
+    modCompile "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
+    //TODO this is a hack, needs a Fabric alternative
+    compile 'com.electronwill.night-config:core:3.6.2'
+}
+
+architectury {
+    common()
+}

+ 5 - 0
common/src/main/java/malte0811/ferritecore/ModMain.java

@@ -0,0 +1,5 @@
+package malte0811.ferritecore;
+
+public class ModMain {
+    public static final String MODID = "ferritecore";
+}

+ 1 - 1
src/main/java/malte0811/ferritecore/ducks/FastMapStateHolder.java → common/src/main/java/malte0811/ferritecore/ducks/FastMapStateHolder.java

@@ -2,7 +2,7 @@ package malte0811.ferritecore.ducks;
 
 import com.google.common.collect.ImmutableMap;
 import malte0811.ferritecore.fastmap.FastMap;
-import net.minecraft.state.Property;
+import net.minecraft.world.level.block.state.properties.Property;
 
 public interface FastMapStateHolder<S> {
     FastMap<S> getStateMap();

+ 0 - 0
src/main/java/malte0811/ferritecore/ducks/NoPropertyStateHolder.java → common/src/main/java/malte0811/ferritecore/ducks/NoPropertyStateHolder.java


+ 2 - 2
src/main/java/malte0811/ferritecore/fastmap/FastMap.java → common/src/main/java/malte0811/ferritecore/fastmap/FastMap.java

@@ -2,7 +2,7 @@ package malte0811.ferritecore.fastmap;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
-import net.minecraft.state.Property;
+import net.minecraft.world.level.block.state.properties.Property;
 
 import javax.annotation.Nullable;
 import java.util.*;
@@ -24,7 +24,7 @@ public class FastMap<Value> {
         for (Property<?> prop : rawKeys) {
             toKeyIndex.put(prop, keys.size());
             keys.add(new FastMapKey<>(prop, factorUpTo));
-            factorUpTo *= prop.getAllowedValues().size();
+            factorUpTo *= prop.getPossibleValues().size();
         }
         this.keys = ImmutableList.copyOf(keys);
         this.toKeyIndex = toKeyIndex.build();

+ 2 - 2
src/main/java/malte0811/ferritecore/fastmap/FastMapKey.java → common/src/main/java/malte0811/ferritecore/fastmap/FastMapKey.java

@@ -2,7 +2,7 @@ package malte0811.ferritecore.fastmap;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
-import net.minecraft.state.Property;
+import net.minecraft.world.level.block.state.properties.Property;
 
 import java.util.List;
 import java.util.Map;
@@ -15,7 +15,7 @@ class FastMapKey<T extends Comparable<T>> {
 
     FastMapKey(Property<T> property, int mapFactor) {
         this.property = property;
-        this.values = ImmutableList.copyOf(property.getAllowedValues());
+        this.values = ImmutableList.copyOf(property.getPossibleValues());
         this.mapFactor = mapFactor;
         ImmutableMap.Builder<Comparable<?>, Integer> toValueIndex = ImmutableMap.builder();
         for (int i = 0; i < this.values.size(); i++) {

+ 1 - 1
src/main/java/malte0811/ferritecore/fastmap/FastSubMap.java → common/src/main/java/malte0811/ferritecore/fastmap/FastSubMap.java

@@ -1,6 +1,6 @@
 package malte0811.ferritecore.fastmap;
 
-import net.minecraft.state.Property;
+import net.minecraft.world.level.block.state.properties.Property;
 
 import javax.annotation.Nonnull;
 import java.util.AbstractMap;

+ 1 - 1
src/main/java/malte0811/ferritecore/fastmap/FastSubMapEntrySet.java → common/src/main/java/malte0811/ferritecore/fastmap/FastSubMapEntrySet.java

@@ -1,6 +1,6 @@
 package malte0811.ferritecore.fastmap;
 
-import net.minecraft.state.Property;
+import net.minecraft.world.level.block.state.properties.Property;
 import org.apache.commons.lang3.tuple.Pair;
 
 import javax.annotation.Nonnull;

+ 13 - 13
src/main/java/malte0811/ferritecore/hash/VoxelShapeArrayHash.java → common/src/main/java/malte0811/ferritecore/hash/VoxelShapeArrayHash.java

@@ -3,24 +3,24 @@ package malte0811.ferritecore.hash;
 import it.unimi.dsi.fastutil.Hash;
 import malte0811.ferritecore.mixin.blockstatecache.VSArrayAccess;
 import malte0811.ferritecore.mixin.blockstatecache.VoxelShapeAccess;
-import net.minecraft.util.math.shapes.VoxelShape;
-import net.minecraft.util.math.shapes.VoxelShapeArray;
-import net.minecraft.util.math.shapes.VoxelShapePart;
+import net.minecraft.world.phys.shapes.ArrayVoxelShape;
+import net.minecraft.world.phys.shapes.DiscreteVoxelShape;
+import net.minecraft.world.phys.shapes.VoxelShape;
 
 import java.util.Objects;
 
-public class VoxelShapeArrayHash implements Hash.Strategy<VoxelShapeArray> {
+public class VoxelShapeArrayHash implements Hash.Strategy<ArrayVoxelShape> {
     public static final VoxelShapeArrayHash INSTANCE = new VoxelShapeArrayHash();
 
     @Override
-    public int hashCode(VoxelShapeArray o) {
+    public int hashCode(ArrayVoxelShape o) {
         VSArrayAccess access = access(o);
-        return 31 * Objects.hash(access.getXPoints(), access.getYPoints(), access.getZPoints())
+        return 31 * Objects.hash(access.getXs(), access.getYs(), access.getZs())
                 + VoxelShapePartHash.INSTANCE.hashCode(getPart(o));
     }
 
     @Override
-    public boolean equals(VoxelShapeArray a, VoxelShapeArray b) {
+    public boolean equals(ArrayVoxelShape a, ArrayVoxelShape b) {
         if (a == b) {
             return true;
         } else if (a == null || b == null) {
@@ -28,18 +28,18 @@ public class VoxelShapeArrayHash implements Hash.Strategy<VoxelShapeArray> {
         }
         VSArrayAccess accessA = access(a);
         VSArrayAccess accessB = access(b);
-        return Objects.equals(accessA.getXPoints(), accessB.getXPoints()) &&
-                Objects.equals(accessA.getYPoints(), accessB.getYPoints()) &&
-                Objects.equals(accessA.getZPoints(), accessB.getZPoints()) &&
+        return Objects.equals(accessA.getXs(), accessB.getXs()) &&
+                Objects.equals(accessA.getYs(), accessB.getYs()) &&
+                Objects.equals(accessA.getZs(), accessB.getZs()) &&
                 VoxelShapePartHash.INSTANCE.equals(getPart(a), getPart(b));
     }
 
     @SuppressWarnings("ConstantConditions")
-    private static VSArrayAccess access(VoxelShapeArray a) {
+    private static VSArrayAccess access(ArrayVoxelShape a) {
         return (VSArrayAccess) (Object) a;
     }
 
-    private static VoxelShapePart getPart(VoxelShape a) {
-        return ((VoxelShapeAccess) a).getPart();
+    private static DiscreteVoxelShape getPart(VoxelShape a) {
+        return ((VoxelShapeAccess) a).getShape();
     }
 }

+ 47 - 0
common/src/main/java/malte0811/ferritecore/hash/VoxelShapeHash.java

@@ -0,0 +1,47 @@
+package malte0811.ferritecore.hash;
+
+import it.unimi.dsi.fastutil.Hash;
+import malte0811.ferritecore.mixin.blockstatecache.VoxelShapeAccess;
+import net.minecraft.world.phys.shapes.ArrayVoxelShape;
+import net.minecraft.world.phys.shapes.CubeVoxelShape;
+import net.minecraft.world.phys.shapes.SliceShape;
+import net.minecraft.world.phys.shapes.VoxelShape;
+
+public class VoxelShapeHash implements Hash.Strategy<VoxelShape> {
+    public static final VoxelShapeHash INSTANCE = new VoxelShapeHash();
+
+    @Override
+    public int hashCode(VoxelShape o) {
+        if (o instanceof SliceShape) {
+            return VoxelShapeSplitHash.INSTANCE.hashCode((SliceShape) o);
+        } else if (o instanceof ArrayVoxelShape) {
+            return VoxelShapeArrayHash.INSTANCE.hashCode((ArrayVoxelShape) o);
+        } else if (o instanceof CubeVoxelShape) {
+            return VoxelShapePartHash.INSTANCE.hashCode(((VoxelShapeAccess) o).getShape());
+        } else {
+            //TODO VSCube?
+            return o.hashCode();
+        }
+    }
+
+    @Override
+    public boolean equals(VoxelShape a, VoxelShape b) {
+        if (a == b) {
+            return true;
+        } else if (a == null || b == null) {
+            return false;
+        } else if (a.getClass() != b.getClass()) {
+            return false;
+        } else if (a instanceof SliceShape) {
+            return VoxelShapeSplitHash.INSTANCE.equals((SliceShape) a, (SliceShape) b);
+        } else if (a instanceof ArrayVoxelShape) {
+            return VoxelShapeArrayHash.INSTANCE.equals((ArrayVoxelShape) a, (ArrayVoxelShape) b);
+        } else if (a instanceof CubeVoxelShape) {
+            return VoxelShapePartHash.INSTANCE.equals(
+                    ((VoxelShapeAccess) a).getShape(), ((VoxelShapeAccess) b).getShape()
+            );
+        } else {
+            return a.equals(b);
+        }
+    }
+}

+ 84 - 0
common/src/main/java/malte0811/ferritecore/hash/VoxelShapePartHash.java

@@ -0,0 +1,84 @@
+package malte0811.ferritecore.hash;
+
+import it.unimi.dsi.fastutil.Hash;
+import malte0811.ferritecore.mixin.blockstatecache.VSPBitSetAccess;
+import malte0811.ferritecore.mixin.blockstatecache.VSPSplitAccess;
+import net.minecraft.world.phys.shapes.BitSetDiscreteVoxelShape;
+import net.minecraft.world.phys.shapes.DiscreteVoxelShape;
+import net.minecraft.world.phys.shapes.SubShape;
+
+import java.util.Objects;
+
+public class VoxelShapePartHash implements Hash.Strategy<DiscreteVoxelShape> {
+    public static final VoxelShapePartHash INSTANCE = new VoxelShapePartHash();
+
+    @Override
+    public int hashCode(DiscreteVoxelShape o) {
+        if (o instanceof SubShape) {
+            VSPSplitAccess access = access((SubShape) o);
+            int result = access.getStartX();
+            result = 31 * result + access.getStartY();
+            result = 31 * result + access.getStartZ();
+            result = 31 * result + access.getEndX();
+            result = 31 * result + access.getEndY();
+            result = 31 * result + access.getEndZ();
+            result = 31 * result + hashCode(access.getParent());
+            return result;
+        } else if (o instanceof BitSetDiscreteVoxelShape) {
+            VSPBitSetAccess access = access((BitSetDiscreteVoxelShape) o);
+            int result = access.getXMin();
+            result = 31 * result + access.getYMin();
+            result = 31 * result + access.getZMin();
+            result = 31 * result + access.getXMax();
+            result = 31 * result + access.getYMax();
+            result = 31 * result + access.getZMax();
+            result = 31 * result + Objects.hashCode(access.getStorage());
+            return result;
+        } else {
+            return Objects.hashCode(o);
+        }
+    }
+
+    @Override
+    public boolean equals(DiscreteVoxelShape a, DiscreteVoxelShape b) {
+        if (a == b) {
+            return true;
+        } else if (a == null || b == null) {
+            return false;
+        } else if (a.getClass() != b.getClass()) {
+            return false;
+        } else if (a instanceof SubShape) {
+            VSPSplitAccess accessA = access((SubShape) a);
+            VSPSplitAccess accessB = access((SubShape) b);
+            return accessA.getEndX() == accessB.getEndX() &&
+                    accessA.getEndY() == accessB.getEndY() &&
+                    accessA.getEndZ() == accessB.getEndZ() &&
+                    accessA.getStartX() == accessB.getStartX() &&
+                    accessA.getStartY() == accessB.getStartY() &&
+                    accessA.getStartZ() == accessB.getStartZ() &&
+                    equals(accessA.getParent(), accessB.getParent());
+        } else if (a instanceof BitSetDiscreteVoxelShape) {
+            VSPBitSetAccess accessA = access((BitSetDiscreteVoxelShape) a);
+            VSPBitSetAccess accessB = access((BitSetDiscreteVoxelShape) b);
+            return accessA.getXMax() == accessB.getXMax() &&
+                    accessA.getYMax() == accessB.getYMax() &&
+                    accessA.getZMax() == accessB.getZMax() &&
+                    accessA.getXMin() == accessB.getXMin() &&
+                    accessA.getYMin() == accessB.getYMin() &&
+                    accessA.getZMin() == accessB.getZMin() &&
+                    accessA.getStorage().equals(accessB.getStorage());
+        } else {
+            return a.equals(b);
+        }
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    private static VSPSplitAccess access(SubShape part) {
+        return (VSPSplitAccess) (Object) part;
+    }
+
+    @SuppressWarnings("ConstantConditions")
+    private static VSPBitSetAccess access(BitSetDiscreteVoxelShape part) {
+        return (VSPBitSetAccess) (Object) part;
+    }
+}

+ 11 - 11
src/main/java/malte0811/ferritecore/hash/VoxelShapeSplitHash.java → common/src/main/java/malte0811/ferritecore/hash/VoxelShapeSplitHash.java

@@ -3,26 +3,26 @@ package malte0811.ferritecore.hash;
 import it.unimi.dsi.fastutil.Hash;
 import malte0811.ferritecore.mixin.blockstatecache.VSSplitAccess;
 import malte0811.ferritecore.mixin.blockstatecache.VoxelShapeAccess;
-import net.minecraft.util.math.shapes.SplitVoxelShape;
-import net.minecraft.util.math.shapes.VoxelShape;
-import net.minecraft.util.math.shapes.VoxelShapePart;
+import net.minecraft.world.phys.shapes.DiscreteVoxelShape;
+import net.minecraft.world.phys.shapes.SliceShape;
+import net.minecraft.world.phys.shapes.VoxelShape;
 
 import java.util.Objects;
 
-public class VoxelShapeSplitHash implements Hash.Strategy<SplitVoxelShape> {
+public class VoxelShapeSplitHash implements Hash.Strategy<SliceShape> {
     public static final VoxelShapeSplitHash INSTANCE = new VoxelShapeSplitHash();
 
     @Override
-    public int hashCode(SplitVoxelShape o) {
+    public int hashCode(SliceShape o) {
         VSSplitAccess access = access(o);
         int result = Objects.hashCode(access.getAxis());
         result = 31 * result + VoxelShapePartHash.INSTANCE.hashCode(getPart(o));
-        result = 31 * result + VoxelShapeHash.INSTANCE.hashCode(access.getShape());
+        result = 31 * result + VoxelShapeHash.INSTANCE.hashCode(access.getDelegate());
         return result;
     }
 
     @Override
-    public boolean equals(SplitVoxelShape a, SplitVoxelShape b) {
+    public boolean equals(SliceShape a, SliceShape b) {
         if (a == b) {
             return true;
         } else if (a == null || b == null) {
@@ -31,15 +31,15 @@ public class VoxelShapeSplitHash implements Hash.Strategy<SplitVoxelShape> {
         VSSplitAccess accessA = access(a);
         VSSplitAccess accessB = access(b);
         return Objects.equals(accessA.getAxis(), accessB.getAxis()) &&
-                VoxelShapeHash.INSTANCE.equals(accessA.getShape(), accessB.getShape()) &&
+                VoxelShapeHash.INSTANCE.equals(accessA.getDelegate(), accessB.getDelegate()) &&
                 VoxelShapePartHash.INSTANCE.equals(getPart(a), getPart(b));
     }
 
-    private static VSSplitAccess access(SplitVoxelShape a) {
+    private static VSSplitAccess access(SliceShape a) {
         return (VSSplitAccess) a;
     }
 
-    private static VoxelShapePart getPart(VoxelShape a) {
-        return ((VoxelShapeAccess) a).getPart();
+    private static DiscreteVoxelShape getPart(VoxelShape a) {
+        return ((VoxelShapeAccess) a).getShape();
     }
 }

+ 34 - 39
src/main/java/malte0811/ferritecore/impl/BlockStateCacheImpl.java → common/src/main/java/malte0811/ferritecore/impl/BlockStateCacheImpl.java

@@ -2,40 +2,35 @@ package malte0811.ferritecore.impl;
 
 import com.mojang.datafixers.util.Pair;
 import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
-import malte0811.ferritecore.ModMain;
 import malte0811.ferritecore.hash.VoxelShapeArrayHash;
 import malte0811.ferritecore.hash.VoxelShapeHash;
 import malte0811.ferritecore.mixin.blockstatecache.VSArrayAccess;
 import malte0811.ferritecore.mixin.blockstatecache.VoxelShapeAccess;
 import malte0811.ferritecore.util.LastAccessedCache;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockState;
-import net.minecraft.util.Direction;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.shapes.ISelectionContext;
-import net.minecraft.util.math.shapes.VoxelShape;
-import net.minecraft.util.math.shapes.VoxelShapeArray;
-import net.minecraft.util.math.shapes.VoxelShapes;
-import net.minecraft.world.IBlockReader;
-import net.minecraftforge.event.TagsUpdatedEvent;
-import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.common.Mod;
-import net.minecraftforge.fml.event.lifecycle.FMLModIdMappingEvent;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.Direction;
+import net.minecraft.world.level.BlockGetter;
+import net.minecraft.world.level.block.state.BlockBehaviour;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.phys.shapes.ArrayVoxelShape;
+import net.minecraft.world.phys.shapes.CollisionContext;
+import net.minecraft.world.phys.shapes.Shapes;
+import net.minecraft.world.phys.shapes.VoxelShape;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
 import java.util.function.Function;
 
-@Mod.EventBusSubscriber(modid = ModMain.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
+//TODO @Mod.EventBusSubscriber(modid = ModMain.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
 public class BlockStateCacheImpl {
     private static final Direction[] DIRECTIONS = Direction.values();
-    public static final Object2ObjectOpenCustomHashMap<VoxelShapeArray, VoxelShapeArray> CACHE_COLLIDE =
+    public static final Object2ObjectOpenCustomHashMap<ArrayVoxelShape, ArrayVoxelShape> CACHE_COLLIDE =
             new Object2ObjectOpenCustomHashMap<>(VoxelShapeArrayHash.INSTANCE);
     public static final LastAccessedCache<VoxelShape, VoxelShape[]> CACHE_PROJECT = new LastAccessedCache<>(
             VoxelShapeHash.INSTANCE, vs -> {
         VoxelShape[] result = new VoxelShape[DIRECTIONS.length];
         for (Direction d : DIRECTIONS) {
-            result[d.ordinal()] = VoxelShapes.getFaceShape(vs, d);
+            result[d.ordinal()] = Shapes.getFaceShape(vs, d);
         }
         return result;
     }
@@ -43,17 +38,17 @@ public class BlockStateCacheImpl {
     public static int collideCalls = 0;
     public static int projectCalls = 0;
 
+    //TODO
     // Caches are populated in two places: a) In ITagCollectionSupplier#updateTags (which triggers this event)
-    @SubscribeEvent
-    public static void onTagReloadVanilla(TagsUpdatedEvent.VanillaTagTypes ignored) {
-        resetCaches();
-    }
-
+    //@SubscribeEvent
+    //public static void onTagReloadVanilla(TagsUpdatedEvent.VanillaTagTypes ignored) {
+    //    resetCaches();
+    //}
     // b) Via ForgeRegistry#bake, which usually triggers this event
-    @SubscribeEvent
-    public static void onModIdMapping(FMLModIdMappingEvent ignored) {
-        resetCaches();
-    }
+    //@SubscribeEvent
+    //public static void onModIdMapping(FMLModIdMappingEvent ignored) {
+    //    resetCaches();
+    //}
 
     private static void resetCaches() {
         //TODO remove
@@ -69,15 +64,15 @@ public class BlockStateCacheImpl {
     }
 
     public static VoxelShape redirectGetCollisionShape(
-            Block block, BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context
+            BlockBehaviour block, BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context
     ) {
         VoxelShape baseResult = block.getCollisionShape(state, worldIn, pos, context);
-        if (!(baseResult instanceof VoxelShapeArray)) {
+        if (!(baseResult instanceof ArrayVoxelShape)) {
             return baseResult;
         }
-        VoxelShapeArray baseArray = (VoxelShapeArray) baseResult;
+        ArrayVoxelShape baseArray = (ArrayVoxelShape) baseResult;
         ++collideCalls;
-        VoxelShapeArray resultArray = CACHE_COLLIDE.computeIfAbsent(baseArray, Function.identity());
+        ArrayVoxelShape resultArray = CACHE_COLLIDE.computeIfAbsent(baseArray, Function.identity());
         replaceInternals(resultArray, baseArray);
         return resultArray;
     }
@@ -85,13 +80,13 @@ public class BlockStateCacheImpl {
     public static VoxelShape redirectFaceShape(VoxelShape shape, Direction face) {
         ++projectCalls;
         Pair<VoxelShape, VoxelShape[]> sides = CACHE_PROJECT.get(shape);
-        if (sides.getFirst() instanceof VoxelShapeArray && shape instanceof VoxelShapeArray) {
-            replaceInternals((VoxelShapeArray) sides.getFirst(), (VoxelShapeArray) shape);
+        if (sides.getFirst() instanceof ArrayVoxelShape && shape instanceof ArrayVoxelShape) {
+            replaceInternals((ArrayVoxelShape) sides.getFirst(), (ArrayVoxelShape) shape);
         }
         return sides.getSecond()[face.ordinal()];
     }
 
-    public static void replaceInternals(VoxelShapeArray toKeep, VoxelShapeArray toReplace) {
+    public static void replaceInternals(ArrayVoxelShape toKeep, ArrayVoxelShape toReplace) {
         if (toKeep == toReplace) {
             return;
         }
@@ -101,15 +96,15 @@ public class BlockStateCacheImpl {
         // that we can't do anything about shallow size and replace the internals with those used in the cache. This is
         // not theoretically 100% safe since VSs can technically be modified after they are created, but handing out VSs
         // that will be modified is unsafe in any case since a lot of vanilla code relies on VSs being immutable.
-        access(toReplace).setXPoints(access(toKeep).getXPoints());
-        access(toReplace).setYPoints(access(toKeep).getYPoints());
-        access(toReplace).setZPoints(access(toKeep).getZPoints());
-        accessVS(toReplace).setProjectionCache(accessVS(toKeep).getProjectionCache());
-        accessVS(toReplace).setPart(accessVS(toKeep).getPart());
+        access(toReplace).setXs(access(toKeep).getXs());
+        access(toReplace).setYs(access(toKeep).getYs());
+        access(toReplace).setZs(access(toKeep).getZs());
+        accessVS(toReplace).setFaces(accessVS(toKeep).getFaces());
+        accessVS(toReplace).setShape(accessVS(toKeep).getShape());
     }
 
     @SuppressWarnings("ConstantConditions")
-    private static VSArrayAccess access(VoxelShapeArray a) {
+    private static VSArrayAccess access(ArrayVoxelShape a) {
         return (VSArrayAccess) (Object) a;
     }
 

+ 16 - 21
src/main/java/malte0811/ferritecore/impl/Deduplicator.java → common/src/main/java/malte0811/ferritecore/impl/Deduplicator.java

@@ -2,18 +2,14 @@ package malte0811.ferritecore.impl;
 
 import com.mojang.datafixers.util.Unit;
 import malte0811.ferritecore.ModMain;
-import net.minecraft.block.BlockState;
 import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.model.IBakedModel;
-import net.minecraft.client.renderer.model.MultipartBakedModel;
-import net.minecraft.client.resources.ReloadListener;
-import net.minecraft.profiler.IProfiler;
-import net.minecraft.resources.IReloadableResourceManager;
-import net.minecraft.resources.IResourceManager;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
-import net.minecraftforge.eventbus.api.SubscribeEvent;
-import net.minecraftforge.fml.common.Mod;
+import net.minecraft.client.resources.model.BakedModel;
+import net.minecraft.client.resources.model.MultiPartBakedModel;
+import net.minecraft.server.packs.resources.ReloadableResourceManager;
+import net.minecraft.server.packs.resources.ResourceManager;
+import net.minecraft.server.packs.resources.SimplePreparableReloadListener;
+import net.minecraft.util.profiling.ProfilerFiller;
+import net.minecraft.world.level.block.state.BlockState;
 import org.apache.commons.lang3.tuple.Pair;
 
 import javax.annotation.Nonnull;
@@ -23,11 +19,11 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.function.Function;
 import java.util.function.Predicate;
 
-@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = ModMain.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
+//TODO @Mod.EventBusSubscriber(value = Dist.CLIENT, modid = ModMain.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
 public class Deduplicator {
     private static final Map<String, String> VARIANT_IDENTITIES = new ConcurrentHashMap<>();
     // Typedefs would be a nice thing to have
-    private static final Map<List<Pair<Predicate<BlockState>, IBakedModel>>, MultipartBakedModel> KNOWN_MULTIPART_MODELS = new ConcurrentHashMap<>();
+    private static final Map<List<Pair<Predicate<BlockState>, BakedModel>>, MultiPartBakedModel> KNOWN_MULTIPART_MODELS = new ConcurrentHashMap<>();
     private static final Map<List<Predicate<BlockState>>, Predicate<BlockState>> OR_PREDICATE_CACHE = new ConcurrentHashMap<>();
     private static final Map<List<Predicate<BlockState>>, Predicate<BlockState>> AND_PREDICATE_CACHE = new ConcurrentHashMap<>();
 
@@ -35,8 +31,8 @@ public class Deduplicator {
         return VARIANT_IDENTITIES.computeIfAbsent(variant, Function.identity());
     }
 
-    public static MultipartBakedModel makeMultipartModel(List<Pair<Predicate<BlockState>, IBakedModel>> selectors) {
-        return KNOWN_MULTIPART_MODELS.computeIfAbsent(selectors, MultipartBakedModel::new);
+    public static MultiPartBakedModel makeMultipartModel(List<Pair<Predicate<BlockState>, BakedModel>> selectors) {
+        return KNOWN_MULTIPART_MODELS.computeIfAbsent(selectors, MultiPartBakedModel::new);
     }
 
     public static Predicate<BlockState> or(List<Predicate<BlockState>> list) {
@@ -53,19 +49,18 @@ public class Deduplicator {
         );
     }
 
-    @SubscribeEvent
-    public static void registerReloadListener(ParticleFactoryRegisterEvent ev) {
+    //TODO @SubscribeEvent
+    public static void registerReloadListener() {
         // Register the reload listener s.t. its "sync" part runs after the model loader reload
-        ((IReloadableResourceManager) Minecraft.getInstance().getResourceManager()).addReloadListener(new ReloadListener<Unit>() {
-            @Nonnull
+        ((ReloadableResourceManager) Minecraft.getInstance().getResourceManager()).registerReloadListener(new SimplePreparableReloadListener<Unit>() {
             @Override
-            protected Unit prepare(@Nonnull IResourceManager resourceManagerIn, @Nonnull IProfiler profilerIn) {
+            protected Unit prepare(ResourceManager resourceManager, ProfilerFiller profilerFiller) {
                 return Unit.INSTANCE;
             }
 
             @Override
             protected void apply(
-                    @Nonnull Unit objectIn, @Nonnull IResourceManager resourceManagerIn, @Nonnull IProfiler profilerIn
+                    Unit object, ResourceManager resourceManager, ProfilerFiller profilerFiller
             ) {
                 VARIANT_IDENTITIES.clear();
                 KNOWN_MULTIPART_MODELS.clear();

+ 8 - 8
src/main/java/malte0811/ferritecore/impl/PropertyValueConditionImpl.java → common/src/main/java/malte0811/ferritecore/impl/PropertyValueConditionImpl.java

@@ -2,10 +2,10 @@ package malte0811.ferritecore.impl;
 
 import com.google.common.base.Splitter;
 import malte0811.ferritecore.util.PredicateHelper;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockState;
-import net.minecraft.state.Property;
-import net.minecraft.state.StateContainer;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.state.StateDefinition;
+import net.minecraft.world.level.block.state.properties.Property;
 import org.apache.commons.lang3.tuple.Pair;
 
 import java.util.List;
@@ -19,7 +19,7 @@ public class PropertyValueConditionImpl {
     private static final Map<Pair<Property<?>, Comparable<?>>, Predicate<BlockState>> STATE_HAS_PROPERTY_CACHE = new ConcurrentHashMap<>();
 
     public static Predicate<BlockState> getPredicate(
-            StateContainer<Block, BlockState> stateContainer, String key, String value, Splitter splitter
+            StateDefinition<Block, BlockState> stateContainer, String key, String value, Splitter splitter
     ) {
         Property<?> property = stateContainer.getProperty(key);
         if (property == null) {
@@ -59,9 +59,9 @@ public class PropertyValueConditionImpl {
 
     private static <T extends Comparable<T>>
     Predicate<BlockState> makePropertyPredicate(
-            StateContainer<Block, BlockState> container, Property<T> property, String subValue, String key, String value
+            StateDefinition<Block, BlockState> container, Property<T> property, String subValue, String key, String value
     ) {
-        Optional<T> optional = property.parseValue(subValue);
+        Optional<T> optional = property.getValue(subValue);
         if (!optional.isPresent()) {
             throw new RuntimeException(String.format(
                     "Unknown value '%s' for property '%s' on '%s' in '%s'",
@@ -74,7 +74,7 @@ public class PropertyValueConditionImpl {
                     pair -> {
                         Comparable<?> valueInt = pair.getRight();
                         Property<?> propInt = pair.getLeft();
-                        return state -> state.get(propInt).equals(valueInt);
+                        return state -> state.getValue(propInt).equals(valueInt);
                     }
             );
         }

+ 1 - 1
src/main/java/malte0811/ferritecore/impl/StateHolderImpl.java → common/src/main/java/malte0811/ferritecore/impl/StateHolderImpl.java

@@ -3,7 +3,7 @@ package malte0811.ferritecore.impl;
 import malte0811.ferritecore.ducks.FastMapStateHolder;
 import malte0811.ferritecore.ducks.NoPropertyStateHolder;
 import malte0811.ferritecore.fastmap.FastMap;
-import net.minecraft.state.Property;
+import net.minecraft.world.level.block.state.properties.Property;
 
 import java.util.Map;
 

+ 41 - 0
common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/BlockStateCacheMixin.java

@@ -0,0 +1,41 @@
+package malte0811.ferritecore.mixin.blockstatecache;
+
+import malte0811.ferritecore.impl.BlockStateCacheImpl;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.Direction;
+import net.minecraft.world.level.BlockGetter;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockBehaviour;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.phys.shapes.CollisionContext;
+import net.minecraft.world.phys.shapes.VoxelShape;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+@Mixin(targets = "net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase$Cache")
+public class BlockStateCacheMixin {
+    @Redirect(
+            method = "<init>",
+            at = @At(
+                    value = "INVOKE",
+                    target = "Lnet/minecraft/world/phys/shapes/Shapes;getFaceShape(Lnet/minecraft/world/phys/shapes/VoxelShape;Lnet/minecraft/core/Direction;)Lnet/minecraft/world/phys/shapes/VoxelShape;"
+            )
+    )
+    private VoxelShape redirectFaceShape(VoxelShape shape, Direction face) {
+        return BlockStateCacheImpl.redirectFaceShape(shape, face);
+    }
+
+    @Redirect(
+            method = "<init>",
+            at = @At(
+                    value = "INVOKE",
+                    target = "Lnet/minecraft/world/level/block/Block;getCollisionShape(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/shapes/CollisionContext;)Lnet/minecraft/world/phys/shapes/VoxelShape;"
+            )
+    )
+    private VoxelShape redirectGetCollisionShape(
+            Block block, BlockState state, BlockGetter worldIn, BlockPos pos, CollisionContext context
+    ) {
+        return BlockStateCacheImpl.redirectGetCollisionShape(block, state, worldIn, pos, context);
+    }
+}

+ 0 - 0
src/main/java/malte0811/ferritecore/mixin/blockstatecache/Config.java → common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/Config.java


+ 8 - 8
src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSArrayAccess.java → common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSArrayAccess.java

@@ -1,27 +1,27 @@
 package malte0811.ferritecore.mixin.blockstatecache;
 
 import it.unimi.dsi.fastutil.doubles.DoubleList;
-import net.minecraft.util.math.shapes.VoxelShapeArray;
+import net.minecraft.world.phys.shapes.ArrayVoxelShape;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.gen.Accessor;
 
-@Mixin(VoxelShapeArray.class)
+@Mixin(ArrayVoxelShape.class)
 public interface VSArrayAccess {
     @Accessor
-    void setXPoints(DoubleList newPoints);
+    void setXs(DoubleList newPoints);
 
     @Accessor
-    void setYPoints(DoubleList newPoints);
+    void setYs(DoubleList newPoints);
 
     @Accessor
-    void setZPoints(DoubleList newPoints);
+    void setZs(DoubleList newPoints);
 
     @Accessor
-    DoubleList getXPoints();
+    DoubleList getXs();
 
     @Accessor
-    DoubleList getYPoints();
+    DoubleList getYs();
 
     @Accessor
-    DoubleList getZPoints();
+    DoubleList getZs();
 }

+ 9 - 9
src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSPBitSetAccess.java → common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSPBitSetAccess.java

@@ -1,31 +1,31 @@
 package malte0811.ferritecore.mixin.blockstatecache;
 
-import net.minecraft.util.math.shapes.BitSetVoxelShapePart;
+import net.minecraft.world.phys.shapes.BitSetDiscreteVoxelShape;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.gen.Accessor;
 
 import java.util.BitSet;
 
-@Mixin(BitSetVoxelShapePart.class)
+@Mixin(BitSetDiscreteVoxelShape.class)
 public interface VSPBitSetAccess {
     @Accessor
-    BitSet getBitSet();
+    BitSet getStorage();
 
     @Accessor
-    int getStartX();
+    int getXMin();
 
     @Accessor
-    int getStartY();
+    int getYMin();
 
     @Accessor
-    int getStartZ();
+    int getZMin();
 
     @Accessor
-    int getEndX();
+    int getXMax();
 
     @Accessor
-    int getEndY();
+    int getYMax();
 
     @Accessor
-    int getEndZ();
+    int getZMax();
 }

+ 4 - 4
src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSPSplitAccess.java → common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSPSplitAccess.java

@@ -1,14 +1,14 @@
 package malte0811.ferritecore.mixin.blockstatecache;
 
-import net.minecraft.util.math.shapes.PartSplitVoxelShape;
-import net.minecraft.util.math.shapes.VoxelShapePart;
+import net.minecraft.world.phys.shapes.DiscreteVoxelShape;
+import net.minecraft.world.phys.shapes.SubShape;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.gen.Accessor;
 
-@Mixin(PartSplitVoxelShape.class)
+@Mixin(SubShape.class)
 public interface VSPSplitAccess {
     @Accessor
-    VoxelShapePart getPart();
+    DiscreteVoxelShape getParent();
 
     @Accessor
     int getStartX();

+ 6 - 6
src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSSplitAccess.java → common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VSSplitAccess.java

@@ -1,20 +1,20 @@
 package malte0811.ferritecore.mixin.blockstatecache;
 
-import net.minecraft.util.Direction;
-import net.minecraft.util.math.shapes.SplitVoxelShape;
-import net.minecraft.util.math.shapes.VoxelShape;
+import net.minecraft.core.Direction;
+import net.minecraft.world.phys.shapes.SliceShape;
+import net.minecraft.world.phys.shapes.VoxelShape;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Mutable;
 import org.spongepowered.asm.mixin.gen.Accessor;
 
-@Mixin(SplitVoxelShape.class)
+@Mixin(SliceShape.class)
 public interface VSSplitAccess {
     @Accessor
     @Mutable
-    void setShape(VoxelShape newShape);
+    void setDelegate(VoxelShape newShape);
 
     @Accessor
-    VoxelShape getShape();
+    VoxelShape getDelegate();
 
     @Accessor
     Direction.Axis getAxis();

+ 6 - 6
src/main/java/malte0811/ferritecore/mixin/blockstatecache/VoxelShapeAccess.java → common/src/main/java/malte0811/ferritecore/mixin/blockstatecache/VoxelShapeAccess.java

@@ -1,7 +1,7 @@
 package malte0811.ferritecore.mixin.blockstatecache;
 
-import net.minecraft.util.math.shapes.VoxelShape;
-import net.minecraft.util.math.shapes.VoxelShapePart;
+import net.minecraft.world.phys.shapes.DiscreteVoxelShape;
+import net.minecraft.world.phys.shapes.VoxelShape;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Mutable;
 import org.spongepowered.asm.mixin.gen.Accessor;
@@ -11,15 +11,15 @@ import javax.annotation.Nullable;
 @Mixin(VoxelShape.class)
 public interface VoxelShapeAccess {
     @Accessor
-    VoxelShapePart getPart();
+    DiscreteVoxelShape getShape();
 
     @Accessor
-    VoxelShape[] getProjectionCache();
+    VoxelShape[] getFaces();
 
     @Accessor
     @Mutable
-    void setPart(VoxelShapePart newPart);
+    void setShape(DiscreteVoxelShape newPart);
 
     @Accessor
-    void setProjectionCache(@Nullable VoxelShape[] newCache);
+    void setFaces(@Nullable VoxelShape[] newCache);
 }

+ 1 - 4
src/main/java/malte0811/ferritecore/mixin/config/FerriteConfig.java → common/src/main/java/malte0811/ferritecore/mixin/config/FerriteConfig.java

@@ -7,10 +7,7 @@ import com.electronwill.nightconfig.core.io.ParsingException;
 import javax.annotation.Nullable;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.function.Predicate;
 
 public class FerriteConfig {

+ 0 - 0
src/main/java/malte0811/ferritecore/mixin/config/FerriteMixinConfig.java → common/src/main/java/malte0811/ferritecore/mixin/config/FerriteMixinConfig.java


+ 0 - 0
src/main/java/malte0811/ferritecore/mixin/dedupmultipart/Config.java → common/src/main/java/malte0811/ferritecore/mixin/dedupmultipart/Config.java


+ 6 - 6
src/main/java/malte0811/ferritecore/mixin/dedupmultipart/MixinMultipartBuilder.java → common/src/main/java/malte0811/ferritecore/mixin/dedupmultipart/MixinMultipartBuilder.java

@@ -1,9 +1,9 @@
 package malte0811.ferritecore.mixin.dedupmultipart;
 
 import malte0811.ferritecore.impl.Deduplicator;
-import net.minecraft.block.BlockState;
-import net.minecraft.client.renderer.model.IBakedModel;
-import net.minecraft.client.renderer.model.MultipartBakedModel;
+import net.minecraft.client.resources.model.BakedModel;
+import net.minecraft.client.resources.model.MultiPartBakedModel;
+import net.minecraft.world.level.block.state.BlockState;
 import org.apache.commons.lang3.tuple.Pair;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.injection.At;
@@ -12,13 +12,13 @@ import org.spongepowered.asm.mixin.injection.Redirect;
 import java.util.List;
 import java.util.function.Predicate;
 
-@Mixin(MultipartBakedModel.Builder.class)
+@Mixin(MultiPartBakedModel.Builder.class)
 public class MixinMultipartBuilder {
     @Redirect(
             method = "build",
-            at = @At(value = "NEW", target = "net/minecraft/client/renderer/model/MultipartBakedModel")
+            at = @At(value = "NEW", target = "net/minecraft/client/resources/model/MultiPartBakedModel")
     )
-    public MultipartBakedModel build(List<Pair<Predicate<BlockState>, IBakedModel>> selectors) {
+    public MultiPartBakedModel build(List<Pair<Predicate<BlockState>, BakedModel>> selectors) {
         return Deduplicator.makeMultipartModel(selectors);
     }
 }

+ 0 - 0
src/main/java/malte0811/ferritecore/mixin/fastmap/Config.java → common/src/main/java/malte0811/ferritecore/mixin/fastmap/Config.java


+ 7 - 7
src/main/java/malte0811/ferritecore/mixin/fastmap/FastMapStateHolderMixin.java → common/src/main/java/malte0811/ferritecore/mixin/fastmap/FastMapStateHolderMixin.java

@@ -5,8 +5,8 @@ import com.google.common.collect.Table;
 import malte0811.ferritecore.ducks.FastMapStateHolder;
 import malte0811.ferritecore.fastmap.FastMap;
 import malte0811.ferritecore.impl.StateHolderImpl;
-import net.minecraft.state.Property;
-import net.minecraft.state.StateHolder;
+import net.minecraft.world.level.block.state.StateHolder;
+import net.minecraft.world.level.block.state.properties.Property;
 import org.spongepowered.asm.mixin.*;
 import org.spongepowered.asm.mixin.injection.At;
 import org.spongepowered.asm.mixin.injection.Redirect;
@@ -18,13 +18,13 @@ public abstract class FastMapStateHolderMixin<O, S> implements FastMapStateHolde
     @Mutable
     @Shadow
     @Final
-    private ImmutableMap<Property<?>, Comparable<?>> properties;
+    private ImmutableMap<Property<?>, Comparable<?>> values;
 
     private int globalTableIndex;
     private FastMap<S> globalTable;
 
     @Redirect(
-            method = "with",
+            method = "setValue",
             at = @At(
                     value = "INVOKE",
                     target = "Lcom/google/common/collect/Table;get(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
@@ -41,7 +41,7 @@ public abstract class FastMapStateHolderMixin<O, S> implements FastMapStateHolde
      * @author malte0811
      */
     @Overwrite
-    public void func_235899_a_(Map<Map<Property<?>, Comparable<?>>, S> states) {
+    public void populateNeighbours(Map<Map<Property<?>, Comparable<?>>, S> states) {
         StateHolderImpl.populateNeighbors(states, this);
     }
 
@@ -57,12 +57,12 @@ public abstract class FastMapStateHolderMixin<O, S> implements FastMapStateHolde
 
     @Override
     public ImmutableMap<Property<?>, Comparable<?>> getVanillaPropertyMap() {
-        return properties;
+        return values;
     }
 
     @Override
     public void deleteVanillaPropertyMap() {
-        properties = null;
+        values = null;
     }
 
     @Override

+ 0 - 0
src/main/java/malte0811/ferritecore/mixin/mrl/Config.java → common/src/main/java/malte0811/ferritecore/mixin/mrl/Config.java


+ 3 - 3
src/main/java/malte0811/ferritecore/mixin/mrl/ModelResourceLocationMixin.java → common/src/main/java/malte0811/ferritecore/mixin/mrl/ModelResourceLocationMixin.java

@@ -1,8 +1,8 @@
 package malte0811.ferritecore.mixin.mrl;
 
 import malte0811.ferritecore.impl.Deduplicator;
-import net.minecraft.client.renderer.model.ModelResourceLocation;
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.client.resources.model.ModelResourceLocation;
+import net.minecraft.resources.ResourceLocation;
 import org.spongepowered.asm.mixin.Final;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Mutable;
@@ -19,7 +19,7 @@ public class ModelResourceLocationMixin {
     private String variant;
 
     @Inject(
-            method = "<init>(Lnet/minecraft/util/ResourceLocation;Ljava/lang/String;)V",
+            method = "<init>(Lnet/minecraft/resources/ResourceLocation;Ljava/lang/String;)V",
             at = @At("TAIL")
     )
     private void constructTail(ResourceLocation location, String variantIn, CallbackInfo ci) {

+ 1 - 1
src/main/java/malte0811/ferritecore/mixin/mrl/ResourceLocationAccess.java → common/src/main/java/malte0811/ferritecore/mixin/mrl/ResourceLocationAccess.java

@@ -1,6 +1,6 @@
 package malte0811.ferritecore.mixin.mrl;
 
-import net.minecraft.util.ResourceLocation;
+import net.minecraft.resources.ResourceLocation;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Mutable;
 import org.spongepowered.asm.mixin.gen.Accessor;

+ 0 - 0
src/main/java/malte0811/ferritecore/mixin/nopropertymap/Config.java → common/src/main/java/malte0811/ferritecore/mixin/nopropertymap/Config.java


+ 2 - 2
src/main/java/malte0811/ferritecore/mixin/nopropertymap/DummyFerriteValuesMixin.java → common/src/main/java/malte0811/ferritecore/mixin/nopropertymap/DummyFerriteValuesMixin.java

@@ -1,8 +1,8 @@
 package malte0811.ferritecore.mixin.nopropertymap;
 
 import com.google.common.collect.ImmutableMap;
-import net.minecraft.state.Property;
-import net.minecraft.state.StateHolder;
+import net.minecraft.world.level.block.state.StateHolder;
+import net.minecraft.world.level.block.state.properties.Property;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Shadow;
 

+ 3 - 3
src/main/java/malte0811/ferritecore/mixin/nopropertymap/NoPropertyStateHolderMixin.java → common/src/main/java/malte0811/ferritecore/mixin/nopropertymap/NoPropertyStateHolderMixin.java

@@ -5,8 +5,8 @@ import malte0811.ferritecore.ducks.FastMapStateHolder;
 import malte0811.ferritecore.ducks.NoPropertyStateHolder;
 import malte0811.ferritecore.fastmap.FastMap;
 import malte0811.ferritecore.fastmap.FastSubMap;
-import net.minecraft.state.Property;
-import net.minecraft.state.StateHolder;
+import net.minecraft.world.level.block.state.StateHolder;
+import net.minecraft.world.level.block.state.properties.Property;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Shadow;
 import org.spongepowered.asm.mixin.injection.At;
@@ -26,7 +26,7 @@ public abstract class NoPropertyStateHolderMixin implements NoPropertyStateHolde
     // All other Mixins: If the new data structures are initialized, use those. Otherwise (if populateNeighbors didn't
     // run yet) use the vanilla code using `properties`
     @Redirect(
-            method = {"get", "func_235903_d_", "with"},
+            method = {"getValue", "getOptionalValue", "setValue"},
             at = @At(
                     value = "INVOKE",
                     target = "Lcom/google/common/collect/ImmutableMap;get(Ljava/lang/Object;)Ljava/lang/Object;",

+ 7 - 7
src/main/java/malte0811/ferritecore/mixin/predicates/AndConditionMixin.java → common/src/main/java/malte0811/ferritecore/mixin/predicates/AndConditionMixin.java

@@ -2,11 +2,11 @@ package malte0811.ferritecore.mixin.predicates;
 
 import malte0811.ferritecore.impl.Deduplicator;
 import malte0811.ferritecore.util.PredicateHelper;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockState;
-import net.minecraft.client.renderer.model.multipart.AndCondition;
-import net.minecraft.client.renderer.model.multipart.ICondition;
-import net.minecraft.state.StateContainer;
+import net.minecraft.client.renderer.block.model.multipart.AndCondition;
+import net.minecraft.client.renderer.block.model.multipart.Condition;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.state.StateDefinition;
 import org.spongepowered.asm.mixin.Final;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Overwrite;
@@ -16,14 +16,14 @@ import java.util.function.Predicate;
 
 @Mixin(AndCondition.class)
 public class AndConditionMixin {
-    @Shadow @Final private Iterable<? extends ICondition> conditions;
+    @Shadow @Final private Iterable<? extends Condition> conditions;
 
     /**
      * @reason Use cached result predicates
      * @author malte0811
      */
     @Overwrite
-    public Predicate<BlockState> getPredicate(StateContainer<Block, BlockState> stateContainer) {
+    public Predicate<BlockState> getPredicate(StateDefinition<Block, BlockState> stateContainer) {
         return Deduplicator.and(PredicateHelper.toCanonicalList(conditions, stateContainer));
     }
 }

+ 0 - 0
src/main/java/malte0811/ferritecore/mixin/predicates/Config.java → common/src/main/java/malte0811/ferritecore/mixin/predicates/Config.java


+ 7 - 7
src/main/java/malte0811/ferritecore/mixin/predicates/OrConditionMixin.java → common/src/main/java/malte0811/ferritecore/mixin/predicates/OrConditionMixin.java

@@ -2,11 +2,11 @@ package malte0811.ferritecore.mixin.predicates;
 
 import malte0811.ferritecore.impl.Deduplicator;
 import malte0811.ferritecore.util.PredicateHelper;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockState;
-import net.minecraft.client.renderer.model.multipart.ICondition;
-import net.minecraft.client.renderer.model.multipart.OrCondition;
-import net.minecraft.state.StateContainer;
+import net.minecraft.client.renderer.block.model.multipart.Condition;
+import net.minecraft.client.renderer.block.model.multipart.OrCondition;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.state.StateDefinition;
 import org.spongepowered.asm.mixin.Final;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Overwrite;
@@ -16,14 +16,14 @@ import java.util.function.Predicate;
 
 @Mixin(OrCondition.class)
 public class OrConditionMixin {
-    @Shadow @Final private Iterable<? extends ICondition> conditions;
+    @Shadow @Final private Iterable<? extends Condition> conditions;
 
     /**
      * @reason Use cached result predicates
      * @author malte0811
      */
     @Overwrite
-    public Predicate<BlockState> getPredicate(StateContainer<Block, BlockState> stateContainer) {
+    public Predicate<BlockState> getPredicate(StateDefinition<Block, BlockState> stateContainer) {
         return Deduplicator.or(PredicateHelper.toCanonicalList(conditions, stateContainer));
     }
 }

+ 8 - 8
src/main/java/malte0811/ferritecore/mixin/predicates/PropertyValueConditionMixin.java → common/src/main/java/malte0811/ferritecore/mixin/predicates/PropertyValueConditionMixin.java

@@ -2,10 +2,10 @@ package malte0811.ferritecore.mixin.predicates;
 
 import com.google.common.base.Splitter;
 import malte0811.ferritecore.impl.PropertyValueConditionImpl;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockState;
-import net.minecraft.client.renderer.model.multipart.PropertyValueCondition;
-import net.minecraft.state.StateContainer;
+import net.minecraft.client.renderer.block.model.multipart.KeyValueCondition;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.state.StateDefinition;
 import org.spongepowered.asm.mixin.Final;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Overwrite;
@@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.Shadow;
 
 import java.util.function.Predicate;
 
-@Mixin(PropertyValueCondition.class)
+@Mixin(KeyValueCondition.class)
 public class PropertyValueConditionMixin {
     @Shadow
     @Final
@@ -23,7 +23,7 @@ public class PropertyValueConditionMixin {
     private String value;
     @Shadow
     @Final
-    private static Splitter SPLITTER;
+    private static Splitter PIPE_SPLITTER;
 
     /**
      * @reason Use cached predicates in the case of multiple specified values
@@ -33,7 +33,7 @@ public class PropertyValueConditionMixin {
      * @author malte0811
      */
     @Overwrite
-    public Predicate<BlockState> getPredicate(StateContainer<Block, BlockState> stateContainer) {
-        return PropertyValueConditionImpl.getPredicate(stateContainer, key, value, SPLITTER);
+    public Predicate<BlockState> getPredicate(StateDefinition<Block, BlockState> stateContainer) {
+        return PropertyValueConditionImpl.getPredicate(stateContainer, key, value, PIPE_SPLITTER);
     }
 }

+ 0 - 0
src/main/java/malte0811/ferritecore/util/LastAccessedCache.java → common/src/main/java/malte0811/ferritecore/util/LastAccessedCache.java


+ 6 - 6
src/main/java/malte0811/ferritecore/util/PredicateHelper.java → common/src/main/java/malte0811/ferritecore/util/PredicateHelper.java

@@ -1,9 +1,9 @@
 package malte0811.ferritecore.util;
 
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockState;
-import net.minecraft.client.renderer.model.multipart.ICondition;
-import net.minecraft.state.StateContainer;
+import net.minecraft.client.renderer.block.model.multipart.Condition;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.state.StateDefinition;
 
 import java.util.ArrayList;
 import java.util.Comparator;
@@ -12,10 +12,10 @@ import java.util.function.Predicate;
 
 public class PredicateHelper {
     public static List<Predicate<BlockState>> toCanonicalList(
-            Iterable<? extends ICondition> conditions, StateContainer<Block, BlockState> stateContainer
+            Iterable<? extends Condition> conditions, StateDefinition<Block, BlockState> stateContainer
     ) {
         ArrayList<Predicate<BlockState>> list = new ArrayList<>();
-        for (ICondition cond : conditions) {
+        for (Condition cond : conditions) {
             list.add(cond.getPredicate(stateContainer));
         }
         return canonize(list);

+ 0 - 0
src/main/resources/META-INF/coremods.json → common/src/main/resources/META-INF/coremods.json


+ 0 - 0
src/main/resources/META-INF/mods.toml → common/src/main/resources/META-INF/mods.toml


+ 0 - 0
src/main/resources/asm/immutable_to_plain_map.js → common/src/main/resources/asm/immutable_to_plain_map.js


+ 0 - 0
src/main/resources/ferritecore.blockstatecache.mixin.json → common/src/main/resources/ferritecore.blockstatecache.mixin.json


+ 0 - 0
src/main/resources/ferritecore.dedupmultipart.mixin.json → common/src/main/resources/ferritecore.dedupmultipart.mixin.json


+ 0 - 0
src/main/resources/ferritecore.fastmap.mixin.json → common/src/main/resources/ferritecore.fastmap.mixin.json


+ 0 - 0
src/main/resources/ferritecore.mrl.mixin.json → common/src/main/resources/ferritecore.mrl.mixin.json


+ 0 - 0
src/main/resources/ferritecore.nopropertymap.mixin.json → common/src/main/resources/ferritecore.nopropertymap.mixin.json


+ 0 - 0
src/main/resources/ferritecore.predicates.mixin.json → common/src/main/resources/ferritecore.predicates.mixin.json


+ 0 - 0
src/main/resources/pack.mcmeta → common/src/main/resources/pack.mcmeta


+ 60 - 0
fabric/build.gradle

@@ -0,0 +1,60 @@
+import java.util.stream.Collectors
+
+plugins {
+    id "com.github.johnrengelman.shadow" version "5.0.0"
+}
+
+configurations {
+    shadow
+}
+
+architectury {
+    platformSetupLoomIde()
+}
+
+dependencies {
+    minecraft("com.mojang:minecraft:${rootProject.minecraft_version}")
+    mappings(minecraft.officialMojangMappings())
+    modCompile("net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}")
+    modCompile("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}")
+    //TODO this is a hack, needs a Fabric alternative
+    compile 'com.electronwill.night-config:core:3.6.2'
+    compile 'com.electronwill.night-config:toml:3.6.2'
+
+    compileOnly(project(path: ":common")) {
+        transitive = false
+    }
+    runtimeOnly(project(path: ":common", configuration: "transformDevelopmentFabric")) {
+        transitive = false
+    }
+    shadow(project(path: ":common", configuration: "transformProductionFabric")) {
+        transitive = false
+    }
+}
+
+processResources {
+    inputs.property "version", project.version
+
+    filesMatching("fabric.mod.json") {
+        expand "version": project.version
+    }
+}
+
+shadowJar {
+    configurations = [project.configurations.shadow]
+    classifier "shadow"
+}
+
+remapJar {
+    dependsOn(shadowJar)
+    input.set(shadowJar.archivePath)
+    classifier "fabric"
+}
+
+def fcMixinConfigs = ["predicates", "fastmap", "nopropertymap", "mrl", "dedupmultipart", "blockstatecache"].stream()
+        .map({s -> archivesBaseName+"."+s+".mixin.json"})
+        .collect(Collectors.toList())
+
+loom {
+    mixinConfigs = fcMixinConfigs
+}

+ 29 - 0
fabric/src/main/resources/fabric.mod.json

@@ -0,0 +1,29 @@
+{
+  "schemaVersion": 1,
+  "id": "ferritecore",
+  "version": "${version}",
+  "name": "FerriteCore",
+  "description": "Reduces memory usage",
+  "authors": [
+    "malte0811"
+  ],
+  "license": "MIT",
+  "environment": "*",
+  "entrypoints": {
+    "main": [
+    ]
+  },
+  "depends": {
+    "fabricloader": ">=0.7.4",
+    "fabric": "*",
+    "minecraft": ">=1.16.4"
+  },
+  "mixins": [
+    "ferritecore.blockstatecache.mixin.json",
+    "ferritecore.dedupmultipart.mixin.json",
+    "ferritecore.fastmap.mixin.json",
+    "ferritecore.mrl.mixin.json",
+    "ferritecore.nopropertymap.mixin.json",
+    "ferritecore.predicates.mixin.json"
+  ]
+}

+ 52 - 0
forge/build.gradle

@@ -0,0 +1,52 @@
+plugins {
+    id "com.github.johnrengelman.shadow" version "5.0.0"
+}
+
+configurations {
+    shadow
+}
+
+architectury {
+    platformSetupLoomIde()
+}
+
+loom {
+     useFabricMixin = true
+}
+
+dependencies {
+    minecraft("com.mojang:minecraft:${rootProject.minecraft_version}")
+    mappings(minecraft.officialMojangMappings())
+    forge("net.minecraftforge:forge:${rootProject.minecraft_version}-${rootProject.forge_version}")
+
+    compileOnly(project(path: ":common")) {
+        transitive = false
+    }
+    runtimeOnly(project(path: ":common", configuration: "transformDevelopmentForge")) {
+        transitive = false
+    }
+    shadow(project(path: ":common", configuration: "transformProductionForge")) {
+        transitive = false
+    }
+}
+
+processResources {
+    inputs.property "version", project.version
+
+    filesMatching("META-INF/mods.toml") {
+        expand "version": project.version
+    }
+}
+
+shadowJar {
+    exclude "fabric.mod.json"
+
+    configurations = [project.configurations.shadow]
+    classifier "shadow"
+}
+
+remapJar {
+    dependsOn(shadowJar)
+    input.set(shadowJar.archivePath)
+    classifier "forge"
+}

+ 1 - 0
forge/gradle.properties

@@ -0,0 +1 @@
+loom.forge=true

+ 1 - 2
src/main/java/malte0811/ferritecore/ModMain.java → forge/src/main/java/malte0811/ferritecore/ModMainForge.java

@@ -4,6 +4,5 @@ import net.minecraftforge.fml.common.Mod;
 
 @Mod(ModMain.MODID)
 @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
-public class ModMain {
-    public static final String MODID = "ferritecore";
+public class ModMainForge {
 }

+ 24 - 0
forge/src/main/resources/META-INF/mods.toml

@@ -0,0 +1,24 @@
+modLoader="javafml"
+loaderVersion="[28,)"
+
+license="MIT"
+[[mods]]
+modId="ferritecore"
+version="${file.jarVersion}"
+displayName="Ferrite Core"
+authors="malte0811"
+description='''
+Reduces memory usage. These changes will probably be PRd to Forge soon.
+'''
+[[dependencies.ferritecore]]
+    modId="forge"
+    mandatory=true
+    versionRange="[35.1.0,)"
+    ordering="NONE"
+    side="BOTH"
+[[dependencies.ferritecore]]
+    modId="minecraft"
+    mandatory=true
+    versionRange="[1.16.4,)"
+    ordering="NONE"
+    side="BOTH"

+ 6 - 0
forge/src/main/resources/pack.mcmeta

@@ -0,0 +1,6 @@
+{
+    "pack": {
+        "description": "ferritecore resources",
+        "pack_format": 4
+    }
+}

+ 14 - 10
gradle.properties

@@ -1,10 +1,14 @@
-# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
-# This is required to provide enough memory for the Minecraft decompilation process.
-org.gradle.jvmargs=-Xmx3G
-org.gradle.daemon=false
-mod_version=1.2
-modid=ferritecore
-mc_version=1.16.5
-forge_version=36.0.0
-mapping=20201028
-mcp_version=1.16.3
+org.gradle.jvmargs=-Xmx2048M
+
+minecraft_version=1.16.5
+
+archives_base_name=ferritecore
+mod_version=2.0
+maven_group=malte0811.ferritecore
+
+architectury_version=1.5.101
+
+fabric_loader_version=0.11.1
+fabric_api_version=0.29.3+1.16
+
+forge_version=36.0.1

BIN
gradle/wrapper/gradle-wrapper.jar


+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip

+ 33 - 20
gradlew

@@ -1,5 +1,21 @@
 #!/usr/bin/env sh
 
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
 ##############################################################################
 ##
 ##  Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
 APP_BASE_NAME=`basename "$0"`
 
 # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
 
 # Use the maximum available, or set MAX_FD != -1 to use that value.
 MAX_FD="maximum"
@@ -66,6 +82,7 @@ esac
 
 CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
 
+
 # Determine the Java command to use to start the JVM.
 if [ -n "$JAVA_HOME" ] ; then
     if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
     GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
 fi
 
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
     APP_HOME=`cygpath --path --mixed "$APP_HOME"`
     CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
     JAVACMD=`cygpath --unix "$JAVACMD"`
 
     # We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
         else
             eval `echo args$i`="\"$arg\""
         fi
-        i=$((i+1))
+        i=`expr $i + 1`
     done
     case $i in
-        (0) set -- ;;
-        (1) set -- "$args0" ;;
-        (2) set -- "$args0" "$args1" ;;
-        (3) set -- "$args0" "$args1" "$args2" ;;
-        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
-        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
-        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
-        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
-        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
-        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+        0) set -- ;;
+        1) set -- "$args0" ;;
+        2) set -- "$args0" "$args1" ;;
+        3) set -- "$args0" "$args1" "$args2" ;;
+        4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
     esac
 fi
 
@@ -159,14 +177,9 @@ save () {
     for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
     echo " "
 }
-APP_ARGS=$(save "$@")
+APP_ARGS=`save "$@"`
 
 # Collect all arguments for the java command, following the shell quoting and substitution rules
 eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
 
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
-  cd "$(dirname "$0")"
-fi
-
 exec "$JAVACMD" "$@"

+ 24 - 19
gradlew.bat

@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem      https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
 @if "%DEBUG%" == "" @echo off
 @rem ##########################################################################
 @rem
@@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
 set APP_BASE_NAME=%~n0
 set APP_HOME=%DIRNAME%
 
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
 @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
 
 @rem Find java.exe
 if defined JAVA_HOME goto findJavaFromJavaHome
 
 set JAVA_EXE=java.exe
 %JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if "%ERRORLEVEL%" == "0" goto execute
 
 echo.
 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -35,7 +54,7 @@ goto fail
 set JAVA_HOME=%JAVA_HOME:"=%
 set JAVA_EXE=%JAVA_HOME%/bin/java.exe
 
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
 
 echo.
 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -45,28 +64,14 @@ echo location of your Java installation.
 
 goto fail
 
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
 :execute
 @rem Setup the command line
 
 set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
 
+
 @rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
 
 :end
 @rem End local scope for the variables with windows NT shell

+ 15 - 0
settings.gradle

@@ -0,0 +1,15 @@
+pluginManagement {
+    repositories {
+        jcenter()
+        maven { url "https://maven.fabricmc.net/" }
+        maven { url "https://dl.bintray.com/shedaniel/cloth" }
+        maven { url "https://files.minecraftforge.net/maven/" }
+        gradlePluginPortal()
+    }
+}
+
+include("common")
+include("fabric")
+include("forge")
+
+rootProject.name = "ferritecore"

+ 0 - 48
src/main/java/malte0811/ferritecore/hash/VoxelShapeHash.java

@@ -1,48 +0,0 @@
-package malte0811.ferritecore.hash;
-
-import it.unimi.dsi.fastutil.Hash;
-import malte0811.ferritecore.mixin.blockstatecache.VoxelShapeAccess;
-import net.minecraft.util.math.shapes.SplitVoxelShape;
-import net.minecraft.util.math.shapes.VoxelShape;
-import net.minecraft.util.math.shapes.VoxelShapeArray;
-import net.minecraft.util.math.shapes.VoxelShapeCube;
-
-public class VoxelShapeHash implements Hash.Strategy<VoxelShape> {
-    public static final VoxelShapeHash INSTANCE = new VoxelShapeHash();
-
-    @Override
-    public int hashCode(VoxelShape o) {
-        if (o instanceof SplitVoxelShape) {
-            return VoxelShapeSplitHash.INSTANCE.hashCode((SplitVoxelShape) o);
-        } else if (o instanceof VoxelShapeArray) {
-            return VoxelShapeArrayHash.INSTANCE.hashCode((VoxelShapeArray) o);
-        } else if (o instanceof VoxelShapeCube) {
-            return VoxelShapePartHash.INSTANCE.hashCode(((VoxelShapeAccess) o).getPart());
-        } else {
-            //TODO VSCube?
-            return o.hashCode();
-        }
-    }
-
-    @Override
-    public boolean equals(VoxelShape a, VoxelShape b) {
-        if (a == b) {
-            return true;
-        } else if (a == null || b == null) {
-            return false;
-        } else if (a.getClass() != b.getClass()) {
-            return false;
-        } else if (a instanceof SplitVoxelShape) {
-            return VoxelShapeSplitHash.INSTANCE.equals((SplitVoxelShape) a, (SplitVoxelShape) b);
-        } else if (a instanceof VoxelShapeArray) {
-            return VoxelShapeArrayHash.INSTANCE.equals((VoxelShapeArray) a, (VoxelShapeArray) b);
-        } else if (a instanceof VoxelShapeCube) {
-            return VoxelShapePartHash.INSTANCE.equals(
-                    ((VoxelShapeAccess) a).getPart(),
-                    ((VoxelShapeAccess) b).getPart()
-            );
-        } else {
-            return a.equals(b);
-        }
-    }
-}

+ 0 - 84
src/main/java/malte0811/ferritecore/hash/VoxelShapePartHash.java

@@ -1,84 +0,0 @@
-package malte0811.ferritecore.hash;
-
-import it.unimi.dsi.fastutil.Hash;
-import malte0811.ferritecore.mixin.blockstatecache.VSPBitSetAccess;
-import malte0811.ferritecore.mixin.blockstatecache.VSPSplitAccess;
-import net.minecraft.util.math.shapes.BitSetVoxelShapePart;
-import net.minecraft.util.math.shapes.PartSplitVoxelShape;
-import net.minecraft.util.math.shapes.VoxelShapePart;
-
-import java.util.Objects;
-
-public class VoxelShapePartHash implements Hash.Strategy<VoxelShapePart> {
-    public static final VoxelShapePartHash INSTANCE = new VoxelShapePartHash();
-
-    @Override
-    public int hashCode(VoxelShapePart o) {
-        if (o instanceof PartSplitVoxelShape) {
-            VSPSplitAccess access = access((PartSplitVoxelShape) o);
-            int result = access.getStartX();
-            result = 31 * result + access.getStartY();
-            result = 31 * result + access.getStartZ();
-            result = 31 * result + access.getEndX();
-            result = 31 * result + access.getEndY();
-            result = 31 * result + access.getEndZ();
-            result = 31 * result + hashCode(access.getPart());
-            return result;
-        } else if (o instanceof BitSetVoxelShapePart) {
-            VSPBitSetAccess access = access((BitSetVoxelShapePart) o);
-            int result = access.getStartX();
-            result = 31 * result + access.getStartY();
-            result = 31 * result + access.getStartZ();
-            result = 31 * result + access.getEndX();
-            result = 31 * result + access.getEndY();
-            result = 31 * result + access.getEndZ();
-            result = 31 * result + Objects.hashCode(access.getBitSet());
-            return result;
-        } else {
-            return Objects.hashCode(o);
-        }
-    }
-
-    @Override
-    public boolean equals(VoxelShapePart a, VoxelShapePart b) {
-        if (a == b) {
-            return true;
-        } else if (a == null || b == null) {
-            return false;
-        } else if (a.getClass() != b.getClass()) {
-            return false;
-        } else if (a instanceof PartSplitVoxelShape) {
-            VSPSplitAccess accessA = access((PartSplitVoxelShape) a);
-            VSPSplitAccess accessB = access((PartSplitVoxelShape) b);
-            return accessA.getEndX() == accessB.getEndX() &&
-                    accessA.getEndY() == accessB.getEndY() &&
-                    accessA.getEndZ() == accessB.getEndZ() &&
-                    accessA.getStartX() == accessB.getStartX() &&
-                    accessA.getStartY() == accessB.getStartY() &&
-                    accessA.getStartZ() == accessB.getStartZ() &&
-                    equals(accessA.getPart(), accessB.getPart());
-        } else if (a instanceof BitSetVoxelShapePart) {
-            VSPBitSetAccess accessA = access((BitSetVoxelShapePart) a);
-            VSPBitSetAccess accessB = access((BitSetVoxelShapePart) b);
-            return accessA.getEndX() == accessB.getEndX() &&
-                    accessA.getEndY() == accessB.getEndY() &&
-                    accessA.getEndZ() == accessB.getEndZ() &&
-                    accessA.getStartX() == accessB.getStartX() &&
-                    accessA.getStartY() == accessB.getStartY() &&
-                    accessA.getStartZ() == accessB.getStartZ() &&
-                    accessA.getBitSet().equals(accessB.getBitSet());
-        } else {
-            return a.equals(b);
-        }
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    private static VSPSplitAccess access(PartSplitVoxelShape part) {
-        return (VSPSplitAccess) (Object) part;
-    }
-
-    @SuppressWarnings("ConstantConditions")
-    private static VSPBitSetAccess access(BitSetVoxelShapePart part) {
-        return (VSPBitSetAccess) (Object) part;
-    }
-}

+ 0 - 41
src/main/java/malte0811/ferritecore/mixin/blockstatecache/BlockStateCacheMixin.java

@@ -1,41 +0,0 @@
-package malte0811.ferritecore.mixin.blockstatecache;
-
-import malte0811.ferritecore.impl.BlockStateCacheImpl;
-import net.minecraft.block.Block;
-import net.minecraft.block.BlockState;
-import net.minecraft.util.Direction;
-import net.minecraft.util.math.BlockPos;
-import net.minecraft.util.math.shapes.ISelectionContext;
-import net.minecraft.util.math.shapes.VoxelShape;
-import net.minecraft.world.IBlockReader;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Redirect;
-
-@Mixin(targets = "net.minecraft.block.AbstractBlock$AbstractBlockState$Cache")
-public class BlockStateCacheMixin {
-    @Redirect(
-            method = "<init>(Lnet/minecraft/block/BlockState;)V",
-            at = @At(
-                    value = "INVOKE",
-                    target = "Lnet/minecraft/util/math/shapes/VoxelShapes;getFaceShape(Lnet/minecraft/util/math/shapes/VoxelShape;Lnet/minecraft/util/Direction;)Lnet/minecraft/util/math/shapes/VoxelShape;"
-            )
-    )
-    private VoxelShape redirectFaceShape(VoxelShape shape, Direction face) {
-        return BlockStateCacheImpl.redirectFaceShape(shape, face);
-    }
-
-    @Redirect(
-            method = "<init>(Lnet/minecraft/block/BlockState;)V",
-            at = @At(
-                    value = "INVOKE",
-                    args = "debug = true",
-                    target = "Lnet/minecraft/block/Block;getCollisionShape(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/IBlockReader;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/shapes/ISelectionContext;)Lnet/minecraft/util/math/shapes/VoxelShape;"
-            )
-    )
-    private VoxelShape redirectGetCollisionShape(
-            Block block, BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context
-    ) {
-        return BlockStateCacheImpl.redirectGetCollisionShape(block, state, worldIn, pos, context);
-    }
-}