Permalink
Browse files

Add base of sendFakeBlock to Sponge and Forge impls

  • Loading branch information...
me4502 committed Aug 18, 2018
1 parent 20b67db commit 0cbfc9308ec202b958fac6e55d4e0d5e873919e3
@@ -29,14 +29,18 @@
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;
import net.minecraft.item.Item;
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 boolean hasPermission(String perm) {
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());
@@ -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<World> 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());

0 comments on commit 0cbfc93

Please sign in to comment.