9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-21 16:09:26 +00:00

移除ignite mod相关代码

This commit is contained in:
XiaoMoMi
2025-06-02 20:12:08 +08:00
parent 9344f6d188
commit 1e5d655205
5 changed files with 22 additions and 94 deletions

View File

@@ -31,7 +31,6 @@ import net.momirealms.craftengine.core.pack.LoadingSequence;
import net.momirealms.craftengine.core.pack.Pack;
import net.momirealms.craftengine.core.pack.ResourceLocation;
import net.momirealms.craftengine.core.pack.model.generation.ModelGeneration;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.config.Config;
import net.momirealms.craftengine.core.plugin.config.ConfigParser;
import net.momirealms.craftengine.core.plugin.context.event.EventFunctions;
@@ -93,11 +92,9 @@ public class BukkitBlockManager extends AbstractBlockManager {
this.blockParser = new BlockParser();
this.initVanillaRegistry();
this.loadMappingsAndAdditionalBlocks();
if (!plugin.requiresRestart()) {
this.registerBlocks();
this.registerEmptyBlock();
}
}
@Override
public void init() {
@@ -276,19 +273,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
}
private void initVanillaRegistry() {
int vanillaStateCount;
if (this.plugin.hasMod()) {
try {
Class<?> modClass = ReflectionUtils.getClazz(CraftEngine.MOD_CLASS);
Field amountField = ReflectionUtils.getDeclaredField(modClass, "vanillaRegistrySize");
vanillaStateCount = amountField.getInt(null);
} catch (Exception e) {
vanillaStateCount = RegistryUtils.currentBlockRegistrySize();
this.plugin.logger().severe("Fatal error", e);
}
} else {
vanillaStateCount = RegistryUtils.currentBlockRegistrySize();
}
int vanillaStateCount = RegistryUtils.currentBlockRegistrySize();
this.plugin.logger().info("Vanilla block count: " + vanillaStateCount);
BlockStateUtils.init(vanillaStateCount);
}
@@ -350,7 +335,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
}
public class BlockParser implements ConfigParser {
public static final String[] CONFIG_SECTION_NAME = new String[] {"blocks", "block"};
public static final String[] CONFIG_SECTION_NAME = new String[]{"blocks", "block"};
@Override
public String[] sectionId() {
@@ -512,10 +497,13 @@ public class BukkitBlockManager extends AbstractBlockManager {
throw new LocalizedResourceConfigException("warning.config.block.state.model.invalid_path", modelPath);
}
json.addProperty("model", modelPath);
if (singleModelMap.containsKey("x")) json.addProperty("x", ResourceConfigUtils.getAsInt(singleModelMap.get("x"), "x"));
if (singleModelMap.containsKey("y")) json.addProperty("y", ResourceConfigUtils.getAsInt(singleModelMap.get("y"), "y"));
if (singleModelMap.containsKey("x"))
json.addProperty("x", ResourceConfigUtils.getAsInt(singleModelMap.get("x"), "x"));
if (singleModelMap.containsKey("y"))
json.addProperty("y", ResourceConfigUtils.getAsInt(singleModelMap.get("y"), "y"));
if (singleModelMap.containsKey("uvlock")) json.addProperty("uvlock", (boolean) singleModelMap.get("uvlock"));
if (singleModelMap.containsKey("weight")) json.addProperty("weight", ResourceConfigUtils.getAsInt(singleModelMap.get("weight"), "weight"));
if (singleModelMap.containsKey("weight"))
json.addProperty("weight", ResourceConfigUtils.getAsInt(singleModelMap.get("weight"), "weight"));
Map<String, Object> generationMap = MiscUtils.castToMap(singleModelMap.get("generation"), true);
if (generationMap != null) {
prepareModelGeneration(ModelGeneration.of(Key.of(modelPath), generationMap));
@@ -723,14 +711,6 @@ public class BukkitBlockManager extends AbstractBlockManager {
Object blockHolder;
Object resourceLocation = createResourceLocation(realBlockKey);
if (this.plugin.hasMod()) {
newRealBlock = CoreReflections.method$Registry$get.invoke(MBuiltInRegistries.BLOCK, resourceLocation);
newBlockState = getOnlyBlockState(newRealBlock);
@SuppressWarnings("unchecked")
Optional<Object> optionalHolder = (Optional<Object>) CoreReflections.method$Registry$getHolder1.invoke(MBuiltInRegistries.BLOCK, CoreReflections.method$ResourceKey$create.invoke(null, MRegistries.instance$Registries$BLOCK, resourceLocation));
blockHolder = optionalHolder.get();
} else {
try {
newRealBlock = BlockGenerator.generateBlock(clientSideBlockType, clientSideBlock, blockProperties);
} catch (Throwable throwable) {
@@ -744,7 +724,6 @@ public class BukkitBlockManager extends AbstractBlockManager {
newBlockState = getOnlyBlockState(newRealBlock);
CoreReflections.method$IdMapper$add.invoke(CoreReflections.instance$Block$BLOCK_STATE_REGISTRY, newBlockState);
}
if (isNoteBlock) {
BlockStateUtils.CLIENT_SIDE_NOTE_BLOCKS.put(newBlockState, new Object());

View File

@@ -53,7 +53,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.jspecify.annotations.Nullable;
import java.io.*;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Path;
@@ -68,8 +67,6 @@ public class BukkitCraftEngine extends CraftEngine {
private SchedulerTask tickTask;
private boolean successfullyLoaded = false;
private boolean successfullyEnabled = false;
private boolean requiresRestart = false;
private boolean hasMod = false;
private AntiGriefLib antiGrief;
private JavaPlugin javaPlugin;
private final Path dataFolderPath;
@@ -90,16 +87,6 @@ public class BukkitCraftEngine extends CraftEngine {
super.logger = logger;
super.platform = new BukkitPlatform();
super.scheduler = new BukkitSchedulerAdapter(this);
// find mod class if present
Class<?> modClass = ReflectionUtils.getClazz(MOD_CLASS);
if (modClass != null) {
Field isSuccessfullyRegistered = ReflectionUtils.getDeclaredField(modClass, "isSuccessfullyRegistered");
try {
requiresRestart = !(boolean) isSuccessfullyRegistered.get(null);
hasMod = true;
} catch (Exception ignore) {
}
}
Class<?> compatibilityClass = Objects.requireNonNull(ReflectionUtils.getClazz(COMPATIBILITY_CLASS), "Compatibility class not found");
try {
super.compatibilityManager = (CompatibilityManager) Objects.requireNonNull(ReflectionUtils.getConstructor(compatibilityClass, 0)).newInstance(this);
@@ -132,7 +119,6 @@ public class BukkitCraftEngine extends CraftEngine {
if (super.blockManager == null) {
injectRegistries();
}
if (this.requiresRestart) return;
try {
WorldStorageInjector.init();
} catch (Exception e) {
@@ -177,17 +163,6 @@ public class BukkitCraftEngine extends CraftEngine {
return;
}
this.successfullyEnabled = true;
if (this.requiresRestart) {
logger().warn(" ");
logger().warn(" ");
logger().warn(" ");
logger().warn("This is the first time you have installed CraftEngine. A restart is required to apply the changes.");
logger().warn(" ");
logger().warn(" ");
logger().warn(" ");
Bukkit.getServer().shutdown();
return;
}
if (!this.successfullyLoaded) {
logger().severe(" ");
logger().severe(" ");
@@ -390,14 +365,6 @@ public class BukkitCraftEngine extends CraftEngine {
);
}
public boolean hasMod() {
return hasMod;
}
public boolean requiresRestart() {
return requiresRestart;
}
public AntiGriefLib antiGrief() {
if (this.antiGrief == null) {
this.antiGrief = AntiGriefLib.builder(this.javaPlugin)

View File

@@ -2,11 +2,8 @@ package net.momirealms.craftengine.bukkit.util;
import net.momirealms.craftengine.core.util.ReflectionUtils;
import net.momirealms.craftengine.core.util.VersionHelper;
import org.bukkit.Bukkit;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
public final class BukkitReflectionUtils {

View File

@@ -43,7 +43,6 @@ import java.util.function.Consumer;
import java.util.function.Supplier;
public abstract class CraftEngine implements Plugin {
public static final String MOD_CLASS = "net.momirealms.craftengine.mod.CraftEnginePlugin";
private static CraftEngine instance;
protected PluginLogger logger;
protected Consumer<Supplier<String>> debugger = (s) -> {};

View File

@@ -22,7 +22,6 @@ import net.momirealms.craftengine.core.plugin.logger.filter.DisconnectLogFilter;
import net.momirealms.craftengine.core.util.AdventureHelper;
import net.momirealms.craftengine.core.util.Key;
import net.momirealms.craftengine.core.util.MiscUtils;
import net.momirealms.craftengine.core.util.ReflectionUtils;
import net.momirealms.craftengine.core.world.InjectionTarget;
import net.momirealms.craftengine.core.world.chunk.storage.CompressionMethod;
@@ -30,8 +29,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
@@ -341,17 +338,6 @@ public class Config {
emoji$book = config.getBoolean("emoji.book", true);
emoji$sign = config.getBoolean("emoji.sign", true);
Class<?> modClazz = ReflectionUtils.getClazz(CraftEngine.MOD_CLASS);
if (modClazz != null) {
Method setMaxChainMethod = ReflectionUtils.getStaticMethod(modClazz, void.class, new String[] {"setMaxChainUpdate"}, int.class);
try {
assert setMaxChainMethod != null;
setMaxChainMethod.invoke(null, performance$max_block_chain_update_limit);
} catch (IllegalAccessException | InvocationTargetException e) {
plugin.logger().warn("Failed to set max chain update", e);
}
}
firstTime = false;
}