diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java index d4b906fc4..817315e92 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java @@ -29,6 +29,8 @@ import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.item.ItemTypes; import io.netty.buffer.Unpooled; import net.minecraft.entity.player.EntityPlayerMP; @@ -36,7 +38,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.network.play.server.SPacketCustomPayload; +import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.common.registry.ForgeRegistries; @@ -164,6 +168,24 @@ public T getFacet(Class cls) { return null; } + @Override + public void sendFakeBlock(Vector pos, BlockStateHolder block) { + BlockPos loc = new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()); + if (block == null) { + // TODO +// player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData()); + } else { + // TODO +// player.sendBlockChange(loc, BukkitAdapter.adapt(block)); + if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) { + player.connection.sendPacket(new SPacketUpdateTileEntity( + new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), 7, + NBTConverter.toNative(((BaseBlock) block).getNbtData())) + ); + } + } + } + @Override public SessionKey getSessionKey() { return new SessionKeyImpl(player.getUniqueID(), player.getName()); diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java index 37774dbc8..662d65e55 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java @@ -30,6 +30,7 @@ import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameModes; import com.sk89q.worldedit.world.item.ItemTypes; @@ -183,6 +184,23 @@ public void setGameMode(GameMode gameMode) { gameMode.getId()).get()); } + @Override + public void sendFakeBlock(Vector pos, BlockStateHolder block) { + org.spongepowered.api.world.Location loc = player.getWorld().getLocation(pos.getX(), pos.getY(), pos.getZ()); + if (block == null) { + player.sendBlockChange(loc.getBlockPosition(), loc.getBlock()); + } else { + // TODO +// player.sendBlockChange(loc, BukkitAdapter.adapt(block)); +// if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) { +// BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); +// if (adapter != null) { +// adapter.sendFakeNBT(player, pos, ((BaseBlock) block).getNbtData()); +// } +// } + } + } + @Override public SessionKey getSessionKey() { return new SessionKeyImpl(player.getUniqueId(), player.getName());