@@ -5,9 +5,12 @@ import com.google.common.util.concurrent.MoreExecutors;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.IRegistryCustom;
|
||||
import net.minecraft.server.DispenserRegistry;
|
||||
import net.minecraft.server.packs.EnumResourcePackType;
|
||||
import net.minecraft.server.packs.ResourcePackVanilla;
|
||||
import net.minecraft.server.packs.repository.ResourcePackSourceVanilla;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.tags.TagRegistry;
|
||||
import net.minecraft.util.Unit;
|
||||
@@ -33,14 +36,15 @@ public abstract class AbstractTestingBase {
|
||||
public static final TagRegistry TAG_REGISTRY;
|
||||
|
||||
static {
|
||||
SharedConstants.a();
|
||||
DispenserRegistry.init();
|
||||
// Set up resource manager
|
||||
ResourceManager resourceManager = new ResourceManager(EnumResourcePackType.SERVER_DATA);
|
||||
// add tags and loot tables for unit tests
|
||||
resourceManager.a(TAG_REGISTRY = new TagRegistry());
|
||||
resourceManager.a(TAG_REGISTRY = new TagRegistry(IRegistryCustom.a()));
|
||||
resourceManager.a(LOOT_TABLE_REGISTRY = new LootTableRegistry(new LootPredicateManager()));
|
||||
// Register vanilla pack
|
||||
resourceManager.a(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla("minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join();
|
||||
resourceManager.a(MoreExecutors.directExecutor(), MoreExecutors.directExecutor(), Collections.singletonList(new ResourcePackVanilla(ResourcePackSourceVanilla.BUILT_IN_METADATA, "minecraft")), CompletableFuture.completedFuture(Unit.INSTANCE)).join();
|
||||
// Bind tags
|
||||
TAG_REGISTRY.a().bind();
|
||||
|
||||
@@ -54,6 +58,6 @@ public abstract class AbstractTestingBase {
|
||||
}
|
||||
}
|
||||
INVALIDATED_MATERIALS = builder.build();
|
||||
Assert.assertEquals("Expected 564 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 564, INVALIDATED_MATERIALS.size());
|
||||
Assert.assertEquals("Expected 590 invalidated materials (got " + INVALIDATED_MATERIALS.size() + ")", 590, INVALIDATED_MATERIALS.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.minecraft.world.item.enchantment.Enchantments;
|
||||
|
||||
public class DummyEnchantments {
|
||||
static {
|
||||
Enchantments.DAMAGE_ALL.getClass();
|
||||
Enchantments.SHARPNESS.getClass();
|
||||
org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.bukkit.support;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class Util {
|
||||
/*
|
||||
public static <T> T getInternalState(Object object, String fieldName) {
|
||||
return getInternalState(object.getClass(), object, fieldName);
|
||||
}
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getInternalState(Class<?> clazz, Object object, String fieldName) {
|
||||
Field field;
|
||||
try {
|
||||
field = clazz.getDeclaredField(fieldName);
|
||||
} catch (SecurityException e) {
|
||||
throw new RuntimeException("Not allowed to access " + clazz, e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException("Unable to find field " + fieldName, e);
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
return (T) field.get(object);
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
throw new RuntimeException("Unable to get internal value");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user