Further work on 1.13.2 WorldEdit for Forge. Forge still is missing too many features to finish this, and I need to work out how to port the command wrapper system over.

Dieser Commit ist enthalten in:
Matthew Miller 2019-02-16 16:13:03 +10:00
Ursprung cf435fd63d
Commit de9798bf7e
3 geänderte Dateien mit 29 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -1,3 +1,4 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties. # 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. # This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

Datei anzeigen

@ -22,9 +22,7 @@ package com.sk89q.worldedit.forge;
import net.minecraft.command.ICommand; import net.minecraft.command.ICommand;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.GameType; import net.minecraft.world.GameType;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.server.ServerLifecycleHooks; import net.minecraftforge.fml.server.ServerLifecycleHooks;
import org.spongepowered.api.entity.living.player.Player;
public interface ForgePermissionsProvider { public interface ForgePermissionsProvider {
@ -52,16 +50,17 @@ public interface ForgePermissionsProvider {
public void registerPermission(ICommand command, String permission) {} public void registerPermission(ICommand command, String permission) {}
} }
class SpongePermissionsProvider implements ForgePermissionsProvider { // TODO Re-add when Sponge for 1.13 is out
// class SpongePermissionsProvider implements ForgePermissionsProvider {
@Override //
public boolean hasPermission(EntityPlayerMP player, String permission) { // @Override
return ((Player) player).hasPermission(permission); // public boolean hasPermission(EntityPlayerMP player, String permission) {
} // return ((Player) player).hasPermission(permission);
// }
@Override //
public void registerPermission(ICommand command, String permission) { // @Override
// public void registerPermission(ICommand command, String permission) {
} //
} // }
// }
} }

Datei anzeigen

@ -46,13 +46,11 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.event.server.FMLServerStartedEvent;
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent; import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
import net.minecraftforge.fml.common.event.FMLServerStartedEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.ForgeRegistries;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -82,33 +80,27 @@ public class ForgeWorldEdit {
public ForgeWorldEdit() { public ForgeWorldEdit() {
inst = this; inst = this;
FMLModLoadingContext.get().getModEventBus().addListener(this::preInit); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::init);
FMLModLoadingContext.get().getModEventBus().addListener(this::init); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::serverAboutToStart);
FMLModLoadingContext.get().getModEventBus().addListener(this::postInit); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::serverStopping);
FMLModLoadingContext.get().getModEventBus().addListener(this::serverAboutToStart); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::serverStarted);
FMLModLoadingContext.get().getModEventBus().addListener(this::serverStopping);
FMLModLoadingContext.get().getModEventBus().addListener(this::serverStarted);
MinecraftForge.EVENT_BUS.register(ThreadSafeCache.getInstance()); MinecraftForge.EVENT_BUS.register(ThreadSafeCache.getInstance());
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
public void preInit(FMLPreInitializationEvent event) { public void init(FMLCommonSetupEvent event) {
// Setup working directory // Setup working directory
workingDir = new File(event.getModConfigurationDirectory() + File.separator + "worldedit"); workingDir = new File(event.getModConfigurationDirectory() + File.separator + "worldedit");
workingDir.mkdir(); workingDir.mkdir();
config = new ForgeConfiguration(this); config = new ForgeConfiguration(this);
config.load(); config.load();
}
public void init(FMLInitializationEvent event) {
WECUIPacketHandler.init(); WECUIPacketHandler.init();
InternalPacketHandler.init(); InternalPacketHandler.init();
proxy.registerHandlers(); proxy.registerHandlers();
}
public void postInit(FMLPostInitializationEvent event) {
LOGGER.info("WorldEdit for Forge (version " + getInternalVersion() + ") is loaded"); LOGGER.info("WorldEdit for Forge (version " + getInternalVersion() + ") is loaded");
} }
@ -122,11 +114,11 @@ public class ForgeWorldEdit {
WorldEdit.getInstance().getPlatformManager().register(platform); WorldEdit.getInstance().getPlatformManager().register(platform);
if (ModList.get().isLoaded("sponge")) { // TODO if (ModList.get().isLoaded("sponge")) {
this.provider = new ForgePermissionsProvider.SpongePermissionsProvider(); // this.provider = new ForgePermissionsProvider.SpongePermissionsProvider();
} else { // } else {
this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform); this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform);
} // }
// TODO Setup states // TODO Setup states
for (ResourceLocation name : ForgeRegistries.BLOCKS.getKeys()) { for (ResourceLocation name : ForgeRegistries.BLOCKS.getKeys()) {