mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-04 20:06:06 +00:00
Merge pull request #341 from sk89q/feature/fmp-compat
Add FMP compatiblity.
This commit is contained in:
commit
c6b477297d
@ -48,6 +48,7 @@
|
|||||||
</subpackage>
|
</subpackage>
|
||||||
|
|
||||||
<subpackage name="forge">
|
<subpackage name="forge">
|
||||||
|
<allow pkg="codechicken.multipart"/>
|
||||||
<allow pkg="cpw"/>
|
<allow pkg="cpw"/>
|
||||||
<allow pkg="net.minecraft"/>
|
<allow pkg="net.minecraft"/>
|
||||||
<allow pkg="net.minecraftforge"/>
|
<allow pkg="net.minecraftforge"/>
|
||||||
|
@ -13,9 +13,17 @@ buildscript {
|
|||||||
|
|
||||||
apply plugin: 'forge'
|
apply plugin: 'forge'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name 'forge'
|
||||||
|
url 'http://files.minecraftforge.net/maven/'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':worldedit-core')
|
compile project(':worldedit-core')
|
||||||
testCompile group: 'org.mockito', name: 'mockito-core', version:'1.9.0-rc1'
|
compile group: 'codechicken', name: 'ForgeMultipart', version: '1.7.10-1.2.0.345', classifier: 'dev'
|
||||||
|
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0-rc1'
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
|
@ -26,8 +26,12 @@ import com.sk89q.worldedit.WorldVector;
|
|||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.forge.compat.ForgeMultipartCompat;
|
||||||
|
import com.sk89q.worldedit.forge.compat.ForgeMultipartExistsCompat;
|
||||||
|
import com.sk89q.worldedit.forge.compat.NoForgeMultipartCompat;
|
||||||
import com.sk89q.worldedit.internal.LocalWorldAdapter;
|
import com.sk89q.worldedit.internal.LocalWorldAdapter;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.Loader;
|
||||||
import cpw.mods.fml.common.Mod;
|
import cpw.mods.fml.common.Mod;
|
||||||
import cpw.mods.fml.common.Mod.EventHandler;
|
import cpw.mods.fml.common.Mod.EventHandler;
|
||||||
import cpw.mods.fml.common.Mod.Instance;
|
import cpw.mods.fml.common.Mod.Instance;
|
||||||
@ -76,6 +80,7 @@ public class ForgeWorldEdit {
|
|||||||
private ForgePlatform platform;
|
private ForgePlatform platform;
|
||||||
private ForgeConfiguration config;
|
private ForgeConfiguration config;
|
||||||
private File workingDir;
|
private File workingDir;
|
||||||
|
private ForgeMultipartCompat compat = new NoForgeMultipartCompat();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
@ -87,6 +92,10 @@ public class ForgeWorldEdit {
|
|||||||
config = new ForgeConfiguration(this);
|
config = new ForgeConfiguration(this);
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
|
if (Loader.isModLoaded("ForgeMultipart")) {
|
||||||
|
compat = new ForgeMultipartExistsCompat();
|
||||||
|
}
|
||||||
|
|
||||||
FMLCommonHandler.instance().bus().register(ThreadSafeCache.getInstance());
|
FMLCommonHandler.instance().bus().register(ThreadSafeCache.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,6 +269,10 @@ public class ForgeWorldEdit {
|
|||||||
return this.workingDir;
|
return this.workingDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ForgeMultipartCompat getFMPCompat() {
|
||||||
|
return compat;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the version of the WorldEdit-for-Forge implementation.
|
* Get the version of the WorldEdit-for-Forge implementation.
|
||||||
*
|
*
|
||||||
|
@ -81,9 +81,10 @@ final class TileEntityUtils {
|
|||||||
tileEntity.readFromNBT(tag);
|
tileEntity.readFromNBT(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
world.setTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ(), tileEntity);
|
tileEntity = ForgeWorldEdit.inst.getFMPCompat().overrideTileEntity(world, tag, tileEntity);
|
||||||
}
|
|
||||||
|
|
||||||
|
setTileEntity(world, position, tileEntity);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Set a tile entity at the given location using the tile entity ID from
|
* Set a tile entity at the given location using the tile entity ID from
|
||||||
* the tag.
|
* the tag.
|
||||||
@ -95,12 +96,26 @@ final class TileEntityUtils {
|
|||||||
static void setTileEntity(World world, Vector position, @Nullable NBTTagCompound tag) {
|
static void setTileEntity(World world, Vector position, @Nullable NBTTagCompound tag) {
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
updateForSet(tag, position);
|
updateForSet(tag, position);
|
||||||
TileEntity tileEntity = TileEntity.createAndLoadEntity(tag);
|
TileEntity tileEntity = makeTileEntity(world, position, tag);
|
||||||
if (tileEntity != null) {
|
if (tileEntity != null) {
|
||||||
world.setTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ(), tileEntity);
|
setTileEntity(world, position, tileEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static TileEntity makeTileEntity(World world, Vector position,
|
||||||
|
NBTTagCompound tag) {
|
||||||
|
TileEntity normal = TileEntity.createAndLoadEntity(tag);
|
||||||
|
return ForgeWorldEdit.inst.getFMPCompat().overrideTileEntity(world, tag,
|
||||||
|
normal);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setTileEntity(World world, Vector position,
|
||||||
|
TileEntity tileEntity) {
|
||||||
|
world.setTileEntity(position.getBlockX(), position.getBlockY(),
|
||||||
|
position.getBlockZ(), tileEntity);
|
||||||
|
ForgeWorldEdit.inst.getFMPCompat().sendDescPacket(world, tileEntity);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a tile entity from the given class.
|
* Construct a tile entity from the given class.
|
||||||
@ -139,5 +154,4 @@ final class TileEntityUtils {
|
|||||||
return genericTE;
|
return genericTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.forge.compat;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public interface ForgeMultipartCompat {
|
||||||
|
|
||||||
|
TileEntity overrideTileEntity(World world, @Nullable NBTTagCompound tag,
|
||||||
|
TileEntity normal);
|
||||||
|
|
||||||
|
void sendDescPacket(World world, TileEntity entity);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.sk89q.worldedit.forge.compat;
|
||||||
|
|
||||||
|
import codechicken.multipart.MultipartHelper;
|
||||||
|
import codechicken.multipart.TileMultipart;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class ForgeMultipartExistsCompat implements ForgeMultipartCompat {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity overrideTileEntity(World world,
|
||||||
|
@Nullable NBTTagCompound tag, TileEntity normal) {
|
||||||
|
if (tag == null) {
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
TileEntity tile = MultipartHelper.createTileFromNBT(world, tag);
|
||||||
|
if (tile == null) {
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendDescPacket(World world, TileEntity entity) {
|
||||||
|
if (entity instanceof TileMultipart) {
|
||||||
|
TileMultipart multi = (TileMultipart) entity;
|
||||||
|
MultipartHelper.sendDescPacket(world, multi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.forge.compat;
|
||||||
|
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class NoForgeMultipartCompat implements ForgeMultipartCompat {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity overrideTileEntity(World world, NBTTagCompound tag,
|
||||||
|
TileEntity normal) {
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendDescPacket(World world, TileEntity entity) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,7 +14,8 @@
|
|||||||
"Forge@[${forgeVersion},)"
|
"Forge@[${forgeVersion},)"
|
||||||
],
|
],
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"Forge@[${forgeVersion},)"
|
"Forge@[${forgeVersion},)",
|
||||||
|
"ForgeMultipart"
|
||||||
],
|
],
|
||||||
"dependants": []
|
"dependants": []
|
||||||
}]
|
}]
|
||||||
|
Loading…
Reference in New Issue
Block a user