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

The following examples show how to use org.bukkit.craftbukkit.util.CraftMagicNumbers#getMaterial() . 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: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityPlayer who, int clickedX, int clickedY, int clickedZ, EnumFacing clickedFace, ItemStack itemstack, net.minecraft.item.Item item) {
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();
    CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
    Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem());

    CraftWorld craftWorld = (CraftWorld) player.getWorld();
    CraftServer craftServer = (CraftServer) player.getServer();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);

    PlayerEvent event = null;
    if (isFilling) {
        event = new PlayerBucketFillEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketFillEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    } else {
        event = new PlayerBucketEmptyEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    }

    craftServer.getPluginManager().callEvent(event);

    return event;
}
 
Example 2
Source File: CraftJukebox.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Material getPlaying() {
    ItemStack record = this.getSnapshot().getRecord();
    if (record.isEmpty()) {
        return Material.AIR;
    }
    return CraftMagicNumbers.getMaterial(record.getItem());
}
 
Example 3
Source File: CraftJukebox.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Material getPlaying() {
    ItemStack record = jukebox.func_145856_a();
    if (record == null) {
        return Material.AIR;
    }
    return CraftMagicNumbers.getMaterial(record.getItem());
}
 
Example 4
Source File: CraftItemStack.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static CraftItemStack asNewCraftStack(Item item, int amount) {
    return new CraftItemStack(CraftMagicNumbers.getMaterial(item), amount, (short) 0, null);
}
 
Example 5
Source File: CraftItemStack.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static ItemMeta getItemMeta(net.minecraft.item.ItemStack item) {
    if (!hasItemMeta(item)) {
        return CraftItemFactory.instance().getItemMeta(getType(item));
    }
    switch (getType(item)) {
        case WRITTEN_BOOK:
            return new CraftMetaBookSigned(item.getTagCompound());
        case BOOK_AND_QUILL:
            return new CraftMetaBook(item.getTagCompound());
        case SKULL_ITEM:
            return new CraftMetaSkull(item.getTagCompound());
        case LEATHER_HELMET:
        case LEATHER_CHESTPLATE:
        case LEATHER_LEGGINGS:
        case LEATHER_BOOTS:
            return new CraftMetaLeatherArmor(item.getTagCompound());
        case POTION:
        case SPLASH_POTION:
        case LINGERING_POTION:
        case TIPPED_ARROW:
            return new CraftMetaPotion(item.getTagCompound());
        case MAP:
            return new CraftMetaMap(item.getTagCompound());
        case FIREWORK:
            return new CraftMetaFirework(item.getTagCompound());
        case FIREWORK_CHARGE:
            return new CraftMetaCharge(item.getTagCompound());
        case ENCHANTED_BOOK:
            return new CraftMetaEnchantedBook(item.getTagCompound());
        case BANNER:
            return new CraftMetaBanner(item.getTagCompound());
        case MONSTER_EGG:
            return new CraftMetaSpawnEgg(item.getTagCompound());
        case KNOWLEDGE_BOOK:
            return new CraftMetaKnowledgeBook(item.getTagCompound());
        case FURNACE:
        case CHEST:
        case TRAPPED_CHEST:
        case JUKEBOX:
        case DISPENSER:
        case DROPPER:
        case SIGN:
        case MOB_SPAWNER:
        case NOTE_BLOCK:
        case BREWING_STAND_ITEM:
        case ENCHANTMENT_TABLE:
        case COMMAND:
        case COMMAND_REPEATING:
        case COMMAND_CHAIN:
        case BEACON:
        case DAYLIGHT_DETECTOR:
        case DAYLIGHT_DETECTOR_INVERTED:
        case HOPPER:
        case REDSTONE_COMPARATOR:
        case FLOWER_POT_ITEM:
        case SHIELD:
        case STRUCTURE_BLOCK:
        case WHITE_SHULKER_BOX:
        case ORANGE_SHULKER_BOX:
        case MAGENTA_SHULKER_BOX:
        case LIGHT_BLUE_SHULKER_BOX:
        case YELLOW_SHULKER_BOX:
        case LIME_SHULKER_BOX:
        case PINK_SHULKER_BOX:
        case GRAY_SHULKER_BOX:
        case SILVER_SHULKER_BOX:
        case CYAN_SHULKER_BOX:
        case PURPLE_SHULKER_BOX:
        case BLUE_SHULKER_BOX:
        case BROWN_SHULKER_BOX:
        case GREEN_SHULKER_BOX:
        case RED_SHULKER_BOX:
        case BLACK_SHULKER_BOX:
        case ENDER_CHEST:
            return new CraftMetaBlockState(item.getTagCompound(), CraftMagicNumbers.getMaterial(item.getItem()));
        default:
            return new CraftMetaItem(item.getTagCompound());
    }
}
 
Example 6
Source File: NMSHacks.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static @Nullable Material materialByKey(String key) {
    final Item item = Item.REGISTRY.get(new MinecraftKey(key));
    return item == null ? null : CraftMagicNumbers.getMaterial(item);
}
 
Example 7
Source File: CraftItemStack.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public static CraftItemStack asNewCraftStack(net.minecraft.item.Item item, int amount) {
    return new CraftItemStack(CraftMagicNumbers.getMaterial(item), amount, (short) 0, null);
}