diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java index daf76bad6..2b555c851 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/CommandWrapper.java @@ -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 List getCommandAliases() { @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(); diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java index c7195da31..9c64b9403 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeAdapter.java @@ -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 @@ public static Vector adapt(Vec3 vector) { 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()); + } + } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java deleted file mode 100644 index 3dcb0dbf3..000000000 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeItemRegistry.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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; - } - } - -} diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java index bec590b03..e89c46112 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java @@ -26,14 +26,12 @@ 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; @@ -58,15 +56,11 @@ 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.BlockPos; -import net.minecraft.util.ClassInheritanceMultiMap; 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; @@ -84,7 +78,6 @@ import net.minecraft.world.gen.feature.WorldGenTrees; import net.minecraft.world.gen.feature.WorldGenerator; - import static com.google.common.base.Preconditions.checkNotNull; /** @@ -147,14 +140,6 @@ public String getName() { 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); @@ -346,7 +331,7 @@ private static WorldGenerator createWorldGenerator(TreeType type) { @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 diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldData.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldData.java index 33248463b..249e93ddc 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldData.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorldData.java @@ -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 @@ 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;