Merge branch 'feature/forge1.8'

This commit is contained in:
Kenzie Togami 2016-03-19 09:42:50 -07:00
commit 219d2da0ff
33 changed files with 1078 additions and 1278 deletions

View File

@ -10,7 +10,7 @@ jdk:
- openjdk6
# Caching for Gradle files, prevents hitting Maven too much.
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- find $HOME/.gradle/ -name '*.lock' -print -exec rm -f {} \;
cache:
directories:
- $HOME/.gradle/caches/

View File

@ -26,9 +26,9 @@ buildscript {
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.0.1'
classpath 'org.ajoberstar:gradle-git:0.12.0'
classpath 'org.ajoberstar:gradle-git:1.4.2'
}
}
@ -36,14 +36,19 @@ if (!project.hasProperty("artifactory_contextUrl")) ext.artifactory_contextUrl =
if (!project.hasProperty("artifactory_user")) ext.artifactory_user = "guest"
if (!project.hasProperty("artifactory_password")) ext.artifactory_password = ""
if (!project.hasProperty("gitCommitHash")) {
if (!project.hasProperty("gitCommitHash") && !JavaVersion.current().isJava6()) {
try {
def repo = Grgit.open(project.file('.'))
def Grgit = Class.forName("org.ajoberstar.grgit.Grgit");
def Grgit_open = Grgit.getDeclaredMethod("open", File.class)
def repo = Grgit_open.invoke(null, project.file('.'))
ext.gitCommitHash = repo.head().abbreviatedId
} catch (Exception e) {
ext.gitCommitHash = "no_git_id"
println "Error getting commit hash: " + e.getMessage()
}
}
if (!project.hasProperty("gitCommitHash")) {
ext.gitCommitHash = "no_git_id"
}
subprojects {
apply plugin: 'java'
@ -75,11 +80,6 @@ subprojects {
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
@ -87,13 +87,23 @@ subprojects {
artifacts {
archives jar
archives sourcesJar
archives javadocJar
}
if (!name.equals('worldedit-forge')) {
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives sourcesJar
}
build.dependsOn(sourcesJar)
}
build.dependsOn(checkstyleMain)
build.dependsOn(checkstyleTest)
build.dependsOn(sourcesJar)
build.dependsOn(javadocJar)
shadowJar {

View File

@ -48,13 +48,14 @@
</subpackage>
<subpackage name="forge">
<allow pkg="codechicken.multipart"/>
<allow pkg="cpw"/>
<allow pkg="net.minecraft"/>
<allow pkg="net.minecraftforge"/>
<allow pkg="com.mojang.authlib"/>
<allow pkg="org.apache.logging.log4j"/>
<allow pkg="org.lwjgl"/>
<allow pkg="io.netty.buffer"/>
<allow pkg="org.spongepowered.api" />
</subpackage>
</subpackage>
</import-control>

Binary file not shown.

View File

@ -1,6 +1,6 @@
#Mon Apr 07 22:45:51 PDT 2014
#Mon Feb 22 17:40:44 PST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-2.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip

10
gradlew vendored
View File

@ -42,11 +42,6 @@ case "`uname`" in
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@ -114,6 +109,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`

2
gradlew.bat vendored
View File

@ -46,7 +46,7 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args

View File

@ -7,28 +7,33 @@ buildscript {
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT'
}
}
apply plugin: 'forge'
repositories {
maven {
name 'forge'
url 'http://files.minecraftforge.net/maven/'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
dependencies {
compile project(':worldedit-core')
compile group: 'codechicken', name: 'ForgeMultipart', version: '1.7.10-1.2.0.345', classifier: 'dev'
compile 'org.spongepowered:spongeapi:3.1.0-SNAPSHOT'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0-rc1'
}
repositories {
maven {
name = "Sponge"
url = "https://repo.spongepowered.org/maven"
}
}
version = "6.1.1"
ext.forgeVersion = "11.15.1.1760"
ext.internalVersion = version + ";" + gitCommitHash
minecraft {
ext.forgeVersion = "10.13.4.1614-1.7.10"
version = "1.7.10-$forgeVersion"
version = "1.8.9-${project.forgeVersion}"
mappings = "snapshot_20160111"
runDir = 'run'
replaceIn "com/sk89q/worldedit/forge/ForgeWorldEdit.java"
replace "%VERSION%", project.version
@ -40,7 +45,7 @@ processResources {
from (sourceSets.main.resources.srcDirs) {
expand 'version': project.version,
'mcVersion': project.minecraft.version,
'forgeVersion': project.minecraft.forgeVersion,
'forgeVersion': project.forgeVersion,
'internalVersion': project.internalVersion
include 'mcmod.info'
}
@ -53,7 +58,8 @@ processResources {
jar {
manifest {
attributes("Class-Path": "truezip.jar WorldEdit/truezip.jar js.jar WorldEdit/js.jar",
"WorldEdit-Version": version)
"WorldEdit-Version": version,
"FMLAT": "worldedit_at.cfg")
}
}
@ -63,8 +69,10 @@ shadowJar {
}
}
reobf.reobf(shadowJar) { spec ->
spec.classpath = sourceSets.main.compileClasspath;
reobf {
shadowJar {
mappingType = 'SEARGE'
}
}
task deobfJar(type: Jar) {
@ -75,5 +83,3 @@ task deobfJar(type: Jar) {
artifacts {
archives deobfJar
}
build.dependsOn(shadowJar)

View File

@ -19,14 +19,14 @@
package com.sk89q.worldedit.forge;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraftforge.common.MinecraftForge;
public class ClientProxy extends CommonProxy {
@Override
public void registerHandlers() {
super.registerHandlers();
FMLCommonHandler.instance().bus().register(new KeyHandler());
MinecraftForge.EVENT_BUS.register(new KeyHandler());
}
}

View File

@ -19,18 +19,14 @@
package com.sk89q.worldedit.forge;
import com.google.common.base.Joiner;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
import com.sk89q.worldedit.util.command.CommandMapping;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.List;
public class CommandWrapper extends CommandBase {
private CommandMapping command;
@ -52,17 +48,6 @@ public class CommandWrapper extends CommandBase {
@Override
public void processCommand(ICommandSender var1, String[] var2) {}
@Override
public List addTabCompletionOptions(ICommandSender sender, String[] arguments) {
if (sender instanceof EntityPlayerMP) {
CommandSuggestionEvent event = new CommandSuggestionEvent(ForgeWorldEdit.inst.wrap((EntityPlayerMP) sender), command.getPrimaryAlias() + " " + Joiner.on(" ").join(arguments));
WorldEdit.getInstance().getEventBus().post(event);
return event.getSuggestions();
} else {
return super.addTabCompletionOptions(sender, arguments);
}
}
@Override
public String getCommandUsage(ICommandSender icommandsender) {
return "/" + command.getPrimaryAlias() + " " + command.getDescription().getUsage();
@ -79,7 +64,7 @@ public class CommandWrapper extends CommandBase {
}
@Override
public int compareTo(@Nullable Object o) {
public int compareTo(@Nullable ICommand o) {
if (o == null) {
return 0;
} else if (o instanceof ICommand) {

View File

@ -19,8 +19,9 @@
package com.sk89q.worldedit.forge;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import com.sk89q.worldedit.forge.gui.GuiHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
public class CommonProxy {

View File

@ -20,10 +20,9 @@
package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.World;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraftforge.common.util.ForgeDirection;
final class ForgeAdapter {
@ -38,15 +37,16 @@ final class ForgeAdapter {
return new Vector(vector.xCoord, vector.yCoord, vector.zCoord);
}
public static int adapt(Direction face) {
switch (face) {
case NORTH: return ForgeDirection.NORTH.ordinal();
case SOUTH: return ForgeDirection.SOUTH.ordinal();
case WEST: return ForgeDirection.WEST.ordinal();
case EAST: return ForgeDirection.EAST.ordinal();
case UP: return ForgeDirection.UP.ordinal();
case DOWN: return ForgeDirection.DOWN.ordinal();
default: return ForgeDirection.UNKNOWN.ordinal();
public static Vector adapt(BlockPos pos) {
return new Vector(pos.getX(), pos.getY(), pos.getZ());
}
public static Vec3 toVec3(Vector vector) {
return new Vec3(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
}
public static BlockPos toBlockPos(Vector vector) {
return new BlockPos(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
}
}

View File

@ -36,6 +36,7 @@ import net.minecraft.entity.item.EntityTNTPrimed;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityGolem;
import net.minecraft.entity.passive.EntityAmbientCreature;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.IAnimals;
import net.minecraft.entity.player.EntityPlayer;
@ -108,7 +109,7 @@ public class ForgeEntityType implements EntityType {
@Override
public boolean isAnimal() {
return entity instanceof IAnimals;
return entity instanceof EntityAnimal;
}
@Override
@ -133,7 +134,7 @@ public class ForgeEntityType implements EntityType {
@Override
public boolean isTagged() {
return entity instanceof EntityLiving && ((EntityLiving) entity).hasCustomNameTag();
return entity instanceof EntityLiving && ((EntityLiving) entity).hasCustomName();
}
@Override

View File

@ -1,53 +0,0 @@
/*
* 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;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.world.registry.ItemRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import javax.annotation.Nullable;
public class ForgeItemRegistry implements ItemRegistry {
@Nullable
@Override
public BaseItem createFromId(String id) {
Item item = (Item) Item.itemRegistry.getObject(id);
if (item != null) {
return new BaseItem(Item.getIdFromItem(item), (short) item.getDamage(new ItemStack(item, 1)));
} else {
return null;
}
}
@Nullable
@Override
public BaseItem createFromId(int id) {
Item item = (Item) Item.itemRegistry.getObjectById(id);
if (item != null) {
return new BaseItem(Item.getIdFromItem(item), (short) item.getDamage(new ItemStack(item, 1)));
} else {
return null;
}
}
}

View File

@ -19,10 +19,11 @@
package com.sk89q.worldedit.forge;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.command.ICommand;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.WorldSettings.GameType;
import net.minecraftforge.fml.common.FMLCommonHandler;
import org.spongepowered.api.entity.living.player.Player;
public interface ForgePermissionsProvider {
@ -42,11 +43,24 @@ public interface ForgePermissionsProvider {
public boolean hasPermission(EntityPlayerMP player, String permission) {
ForgeConfiguration configuration = platform.getConfiguration();
return configuration.cheatMode ||
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().func_152596_g(player.getGameProfile()) ||
FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().canSendCommands(player.getGameProfile()) ||
(configuration.creativeEnable && player.theItemInWorldManager.getGameType() == GameType.CREATIVE);
}
@Override
public void registerPermission(ICommand command, String permission) {}
}
public static class SpongePermissionsProvider implements ForgePermissionsProvider {
@Override
public boolean hasPermission(EntityPlayerMP player, String permission) {
return ((Player) player).hasPermission(permission);
}
@Override
public void registerPermission(ICommand command, String permission) {
}
}
}

View File

@ -28,7 +28,7 @@ import com.sk89q.worldedit.extension.platform.Preference;
import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.world.World;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.block.Block;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.entity.EntityList;
@ -38,8 +38,10 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.ServerConfigurationManager;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.common.FMLCommonHandler;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -121,7 +123,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
if (player instanceof ForgePlayer) {
return player;
} else {
EntityPlayerMP entity = server.getConfigurationManager().func_152612_a(player.getName());
EntityPlayerMP entity = server.getConfigurationManager().getPlayerByUsername(player.getName());
return entity != null ? new ForgePlayer(this, entity) : null;
}
}
@ -202,7 +204,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform {
List<Actor> users = new ArrayList<Actor>();
ServerConfigurationManager scm = server.getConfigurationManager();
for (String name : scm.getAllUsernames()) {
EntityPlayerMP entity = scm.func_152612_a(name);
EntityPlayerMP entity = scm.getPlayerByUsername(name);
if (entity != null) {
users.add(new ForgePlayer(this, entity));
}

View File

@ -33,8 +33,11 @@ import com.sk89q.worldedit.util.Location;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.play.server.S3FPacketCustomPayload;
import net.minecraft.util.ChatComponentText;
import io.netty.buffer.Unpooled;
import net.minecraft.util.EnumChatFormatting;
import javax.annotation.Nullable;
@ -64,7 +67,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override
public String getName() {
return this.player.getCommandSenderName();
return this.player.getName();
}
@Override
@ -78,8 +81,8 @@ public class ForgePlayer extends AbstractPlayerActor {
return new Location(
ForgeWorldEdit.inst.getWorld(this.player.worldObj),
position,
this.player.cameraYaw,
this.player.cameraPitch);
this.player.rotationYaw,
this.player.rotationPitch);
}
@Override
@ -114,7 +117,8 @@ public class ForgePlayer extends AbstractPlayerActor {
if (params.length > 0) {
send = send + "|" + StringUtil.joinString(params, "|");
}
S3FPacketCustomPayload packet = new S3FPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, send.getBytes(WECUIPacketHandler.UTF_8_CHARSET));
PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(WECUIPacketHandler.UTF_8_CHARSET)));
S3FPacketCustomPayload packet = new S3FPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, buffer);
this.player.playerNetServerHandler.sendPacket(packet);
}
@ -127,28 +131,30 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override
public void printDebug(String msg) {
for (String part : msg.split("\n")) {
this.player.addChatMessage(new ChatComponentText("\u00a77" + part));
}
sendColorized(msg, EnumChatFormatting.GRAY);
}
@Override
public void print(String msg) {
for (String part : msg.split("\n")) {
this.player.addChatMessage(new ChatComponentText("\u00a7d" + part));
}
sendColorized(msg, EnumChatFormatting.LIGHT_PURPLE);
}
@Override
public void printError(String msg) {
sendColorized(msg, EnumChatFormatting.RED);
}
private void sendColorized(String msg, EnumChatFormatting formatting) {
for (String part : msg.split("\n")) {
this.player.addChatMessage(new ChatComponentText("\u00a7c" + part));
ChatComponentText component = new ChatComponentText(part);
component.getChatStyle().setColor(formatting);
this.player.addChatMessage(component);
}
}
@Override
public void setPosition(Vector pos, float pitch, float yaw) {
this.player.playerNetServerHandler.setPlayerLocation(pos.getX(), pos.getY(), pos.getZ(), pitch, yaw);
this.player.playerNetServerHandler.setPlayerLocation(pos.getX(), pos.getY(), pos.getZ(), yaw, pitch);
}
@Override
@ -174,7 +180,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override
public SessionKey getSessionKey() {
return new SessionKeyImpl(player.getUniqueID(), player.getCommandSenderName());
return new SessionKeyImpl(player.getUniqueID(), player.getName());
}
private static class SessionKeyImpl implements SessionKey {

View File

@ -26,31 +26,41 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.blocks.LazyBlock;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.internal.Constants;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.registry.WorldData;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockOldLeaf;
import net.minecraft.block.BlockOldLog;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.LongHashMap;
import net.minecraft.util.BlockPos;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderServer;
@ -68,16 +78,6 @@ import net.minecraft.world.gen.feature.WorldGenTaiga2;
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;
import javax.annotation.Nullable;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@ -85,8 +85,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class ForgeWorld extends AbstractWorld {
private static final Logger logger = Logger.getLogger(ForgeWorld.class.getCanonicalName());
private static final Random random = new Random();
private static final int UPDATE = 1, NOTIFY = 2, NOTIFY_CLIENT = 4;
private static final Logger logger = Logger.getLogger(ForgeWorld.class.getCanonicalName());
private static final IBlockState JUNGLE_LOG = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.JUNGLE);
private static final IBlockState JUNGLE_LEAF = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.JUNGLE).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
private static final IBlockState JUNGLE_SHRUB = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false));
private final WeakReference<World> worldRef;
/**
@ -134,14 +140,6 @@ public class ForgeWorld extends AbstractWorld {
return getWorld().getWorldInfo().getWorldName();
}
@Override
public boolean useItem(Vector position, BaseItem item, Direction face) {
Item nativeItem = Item.getItemById(item.getType());
ItemStack stack = new ItemStack(nativeItem, 1, item.getData());
World world = getWorld();
return stack.tryPlaceItemIntoWorld(new WorldEditFakePlayer((WorldServer) world), world, position.getBlockX(), position.getBlockY(), position.getBlockZ(), ForgeAdapter.adapt(face), 0, 0, 0);
}
@Override
public boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException {
checkNotNull(position);
@ -154,33 +152,29 @@ public class ForgeWorld extends AbstractWorld {
// First set the block
Chunk chunk = world.getChunkFromChunkCoords(x >> 4, z >> 4);
int previousId = 0;
if (notifyAndLight) {
previousId = Block.getIdFromBlock(chunk.getBlock(x & 15, y, z & 15));
}
boolean successful = chunk.func_150807_a(x & 15, y, z & 15, Block.getBlockById(block.getId()), block.getData());
BlockPos pos = new BlockPos(x, y, z);
IBlockState old = chunk.getBlockState(pos);
IBlockState newState = Block.getBlockById(block.getId()).getStateFromMeta(block.getData());
IBlockState successState = chunk.setBlockState(pos, newState);
boolean successful = successState != null;
// Create the TileEntity
if (successful) {
CompoundTag tag = block.getNbtData();
if (tag != null) {
NBTTagCompound nativeTag = NBTConverter.toNative(tag);
if (block.hasNbtData()) {
// Kill the old TileEntity
world.removeTileEntity(pos);
NBTTagCompound nativeTag = NBTConverter.toNative(block.getNbtData());
nativeTag.setString("id", block.getNbtId());
TileEntityUtils.setTileEntity(getWorld(), position, nativeTag);
TileEntityUtils.setTileEntity(world, position, nativeTag);
}
}
if (notifyAndLight) {
world.func_147451_t(x, y, z);
world.markBlockForUpdate(x, y, z);
world.notifyBlockChange(x, y, z, Block.getBlockById(previousId));
Block mcBlock = Block.getBlockById(previousId);
if (mcBlock != null && mcBlock.hasComparatorInputOverride()) {
world.func_147453_f(x, y, z, Block.getBlockById(block.getId()));
if (!successful) {
newState = old;
}
world.checkLight(pos);
world.markAndNotifyBlock(pos, chunk, old, newState, UPDATE | NOTIFY);
}
return successful;
@ -189,13 +183,13 @@ public class ForgeWorld extends AbstractWorld {
@Override
public int getBlockLightLevel(Vector position) {
checkNotNull(position);
return getWorld().getBlockLightValue(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return getWorld().getLight(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
}
@Override
public boolean clearContainerBlockContents(Vector position) {
checkNotNull(position);
TileEntity tile = getWorld().getTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ());
TileEntity tile = getWorld().getTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
if ((tile instanceof IInventory)) {
IInventory inv = (IInventory) tile;
int size = inv.getSizeInventory();
@ -210,7 +204,7 @@ public class ForgeWorld extends AbstractWorld {
@Override
public BaseBiome getBiome(Vector2D position) {
checkNotNull(position);
return new BaseBiome(getWorld().getBiomeGenForCoords(position.getBlockX(), position.getBlockZ()).biomeID);
return new BaseBiome(getWorld().getBiomeGenForCoords(new BlockPos(position.getBlockX(), 0, position.getBlockZ())).biomeID);
}
@Override
@ -218,8 +212,8 @@ public class ForgeWorld extends AbstractWorld {
checkNotNull(position);
checkNotNull(biome);
Chunk chunk = getWorld().getChunkFromBlockCoords(position.getBlockX(), position.getBlockZ());
if ((chunk != null) && (chunk.isChunkLoaded)) {
Chunk chunk = getWorld().getChunkFromBlockCoords(new BlockPos(position.getBlockX(), 0, position.getBlockZ()));
if ((chunk != null) && (chunk.isLoaded())) {
chunk.getBiomeArray()[((position.getBlockZ() & 0xF) << 4 | position.getBlockX() & 0xF)] = (byte) biome.getId();
return true;
}
@ -237,7 +231,7 @@ public class ForgeWorld extends AbstractWorld {
}
EntityItem entity = new EntityItem(getWorld(), position.getX(), position.getY(), position.getZ(), ForgeWorldEdit.toForgeItemStack(item));
entity.delayBeforeCanPickup = 10;
entity.setPickupDelay(10);
getWorld().spawnEntityInWorld(entity);
}
@ -264,38 +258,7 @@ public class ForgeWorld extends AbstractWorld {
return false;
}
ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
Field u;
try {
u = ChunkProviderServer.class.getDeclaredField("field_73248_b"); // chunksToUnload
} catch(NoSuchFieldException e) {
u = ChunkProviderServer.class.getDeclaredField("chunksToUnload");
}
u.setAccessible(true);
Set<?> unloadQueue = (Set<?>) u.get(chunkServer);
Field m;
try {
m = ChunkProviderServer.class.getDeclaredField("field_73244_f"); // loadedChunkHashMap
} catch(NoSuchFieldException e) {
m = ChunkProviderServer.class.getDeclaredField("loadedChunkHashMap");
}
m.setAccessible(true);
LongHashMap loadedMap = (LongHashMap) m.get(chunkServer);
Field lc;
try {
lc = ChunkProviderServer.class.getDeclaredField("field_73245_g"); // loadedChunkHashMap
} catch(NoSuchFieldException e) {
lc = ChunkProviderServer.class.getDeclaredField("loadedChunks");
}
lc.setAccessible(true);
@SuppressWarnings("unchecked") List<Chunk> loaded = (List<Chunk>) lc.get(chunkServer);
Field p;
try {
p = ChunkProviderServer.class.getDeclaredField("field_73246_d"); // currentChunkProvider
} catch(NoSuchFieldException e) {
p = ChunkProviderServer.class.getDeclaredField("currentChunkProvider");
}
p.setAccessible(true);
IChunkProvider chunkProvider = (IChunkProvider) p.get(chunkServer);
IChunkProvider chunkProvider = chunkServer.serverChunkGenerator;
for (Vector2D coord : chunks) {
long pos = ChunkCoordIntPair.chunkXZ2Int(coord.getBlockX(), coord.getBlockZ());
@ -304,11 +267,11 @@ public class ForgeWorld extends AbstractWorld {
mcChunk = chunkServer.loadChunk(coord.getBlockX(), coord.getBlockZ());
mcChunk.onChunkUnload();
}
unloadQueue.remove(pos);
loadedMap.remove(pos);
chunkServer.droppedChunksSet.remove(pos);
chunkServer.id2ChunkMap.remove(pos);
mcChunk = chunkProvider.provideChunk(coord.getBlockX(), coord.getBlockZ());
loadedMap.add(pos, mcChunk);
loaded.add(mcChunk);
chunkServer.id2ChunkMap.add(pos, mcChunk);
chunkServer.loadedChunks.add(mcChunk);
if (mcChunk != null) {
mcChunk.onChunkLoad();
mcChunk.populateChunk(chunkProvider, chunkProvider, coord.getBlockX(), coord.getBlockZ());
@ -346,12 +309,12 @@ public class ForgeWorld extends AbstractWorld {
case REDWOOD: return new WorldGenTaiga2(true);
case TALL_REDWOOD: return new WorldGenTaiga1();
case BIRCH: return new WorldGenForest(true, false);
case JUNGLE: return new WorldGenMegaJungle(true, 10, 20, 3, 3);
case SMALL_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), 3, 3, false);
case SHORT_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), 3, 3, true);
case JUNGLE_BUSH: return new WorldGenShrub(3, 0);
case RED_MUSHROOM: return new WorldGenBigMushroom(1);
case BROWN_MUSHROOM: return new WorldGenBigMushroom(0);
case JUNGLE: return new WorldGenMegaJungle(true, 10, 20, JUNGLE_LOG, JUNGLE_LEAF);
case SMALL_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, false);
case SHORT_JUNGLE: return new WorldGenTrees(true, 4 + random.nextInt(7), JUNGLE_LOG, JUNGLE_LEAF, true);
case JUNGLE_BUSH: return new WorldGenShrub(JUNGLE_LOG, JUNGLE_SHRUB);
case RED_MUSHROOM: return new WorldGenBigMushroom(Blocks.brown_mushroom_block);
case BROWN_MUSHROOM: return new WorldGenBigMushroom(Blocks.red_mushroom_block);
case SWAMP: return new WorldGenSwamp();
case ACACIA: return new WorldGenSavannaTree(true);
case DARK_OAK: return new WorldGenCanopyTree(true);
@ -368,7 +331,7 @@ public class ForgeWorld extends AbstractWorld {
@Override
public boolean generateTree(TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException {
WorldGenerator generator = createWorldGenerator(type);
return generator != null ? generator.generate(getWorld(), random, position.getBlockX(), position.getBlockY(), position.getBlockZ()) : false;
return generator != null ? generator.generate(getWorld(), random, ForgeAdapter.toBlockPos(position)) : false;
}
@Override
@ -384,23 +347,23 @@ public class ForgeWorld extends AbstractWorld {
@Override
public BaseBlock getBlock(Vector position) {
World world = getWorld();
int id = Block.getIdFromBlock(world.getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
int data = world.getBlockMetadata(position.getBlockX(), position.getBlockY(), position.getBlockZ());
TileEntity tile = getWorld().getTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ());
BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
IBlockState state = world.getBlockState(pos);
TileEntity tile = getWorld().getTileEntity(pos);
if (tile != null) {
return new TileEntityBaseBlock(id, data, tile);
return new TileEntityBaseBlock(Block.getIdFromBlock(state.getBlock()), state.getBlock().getMetaFromState(state), tile);
} else {
return new BaseBlock(id, data);
return new BaseBlock(Block.getIdFromBlock(state.getBlock()), state.getBlock().getMetaFromState(state));
}
}
@Override
public BaseBlock getLazyBlock(Vector position) {
World world = getWorld();
int id = Block.getIdFromBlock(world.getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ()));
int data = world.getBlockMetadata(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return new LazyBlock(id, data, this, position);
BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ());
IBlockState state = world.getBlockState(pos);
return new LazyBlock(Block.getIdFromBlock(state.getBlock()), state.getBlock().getMetaFromState(state), this, position);
}
@Override
@ -425,7 +388,6 @@ public class ForgeWorld extends AbstractWorld {
}
@Override
@SuppressWarnings("unchecked")
public List<? extends Entity> getEntities(Region region) {
List<Entity> entities = new ArrayList<Entity>();
World world = getWorld();
@ -441,8 +403,8 @@ public class ForgeWorld extends AbstractWorld {
@Override
public List<? extends Entity> getEntities() {
List<Entity> entities = new ArrayList<Entity>();
for (Object entity : getWorld().loadedEntityList) {
entities.add(new ForgeEntity((net.minecraft.entity.Entity) entity));
for (net.minecraft.entity.Entity entity : getWorld().loadedEntityList) {
entities.add(new ForgeEntity(entity));
}
return entities;
}

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.world.registry.BiomeRegistry;
import com.sk89q.worldedit.world.registry.ItemRegistry;
import com.sk89q.worldedit.world.registry.LegacyWorldData;
/**
@ -29,14 +28,8 @@ import com.sk89q.worldedit.world.registry.LegacyWorldData;
class ForgeWorldData extends LegacyWorldData {
private static final ForgeWorldData INSTANCE = new ForgeWorldData();
private final ItemRegistry itemRegistry = new ForgeItemRegistry();
private final BiomeRegistry biomeRegistry = new ForgeBiomeRegistry();
@Override
public ItemRegistry getItemRegistry() {
return itemRegistry;
}
@Override
public BiomeRegistry getBiomeRegistry() {
return biomeRegistry;

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit.forge;
import org.apache.logging.log4j.Logger;
import com.google.common.base.Joiner;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -26,24 +28,10 @@ import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
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 cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import java.io.File;
import java.util.Map;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -51,13 +39,22 @@ import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.util.Map;
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
import net.minecraftforge.fml.common.Loader;
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.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.common.event.FMLServerStartedEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import static com.google.common.base.Preconditions.checkNotNull;
import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
/**
* The Forge implementation of WorldEdit.
@ -80,7 +77,6 @@ public class ForgeWorldEdit {
private ForgePlatform platform;
private ForgeConfiguration config;
private File workingDir;
private ForgeMultipartCompat compat = new NoForgeMultipartCompat();
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
@ -92,16 +88,13 @@ public class ForgeWorldEdit {
config = new ForgeConfiguration(this);
config.load();
if (Loader.isModLoaded("ForgeMultipart")) {
compat = new ForgeMultipartExistsCompat();
}
FMLCommonHandler.instance().bus().register(ThreadSafeCache.getInstance());
MinecraftForge.EVENT_BUS.register(ThreadSafeCache.getInstance());
}
@EventHandler
public void init(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(this);
WECUIPacketHandler.init();
proxy.registerHandlers();
}
@ -122,8 +115,13 @@ public class ForgeWorldEdit {
this.platform = new ForgePlatform(this);
WorldEdit.getInstance().getPlatformManager().register(platform);
if (Loader.isModLoaded("sponge")) {
this.provider = new ForgePermissionsProvider.SpongePermissionsProvider();
} else {
this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform);
}
}
@EventHandler
public void serverStopping(FMLServerStoppingEvent event) {
@ -165,7 +163,7 @@ public class ForgeWorldEdit {
Action action = event.action;
switch (action) {
case LEFT_CLICK_BLOCK: {
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), event.x, event.y, event.z);
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), event.pos.getX(), event.pos.getY(), event.pos.getZ());
if (we.handleBlockLeftClick(player, pos)) {
event.setCanceled(true);
@ -178,7 +176,7 @@ public class ForgeWorldEdit {
break;
}
case RIGHT_CLICK_BLOCK: {
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), event.x, event.y, event.z);
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), event.pos.getX(), event.pos.getY(), event.pos.getZ());
if (we.handleBlockRightClick(player, pos)) {
event.setCanceled(true);
@ -203,7 +201,7 @@ public class ForgeWorldEdit {
public static ItemStack toForgeItemStack(BaseItemStack item) {
ItemStack ret = new ItemStack(Item.getItemById(item.getType()), item.getAmount(), item.getData());
for (Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
ret.addEnchantment(net.minecraft.enchantment.Enchantment.enchantmentsList[((Integer) entry.getKey())], (Integer) entry.getValue());
ret.addEnchantment(net.minecraft.enchantment.Enchantment.getEnchantmentById(entry.getKey()), entry.getValue());
}
return ret;
@ -269,10 +267,6 @@ public class ForgeWorldEdit {
return this.workingDir;
}
public ForgeMultipartCompat getFMPCompat() {
return compat;
}
/**
* Get the version of the WorldEdit-for-Forge implementation.
*

View File

@ -20,11 +20,13 @@
package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.forge.gui.GuiHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import org.lwjgl.input.Keyboard;
public class KeyHandler {

View File

@ -170,7 +170,7 @@ final class NBTConverter {
}
public static IntArrayTag fromNative(NBTTagIntArray other) {
int[] value = other.func_150302_c();
int[] value = other.getIntArray();
return new IntArrayTag(Arrays.copyOf(value, value.length));
}
@ -192,28 +192,28 @@ final class NBTConverter {
}
public static LongTag fromNative(NBTTagLong other) {
return new LongTag(other.func_150291_c());
return new LongTag(other.getLong());
}
public static StringTag fromNative(NBTTagString other) {
return new StringTag(other.func_150285_a_());
return new StringTag(other.getString());
}
public static IntTag fromNative(NBTTagInt other) {
return new IntTag(other.func_150287_d());
return new IntTag(other.getInt());
}
public static ByteTag fromNative(NBTTagByte other) {
return new ByteTag(other.func_150290_f());
return new ByteTag(other.getByte());
}
public static ByteArrayTag fromNative(NBTTagByteArray other) {
byte[] value = other.func_150292_c();
byte[] value = other.getByteArray();
return new ByteArrayTag(Arrays.copyOf(value, value.length));
}
public static CompoundTag fromNative(NBTTagCompound other) {
@SuppressWarnings("unchecked") Collection<String> tags = other.func_150296_c();
@SuppressWarnings("unchecked") Set<String> tags = other.getKeySet();
Map<String, Tag> map = new HashMap<String, Tag>();
for (String tagName : tags) {
map.put(tagName, fromNative(other.getTag(tagName)));
@ -222,15 +222,15 @@ final class NBTConverter {
}
public static FloatTag fromNative(NBTTagFloat other) {
return new FloatTag(other.func_150288_h());
return new FloatTag(other.getFloat());
}
public static ShortTag fromNative(NBTTagShort other) {
return new ShortTag(other.func_150289_e());
return new ShortTag(other.getShort());
}
public static DoubleTag fromNative(NBTTagDouble other) {
return new DoubleTag(other.func_150286_g());
return new DoubleTag(other.getDouble());
}
}

View File

@ -19,10 +19,11 @@
package com.sk89q.worldedit.forge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.Collections;
import java.util.HashSet;
@ -56,7 +57,8 @@ public class ThreadSafeCache {
if (now - lastRefresh > REFRESH_DELAY) {
Set<UUID> onlineIds = new HashSet<UUID>();
if (FMLCommonHandler.instance().getMinecraftServerInstance() == null) {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if (server == null || server.getConfigurationManager() == null) {
return;
}
for (Object object : FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().playerEntityList) {

View File

@ -20,12 +20,15 @@
package com.sk89q.worldedit.forge;
import com.sk89q.worldedit.Vector;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.lang.reflect.Constructor;
import static com.google.common.base.Preconditions.checkNotNull;
@ -81,10 +84,9 @@ final class TileEntityUtils {
tileEntity.readFromNBT(tag);
}
tileEntity = ForgeWorldEdit.inst.getFMPCompat().overrideTileEntity(world, tag, tileEntity);
setTileEntity(world, position, tileEntity);
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
}
/**
* Set a tile entity at the given location using the tile entity ID from
* the tag.
@ -96,27 +98,13 @@ final class TileEntityUtils {
static void setTileEntity(World world, Vector position, @Nullable NBTTagCompound tag) {
if (tag != null) {
updateForSet(tag, position);
TileEntity tileEntity = makeTileEntity(world, position, tag);
TileEntity tileEntity = TileEntity.createAndLoadEntity(tag);
if (tileEntity != null) {
setTileEntity(world, position, tileEntity);
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), 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.
*

View File

@ -19,22 +19,23 @@
package com.sk89q.worldedit.forge;
import java.nio.charset.Charset;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.play.client.C17PacketCustomPayload;
import com.sk89q.worldedit.LocalSession;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.network.FMLEventChannel;
import cpw.mods.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import java.nio.charset.Charset;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.PacketBuffer;
import net.minecraft.network.ThreadQuickExitException;
import net.minecraft.network.play.server.S3FPacketCustomPayload;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.FMLEventChannel;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientCustomPacketEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
public class WECUIPacketHandler {
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
private static FMLEventChannel WECUI_CHANNEL;
public static FMLEventChannel WECUI_CHANNEL;
public static void init() {
WECUI_CHANNEL = NetworkRegistry.INSTANCE.newEventDrivenChannel(ForgeWorldEdit.CUI_PLUGIN_CHANNEL);
@ -43,7 +44,6 @@ public class WECUIPacketHandler {
@SubscribeEvent
public void onPacketData(ServerCustomPacketEvent event) {
C17PacketCustomPayload rawPacket = (C17PacketCustomPayload) event.packet.toC17Packet();
if (event.packet.channel().equals(ForgeWorldEdit.CUI_PLUGIN_CHANNEL)) {
EntityPlayerMP player = getPlayerFromEvent(event);
LocalSession session = ForgeWorldEdit.inst.getSession((EntityPlayerMP) player);
@ -52,8 +52,17 @@ public class WECUIPacketHandler {
return;
}
String text = new String(rawPacket.func_149558_e(), UTF_8_CHARSET);
String text = event.packet.payload().toString(UTF_8_CHARSET);
session.handleCUIInitializationMessage(text);
session.describeCUI(ForgeWorldEdit.inst.wrap(player));
}
}
@SubscribeEvent
public void callProcessPacket(ClientCustomPacketEvent event) {
try {
new S3FPacketCustomPayload(event.packet.channel(), new PacketBuffer(event.packet.payload())).processPacket(event.handler);
} catch (ThreadQuickExitException suppress) {
}
}

View File

@ -1,34 +0,0 @@
/*
* 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);
}

View File

@ -1,51 +0,0 @@
/*
* 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);
}
}
}

View File

@ -1,38 +0,0 @@
/*
* 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) {
}
}

View File

@ -19,9 +19,9 @@
package com.sk89q.worldedit.forge.gui;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;
public class GuiHandler implements IGuiHandler {

View File

@ -0,0 +1,4 @@
public net.minecraft.world.gen.ChunkProviderServer field_73248_b # droppedChunksSet
public net.minecraft.world.gen.ChunkProviderServer field_73244_f # id2ChunkMap
public net.minecraft.world.gen.ChunkProviderServer field_73245_g # loadedChunks
public net.minecraft.world.gen.ChunkProviderServer field_73246_d # serverChunkGenerator

View File

@ -1,12 +1,12 @@
[{
"modid": "WorldEdit",
"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" ],
"authors": [ "sk89q", "wizjany", "TomyLobo", "kenzierocks" ],
"credits": "",
"logoFile": "",
"screenshots": [],
@ -15,7 +15,7 @@
],
"dependencies": [
"Forge@[${forgeVersion},)",
"ForgeMultipart"
"sponge"
],
"dependants": []
}]