org.bukkit.Material#PLAYER_HEAD源码实例Demo

下面列出了org.bukkit.Material#PLAYER_HEAD 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Transport-Pipes   文件: ItemService.java
public ItemStack createHeadItem(String uuid, String textureValue, String textureSignature) {
    WrappedGameProfile wrappedProfile = new WrappedGameProfile(UUID.fromString(uuid), null);
    wrappedProfile.getProperties().put("textures", new WrappedSignedProperty("textures", textureValue, textureSignature));

    ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
    SkullMeta sm = (SkullMeta) skull.getItemMeta();
    sm.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(uuid)));

    Field profileField;
    try {
        profileField = sm.getClass().getDeclaredField("profile");
        profileField.setAccessible(true);
        profileField.set(sm, wrappedProfile.getHandle());
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
        e1.printStackTrace();
    }

    skull.setItemMeta(sm);
    return skull;
}
 
源代码2 项目: Slimefun4   文件: SlimefunUtils.java
/**
 * This method returns an {@link ItemStack} for the given texture.
 * The result will be a Player Head with this texture.
 * 
 * @param texture
 *            The texture for this head (base64 or hash)
 * @return An {@link ItemStack} with this Head texture
 */
public static ItemStack getCustomHead(String texture) {
    if (SlimefunPlugin.instance == null) {
        throw new PrematureCodeException("You cannot instantiate a custom head before Slimefun was loaded.");
    }

    if (SlimefunPlugin.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
        // com.mojang.authlib.GameProfile does not exist in a Test Environment
        return new ItemStack(Material.PLAYER_HEAD);
    }

    String base64 = texture;

    if (PatternUtils.ALPHANUMERIC.matcher(texture).matches()) {
        base64 = Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}").getBytes(StandardCharsets.UTF_8));
    }

    return SkullItem.fromBase64(base64);
}
 
源代码3 项目: IF   文件: SkullUtil.java
/**
 * Gets a skull from the specified id. The id is the value from the textures.minecraft.net website after the last
 * '/' character.
 *
 * @param id the skull id
 * @return the skull item
 * @since 0.5.0
 */
@NotNull
public static ItemStack getSkull(@NotNull String id) {
    ItemStack item = new ItemStack(Material.PLAYER_HEAD);
    ItemMeta itemMeta = Objects.requireNonNull(item.getItemMeta());
    setSkull(itemMeta, id);
    item.setItemMeta(itemMeta);
    return item;
}
 
源代码4 项目: QualityArmory   文件: MultiVersionLookup.java
public static Material getSkull() {
	if (skull == null) {
		try {
			skull = Material.matchMaterial("SKULL_ITEM");
		} catch (Error | Exception e) {
		}
		if (skull == null)
			skull = Material.PLAYER_HEAD;
	}
	return skull;
}
 
源代码5 项目: Slimefun4   文件: TestCargoNodeListener.java
@Test
public void testNonCargoNode() {
    Player player = server.addPlayer();
    Location l = new Location(player.getWorld(), 190, 50, 400);
    Block b = l.getBlock();
    Block against = b.getRelative(BlockFace.DOWN);

    ItemStack item = new ItemStack(Material.PLAYER_HEAD);

    BlockPlaceEvent event = new BlockPlaceEvent(b, new BlockStateMock(), against, item, player, true, EquipmentSlot.HAND);
    listener.onCargoNodePlace(event);
    Assertions.assertFalse(event.isCancelled());
}
 
源代码6 项目: ExoticGarden   文件: Schematic.java
public static Material parseId(short blockId, byte blockData) {
    switch (blockId) {
    case 6:
        if (blockData == 0) return Material.OAK_SAPLING;
        if (blockData == 1) return Material.SPRUCE_SAPLING;
        if (blockData == 2) return Material.BIRCH_SAPLING;
        if (blockData == 3) return Material.JUNGLE_SAPLING;
        if (blockData == 4) return Material.ACACIA_SAPLING;
        if (blockData == 5) return Material.DARK_OAK_SAPLING;
        break;
    case 17:
        if (blockData == 0 || blockData == 4 || blockData == 8 || blockData == 12) return Material.OAK_LOG;
        if (blockData == 1 || blockData == 5 || blockData == 9 || blockData == 13) return Material.SPRUCE_LOG;
        if (blockData == 2 || blockData == 6 || blockData == 10 || blockData == 14) return Material.BIRCH_LOG;
        if (blockData == 3 || blockData == 7 || blockData == 11 || blockData == 15) return Material.JUNGLE_LOG;
        break;
    case 18:
        if (blockData == 0 || blockData == 4 || blockData == 8 || blockData == 12) return Material.OAK_LEAVES;
        if (blockData == 1 || blockData == 5 || blockData == 9 || blockData == 13) return Material.SPRUCE_LEAVES;
        if (blockData == 2 || blockData == 6 || blockData == 10 || blockData == 14) return Material.BIRCH_LEAVES;
        if (blockData == 3 || blockData == 7 || blockData == 11 || blockData == 15) return Material.JUNGLE_LEAVES;
        return Material.OAK_LEAVES;
    case 161:
        if (blockData == 0 || blockData == 4 || blockData == 8 || blockData == 12) return Material.ACACIA_LEAVES;
        if (blockData == 1 || blockData == 5 || blockData == 9 || blockData == 13) return Material.DARK_OAK_LEAVES;
        break;
    case 162:
        if (blockData == 0 || blockData == 4 || blockData == 8 || blockData == 12) return Material.ACACIA_LOG;
        if (blockData == 1 || blockData == 5 || blockData == 9 || blockData == 13) return Material.DARK_OAK_LOG;
        break;
    case 144:
        return Material.PLAYER_HEAD;
    default:
        return null;
    }

    return null;
}
 
源代码7 项目: ArmorStandTools   文件: MainListener.java
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
    Block b = event.getBlock();
    if((b.getType() == Material.PLAYER_HEAD && b.hasMetadata("protected")) || (b.getType() == Material.SIGN && b.hasMetadata("armorStand"))) {
        event.setCancelled(true);
    }
}
 
源代码8 项目: uSkyBlock   文件: AbstractConfigMenu.java
protected ItemStack createItem(String item) {
    if (item == null) {
        return null;
    }
    Matcher m = UUID_PATTERN.matcher(item);
    if (m.matches()) {
        ItemStack itemStack = new ItemStack(Material.PLAYER_HEAD, 1);
        Bukkit.getUnsafe().modifyItemStack(itemStack, item);
        ItemMeta itemMeta = itemStack.getItemMeta();
        itemMeta.setDisplayName(tr(itemMeta.getDisplayName()));
        itemStack.setItemMeta(itemMeta);
        return itemStack;
    }
    return null;
}
 
源代码9 项目: Slimefun4   文件: SlimefunItemStack.java
private static ItemStack getSkull(String id, String texture) {
    if (SlimefunPlugin.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
        return new ItemStack(Material.PLAYER_HEAD);
    }

    return SkullItem.fromBase64(getTexture(id, texture));
}
 
源代码10 项目: Slimefun4   文件: BlockPhysicsListener.java
@EventHandler(ignoreCancelled = true)
public void onLiquidFlow(BlockFromToEvent e) {
    Block block = e.getToBlock();

    if (block.getType() == Material.PLAYER_HEAD || block.getType() == Material.PLAYER_WALL_HEAD || Tag.SAPLINGS.isTagged(block.getType())) {
        String item = BlockStorage.checkID(block);

        if (item != null) {
            e.setCancelled(true);
        }
    }
}
 
源代码11 项目: Slimefun4   文件: ExplosiveTool.java
protected void breakBlock(Player p, ItemStack item, Block b, int fortune, List<ItemStack> drops) {
    if (b.getType() != Material.AIR && !b.isLiquid() && !MaterialCollections.getAllUnbreakableBlocks().contains(b.getType()) && SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) {
        SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK);

        b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
        SlimefunItem sfItem = BlockStorage.check(b);

        if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
            SlimefunBlockHandler handler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());

            if (handler != null && !handler.onBreak(p, b, sfItem, UnregisterReason.PLAYER_BREAK)) {
                drops.add(BlockStorage.retrieve(b));
            }
        }
        else if (b.getType() == Material.PLAYER_HEAD || b.getType().name().endsWith("_SHULKER_BOX")) {
            b.breakNaturally();
        }
        else {
            boolean applyFortune = b.getType().name().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE;

            for (ItemStack drop : b.getDrops(getItem())) {
                // For some reason this check is necessary with Paper
                if (drop != null && drop.getType() != Material.AIR) {
                    b.getWorld().dropItemNaturally(b.getLocation(), applyFortune ? new CustomItem(drop, fortune) : drop);
                }
            }

            b.setType(Material.AIR);
        }

        damageItem(p, item);
    }
}
 
源代码12 项目: Slimefun4   文件: SwordOfBeheading.java
@Override
public EntityKillHandler getItemHandler() {
    return (e, entity, killer, item) -> {
        Random random = ThreadLocalRandom.current();

        if (e.getEntity() instanceof Zombie) {
            if (random.nextInt(100) < chanceZombie.getValue()) {
                e.getDrops().add(new ItemStack(Material.ZOMBIE_HEAD));
            }
        }
        else if (e.getEntity() instanceof WitherSkeleton) {
            if (random.nextInt(100) < chanceWitherSkeleton.getValue()) {
                e.getDrops().add(new ItemStack(Material.WITHER_SKELETON_SKULL));
            }
        }
        else if (e.getEntity() instanceof Skeleton) {
            if (random.nextInt(100) < chanceSkeleton.getValue()) {
                e.getDrops().add(new ItemStack(Material.SKELETON_SKULL));
            }
        }
        else if (e.getEntity() instanceof Creeper) {
            if (random.nextInt(100) < chanceCreeper.getValue()) {
                e.getDrops().add(new ItemStack(Material.CREEPER_HEAD));
            }
        }
        else if (e.getEntity() instanceof Player && random.nextInt(100) < chancePlayer.getValue()) {
            ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
            ItemMeta meta = skull.getItemMeta();
            ((SkullMeta) meta).setOwningPlayer((Player) e.getEntity());
            skull.setItemMeta(meta);

            e.getDrops().add(skull);
        }
    };
}
 
源代码13 项目: VoxelGamesLibv2   文件: MapScanner.java
/**
 * Searches the map for "markers". Most of the time these are implemented as tile entities (skulls)
 *
 * @param map    the map to scan
 * @param center the center location
 * @param range  the range in where to scan
 */
public void searchForMarkers(@Nonnull Map map, @Nonnull Vector3D center, int range, @Nonnull UUID gameid) {
    World world = Bukkit.getWorld(map.getLoadedName(gameid));
    if (world == null) {
        throw new MapException("Could not find world " + map.getLoadedName(gameid) + "(" + map.getInfo().getDisplayName() + ")" + ". Is it loaded?");
    }

    List<Marker> markers = new ArrayList<>();
    List<ChestMarker> chestMarkers = new ArrayList<>();

    int startX = (int) center.getX();
    int startY = (int) center.getZ();

    int minX = Math.min(startX - range, startX + range);
    int minZ = Math.min(startY - range, startY + range);

    int maxX = Math.max(startX - range, startX + range);
    int maxZ = Math.max(startY - range, startY + range);

    for (int x = minX; x <= maxX; x += 16) {
        for (int z = minZ; z <= maxZ; z += 16) {
            Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
            for (BlockState te : chunk.getTileEntities()) {
                if (te.getType() == Material.PLAYER_HEAD) {
                    Skull skull = (Skull) te;
                    String markerData = getMarkerData(skull);
                    if (markerData == null) continue;
                    MarkerDefinition markerDefinition = mapHandler.createMarkerDefinition(markerData);
                    markers.add(new Marker(new Vector3D(skull.getX(), skull.getY(), skull.getZ()),
                            DirectionUtil.directionToYaw(skull.getRotation()),
                            markerData, markerDefinition));
                } else if (te.getType() == Material.CHEST) {
                    Chest chest = (Chest) te;
                    String name = chest.getBlockInventory().getName();
                    ItemStack[] items = new ItemStack[chest.getBlockInventory()
                            .getStorageContents().length];
                    for (int i = 0; i < items.length; i++) {
                        ItemStack is = chest.getBlockInventory().getItem(i);
                        if (is == null) {
                            items[i] = new ItemStack(Material.AIR);
                        } else {
                            items[i] = is;
                        }
                    }
                    chestMarkers
                            .add(new ChestMarker(new Vector3D(chest.getX(), chest.getY(), chest.getZ()), name,
                                    items));
                }
            }
        }
    }

    map.setMarkers(markers);
    map.setChestMarkers(chestMarkers);
}
 
源代码14 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public boolean headCheck(Block h1) {
	return (h1.getType() == Material.PLAYER_WALL_HEAD || h1.getType() == Material.PLAYER_HEAD || h1.getType() == Material.SKELETON_SKULL);
}
 
源代码15 项目: SkyWarsReloaded   文件: NMSHandler.java
@Override
public ItemStack getBlankPlayerHead() {
	return new ItemStack(Material.PLAYER_HEAD, 1);
}
 
源代码16 项目: uSkyBlock   文件: SkyBlockMenu.java
public Inventory displayPartyPlayerGUI(final Player player, final String pname) {
    List<String> lores = new ArrayList<>();
    String emptyTitle = tr("{0} <{1}>", "", tr("Permissions"));
    String title = tr("{0} <{1}>", pname.substring(0, Math.min(32-emptyTitle.length(), pname.length())), tr("Permissions"));
    Inventory menu = Bukkit.createInventory(new UltimateHolder(player, title, MenuType.DEFAULT), 9, title);
    final ItemStack pHead = new ItemStack(Material.PLAYER_HEAD, 1);
    final SkullMeta meta3 = (SkullMeta) pHead.getItemMeta();
    ItemMeta meta2 = sign.getItemMeta();
    meta2.setDisplayName(tr("\u00a79Player Permissions"));
    addLore(lores, tr("\u00a7eClick here to return to\n\u00a7eyour island group''s info."));
    meta2.setLore(lores);
    sign.setItemMeta(meta2);
    menu.addItem(sign);
    lores.clear();
    meta3.setOwner(pname);
    meta3.setDisplayName(tr("\u00a7e{0}''\u00a79s Permissions", pname));
    addLore(lores, tr("\u00a7eHover over an icon to view\n\u00a7ea permission. Change the\n\u00a7epermission by clicking it."));
    meta3.setLore(lores);
    pHead.setItemMeta(meta3);
    menu.addItem(pHead);
    lores.clear();
    IslandInfo islandInfo = plugin.getIslandInfo(player);
    boolean isLeader = islandInfo.isLeader(player);
    for (PartyPermissionMenuItem menuItem : permissionMenuItems) {
        ItemStack itemStack = menuItem.getIcon();
        meta2 = itemStack.getItemMeta();
        if (islandInfo.hasPerm(pname, menuItem.getPerm())) {
            meta2.setDisplayName("\u00a7a" + menuItem.getTitle());
            lores.add(tr("\u00a7fThis player \u00a7acan"));
            addLore(lores, "\u00a7f", menuItem.getDescription());
            if (isLeader) {
                addLore(lores, "\u00a7f", tr("Click here to remove this permission."));
            }
        } else {
            meta2.setDisplayName("\u00a7c" + menuItem.getTitle());
            lores.add(tr("\u00a7fThis player \u00a7ccannot"));
            addLore(lores, "\u00a7f", menuItem.getDescription());
            if (isLeader) {
                addLore(lores, "\u00a7f", tr("Click here to grant this permission."));
            }
        }
        meta2.setLore(lores);
        itemStack.setItemMeta(meta2);
        menu.addItem(itemStack);
        lores.clear();
    }
    return menu;
}
 
源代码17 项目: uSkyBlock   文件: SkyBlockMenu.java
public Inventory displayPartyGUI(final Player player) {
    List<String> lores = new ArrayList<>();
    String title = "\u00a79" + tr("Island Group Members");
    Inventory menu = Bukkit.createInventory(new UltimateHolder(player, title, MenuType.DEFAULT), 18, title);
    IslandInfo islandInfo = plugin.getIslandInfo(player);
    final Set<String> memberList = islandInfo.getMembers();
    final ItemMeta meta2 = sign.getItemMeta();
    meta2.setDisplayName("\u00a7a" + tr("Island Group Members"));
    lores.add(tr("Group Members: \u00a72{0}\u00a77/\u00a7e{1}", islandInfo.getPartySize(), islandInfo.getMaxPartySize()));
    if (islandInfo.getPartySize() < islandInfo.getMaxPartySize()) {
        addLore(lores, tr("\u00a7aMore players can be invited to this island."));
    } else {
        addLore(lores, tr("\u00a7cThis island is full."));
    }
    addLore(lores, tr("\u00a7eHover over a player''s icon to\n\u00a7eview their permissions. The\n\u00a7eleader can change permissions\n\u00a7eby clicking a player''s icon."));
    meta2.setLore(lores);
    sign.setItemMeta(meta2);
    menu.addItem(sign.clone());
    lores.clear();
    for (String temp : memberList) {
        ItemStack headItem = new ItemStack(Material.PLAYER_HEAD, 1);
        SkullMeta meta3 = (SkullMeta) headItem.getItemMeta();
        meta3.setDisplayName(tr("\u00a7e{0}''s\u00a79 Permissions", temp));
        meta3.setOwner(temp);
        boolean isLeader = islandInfo.isLeader(temp);
        if (isLeader) {
            addLore(lores, "\u00a7a\u00a7l", tr("Leader"));
        } else {
            addLore(lores, "\u00a7e\u00a7l", tr("Member"));
        }
        for (PartyPermissionMenuItem perm : permissionMenuItems) {
            if (isLeader || islandInfo.hasPerm(temp, perm.getPerm())) {
                lores.add("\u00a7a" + tr("Can {0}", "\u00a7f" + perm.getShortDescription()));
            } else {
                lores.add("\u00a7c" + tr("Cannot {0}", "\u00a7f" + perm.getShortDescription()));
            }
        }
        if (islandInfo.isLeader(player.getName())) {
            addLore(lores, tr("\u00a7e<Click to change this player''s permissions>"));
        }
        meta3.setLore(lores);
        headItem.setItemMeta(meta3);
        menu.addItem(headItem);
        lores.clear();
    }
    return menu;
}
 
源代码18 项目: uSkyBlock   文件: SkyBlockMenu.java
private void onClickMainMenu(InventoryClickEvent event, ItemStack currentItem, Player p, int slotIndex) {
    event.setCancelled(true);
    if (slotIndex < 0 || slotIndex > 35) {
        return;
    }
    PlayerInfo playerInfo = plugin.getPlayerInfo(p);
    IslandInfo islandInfo = plugin.getIslandInfo(playerInfo);
    if (currentItem.getType() == Material.JUNGLE_SAPLING) {
        p.closeInventory();
        p.performCommand("island biome");
    } else if (currentItem.getType() == Material.PLAYER_HEAD) {
        p.closeInventory();
        p.performCommand("island party");
    } else if (currentItem.getType() == Material.RED_BED) {
        p.closeInventory();
        p.performCommand("island sethome");
        p.performCommand("island");
    } else if (currentItem.getType() == Material.GRASS) {
        p.closeInventory();
        p.performCommand("island spawn");
    } else if (currentItem.getType() == Material.HOPPER) {
        p.closeInventory();
        p.performCommand("island setwarp");
        p.performCommand("island");
    } else if (currentItem.getType() == Material.WRITABLE_BOOK) {
        p.closeInventory();
        p.performCommand("island log");
    } else if (currentItem.getType() == Material.OAK_DOOR) {
        p.closeInventory();
        p.performCommand("island home");
    } else if (currentItem.getType() == Material.EXPERIENCE_BOTTLE) {
        p.closeInventory();
        p.performCommand("island level");
    } else if (currentItem.getType() == Material.DIAMOND_ORE) {
        p.closeInventory();
        p.performCommand("c");
    } else if (currentItem.getType() == Material.END_STONE || currentItem.getType() == Material.END_PORTAL_FRAME) {
        p.closeInventory();
        p.performCommand("island togglewarp");
        p.performCommand("island");
    } else if (currentItem.getType() == Material.IRON_BARS && islandInfo.isLocked()) {
        p.closeInventory();
        p.performCommand("island unlock");
        p.performCommand("island");
    } else if (currentItem.getType() == Material.IRON_BARS && !islandInfo.isLocked()) {
        p.closeInventory();
        p.performCommand("island lock");
        p.performCommand("island");
    } else if (slotIndex == 17) {
        if (islandInfo.isLeader(p) && plugin.getConfig().getBoolean("island-schemes-enabled", true)) {
            p.closeInventory();
            p.openInventory(createRestartGUI(p));
        } else {
            if (plugin.getConfirmHandler().millisLeft(p, "/is leave") > 0) {
                p.closeInventory();
                p.performCommand("island leave");
            } else {
                p.performCommand("island leave");
                updateLeaveMenuItemTimer(p, event.getInventory(), currentItem);
            }
        }
    } else {
        if (!isExtraMenuAction(p, currentItem)) {
            p.closeInventory();
            p.performCommand("island");
        }
    }
}
 
源代码19 项目: uSkyBlock   文件: StringEditMenu.java
@Override
public boolean onClick(InventoryClickEvent e) {
    if (!(e.getInventory().getHolder() instanceof UltimateHolder) ||
            !stripFormatting(((UltimateHolder) e.getInventory().getHolder()).getTitle()).equals(stripFormatting(getTitle()))) {
        return false;
    }
    Player player = (Player) e.getWhoClicked();
    ItemStack returnItem = e.getInventory().getItem(0);
    String configName = returnItem.getItemMeta().getLore().get(0);
    String path = returnItem.getItemMeta().getLore().get(1);
    int page = getPage(returnItem.getItemMeta().getLore().get(2));
    ItemStack currentItem = e.getCurrentItem();
    boolean isCaps = e.getInventory().getItem(capsIndex).getItemMeta().getDisplayName().equals(tr("Caps On"));
    if (currentItem != null) {
        YmlConfiguration config = FileUtil.getYmlConfiguration(configName);
        String value = config.getString(path);
        if (e.getSlot() == capsIndex) {
            // Toggle caps
            ItemStack capsItem = isCaps ? capsOff.clone() : capsOn.clone();
            ItemMeta meta = capsItem.getItemMeta();
            meta.setLore(Arrays.asList(value));
            capsItem.setItemMeta(meta);
            e.getInventory().setItem(capsIndex, capsItem);
            isCaps = !isCaps;
        } else if (e.getSlot() == backspaceIndex) {
            if (value.length() > 0) {
                value = value.substring(0, value.length() - 1);
                config.set(path, value);
                config.set("dirty", true);
            }
        } else if (e.getSlot() == returnIndex) {
            player.openInventory(parent.createEditMenu(configName, path, page));
            return true;
        } else if (currentItem.getType() == Material.PLAYER_HEAD) {
            String character = stripFormatting(currentItem.getItemMeta().getDisplayName());
            if (character.isEmpty()) {
                character = " ";
            }
            value += isCaps ? character.toUpperCase() : character.toLowerCase();
            config.set(path, value);
            config.set("dirty", true);
        }
        // re-load the ui (refresh)
        player.openInventory(createEditMenuInternal(configName, path, page, isCaps));
    }
    return true;
}
 
源代码20 项目: Slimefun4   文件: ProgrammableAndroid.java
protected void tick(Block b) {
    if (b.getType() != Material.PLAYER_HEAD) {
        // The Android was destroyed or moved.
        return;
    }

    if ("false".equals(BlockStorage.getLocationInfo(b.getLocation(), "paused"))) {
        BlockMenu menu = BlockStorage.getInventory(b);
        float fuel = Float.parseFloat(BlockStorage.getLocationInfo(b.getLocation(), "fuel"));

        if (fuel < 0.001) {
            consumeFuel(b, menu);
        }
        else {
            String[] script = PatternUtils.DASH.split(BlockStorage.getLocationInfo(b.getLocation(), "script"));

            int index = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "index")) + 1;
            if (index >= script.length) {
                index = 0;
            }

            boolean refresh = true;
            BlockStorage.addBlockInfo(b, "fuel", String.valueOf(fuel - 1));
            Instruction instruction = Instruction.valueOf(script[index]);

            if (getAndroidType().isType(instruction.getRequiredType())) {
                BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));

                switch (instruction) {
                case START:
                case WAIT:
                    // Just "waiting" here which means we do nothing
                    break;
                case REPEAT:
                    BlockStorage.addBlockInfo(b, "index", String.valueOf(0));
                    break;
                case CHOP_TREE:
                    refresh = chopTree(b, menu, face);
                    break;
                default:
                    instruction.execute(this, b, menu, face);
                    break;
                }
            }

            if (refresh) {
                BlockStorage.addBlockInfo(b, "index", String.valueOf(index));
            }
        }
    }
}
 
 方法所在类
 同类方法