[Forge] Update to 1.8

This commit is contained in:
Kenzie Togami 2015-01-15 19:39:15 -08:00
parent 23d6fa7579
commit ba363bce20
16 changed files with 104 additions and 87 deletions

View File

@ -54,6 +54,7 @@
<allow pkg="com.mojang.authlib"/>
<allow pkg="org.apache.logging.log4j"/>
<allow pkg="org.lwjgl"/>
<allow pkg="io.netty.buffer"/>
</subpackage>
</subpackage>
</import-control>

View File

@ -19,8 +19,8 @@ dependencies {
}
minecraft {
ext.forgeVersion = "10.13.1.1225"
version = "1.7.10-$forgeVersion"
ext.forgeVersion = "11.14.0.1281"
version = "1.8-$forgeVersion-1.8"
replaceIn "com/sk89q/worldedit/forge/ForgeWorldEdit.java"
replace "%VERSION%", project.version

View File

@ -19,7 +19,7 @@
package com.sk89q.worldedit.forge;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
public class ClientProxy extends CommonProxy {

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

@ -133,7 +133,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

@ -19,10 +19,10 @@
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;
public interface ForgePermissionsProvider {
@ -42,7 +42,7 @@ 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);
}

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,10 @@ 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 javax.annotation.Nullable;
@ -64,7 +66,7 @@ public class ForgePlayer extends AbstractPlayerActor {
@Override
public String getName() {
return this.player.getCommandSenderName();
return this.player.getName();
}
@Override
@ -114,7 +116,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);
}
@ -174,7 +177,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

@ -39,7 +39,9 @@ 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 net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
@ -47,6 +49,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ClassInheritanceMultiMap;
import net.minecraft.util.LongHashMap;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
@ -69,6 +73,7 @@ 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;
@ -85,6 +90,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class ForgeWorld extends AbstractWorld {
private static final int UPDATE = 1, NOTIFY = 2, NOTIFY_CLIENT = 4;
private static final Logger logger = Logger.getLogger(ForgeWorld.class.getCanonicalName());
private static final Random random = new Random();
private final WeakReference<World> worldRef;
@ -154,33 +160,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 +191,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 +212,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 +220,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 +239,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);
}
@ -384,23 +386,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

View File

@ -27,19 +27,7 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.internal.LocalWorldAdapter;
import cpw.mods.fml.common.FMLCommonHandler;
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 net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -47,6 +35,20 @@ import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
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 org.apache.logging.log4j.Logger;
import java.io.File;
@ -156,7 +158,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);
@ -169,7 +171,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);

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;
@ -55,8 +56,9 @@ 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,7 +84,7 @@ final class TileEntityUtils {
tileEntity.readFromNBT(tag);
}
world.setTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ(), tileEntity);
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
}
/**
@ -97,7 +100,7 @@ final class TileEntityUtils {
updateForSet(tag, position);
TileEntity tileEntity = TileEntity.createAndLoadEntity(tag);
if (tileEntity != null) {
world.setTileEntity(position.getBlockX(), position.getBlockY(), position.getBlockZ(), tileEntity);
world.setTileEntity(new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()), tileEntity);
}
}
}

View File

@ -24,14 +24,13 @@ import java.nio.charset.Charset;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.network.play.client.C17PacketCustomPayload;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.FMLEventChannel;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ServerCustomPacketEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
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;
public class WECUIPacketHandler {
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
private static FMLEventChannel WECUI_CHANNEL;
@ -52,7 +51,7 @@ public class WECUIPacketHandler {
return;
}
String text = new String(rawPacket.func_149558_e(), UTF_8_CHARSET);
String text = new String(rawPacket.getBufferData().array(), UTF_8_CHARSET);
session.handleCUIInitializationMessage(text);
}
}

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 {