Created
March 31, 2014 00:04
-
-
Save aadnk/9882293 to your computer and use it in GitHub Desktop.
Sending a WrapperPlayServerMultiBlockChange packet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.comphenix.example; | |
import org.bukkit.Location; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.entity.Player; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class PlayServerMultiBlockChange extends JavaPlugin { | |
@Override | |
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | |
if (sender instanceof Player) { | |
Player reciever = (Player) sender; | |
Location loc = reciever.getLocation(); | |
WrapperPlayServerMultiBlockChange change = new WrapperPlayServerMultiBlockChange(); | |
// Construct the block changes | |
BlockChangeArray changeArray = new BlockChangeArray(64); | |
int index = 0; | |
// Create a 4x4x4 stone cube | |
for (int x = 0; x < 4; x++) { | |
for (int z = 0; z < 4; z++) { | |
for (int y = 0; y < 4; y++) { | |
changeArray.getBlockChange(index++). | |
setBlockID(1). | |
setMetadata(0). | |
setRelativeX(x). | |
setRelativeZ(z). | |
setAbsoluteY(loc.getBlockY() + y); | |
} | |
} | |
} | |
change.setChunkX(loc.getBlockX() >> 4); | |
change.setChunkZ(loc.getBlockZ() >> 4); | |
change.setRecordData(changeArray); | |
change.sendPacket(reciever); | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This requires AbstractPacket, BlockChangeArray and WrapperPlayServerMultiBlockChange from PacketWrapper.