mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-21 04:49:51 +08:00
Add base of sendFakeBlock to Sponge and Forge impls
This commit is contained in:
parent
20b67db48d
commit
0cbfc9308e
@ -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> T getFacet(Class<? extends T> 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());
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user