cn.nukkit.item.Item Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.item;
import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.api.PowerNukkitDifference;
import cn.nukkit.api.PowerNukkitOnly;
import cn.nukkit.api.Since;
import cn.nukkit.block.Block;
import cn.nukkit.block.BlockID;
import cn.nukkit.blockproperty.UnknownRuntimeIdException;
import cn.nukkit.blockproperty.exception.InvalidBlockPropertyMetaException;
import cn.nukkit.blockstate.BlockState;
import cn.nukkit.blockstate.BlockStateRegistry;
import cn.nukkit.blockstate.exception.InvalidBlockStateException;
import cn.nukkit.entity.Entity;
import cn.nukkit.inventory.Fuel;
import cn.nukkit.item.enchantment.Enchantment;
import cn.nukkit.level.Level;
import cn.nukkit.math.BlockFace;
import cn.nukkit.math.Vector3;
import cn.nukkit.nbt.NBTIO;
import cn.nukkit.nbt.tag.CompoundTag;
import cn.nukkit.nbt.tag.ListTag;
import cn.nukkit.nbt.tag.StringTag;
import cn.nukkit.nbt.tag.Tag;
import cn.nukkit.utils.Binary;
import cn.nukkit.utils.Config;
import cn.nukkit.utils.MainLogger;
import cn.nukkit.utils.Utils;
import io.netty.util.internal.EmptyArrays;
import it.unimi.dsi.fastutil.ints.Int2IntArrayMap;
import it.unimi.dsi.fastutil.ints.Int2IntMap;
import lombok.extern.log4j.Log4j2;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.Modifier;
import java.nio.ByteOrder;
import java.util.*;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author MagicDroidX (Nukkit Project)
*/
@Log4j2
public class Item implements Cloneable, BlockID, ItemID {
//Normal Item IDs
@PowerNukkitOnly
@Since("1.4.0.0-PN")
public static final Item[] EMPTY_ARRAY = new Item[0];
protected static String UNKNOWN_STR = "Unknown";
public static Class[] list = null;
private static Map itemIds = Arrays.stream(ItemID.class.getDeclaredFields())
.filter(field-> field.getModifiers() == (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL))
.filter(field -> field.getType().equals(int.class))
.collect(Collectors.toMap(
field -> field.getName().toLowerCase(),
field -> {
try {
return field.getInt(null);
} catch (IllegalAccessException e) {
throw new InternalError(e);
}
},
(e1, e2) -> e1, LinkedHashMap::new
));
private static Map blockIds = Arrays.stream(BlockID.class.getDeclaredFields())
.filter(field-> field.getModifiers() == (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL))
.filter(field -> field.getType().equals(int.class))
.collect(Collectors.toMap(
field -> field.getName().toLowerCase(),
field -> {
try {
int blockId = field.getInt(null);
if (blockId > 255) {
return 255 - blockId;
}
return blockId;
} catch (IllegalAccessException e) {
throw new InternalError(e);
}
},
(e1, e2) -> e1, LinkedHashMap::new
));
protected Block block = null;
protected final int id;
protected int meta;
protected boolean hasMeta = true;
private byte[] tags = EmptyArrays.EMPTY_BYTES;
private transient CompoundTag cachedNBT = null;
public int count;
protected int durability = 0;
protected String name;
public Item(int id) {
this(id, 0, 1, UNKNOWN_STR);
}
public Item(int id, Integer meta) {
this(id, meta, 1, UNKNOWN_STR);
}
public Item(int id, Integer meta, int count) {
this(id, meta, count, UNKNOWN_STR);
}
public Item(int id, Integer meta, int count, String name) {
//this.id = id & 0xffff;
this.id = id;
if (meta != null && meta >= 0) {
this.meta = meta & 0xffff;
} else {
this.hasMeta = false;
}
this.count = count;
this.name = name != null? name.intern() : null;
/*f (this.block != null && this.id <= 0xff && Block.list[id] != null) { //probably useless
this.block = Block.get(this.id, this.meta);
this.name = this.block.getName();
}*/
}
public boolean hasMeta() {
return hasMeta;
}
public boolean canBeActivated() {
return false;
}
public static void init() {
if (list == null) {
list = new Class[65535];
list[IRON_SHOVEL] = ItemShovelIron.class; //256
list[IRON_PICKAXE] = ItemPickaxeIron.class; //257
list[IRON_AXE] = ItemAxeIron.class; //258
list[FLINT_AND_STEEL] = ItemFlintSteel.class; //259
list[APPLE] = ItemApple.class; //260
list[BOW] = ItemBow.class; //261
list[ARROW] = ItemArrow.class; //262
list[COAL] = ItemCoal.class; //263
list[DIAMOND] = ItemDiamond.class; //264
list[IRON_INGOT] = ItemIngotIron.class; //265
list[GOLD_INGOT] = ItemIngotGold.class; //266
list[IRON_SWORD] = ItemSwordIron.class; //267
list[WOODEN_SWORD] = ItemSwordWood.class; //268
list[WOODEN_SHOVEL] = ItemShovelWood.class; //269
list[WOODEN_PICKAXE] = ItemPickaxeWood.class; //270
list[WOODEN_AXE] = ItemAxeWood.class; //271
list[STONE_SWORD] = ItemSwordStone.class; //272
list[STONE_SHOVEL] = ItemShovelStone.class; //273
list[STONE_PICKAXE] = ItemPickaxeStone.class; //274
list[STONE_AXE] = ItemAxeStone.class; //275
list[DIAMOND_SWORD] = ItemSwordDiamond.class; //276
list[DIAMOND_SHOVEL] = ItemShovelDiamond.class; //277
list[DIAMOND_PICKAXE] = ItemPickaxeDiamond.class; //278
list[DIAMOND_AXE] = ItemAxeDiamond.class; //279
list[STICK] = ItemStick.class; //280
list[BOWL] = ItemBowl.class; //281
list[MUSHROOM_STEW] = ItemMushroomStew.class; //282
list[GOLD_SWORD] = ItemSwordGold.class; //283
list[GOLD_SHOVEL] = ItemShovelGold.class; //284
list[GOLD_PICKAXE] = ItemPickaxeGold.class; //285
list[GOLD_AXE] = ItemAxeGold.class; //286
list[STRING] = ItemString.class; //287
list[FEATHER] = ItemFeather.class; //288
list[GUNPOWDER] = ItemGunpowder.class; //289
list[WOODEN_HOE] = ItemHoeWood.class; //290
list[STONE_HOE] = ItemHoeStone.class; //291
list[IRON_HOE] = ItemHoeIron.class; //292
list[DIAMOND_HOE] = ItemHoeDiamond.class; //293
list[GOLD_HOE] = ItemHoeGold.class; //294
list[WHEAT_SEEDS] = ItemSeedsWheat.class; //295
list[WHEAT] = ItemWheat.class; //296
list[BREAD] = ItemBread.class; //297
list[LEATHER_CAP] = ItemHelmetLeather.class; //298
list[LEATHER_TUNIC] = ItemChestplateLeather.class; //299
list[LEATHER_PANTS] = ItemLeggingsLeather.class; //300
list[LEATHER_BOOTS] = ItemBootsLeather.class; //301
list[CHAIN_HELMET] = ItemHelmetChain.class; //302
list[CHAIN_CHESTPLATE] = ItemChestplateChain.class; //303
list[CHAIN_LEGGINGS] = ItemLeggingsChain.class; //304
list[CHAIN_BOOTS] = ItemBootsChain.class; //305
list[IRON_HELMET] = ItemHelmetIron.class; //306
list[IRON_CHESTPLATE] = ItemChestplateIron.class; //307
list[IRON_LEGGINGS] = ItemLeggingsIron.class; //308
list[IRON_BOOTS] = ItemBootsIron.class; //309
list[DIAMOND_HELMET] = ItemHelmetDiamond.class; //310
list[DIAMOND_CHESTPLATE] = ItemChestplateDiamond.class; //311
list[DIAMOND_LEGGINGS] = ItemLeggingsDiamond.class; //312
list[DIAMOND_BOOTS] = ItemBootsDiamond.class; //313
list[GOLD_HELMET] = ItemHelmetGold.class; //314
list[GOLD_CHESTPLATE] = ItemChestplateGold.class; //315
list[GOLD_LEGGINGS] = ItemLeggingsGold.class; //316
list[GOLD_BOOTS] = ItemBootsGold.class; //317
list[FLINT] = ItemFlint.class; //318
list[RAW_PORKCHOP] = ItemPorkchopRaw.class; //319
list[COOKED_PORKCHOP] = ItemPorkchopCooked.class; //320
list[PAINTING] = ItemPainting.class; //321
list[GOLDEN_APPLE] = ItemAppleGold.class; //322
list[SIGN] = ItemSign.class; //323
list[WOODEN_DOOR] = ItemDoorWood.class; //324
list[BUCKET] = ItemBucket.class; //325
list[MINECART] = ItemMinecart.class; //328
list[SADDLE] = ItemSaddle.class; //329
list[IRON_DOOR] = ItemDoorIron.class; //330
list[REDSTONE] = ItemRedstone.class; //331
list[SNOWBALL] = ItemSnowball.class; //332
list[BOAT] = ItemBoat.class; //333
list[LEATHER] = ItemLeather.class; //334
list[KELP] = ItemKelp.class; //335
list[BRICK] = ItemBrick.class; //336
list[CLAY] = ItemClay.class; //337
list[SUGARCANE] = ItemSugarcane.class; //338
list[PAPER] = ItemPaper.class; //339
list[BOOK] = ItemBook.class; //340
list[SLIMEBALL] = ItemSlimeball.class; //341
list[MINECART_WITH_CHEST] = ItemMinecartChest.class; //342
list[EGG] = ItemEgg.class; //344
list[COMPASS] = ItemCompass.class; //345
list[FISHING_ROD] = ItemFishingRod.class; //346
list[CLOCK] = ItemClock.class; //347
list[GLOWSTONE_DUST] = ItemGlowstoneDust.class; //348
list[RAW_FISH] = ItemFish.class; //349
list[COOKED_FISH] = ItemFishCooked.class; //350
list[DYE] = ItemDye.class; //351
list[BONE] = ItemBone.class; //352
list[SUGAR] = ItemSugar.class; //353
list[CAKE] = ItemCake.class; //354
list[BED] = ItemBed.class; //355
list[REPEATER] = ItemRedstoneRepeater.class; //356
list[COOKIE] = ItemCookie.class; //357
list[MAP] = ItemMap.class; //358
list[SHEARS] = ItemShears.class; //359
list[MELON] = ItemMelon.class; //360
list[PUMPKIN_SEEDS] = ItemSeedsPumpkin.class; //361
list[MELON_SEEDS] = ItemSeedsMelon.class; //362
list[RAW_BEEF] = ItemBeefRaw.class; //363
list[STEAK] = ItemSteak.class; //364
list[RAW_CHICKEN] = ItemChickenRaw.class; //365
list[COOKED_CHICKEN] = ItemChickenCooked.class; //366
list[ROTTEN_FLESH] = ItemRottenFlesh.class; //367
list[ENDER_PEARL] = ItemEnderPearl.class; //368
list[BLAZE_ROD] = ItemBlazeRod.class; //369
list[GHAST_TEAR] = ItemGhastTear.class; //370
list[GOLD_NUGGET] = ItemNuggetGold.class; //371
list[NETHER_WART] = ItemNetherWart.class; //372
list[POTION] = ItemPotion.class; //373
list[GLASS_BOTTLE] = ItemGlassBottle.class; //374
list[SPIDER_EYE] = ItemSpiderEye.class; //375
list[FERMENTED_SPIDER_EYE] = ItemSpiderEyeFermented.class; //376
list[BLAZE_POWDER] = ItemBlazePowder.class; //377
list[MAGMA_CREAM] = ItemMagmaCream.class; //378
list[BREWING_STAND] = ItemBrewingStand.class; //379
list[CAULDRON] = ItemCauldron.class; //380
list[ENDER_EYE] = ItemEnderEye.class; //381
list[GLISTERING_MELON] = ItemMelonGlistering.class; //382
list[SPAWN_EGG] = ItemSpawnEgg.class; //383
list[EXPERIENCE_BOTTLE] = ItemExpBottle.class; //384
list[FIRE_CHARGE] = ItemFireCharge.class; //385
list[BOOK_AND_QUILL] = ItemBookAndQuill.class; //386
list[WRITTEN_BOOK] = ItemBookWritten.class; //387
list[EMERALD] = ItemEmerald.class; //388
list[ITEM_FRAME] = ItemItemFrame.class; //389
list[FLOWER_POT] = ItemFlowerPot.class; //390
list[CARROT] = ItemCarrot.class; //391
list[POTATO] = ItemPotato.class; //392
list[BAKED_POTATO] = ItemPotatoBaked.class; //393
list[POISONOUS_POTATO] = ItemPotatoPoisonous.class; //394
list[EMPTY_MAP] = ItemEmptyMap.class; //395
list[GOLDEN_CARROT] = ItemCarrotGolden.class; //396
list[SKULL] = ItemSkull.class; //397
list[CARROT_ON_A_STICK] = ItemCarrotOnAStick.class; //398
list[NETHER_STAR] = ItemNetherStar.class; //399
list[PUMPKIN_PIE] = ItemPumpkinPie.class; //400
list[FIREWORKS] = ItemFirework.class; //401
list[ENCHANTED_BOOK] = ItemBookEnchanted.class; //403
list[COMPARATOR] = ItemRedstoneComparator.class; //404
list[NETHER_BRICK] = ItemNetherBrick.class; //405
list[QUARTZ] = ItemQuartz.class; //406
list[MINECART_WITH_TNT] = ItemMinecartTNT.class; //407
list[MINECART_WITH_HOPPER] = ItemMinecartHopper.class; //408
list[PRISMARINE_SHARD] = ItemPrismarineShard.class; //409
list[HOPPER] = ItemHopper.class;
list[RAW_RABBIT] = ItemRabbitRaw.class; //411
list[COOKED_RABBIT] = ItemRabbitCooked.class; //412
list[RABBIT_STEW] = ItemRabbitStew.class; //413
list[RABBIT_FOOT] = ItemRabbitFoot.class; //414
list[RABBIT_HIDE] = ItemRabbitHide.class; //415
list[LEATHER_HORSE_ARMOR] = ItemHorseArmorLeather.class; //416
list[IRON_HORSE_ARMOR] = ItemHorseArmorIron.class; //417
list[GOLD_HORSE_ARMOR] = ItemHorseArmorGold.class; //418
list[DIAMOND_HORSE_ARMOR] = ItemHorseArmorDiamond.class; //419
list[LEAD] = ItemLead.class; //420
list[NAME_TAG] = ItemNameTag.class; //421
list[PRISMARINE_CRYSTALS] = ItemPrismarineCrystals.class; //422
list[RAW_MUTTON] = ItemMuttonRaw.class; //423
list[COOKED_MUTTON] = ItemMuttonCooked.class; //424
list[Item.ARMOR_STAND] = ItemArmorStand.class; //425
list[END_CRYSTAL] = ItemEndCrystal.class; //426
list[SPRUCE_DOOR] = ItemDoorSpruce.class; //427
list[BIRCH_DOOR] = ItemDoorBirch.class; //428
list[JUNGLE_DOOR] = ItemDoorJungle.class; //429
list[ACACIA_DOOR] = ItemDoorAcacia.class; //430
list[DARK_OAK_DOOR] = ItemDoorDarkOak.class; //431
list[CHORUS_FRUIT] = ItemChorusFruit.class; //432
list[POPPED_CHORUS_FRUIT] = ItemChorusFruitPopped.class; //433
list[BANNER_PATTERN] = ItemBannerPattern.class; //434
list[DRAGON_BREATH] = ItemDragonBreath.class; //437
list[SPLASH_POTION] = ItemPotionSplash.class; //438
list[LINGERING_POTION] = ItemPotionLingering.class; //441
list[ELYTRA] = ItemElytra.class; //444
list[SHULKER_SHELL] = ItemShulkerShell.class; //445
list[BANNER] = ItemBanner.class; //446
list[TOTEM] = ItemTotem.class; //450
list[IRON_NUGGET] = ItemNuggetIron.class; //452
list[TRIDENT] = ItemTrident.class; //455
list[BEETROOT] = ItemBeetroot.class; //457
list[BEETROOT_SEEDS] = ItemSeedsBeetroot.class; //458
list[BEETROOT_SOUP] = ItemBeetrootSoup.class; //459
list[RAW_SALMON] = ItemSalmon.class; //460
list[CLOWNFISH] = ItemClownfish.class; //461
list[PUFFERFISH] = ItemPufferfish.class; //462
list[COOKED_SALMON] = ItemSalmonCooked.class; //463
list[DRIED_KELP] = ItemDriedKelp.class; //464
list[GOLDEN_APPLE_ENCHANTED] = ItemAppleGoldEnchanted.class; //466
list[TURTLE_SHELL] = ItemTurtleShell.class; //469
list[SPRUCE_SIGN] = ItemSpruceSign.class; //472
list[BIRCH_SIGN] = ItemBirchSign.class; //473
list[JUNGLE_SIGN] = ItemJungleSign.class; //474
list[ACACIA_SIGN] = ItemAcaciaSign.class; //475
list[DARKOAK_SIGN] = ItemDarkOakSign.class; //476
list[SWEET_BERRIES] = ItemSweetBerries.class; //477
list[RECORD_13] = ItemRecord13.class; //500
list[RECORD_CAT] = ItemRecordCat.class; //501
list[RECORD_BLOCKS] = ItemRecordBlocks.class; //502
list[RECORD_CHIRP] = ItemRecordChirp.class; //503
list[RECORD_FAR] = ItemRecordFar.class; //504
list[RECORD_MALL] = ItemRecordMall.class; //505
list[RECORD_MELLOHI] = ItemRecordMellohi.class; //506
list[RECORD_STAL] = ItemRecordStal.class; //507
list[RECORD_STRAD] = ItemRecordStrad.class; //508
list[RECORD_WARD] = ItemRecordWard.class; //509
list[RECORD_11] = ItemRecord11.class; //510
list[RECORD_WAIT] = ItemRecordWait.class; //511
list[SHIELD] = ItemShield.class; //513
list[CAMPFIRE] = ItemCampfire.class; //720
list[SUSPICIOUS_STEW] = ItemSuspiciousStew.class; //734
list[HONEYCOMB] = ItemHoneycomb.class; //736
list[HONEY_BOTTLE] = ItemHoneyBottle.class; //737
list[LODESTONECOMPASS] = ItemCompassLodestone.class; //741;
list[NETHERITE_INGOT] = ItemIngotNetherite.class; //742
list[NETHERITE_SWORD] = ItemSwordNetherite.class; //743
list[NETHERITE_SHOVEL] = ItemShovelNetherite.class; //744
list[NETHERITE_PICKAXE] = ItemPickaxeNetherite.class; //745
list[NETHERITE_AXE] = ItemAxeNetherite.class; //746
list[NETHERITE_HOE] = ItemHoeNetherite.class; //747
list[NETHERITE_HELMET] = ItemHelmetNetherite.class; //748
list[NETHERITE_CHESTPLATE] = ItemChestplateNetherite.class; //749
list[NETHERITE_LEGGINGS] = ItemLeggingsNetherite.class; //750
list[NETHERITE_BOOTS] = ItemBootsNetherite.class; //751
list[NETHERITE_SCRAP] = ItemScrapNetherite.class; //752
list[CRIMSON_SIGN] = ItemCrimsonSign.class; //753
list[WARPED_SIGN] = ItemWarpedSign.class; //754
list[CRIMSON_DOOR] = ItemDoorCrimson.class; //755
list[WARPED_DOOR] = ItemDoorWarped.class; //756
list[WARPED_FUNGUS_ON_A_STICK] = ItemWarpedFungusOnAStick.class; //757
list[CHAIN] = ItemChain.class; //758
list[RECORD_PIGSTEP] = ItemRecordPigstep.class; //759
list[NETHER_SPROUTS] = ItemNetherSprouts.class; //760
list[SOUL_CAMPFIRE] = ItemCampfireSoul.class; //801
list[COD_BUCKET] = ItemBucketFishCod.class; //802
list[GHAST_SPAWN_EGG] = ItemSpawnEggGhast.class; //803
list[FLOWER_BANNER_PATTERN] = ItemBannerPatternFlower.class; //804
list[ZOGLIN_SPAWN_EGG] = ItemSpawnEggZoglin.class; //805
list[BLUE_DYE] = ItemDyeBlue.class; //806
list[SKULL_BANNER_PATTERN] = ItemBannerPatternSkull.class; //807
list[ENDERMITE_SPAWN_EGG] = ItemSpawnEggEndermite.class; //808
list[POLAR_BEAR_SPAWN_EGG] = ItemSpawnEggPolarBear.class; //809
list[WHITE_DYE] = ItemDyeWhite.class; //810
list[TROPICAL_FISH_BUCKET] = ItemBucketFishTropical.class; //811
list[CYAN_DYE] = ItemDyeCyan.class; //812
list[LIGHT_BLUE_DYE] = ItemDyeLightBlue.class; //813
list[LIME_DYE] = ItemDyeLime.class; //814
list[ZOMBIE_VILLAGER_SPAWN_EGG] = ItemSpawnEggZombieVillager.class; //815
list[STRAY_SPAWN_EGG] = ItemSpawnEggStray.class; //816
list[GREEN_DYE] = ItemDyeGreen.class; //817
list[EVOKER_SPAWN_EGG] = ItemSpawnEggEvoker.class; //818
list[WITHER_SKELETON_SPAWN_EGG] = ItemSpawnEggWitherSkeleton.class; //819
list[SALMON_BUCKET] = ItemBucketFishSalmon.class; //820
list[JUNGLE_BOAT] = ItemBoatJungle.class; //821
list[BLACK_DYE] = ItemDyeBlack.class; //822
list[MAGMA_CUBE_SPAWN_EGG] = ItemSpawnEggMagmaCube.class; //823
list[TROPICAL_FISH_SPAWN_EGG] = ItemSpawnEggTropicalFish.class; //824
list[VEX_SPAWN_EGG] = ItemSpawnEggVex.class; //825
list[FIELD_MASONED_BANNER_PATTERN] = ItemBannerPatternFieldMasoned.class; //826
list[WANDERING_TRADER_SPAWN_EGG] = ItemSpawnEggWanderingTrader.class; //827
list[BROWN_DYE] = ItemDyeBrown.class; //828
list[PANDA_SPAWN_EGG] = ItemSpawnEggPanda.class; //829
list[SILVERFISH_SPAWN_EGG] = ItemSpawnEggSilverfish.class; //830
list[OCELOT_SPAWN_EGG] = ItemSpawnEggOcelot.class; //831
list[LAVA_BUCKET] = ItemBucketLava.class; //832
list[SKELETON_SPAWN_EGG] = ItemSpawnEggSkeleton.class; //833
list[VILLAGER_SPAWN_EGG] = ItemSpawnEggVillager.class; //834
list[ELDER_GUARDIAN_SPAWN_EGG] = ItemSpawnEggElderGuardian.class; //835
list[ACACIA_BOAT] = ItemBoatAcacia.class; //836
list[OAK_BOAT] = ItemBoatOak.class; //837
list[PHANTOM_SPAWN_EGG] = ItemSpawnEggPhantom.class; //838
list[HOGLIN_SPAWN_EGG] = ItemSpawnEggHoglin.class; //839
list[DARK_OAK_BOAT] = ItemBoatDarkOak.class; //840
list[HUSK_SPAWN_EGG] = ItemSpawnEggHusk.class; //841
list[BLAZE_SPAWN_EGG] = ItemSpawnEggBlaze.class; //842
list[BORDURE_INDENTED_BANNER_PATTERN] = ItemBannerPatternBordureIndented.class; //843
list[MULE_SPAWN_EGG] = ItemSpawnEggMule.class; //844
list[CREEPER_BANNER_PATTERN] = ItemBannerPatternCreeper.class; //845
list[ZOMBIE_HORSE_SPAWN_EGG] = ItemSpawnEggZombieHorse.class; //846
list[BEE_SPAWN_EGG] = ItemSpawnEggBee.class; //847
list[COD_SPAWN_EGG] = ItemSpawnEggCod.class; //848
list[LLAMA_SPAWN_EGG] = ItemSpawnEggLlama.class; //849
list[FOX_SPAWN_EGG] = ItemSpawnEggFox.class; //850
list[PIGLIN_BRUTE_SPAWN_EGG] = ItemSpawnEggPiglinBrute.class; //851
list[PIG_SPAWN_EGG] = ItemSpawnEggPig.class; //852
list[COW_SPAWN_EGG] = ItemSpawnEggCow.class; //853
list[NPC_SPAWN_EGG] = ItemSpawnEggNpc.class; //854
list[SQUID_SPAWN_EGG] = ItemSpawnEggSquid.class; //855
list[MAGENTA_DYE] = ItemDyeMagenta.class; //856
list[RED_DYE] = ItemDyeRed.class; //857
list[WITCH_SPAWN_EGG] = ItemSpawnEggWitch.class; //858
list[INK_SAC] = ItemInkSac.class; //859
list[ORANGE_DYE] = ItemDyeOrange.class; //860
list[PILLAGER_SPAWN_EGG] = ItemSpawnEggPillager.class; //861
list[CAVE_SPIDER_SPAWN_EGG] = ItemSpawnEggCaveSpider.class; //862
list[BONE_MEAL] = ItemBoneMeal.class; //863
list[PUFFERFISH_BUCKET] = ItemBucketFishPufferfish.class; //864
list[BAT_SPAWN_EGG] = ItemSpawnEggBat.class; //865
list[SPRUCE_BOAT] = ItemBoatSpruce.class; //866
list[SPIDER_SPAWN_EGG] = ItemSpawnEggSpider.class; //867
list[PIGLIN_BANNER_PATTERN] = ItemBannerPatternPiglin.class; //868
list[RABBIT_SPAWN_EGG] = ItemSpawnEggRabbit.class; //869
list[MOJANG_BANNER_PATTERN] = ItemBannerPatternMojang.class; //870
list[PIGLIN_SPAWN_EGG] = ItemSpawnEggPiglin.class; //871
list[TURTLE_SPAWN_EGG] = ItemSpawnEggTurtle.class; //872
list[MOOSHROOM_SPAWN_EGG] = ItemSpawnEggMooshroom.class; //873
list[PUFFERFISH_SPAWN_EGG] = ItemSpawnEggPufferfish.class; //874
list[PARROT_SPAWN_EGG] = ItemSpawnEggParrot.class; //875
list[ZOMBIE_SPAWN_EGG] = ItemSpawnEggZombie.class; //876
list[WOLF_SPAWN_EGG] = ItemSpawnEggWolf.class; //877
list[GRAY_DYE] = ItemDyeGray.class; //878
list[COCOA_BEANS] = ItemCocoaBeans.class; //879
list[SKELETON_HORSE_SPAWN_EGG] = ItemSpawnEggSkeletonHorse.class; //880
list[SHEEP_SPAWN_EGG] = ItemSpawnEggSheep.class; //881
list[SLIME_SPAWN_EGG] = ItemSpawnEggSlime.class; //882
list[VINDICATOR_SPAWN_EGG] = ItemSpawnEggVindicator.class; //883
list[DROWNED_SPAWN_EGG] = ItemSpawnEggDrowned.class; //884
list[MILK_BUCKET] = ItemBucketMilk.class; //885
list[DOLPHIN_SPAWN_EGG] = ItemSpawnEggDolphin.class; //886
list[DONKEY_SPAWN_EGG] = ItemSpawnEggDonkey.class; //887
list[PURPLE_DYE] = ItemDyePurple.class; //888
list[BIRCH_BOAT] = ItemBoatBirch.class; //889
//list[DEBUG_STICK] = Item.Debug_stick.class; //890
list[ENDERMAN_SPAWN_EGG] = ItemSpawnEggEnderman.class; //891
list[CHICKEN_SPAWN_EGG] = ItemSpawnEggChicken.class; //892
list[SHULKER_SPAWN_EGG] = ItemSpawnEggShulker.class; //893
list[STRIDER_SPAWN_EGG] = ItemSpawnEggStrider.class; //894
list[ZOMBIE_PIGMAN_SPAWN_EGG] = ItemSpawnEggZombiePigman.class; //895
list[YELLOW_DYE] = ItemDyeYellow.class; //896
list[CAT_SPAWN_EGG] = ItemSpawnEggCat.class; //897
list[GUARDIAN_SPAWN_EGG] = ItemSpawnEggGuardian.class; //898
list[PINK_DYE] = ItemDyePink.class; //899
list[SALMON_SPAWN_EGG] = ItemSpawnEggSalmon.class; //900
list[CREEPER_SPAWN_EGG] = ItemSpawnEggCreeper.class; //901
list[HORSE_SPAWN_EGG] = ItemSpawnEggHorse.class; //902
list[LAPIS_LAZULI] = ItemLapisLazuli.class; //903
list[RAVAGER_SPAWN_EGG] = ItemSpawnEggRavager.class; //904
list[WATER_BUCKET] = ItemBucketWater.class; //905
list[LIGHT_GRAY_DYE] = ItemDyeLightGray.class; //906
list[CHARCOAL] = ItemCharcoal.class; //907
list[AGENT_SPAWN_EGG] = ItemSpawnEggAgent.class; //908
for (int i = 0; i < 256; ++i) {
if (Block.list[i] != null) {
list[i] = Block.list[i];
}
}
}
initCreativeItems();
}
private static List itemList;
@PowerNukkitOnly
@Since("1.4.0.0-PN")
public static List rebuildItemList() {
return itemList = Collections.unmodifiableList(Stream.of(
BlockStateRegistry.getPersistenceNames().stream()
.map(name-> name.substring(name.indexOf(':') + 1)),
itemIds.keySet().stream()
).flatMap(Function.identity()).distinct().collect(Collectors.toList()));
}
@PowerNukkitOnly
@Since("1.4.0.0-PN")
public static List getItemList() {
List itemList = Item.itemList;
if (itemList == null) {
return rebuildItemList();
}
return itemList;
}
private static final ArrayList- creative = new ArrayList<>();
@SuppressWarnings("unchecked")
private static void initCreativeItems() {
clearCreativeItems();
Config config = new Config(Config.JSON);
config.load(Server.class.getClassLoader().getResourceAsStream("creativeitems.json"));
List