ソースを参照

Remove assertion preventing re-initialization of neighbor table, see Virtuoel/Statement#5
Fix unit test

malte0811 4 年 前
コミット
8a2feef55c

+ 3 - 1
common/src/main/java/malte0811/ferritecore/classloading/FastImmutableMapDefiner.java

@@ -20,6 +20,8 @@ import java.lang.reflect.Method;
  */
 public class FastImmutableMapDefiner {
     private static final Logger LOGGER = LogManager.getLogger("FerriteCore - class definer");
+    public static String GOOGLE_ACCESS_PREFIX = "/googleaccess/";
+
     private static final LazyValue<Definer> DEFINE_CLASS = new LazyValue<>(() -> {
         try {
             // Try to create a Java 9+ style class definer
@@ -79,7 +81,7 @@ public class FastImmutableMapDefiner {
 
     private static void defineInAppClassloader(String name) throws Exception {
         InputStream byteInput = FastImmutableMapDefiner.class.getResourceAsStream(
-                "/googleaccess/" + name.replace('.', '/') + ".class"
+                GOOGLE_ACCESS_PREFIX + name.replace('.', '/') + ".class"
         );
         byte[] classBytes = new byte[byteInput.available()];
         final int bytesRead = byteInput.read(classBytes);

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

@@ -19,9 +19,7 @@ public class StateHolderImpl {
      */
     public static <S>
     void populateNeighbors(Map<Map<Property<?>, Comparable<?>>, S> states, FastMapStateHolder<S> holder) {
-        if (holder.getStateMap() != null) {
-            throw new IllegalStateException();
-        } else if (states == LAST_STATE_MAP.get()) {
+        if (states == LAST_STATE_MAP.get()) {
             // Use threadlocal state to use the same fast map for all states of one block
             holder.setStateMap((FastMap<S>) LAST_FAST_STATE_MAP.get());
         } else {

+ 6 - 4
common/src/test/java/malte0811/ferritecore/fastmap/FastMapTest.java

@@ -10,10 +10,7 @@ import malte0811.ferritecore.classloading.FastImmutableMapDefiner;
 import malte0811.ferritecore.ducks.FastMapStateHolder;
 import net.minecraft.state.*;
 import net.minecraft.util.Direction;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.DynamicTest;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.TestFactory;
+import org.junit.jupiter.api.*;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -29,6 +26,11 @@ public class FastMapTest {
     private static final EnumProperty<Direction> DIR = DirectionProperty.create("C", Direction.class);
     private static final BooleanList BOOLS = new BooleanArrayList(new boolean[]{false, true});
 
+    @BeforeAll
+    public static void init() {
+        FastImmutableMapDefiner.GOOGLE_ACCESS_PREFIX = "/";
+    }
+
     @TestFactory
     public Stream<DynamicTest> basicMapping() {
         return forEachType(TestData::testBasic);