3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 04:20:06 +01:00

Further work on Forge 1.13 compat.

Dieser Commit ist enthalten in:
Matthew Miller 2018-12-15 22:13:13 +10:00
Ursprung 11cf5377d9
Commit 7a08098b03
12 geänderte Dateien mit 89 neuen und 74 gelöschten Zeilen

Datei anzeigen

@ -2,7 +2,7 @@ buildscript {
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven { url = "http://files.minecraftforge.net/maven" } maven { url = "https://files.minecraftforge.net/maven" }
jcenter() jcenter()
} }
@ -14,7 +14,7 @@ buildscript {
apply plugin: 'net.minecraftforge.gradle' apply plugin: 'net.minecraftforge.gradle'
def minecraftVersion = "1.13" def minecraftVersion = "1.13"
def forgeVersion = "24.0.16-1.13-pre" def forgeVersion = "24.0.32-1.13-pre"
dependencies { dependencies {
compile project(':worldedit-core') compile project(':worldedit-core')
@ -28,26 +28,28 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
minecraft { minecraft {
mappings channel: 'snapshot', version: '20181215' mappings channel: 'snapshot', version: '20180921-1.13'
// runDir = 'run'
// replaceIn "com/sk89q/worldedit/forge/ForgeWorldEdit.java"
// replace "%VERSION%", project.version
} }
project.archivesBaseName = "${project.archivesBaseName}-mc${minecraftVersion}" project.archivesBaseName = "${project.archivesBaseName}-mc${minecraftVersion}"
processResources { processResources {
from (sourceSets.main.resources.srcDirs) { // this will ensure that this task is redone when the versions change.
expand 'version': project.version, inputs.property 'version', project.version
'mcVersion': minecraftVersion, inputs.property 'mcversion', minecraftVersion
'forgeVersion': forgeVersion, inputs.property 'internalVersion', internalVersion
'internalVersion': project.internalVersion
include 'mcmod.info' // replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'META_INF/mods.toml'
// replace version and mcversion
expand 'version':project.version, 'mcversion': minecraftVersion, 'internalVersion': internalVersion
} }
from (sourceSets.main.resources.srcDirs) { // copy everything else except the mcmod.info
exclude 'mcmod.info' from(sourceSets.main.resources.srcDirs) {
exclude 'META_INF/mods.toml'
} }
} }

Datei anzeigen

@ -63,12 +63,12 @@ public class ForgeBlockMaterial extends PassthroughBlockMaterial {
@Override @Override
public boolean isFragileWhenPushed() { public boolean isFragileWhenPushed() {
return delegate.getMobilityFlag() == EnumPushReaction.DESTROY; return delegate.getPushReaction() == EnumPushReaction.DESTROY;
} }
@Override @Override
public boolean isUnpushable() { public boolean isUnpushable() {
return delegate.getMobilityFlag() == EnumPushReaction.BLOCK; return delegate.getPushReaction() == EnumPushReaction.BLOCK;
} }
@Override @Override
@ -78,7 +78,7 @@ public class ForgeBlockMaterial extends PassthroughBlockMaterial {
@Override @Override
public boolean isBurnable() { public boolean isBurnable() {
return delegate.getCanBurn(); return delegate.isFlammable();
} }
@Override @Override

Datei anzeigen

@ -136,7 +136,7 @@ public class ForgeEntityProperties implements EntityProperties {
@Override @Override
public boolean isTagged() { public boolean isTagged() {
return entity instanceof EntityLiving && ((EntityLiving) entity).hasCustomName(); return entity.hasCustomName();
} }
@Override @Override

Datei anzeigen

@ -44,10 +44,10 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent; import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickEmpty; import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickEmpty;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
@ -56,7 +56,8 @@ import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.common.event.FMLServerStartedEvent; import net.minecraftforge.fml.common.event.FMLServerStartedEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent; import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result; import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.File; import java.io.File;
@ -64,16 +65,15 @@ import java.io.File;
/** /**
* The Forge implementation of WorldEdit. * The Forge implementation of WorldEdit.
*/ */
@Mod(modid = ForgeWorldEdit.MOD_ID, name = "WorldEdit", version = "%VERSION%", acceptableRemoteVersions = "*") @Mod(ForgeWorldEdit.MOD_ID)
public class ForgeWorldEdit { public class ForgeWorldEdit {
public static Logger logger; private static final Logger LOGGER = LogManager.getLogger();
public static final String MOD_ID = "worldedit"; public static final String MOD_ID = "worldedit";
public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui"; public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui";
private ForgePermissionsProvider provider; private ForgePermissionsProvider provider;
@Instance(MOD_ID)
public static ForgeWorldEdit inst; public static ForgeWorldEdit inst;
@SidedProxy(serverSide = "com.sk89q.worldedit.forge.CommonProxy", clientSide = "com.sk89q.worldedit.forge.ClientProxy") @SidedProxy(serverSide = "com.sk89q.worldedit.forge.CommonProxy", clientSide = "com.sk89q.worldedit.forge.ClientProxy")
@ -83,36 +83,42 @@ public class ForgeWorldEdit {
private ForgeConfiguration config; private ForgeConfiguration config;
private File workingDir; private File workingDir;
@EventHandler public ForgeWorldEdit() {
inst = this;
FMLModLoadingContext.get().getModEventBus().addListener(this::preInit);
FMLModLoadingContext.get().getModEventBus().addListener(this::init);
FMLModLoadingContext.get().getModEventBus().addListener(this::postInit);
FMLModLoadingContext.get().getModEventBus().addListener(this::serverAboutToStart);
FMLModLoadingContext.get().getModEventBus().addListener(this::serverStopping);
FMLModLoadingContext.get().getModEventBus().addListener(this::serverStarted);
MinecraftForge.EVENT_BUS.register(ThreadSafeCache.getInstance());
MinecraftForge.EVENT_BUS.register(this);
}
public void preInit(FMLPreInitializationEvent event) { public void preInit(FMLPreInitializationEvent event) {
logger = event.getModLog();
// 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();
MinecraftForge.EVENT_BUS.register(ThreadSafeCache.getInstance());
} }
@EventHandler
public void init(FMLInitializationEvent event) { public void init(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(this);
WECUIPacketHandler.init(); WECUIPacketHandler.init();
InternalPacketHandler.init(); InternalPacketHandler.init();
proxy.registerHandlers(); proxy.registerHandlers();
} }
@EventHandler
public void postInit(FMLPostInitializationEvent event) { public void postInit(FMLPostInitializationEvent event) {
logger.info("WorldEdit for Forge (version " + getInternalVersion() + ") is loaded"); LOGGER.info("WorldEdit for Forge (version " + getInternalVersion() + ") is loaded");
} }
@EventHandler
public void serverAboutToStart(FMLServerAboutToStartEvent event) { public void serverAboutToStart(FMLServerAboutToStartEvent event) {
if (this.platform != null) { if (this.platform != null) {
logger.warn("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't"); LOGGER.warn("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't");
WorldEdit.getInstance().getPlatformManager().unregister(platform); WorldEdit.getInstance().getPlatformManager().unregister(platform);
} }
@ -141,14 +147,12 @@ public class ForgeWorldEdit {
} }
} }
@EventHandler
public void serverStopping(FMLServerStoppingEvent event) { public void serverStopping(FMLServerStoppingEvent event) {
WorldEdit worldEdit = WorldEdit.getInstance(); WorldEdit worldEdit = WorldEdit.getInstance();
worldEdit.getSessionManager().unload(); worldEdit.getSessionManager().unload();
worldEdit.getPlatformManager().unregister(platform); worldEdit.getPlatformManager().unregister(platform);
} }
@EventHandler
public void serverStarted(FMLServerStartedEvent event) { public void serverStarted(FMLServerStartedEvent event) {
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
} }
@ -183,11 +187,11 @@ public class ForgeWorldEdit {
boolean isLeftDeny = event instanceof PlayerInteractEvent.LeftClickBlock boolean isLeftDeny = event instanceof PlayerInteractEvent.LeftClickBlock
&& ((PlayerInteractEvent.LeftClickBlock) event) && ((PlayerInteractEvent.LeftClickBlock) event)
.getUseItem() == Result.DENY; .getUseItem() == Event.Result.DENY;
boolean isRightDeny = boolean isRightDeny =
event instanceof PlayerInteractEvent.RightClickBlock event instanceof PlayerInteractEvent.RightClickBlock
&& ((PlayerInteractEvent.RightClickBlock) event) && ((PlayerInteractEvent.RightClickBlock) event)
.getUseItem() == Result.DENY; .getUseItem() == Event.Result.DENY;
if (isLeftDeny || isRightDeny || event.getEntity().world.isRemote) { if (isLeftDeny || isRightDeny || event.getEntity().world.isRemote) {
return; return;
} }
@ -233,7 +237,7 @@ public class ForgeWorldEdit {
if (item.getNbtData() != null) { if (item.getNbtData() != null) {
forgeCompound = NBTConverter.toNative(item.getNbtData()); forgeCompound = NBTConverter.toNative(item.getNbtData());
} }
return new ItemStack(Item.getByNameOrId(item.getType().getId()), item.getAmount(), 0, forgeCompound); return new ItemStack(Item.REGISTRY.get(new ResourceLocation(item.getType().getId())), item.getAmount(), 0, forgeCompound);
} }
/** /**

Datei anzeigen

@ -20,18 +20,19 @@
package com.sk89q.worldedit.forge; package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.forge.net.LeftClickAirEventMessage; import com.sk89q.worldedit.forge.net.LeftClickAirEventMessage;
import net.minecraftforge.fml.common.network.NetworkRegistry; import javafx.geometry.Side;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;
import java.nio.charset.Charset; import java.nio.charset.Charset;
public class InternalPacketHandler { public class InternalPacketHandler {
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8"); public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
public static SimpleNetworkWrapper CHANNEL; public static SimpleChannel CHANNEL;
public static void init() { public static void init() {
CHANNEL = NetworkRegistry.INSTANCE.newSimpleChannel(ForgeWorldEdit.MOD_ID); CHANNEL = NetworkRegistry.newSimpleChannel(new ResourceLocation(ForgeWorldEdit.MOD_ID, "worldedit"), () -> "1", check -> true, check -> true);
CHANNEL.registerMessage(LeftClickAirEventMessage.Handler.class, LeftClickAirEventMessage.class, 0, Side.SERVER); CHANNEL.registerMessage(LeftClickAirEventMessage.Handler.class, LeftClickAirEventMessage.class, 0, Side.SERVER);
} }

Datei anzeigen

@ -22,14 +22,14 @@ package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.forge.gui.GuiHandler; import com.sk89q.worldedit.forge.gui.GuiHandler;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding; import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
public class KeyHandler { public class KeyHandler {
private static Minecraft mc = Minecraft.getMinecraft(); private static Minecraft mc = Minecraft.getInstance();
private static KeyBinding mainKey = new KeyBinding("WorldEdit Reference", Keyboard.KEY_L, "WorldEdit"); private static KeyBinding mainKey = new KeyBinding("WorldEdit Reference", Keyboard.KEY_L, "WorldEdit");
public KeyHandler() { public KeyHandler() {

Datei anzeigen

@ -21,8 +21,7 @@ package com.sk89q.worldedit.forge;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.Collections; import java.util.Collections;

Datei anzeigen

@ -81,7 +81,7 @@ final class TileEntityUtils {
if (tag != null) { if (tag != null) {
// Set X, Y, Z // Set X, Y, Z
updateForSet(tag, position); updateForSet(tag, position);
tileEntity.readFromNBT(tag); tileEntity.read(tag);
} }
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity); world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
@ -98,7 +98,7 @@ final class TileEntityUtils {
static void setTileEntity(World world, BlockVector3 position, @Nullable NBTTagCompound tag) { static void setTileEntity(World world, BlockVector3 position, @Nullable NBTTagCompound tag) {
if (tag != null) { if (tag != null) {
updateForSet(tag, position); updateForSet(tag, position);
TileEntity tileEntity = TileEntity.create(world, tag); TileEntity tileEntity = TileEntity.create(tag);
if (tileEntity != null) { if (tileEntity != null) {
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity); world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
} }
@ -143,7 +143,7 @@ final class TileEntityUtils {
public static NBTTagCompound copyNbtData(TileEntity tile) { public static NBTTagCompound copyNbtData(TileEntity tile) {
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
tile.writeToNBT(tag); tile.write(tag);
return tag; return tag;
} }
} }

Datei anzeigen

@ -25,7 +25,7 @@ import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.network.ThreadQuickExitException; import net.minecraft.network.ThreadQuickExitException;
import net.minecraft.network.play.server.SPacketCustomPayload; import net.minecraft.network.play.server.SPacketCustomPayload;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.network.FMLEventChannel; import net.minecraftforge.fml.common.network.FMLEventChannel;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;

Datei anzeigen

@ -0,0 +1,30 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml"
# A version range to match for said mod loader - for regular FML @Mod it will be the minecraft version (without the 1.)
loaderVersion="[13,)"
# A URL to refer people to when problems occur with this mod
issueTrackerURL="https://discord.gg/YKbmj7V"
# A URL for the "homepage" for this mod, displayed in the mod UI
displayURL="http://wiki.sk89q.com/wiki/WorldEdit/"
# A file name (in the root of the mod JAR) containing a logo for display
logoFile="worldedit-icon.png"
# A text field displayed in the mod UI
authors="sk89q, wizjany, TomyLobo, kenzierocks, Me4502"
# A list of mods - how many allowed here is determined by the individual mod loader
[[worldedit]]
# The modid of the mod
modId="worldedit"
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="${internalVersion}"
# A display name for the mod
displayName="WorldEdit"
# The description text for the mod (multi line!)
description='''
WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both single player and multiplayer.
'''
[[dependencies.sponge]]
modId="sponge"
mandatory=false
versionRange="[1.13]"
ordering="NONE"
side="BOTH"

Datei anzeigen

@ -1,21 +0,0 @@
[{
"modid": "worldedit",
"name": "WorldEdit",
"description": "WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both single player and multiplayer.",
"version": "${internalVersion}",
"mcversion": "${mcVersion}",
"url": "http://wiki.sk89q.com/wiki/WorldEdit",
"updateUrl": "",
"authors": [ "sk89q", "wizjany", "TomyLobo", "kenzierocks", "Me4502" ],
"credits": "",
"logoFile": "",
"screenshots": [],
"requiredMods": [
"Forge@[${forgeVersion},)"
],
"dependencies": [
"Forge@[${forgeVersion},)",
"sponge"
],
"dependants": []
}]

Binäre Datei nicht angezeigt.

Nachher

Breite:  |  Höhe:  |  Größe: 5.5 KiB