Java Code Examples for org.bukkit.craftbukkit.util.CraftMagicNumbers#getBlock()

The following examples show how to use org.bukkit.craftbukkit.util.CraftMagicNumbers#getBlock() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Test if the given tool is capable of "efficiently" mining the given block.
 *
 * Derived from CraftBlock.itemCausesDrops()
 */
public static boolean canMineBlock(MaterialData blockMaterial, org.bukkit.inventory.ItemStack tool) {
    if(!blockMaterial.getItemType().isBlock()) {
        throw new IllegalArgumentException("Material '" + blockMaterial + "' is not a block");
    }

    net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(blockMaterial.getItemType());
    net.minecraft.server.Item nmsTool = tool == null ? null : CraftMagicNumbers.getItem(tool.getType());

    return nmsBlock != null && (nmsBlock.getBlockData().getMaterial().isAlwaysDestroyable() ||
                                (nmsTool != null && nmsTool.canDestroySpecialBlock(nmsBlock.getBlockData())));
}
 
Example 2
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Set<MaterialData> getBlockStates(Material material) {
    ImmutableSet.Builder<MaterialData> materials = ImmutableSet.builder();
    Block nmsBlock = CraftMagicNumbers.getBlock(material);
    List<IBlockData> states = nmsBlock.s().a();
    if(states != null) {
        for(IBlockData state : states) {
            int data = nmsBlock.toLegacyData(state);
            materials.add(material.getNewData((byte) data));
        }
    }
    return materials.build();
}
 
Example 3
Source File: CraftPlayer.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void sendBlockChange(Location loc, int material, byte data) {
    if (getHandle().playerNetServerHandler == null) return;

    S23PacketBlockChange packet = new S23PacketBlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());

    packet.field_148883_d = CraftMagicNumbers.getBlock(material);
    packet.field_148884_e = data;
    getHandle().playerNetServerHandler.sendPacket(packet);
}
 
Example 4
Source File: CraftBlock.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
private net.minecraft.block.Block getNMSBlock() {
    return CraftMagicNumbers.getBlock(this); // TODO: UPDATE THIS
}
 
Example 5
Source File: CraftBlock.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
private static net.minecraft.block.Block getNMSBlock(int type) {
    return CraftMagicNumbers.getBlock(type);
}
 
Example 6
Source File: CraftShulkerBox.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public DyeColor getColor() {
    net.minecraft.block.Block block = CraftMagicNumbers.getBlock(this.getType());

    return DyeColor.getByWoolData((byte) ((BlockShulkerBox) block).color.getMetadata());
}
 
Example 7
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
private static @Nullable String getBlockTranslationKey(Material material) {
    Block nmsBlock = CraftMagicNumbers.getBlock(material);
    return nmsBlock == null ? null : getTranslationKey(nmsBlock);
}
 
Example 8
Source File: CraftBlock.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public net.minecraft.block.Block getNMSBlock() {
    return CraftMagicNumbers.getBlock(this); // TODO: UPDATE THIS
}
 
Example 9
Source File: CraftBlock.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
private static net.minecraft.block.Block getNMSBlock(int type) {
    return CraftMagicNumbers.getBlock(type);
}