3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 01:50:06 +01:00

Fixes for master-rebase on forge1.8

Dieser Commit ist enthalten in:
Kenzie Togami 2016-01-12 02:23:49 -08:00
Ursprung 337ecb2864
Commit e91859130c
5 geänderte Dateien mit 17 neuen und 107 gelöschten Zeilen

Datei anzeigen

@ -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();

Datei anzeigen

@ -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());
}
}

Datei anzeigen

@ -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;
}
}
}

Datei anzeigen

@ -26,14 +26,12 @@ 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;
@ -58,15 +56,11 @@ 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.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.WorldGenTaiga2;
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 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);
@ -346,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

Datei anzeigen

@ -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;