> targets = new Int2ObjectOpenHashMap<>();
- for (Player player : players) {
- targets.computeIfAbsent(player.protocol, i -> new ObjectArrayList<>()).add(player);
- }
- return targets;
- }
-
- /**
- * Checks the current thread against the expected primary thread for the server.
- *
- * Note: this method should not be used to indicate the current synchronized state of the runtime. A current thread matching the main thread indicates that it is synchronized, but a mismatch does not preclude the same assumption.
- *
- * @return true if the current thread matches the expected primary thread, false otherwise
- */
- public boolean isPrimaryThread() {
- return (Thread.currentThread() == currentThread);
- }
-
- /**
- * Get server's primary thread
- *
- * @return primary thread
- */
- public Thread getPrimaryThread() {
- return currentThread;
- }
-
- /**
- * Internal method to register all default entities
- */
- private static void registerEntities() {
- //Items
- Entity.registerEntity("Item", EntityItem.class);
- Entity.registerEntity("Painting", EntityPainting.class);
- Entity.registerEntity("XpOrb", EntityXPOrb.class);
- Entity.registerEntity("ArmorStand", EntityArmorStand.class);
- Entity.registerEntity("EndCrystal", EntityEndCrystal.class);
- Entity.registerEntity("FallingSand", EntityFallingBlock.class);
- Entity.registerEntity("PrimedTnt", EntityPrimedTNT.class);
- Entity.registerEntity("Firework", EntityFirework.class);
- //Projectiles
- Entity.registerEntity("Arrow", EntityArrow.class);
- Entity.registerEntity("Snowball", EntitySnowball.class);
- Entity.registerEntity("EnderPearl", EntityEnderPearl.class);
- Entity.registerEntity("ThrownExpBottle", EntityExpBottle.class);
- Entity.registerEntity("ThrownPotion", EntityPotion.class);
- Entity.registerEntity("Egg", EntityEgg.class);
- Entity.registerEntity("BlazeFireBall", EntityBlazeFireBall.class);
- Entity.registerEntity("GhastFireBall", EntityGhastFireBall.class);
- Entity.registerEntity("ShulkerBullet", EntityShulkerBullet.class);
- Entity.registerEntity("ThrownLingeringPotion", EntityPotionLingering.class);
- Entity.registerEntity("ThrownTrident", EntityThrownTrident.class);
- Entity.registerEntity("WitherSkull", EntityWitherSkull.class);
- Entity.registerEntity("BlueWitherSkull", EntityBlueWitherSkull.class);
- Entity.registerEntity("LlamaSpit", EntityLlamaSpit.class);
- Entity.registerEntity("EvocationFangs", EntityEvocationFangs.class);
- Entity.registerEntity("EnderCharge", EntityEnderCharge.class);
- Entity.registerEntity("FishingHook", EntityFishingHook.class);
- //Monsters
- Entity.registerEntity("Blaze", EntityBlaze.class);
- Entity.registerEntity("Creeper", EntityCreeper.class);
- Entity.registerEntity("CaveSpider", EntityCaveSpider.class);
- Entity.registerEntity("Drowned", EntityDrowned.class);
- Entity.registerEntity("ElderGuardian", EntityElderGuardian.class);
- Entity.registerEntity("EnderDragon", EntityEnderDragon.class);
- Entity.registerEntity("Enderman", EntityEnderman.class);
- Entity.registerEntity("Endermite", EntityEndermite.class);
- Entity.registerEntity("Evoker", EntityEvoker.class);
- Entity.registerEntity("Ghast", EntityGhast.class);
- Entity.registerEntity("Guardian", EntityGuardian.class);
- Entity.registerEntity("Husk", EntityHusk.class);
- Entity.registerEntity("MagmaCube", EntityMagmaCube.class);
- Entity.registerEntity("Phantom", EntityPhantom.class);
- Entity.registerEntity("Ravager", EntityRavager.class);
- Entity.registerEntity("Shulker", EntityShulker.class);
- Entity.registerEntity("Silverfish", EntitySilverfish.class);
- Entity.registerEntity("Skeleton", EntitySkeleton.class);
- Entity.registerEntity("SkeletonHorse", EntitySkeletonHorse.class);
- Entity.registerEntity("Slime", EntitySlime.class);
- Entity.registerEntity("Spider", EntitySpider.class);
- Entity.registerEntity("Stray", EntityStray.class);
- Entity.registerEntity("Vindicator", EntityVindicator.class);
- Entity.registerEntity("Vex", EntityVex.class);
- Entity.registerEntity("WitherSkeleton", EntityWitherSkeleton.class);
- Entity.registerEntity("Wither", EntityWither.class);
- Entity.registerEntity("Witch", EntityWitch.class);
- Entity.registerEntity("ZombiePigman", EntityZombiePigman.class);
- Entity.registerEntity("ZombieVillager", EntityZombieVillager.class);
- Entity.registerEntity("Zombie", EntityZombie.class);
- Entity.registerEntity("Pillager", EntityPillager.class);
- Entity.registerEntity("ZombieVillagerV2", EntityZombieVillagerV2.class);
- Entity.registerEntity("Hoglin", EntityHoglin.class);
- Entity.registerEntity("Piglin", EntityPiglin.class);
- Entity.registerEntity("Zoglin", EntityZoglin.class);
- Entity.registerEntity("PiglinBrute", EntityPiglinBrute.class);
- //Passive
- Entity.registerEntity("Bat", EntityBat.class);
- Entity.registerEntity("Cat", EntityCat.class);
- Entity.registerEntity("Chicken", EntityChicken.class);
- Entity.registerEntity("Cod", EntityCod.class);
- Entity.registerEntity("Cow", EntityCow.class);
- Entity.registerEntity("Dolphin", EntityDolphin.class);
- Entity.registerEntity("Donkey", EntityDonkey.class);
- Entity.registerEntity("Horse", EntityHorse.class);
- Entity.registerEntity("IronGolem", EntityIronGolem.class);
- Entity.registerEntity("Llama", EntityLlama.class);
- Entity.registerEntity("Mooshroom", EntityMooshroom.class);
- Entity.registerEntity("Mule", EntityMule.class);
- Entity.registerEntity("Panda", EntityPanda.class);
- Entity.registerEntity("Parrot", EntityParrot.class);
- Entity.registerEntity("PolarBear", EntityPolarBear.class);
- Entity.registerEntity("Pig", EntityPig.class);
- Entity.registerEntity("Pufferfish", EntityPufferfish.class);
- Entity.registerEntity("Rabbit", EntityRabbit.class);
- Entity.registerEntity("Salmon", EntitySalmon.class);
- Entity.registerEntity("Sheep", EntitySheep.class);
- Entity.registerEntity("Squid", EntitySquid.class);
- Entity.registerEntity("SnowGolem", EntitySnowGolem.class);
- Entity.registerEntity("TropicalFish", EntityTropicalFish.class);
- Entity.registerEntity("Turtle", EntityTurtle.class);
- Entity.registerEntity("Wolf", EntityWolf.class);
- Entity.registerEntity("Ocelot", EntityOcelot.class);
- Entity.registerEntity("Villager", EntityVillager.class);
- Entity.registerEntity("ZombieHorse", EntityZombieHorse.class);
- Entity.registerEntity("WanderingTrader", EntityWanderingTrader.class);
- Entity.registerEntity("VillagerV2", EntityVillagerV2.class);
- Entity.registerEntity("Fox", EntityFox.class);
- Entity.registerEntity("Bee", EntityBee.class);
- Entity.registerEntity("Strider", EntityStrider.class);
- Entity.registerEntity("Goat", EntityGoat.class);
- Entity.registerEntity("Axolotl", EntityAxolotl.class);
- Entity.registerEntity("GlowSquid", EntityGlowSquid.class);
- //Vehicles
- Entity.registerEntity("MinecartRideable", EntityMinecartEmpty.class);
- Entity.registerEntity("MinecartChest", EntityMinecartChest.class);
- Entity.registerEntity("MinecartHopper", EntityMinecartHopper.class);
- Entity.registerEntity("MinecartTnt", EntityMinecartTNT.class);
- Entity.registerEntity("Boat", EntityBoat.class);
- //Others
- Entity.registerEntity("Human", EntityHuman.class, true);
- Entity.registerEntity("Lightning", EntityLightning.class);
- }
-
- /**
- * Internal method to register all default block entities
- */
- private static void registerBlockEntities() {
- BlockEntity.registerBlockEntity(BlockEntity.FURNACE, BlockEntityFurnace.class);
- BlockEntity.registerBlockEntity(BlockEntity.CHEST, BlockEntityChest.class);
- BlockEntity.registerBlockEntity(BlockEntity.SIGN, BlockEntitySign.class);
- BlockEntity.registerBlockEntity(BlockEntity.ENCHANT_TABLE, BlockEntityEnchantTable.class);
- BlockEntity.registerBlockEntity(BlockEntity.SKULL, BlockEntitySkull.class);
- BlockEntity.registerBlockEntity(BlockEntity.FLOWER_POT, BlockEntityFlowerPot.class);
- BlockEntity.registerBlockEntity(BlockEntity.BREWING_STAND, BlockEntityBrewingStand.class);
- BlockEntity.registerBlockEntity(BlockEntity.ITEM_FRAME, BlockEntityItemFrame.class);
- BlockEntity.registerBlockEntity(BlockEntity.CAULDRON, BlockEntityCauldron.class);
- BlockEntity.registerBlockEntity(BlockEntity.ENDER_CHEST, BlockEntityEnderChest.class);
- BlockEntity.registerBlockEntity(BlockEntity.BEACON, BlockEntityBeacon.class);
- BlockEntity.registerBlockEntity(BlockEntity.PISTON_ARM, BlockEntityPistonArm.class);
- BlockEntity.registerBlockEntity(BlockEntity.COMPARATOR, BlockEntityComparator.class);
- BlockEntity.registerBlockEntity(BlockEntity.HOPPER, BlockEntityHopper.class);
- BlockEntity.registerBlockEntity(BlockEntity.BED, BlockEntityBed.class);
- BlockEntity.registerBlockEntity(BlockEntity.JUKEBOX, BlockEntityJukebox.class);
- BlockEntity.registerBlockEntity(BlockEntity.SHULKER_BOX, BlockEntityShulkerBox.class);
- BlockEntity.registerBlockEntity(BlockEntity.BANNER, BlockEntityBanner.class);
- BlockEntity.registerBlockEntity(BlockEntity.DROPPER, BlockEntityDropper.class);
- BlockEntity.registerBlockEntity(BlockEntity.DISPENSER, BlockEntityDispenser.class);
- BlockEntity.registerBlockEntity(BlockEntity.MOB_SPAWNER, BlockEntitySpawner.class);
- BlockEntity.registerBlockEntity(BlockEntity.MUSIC, BlockEntityMusic.class);
- }
-
- /**
- * Is nether enabled on this server
- *
- * @return nether enabled
- */
- public boolean isNetherAllowed() {
- return this.netherEnabled;
- }
-
- /**
- * Get player data serializer that is used to save player data
- *
- * @return player data serializer
- */
- public PlayerDataSerializer getPlayerDataSerializer() {
- return playerDataSerializer;
- }
-
- /**
- * Set player data serializer that is used to save player data
- *
- * @param playerDataSerializer player data serializer
- */
- public void setPlayerDataSerializer(PlayerDataSerializer playerDataSerializer) {
- this.playerDataSerializer = Preconditions.checkNotNull(playerDataSerializer, "playerDataSerializer");
- }
-
- /**
- * Get the Server instance
- *
- * @return Server
- */
- public static Server getInstance() {
- return instance;
- }
-
- /**
- * SuomiCraft PE mode tweaks some stuff to work better on SuomiCraft PE server.
- *
- * @return SuomiCraft PE mode enabled
- */
- public boolean suomiCraftPEMode() {
- return suomicraftMode;
- }
-
- /**
- * Get the mob spawner task
- *
- * @return spawner task
- */
- public SpawnerTask getSpawnerTask() {
- return this.spawnerTask;
- }
-
- /**
- * Load some settings from server.properties
- */
- private void loadSettings() {
- this.forceLanguage = this.getPropertyBoolean("force-language", false);
- this.networkCompressionLevel = Math.max(Math.min(this.getPropertyInt("compression-level", 4), 9), 0);
- this.autoTickRate = this.getPropertyBoolean("auto-tick-rate", true);
- this.autoTickRateLimit = this.getPropertyInt("auto-tick-rate-limit", 20);
- this.alwaysTickPlayers = this.getPropertyBoolean("always-tick-players", false);
- this.baseTickRate = this.getPropertyInt("base-tick-rate", 1);
- this.suomicraftMode = this.getPropertyBoolean("suomicraft-mode", false);
- this.callDataPkSendEv = this.getPropertyBoolean("call-data-pk-send-event", true);
- this.callBatchPkEv = this.getPropertyBoolean("call-batch-pk-send-event", true);
- this.doLevelGC = this.getPropertyBoolean("do-level-gc", true);
- this.mobAiEnabled = this.getPropertyBoolean("mob-ai", true);
- this.netherEnabled = this.getPropertyBoolean("nether", true);
- this.endEnabled = this.getPropertyBoolean("end", false);
- this.xboxAuth = this.getPropertyBoolean("xbox-auth", true);
- this.bedSpawnpoints = this.getPropertyBoolean("bed-spawnpoints", true);
- this.achievementsEnabled = this.getPropertyBoolean("achievements", true);
- this.dimensionsEnabled = this.getPropertyBoolean("dimensions", true);
- this.banXBAuthFailed = this.getPropertyBoolean("temp-ip-ban-failed-xbox-auth", false);
- this.pvpEnabled = this.getPropertyBoolean("pvp", true);
- this.announceAchievements = this.getPropertyBoolean("announce-player-achievements", false);
- this.spawnEggsEnabled = this.getPropertyBoolean("spawn-eggs", true);
- this.xpBottlesOnCreative = this.getPropertyBoolean("xp-bottles-on-creative", false);
- this.shouldSavePlayerData = this.getPropertyBoolean("save-player-data", true);
- this.mobsFromBlocks = this.getPropertyBoolean("block-listener", true);
- this.explosionBreakBlocks = this.getPropertyBoolean("explosion-break-blocks", true);
- this.vanillaBossBar = this.getPropertyBoolean("vanilla-bossbars", false);
- this.stopInGame = this.getPropertyBoolean("stop-in-game", false);
- this.opInGame = this.getPropertyBoolean("op-in-game", false);
- this.lightUpdates = this.getPropertyBoolean("light-updates", false);
- this.queryPlugins = this.getPropertyBoolean("query-plugins", false);
- this.flyChecks = this.getPropertyBoolean("allow-flight", false);
- this.isHardcore = this.getPropertyBoolean("hardcore", false);
- this.despawnMobs = this.getPropertyBoolean("entity-despawn-task", true);
- this.forceResources = this.getPropertyBoolean("force-resources", false);
- this.whitelistEnabled = this.getPropertyBoolean("white-list", false);
- this.checkOpMovement = this.getPropertyBoolean("check-op-movement", false);
- this.forceGamemode = this.getPropertyBoolean("force-gamemode", true);
- this.doNotLimitInteractions = this.getPropertyBoolean("do-not-limit-interactions", false);
- this.motd = this.getPropertyString("motd", "Minecraft Server");
- this.viewDistance = this.getPropertyInt("view-distance", 8);
- this.mobDespawnTicks = this.getPropertyInt("ticks-per-entity-despawns", 12000);
- this.port = this.getPropertyInt("server-port", 19132);
- this.ip = this.getPropertyString("server-ip", "0.0.0.0");
- this.skinChangeCooldown = this.getPropertyInt("skin-change-cooldown", 30);
- this.strongIPBans = this.getPropertyBoolean("strong-ip-bans", false);
- this.spawnRadius = this.getPropertyInt("spawn-protection", 10);
- this.spawnAnimals = this.getPropertyBoolean("spawn-animals", true);
- this.spawnMonsters = this.getPropertyBoolean("spawn-mobs", true);
- this.autoSaveTicks = this.getPropertyInt("ticks-per-autosave", 6000);
- this.doNotLimitSkinGeometry = this.getPropertyBoolean("do-not-limit-skin-geometry", true);
- this.anvilsEnabled = this.getPropertyBoolean("anvils-enabled", true);
- this.chunksPerTick = this.getPropertyInt("chunk-sending-per-tick", 4);
- this.spawnThreshold = this.getPropertyInt("spawn-threshold", 56);
- this.savePlayerDataByUuid = this.getPropertyBoolean("save-player-data-by-uuid", true);
- this.vanillaPortals = this.getPropertyBoolean("vanilla-portals", true);
- this.personaSkins = this.getPropertyBoolean("persona-skins", true);
- this.cacheChunks = this.getPropertyBoolean("cache-chunks", false);
- this.callEntityMotionEv = this.getPropertyBoolean("call-entity-motion-event", true);
- this.updateChecks = this.getPropertyBoolean("update-notifications", true);
- this.minimumProtocol = this.getPropertyInt("multiversion-min-protocol", 0);
- this.whitelistReason = this.getPropertyString("whitelist-reason", "§cServer is white-listed").replace("§n", "\n");
- this.c_s_spawnThreshold = (int) Math.ceil(Math.sqrt(this.spawnThreshold));
- try {
- this.gamemode = this.getPropertyInt("gamemode", 0) & 0b11;
- } catch (NumberFormatException exception) {
- this.gamemode = getGamemodeFromString(this.getPropertyString("gamemode")) & 0b11;
- }
- String list = this.getPropertyString("do-not-tick-worlds");
- if (!list.trim().isEmpty()) {
- StringTokenizer tokenizer = new StringTokenizer(list, ", ");
- while (tokenizer.hasMoreTokens()) {
- noTickingWorlds.add(tokenizer.nextToken());
- }
- }
- }
-
- /**
- * Internal: Warn user about non multiversion compatible plugins.
- */
- public static void mvw(String action) {
- if (getInstance().minimumProtocol != ProtocolInfo.CURRENT_PROTOCOL) {
- if (Nukkit.DEBUG > 1) {
- getInstance().getLogger().logException(new PluginException("Default " + action + " used by a plugin. This can cause instability with the multiversion."));
- } else {
- getInstance().getLogger().warning("Default " + action + " used by a plugin. This can cause instability with the multiversion.");
- }
- }
- }
-
- /**
- * This class contains all default server.properties values.
- */
- private static class ServerProperties extends ConfigSection {
- {
- put("motd", "Minecraft Server");
- put("sub-motd", "Powered by Nukkit");
- put("server-port", 19132);
- put("server-ip", "0.0.0.0");
- put("view-distance", 8);
- put("white-list", false);
- put("achievements", true);
- put("announce-player-achievements", false);
- put("spawn-protection", 10);
- put("max-players", 50);
- put("spawn-animals", true);
- put("spawn-mobs", true);
- put("gamemode", 0);
- put("force-gamemode", true);
- put("hardcore", false);
- put("pvp", true);
- put("difficulty", 2);
- put("generator-settings", "");
- put("level-name", "world");
- put("level-seed", "");
- put("level-type", "default");
- put("enable-query", true);
- put("enable-rcon", false);
- put("rcon.password", Base64.getEncoder().encodeToString(UUID.randomUUID().toString().replace("-", "").getBytes()).substring(3, 13));
- put("auto-save", true);
- put("force-resources", false);
- put("xbox-auth", true);
- put("bed-spawnpoints", true);
- put("explosion-break-blocks", true);
- put("stop-in-game", false);
- put("op-in-game", true);
- put("xp-bottles-on-creative", true);
- put("spawn-eggs", true);
- put("mob-ai", true);
- put("entity-auto-spawn-task", true);
- put("entity-despawn-task", true);
- put("language", "eng");
- put("force-language", false);
- put("shutdown-message", "§cServer closed");
- put("save-player-data", true);
- put("query-plugins", false);
- put("debug-level", 1);
- put("async-workers", "auto");
- put("zlib-provider", 2);
- put("compression-level", 4);
- put("auto-tick-rate", true);
- put("auto-tick-rate-limit", 20);
- put("base-tick-rate", 1);
- put("always-tick-players", false);
- put("enable-timings", false);
- put("timings-verbose", false);
- put("timings-privacy", false);
- put("timings-history-interval", 6000);
- put("timings-history-length", 72000);
- put("timings-bypass-max", false);
- put("light-updates", false);
- put("clear-chunk-tick-list", true);
- put("cache-chunks", false);
- put("spawn-threshold", 56);
- put("chunk-sending-per-tick", 4);
- put("chunk-ticking-per-tick", 40);
- put("chunk-ticking-radius", 3);
- put("chunk-generation-queue-size", 8);
- put("chunk-generation-population-queue-size", 8);
- put("ticks-per-autosave", 6000);
- put("ticks-per-entity-spawns", 200);
- put("ticks-per-entity-despawns", 12000);
- put("thread-watchdog", true);
- put("thread-watchdog-tick", 60000);
- put("nether", true);
- put("end", false);
- put("suomicraft-mode", false);
- put("do-not-tick-worlds", "");
- put("load-all-worlds", true);
- put("ansi-title", true);
- put("worlds-entity-spawning-disabled", "");
- put("block-listener", true);
- put("allow-flight", false);
- put("timeout-milliseconds", 25000);
- put("multiversion-min-protocol", 0);
- put("vanilla-bossbars", false);
- put("dimensions", true);
- put("whitelist-reason", "§cServer is white-listed");
- put("chemistry-resources-enabled", false);
- put("strong-ip-bans", false);
- put("worlds-level-auto-save-disabled", "");
- put("temp-ip-ban-failed-xbox-auth", false);
- put("call-data-pk-send-event", true);
- put("call-batch-pk-send-event", true);
- put("do-level-gc", true);
- put("skin-change-cooldown", 30);
- put("check-op-movement", false);
- put("do-not-limit-interactions", false);
- put("do-not-limit-skin-geometry", true);
- put("automatic-bug-report", true);
- put("anvils-enabled", true);
- put("save-player-data-by-uuid", true);
- put("vanilla-portals", true);
- put("persona-skins", true);
- put("multi-nether-worlds", "");
- put("call-entity-motion-event", true);
- put("update-notifications", true);
- put("bstats-metrics", true);
- put("min-mtu", 576);
- put("max-mtu", 1492);
- }
- }
-
- private class ConsoleThread extends Thread implements InterruptibleThread {
-
- @Override
- public void run() {
- console.start();
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/api/API.java b/src/main/java/cn/nukkit/api/API.java
deleted file mode 100644
index 9276ee5bb..000000000
--- a/src/main/java/cn/nukkit/api/API.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package cn.nukkit.api;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import static cn.nukkit.api.API.Definition.UNIVERSAL;
-import static cn.nukkit.api.API.Usage.BLEEDING;
-
-/**
- * Describes an API element.
- *
- * @author Lin Mulan, Nukkit Project
- * @see Usage
- * @see Definition
- */
-@Retention(RetentionPolicy.SOURCE)
-@Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.ANNOTATION_TYPE, ElementType.TYPE})
-@API(usage = BLEEDING, definition = UNIVERSAL)
-@SuppressWarnings("unused")
-public @interface API {
-
- /**
- * Indicates the level of stability of an API element.
- * The stability also describes when to use this API element.
- *
- * @return The stability
- * @see Usage
- */
- Usage usage();
-
- /**
- * Indicates definition or the platforms this API element supports.
- *
- * @return The definition
- * @see Definition
- */
- Definition definition();
-
- /**
- * Enum constant for API usage. Indicates when to use this API element.
- *
- * @see #DEPRECATED
- * @see #INCUBATING
- * @see #BLEEDING
- * @see #EXPERIMENTAL
- * @see #MAINTAINED
- * @see #STABLE
- */
- enum Usage {
-
- /**
- * Should no longer be used, might disappear in the next minor release.
- */
- DEPRECATED,
-
- /**
- * Intended for features in drafts. Should only be used for tests.
- *
- * Might contains notable new features, but will be moved to a new package before remarking to {@link #BLEEDING}.
- * Could be unsafe, might be removed without prior notice. Warnings will be send if used.
- */
- INCUBATING,
-
- /**
- * Intended for features in early development. Should only be used for tests.
- *
- *
Might be unwrapped, unsafe or have unchecked parameters.
- * Further contribution was demanded to enhance, strengthen or simplify before remarking to {@link #EXPERIMENTAL}.
- * Might be removed or modified without prior notice.
- */
- BLEEDING,
-
- /**
- * Intended for new, experimental features where we are looking for feedback.
- * At least stable for development.
- *
- *
Use with caution, might be remarked to {@link #MAINTAINED} or {@link #STABLE} in the future,
- * but also might be removed without prior notice.
- */
- EXPERIMENTAL,
-
- /**
- * Intended for features that was tested, documented and at least stable for production use.
- *
- *
These features will not be modified in a backwards-incompatible way for at least next minor release
- * of the current major version. Will be remarked to {@link #DEPRECATED} first if scheduled for removal.
- */
- MAINTAINED,
-
- /**
- * Intended for features that was tested, documented and is preferred in production use.
- *
- *
Will not be changed in a backwards-incompatible way in the current version.
- */
- STABLE
- }
-
- /**
- * Enum constant for API definition. Indicates which client platform this API element supports.
- *
- * @see #INTERNAL
- * @see #PLATFORM_NATIVE
- * @see #UNIVERSAL
- */
- enum Definition {
-
- /**
- * Intended for features should only be used by Nukkit itself.
- * Should not be used in production.
- */
- INTERNAL,
-
- /**
- * Intended for features only available on one or several client platforms.
- *
- *
By using {@code PLATFORM_NATIVE} features, program will lose some cross-platform features provided.
- * Might not available in some client platforms. Read the documents carefully before using this API element.
- */
- PLATFORM_NATIVE,
-
- /**
- * Intended for features implemented in all client platforms.
- *
- *
Preferred to use for production use, but sometimes be lack of platform-native features.
- */
- UNIVERSAL
- }
-}
diff --git a/src/main/java/cn/nukkit/block/Block.java b/src/main/java/cn/nukkit/block/Block.java
deleted file mode 100644
index 159faaffc..000000000
--- a/src/main/java/cn/nukkit/block/Block.java
+++ /dev/null
@@ -1,1000 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.MovingObjectPosition;
-import cn.nukkit.level.Position;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.metadata.MetadataValue;
-import cn.nukkit.metadata.Metadatable;
-import cn.nukkit.plugin.Plugin;
-import cn.nukkit.potion.Effect;
-import cn.nukkit.utils.BlockColor;
-
-import java.lang.reflect.Constructor;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class Block extends Position implements Metadatable, Cloneable, BlockID {
-
- @SuppressWarnings("rawtypes")
- public static Class[] list = null;
- public static Block[] fullList = null;
- public static int[] light = null;
- public static int[] lightFilter = null;
- public static boolean[] solid = null;
- public static double[] hardness = null;
- public static boolean[] transparent = null;
- public AxisAlignedBB boundingBox = null;
- public AxisAlignedBB collisionBoundingBox = null;
- public static boolean[] hasMeta = null;
-
- protected Block() {}
-
- @SuppressWarnings("unchecked")
- public static void init() {
- if (list == null) {
- list = new Class[256];
- fullList = new Block[4096];
- light = new int[256];
- lightFilter = new int[256];
- solid = new boolean[256];
- hardness = new double[256];
- transparent = new boolean[256];
- hasMeta = new boolean[256];
-
- list[AIR] = BlockAir.class; //0
- list[STONE] = BlockStone.class; //1
- list[GRASS] = BlockGrass.class; //2
- list[DIRT] = BlockDirt.class; //3
- list[COBBLESTONE] = BlockCobblestone.class; //4
- list[PLANKS] = BlockPlanks.class; //5
- list[SAPLING] = BlockSapling.class; //6
- list[BEDROCK] = BlockBedrock.class; //7
- list[WATER] = BlockWater.class; //8
- list[STILL_WATER] = BlockWaterStill.class; //9
- list[LAVA] = BlockLava.class; //10
- list[STILL_LAVA] = BlockLavaStill.class; //11
- list[SAND] = BlockSand.class; //12
- list[GRAVEL] = BlockGravel.class; //13
- list[GOLD_ORE] = BlockOreGold.class; //14
- list[IRON_ORE] = BlockOreIron.class; //15
- list[COAL_ORE] = BlockOreCoal.class; //16
- list[WOOD] = BlockWood.class; //17
- list[LEAVES] = BlockLeaves.class; //18
- list[SPONGE] = BlockSponge.class; //19
- list[GLASS] = BlockGlass.class; //20
- list[LAPIS_ORE] = BlockOreLapis.class; //21
- list[LAPIS_BLOCK] = BlockLapis.class; //22
- list[DISPENSER] = BlockDispenser.class; //23
- list[SANDSTONE] = BlockSandstone.class; //24
- list[NOTEBLOCK] = BlockNoteblock.class; //25
- list[BED_BLOCK] = BlockBed.class; //26
- list[POWERED_RAIL] = BlockRailPowered.class; //27
- list[DETECTOR_RAIL] = BlockRailDetector.class; //28
- list[STICKY_PISTON] = BlockPistonSticky.class; //29
- list[COBWEB] = BlockCobweb.class; //30
- list[TALL_GRASS] = BlockTallGrass.class; //31
- list[DEAD_BUSH] = BlockDeadBush.class; //32
- list[PISTON] = BlockPiston.class; //33
- list[PISTON_HEAD] = BlockPistonHead.class; //34
- list[WOOL] = BlockWool.class; //35
- list[DANDELION] = BlockDandelion.class; //37
- list[FLOWER] = BlockFlower.class; //38
- list[BROWN_MUSHROOM] = BlockMushroomBrown.class; //39
- list[RED_MUSHROOM] = BlockMushroomRed.class; //40
- list[GOLD_BLOCK] = BlockGold.class; //41
- list[IRON_BLOCK] = BlockIron.class; //42
- list[DOUBLE_STONE_SLAB] = BlockDoubleSlabStone.class; //43
- list[STONE_SLAB] = BlockSlabStone.class; //44
- list[BRICKS_BLOCK] = BlockBricks.class; //45
- list[TNT] = BlockTNT.class; //46
- list[BOOKSHELF] = BlockBookshelf.class; //47
- list[MOSS_STONE] = BlockMossStone.class; //48
- list[OBSIDIAN] = BlockObsidian.class; //49
- list[TORCH] = BlockTorch.class; //50
- list[FIRE] = BlockFire.class; //51
- list[MONSTER_SPAWNER] = BlockMobSpawner.class; //52
- list[WOOD_STAIRS] = BlockStairsWood.class; //53
- list[CHEST] = BlockChest.class; //54
- list[REDSTONE_WIRE] = BlockRedstoneWire.class; //55
- list[DIAMOND_ORE] = BlockOreDiamond.class; //56
- list[DIAMOND_BLOCK] = BlockDiamond.class; //57
- list[WORKBENCH] = BlockCraftingTable.class; //58
- list[WHEAT_BLOCK] = BlockWheat.class; //59
- list[FARMLAND] = BlockFarmland.class; //60
- list[FURNACE] = BlockFurnace.class; //61
- list[BURNING_FURNACE] = BlockFurnaceBurning.class; //62
- list[SIGN_POST] = BlockSignPost.class; //63
- list[WOOD_DOOR_BLOCK] = BlockDoorWood.class; //64
- list[LADDER] = BlockLadder.class; //65
- list[RAIL] = BlockRail.class; //66
- list[COBBLESTONE_STAIRS] = BlockStairsCobblestone.class; //67
- list[WALL_SIGN] = BlockWallSign.class; //68
- list[LEVER] = BlockLever.class; //69
- list[STONE_PRESSURE_PLATE] = BlockPressurePlateStone.class; //70
- list[IRON_DOOR_BLOCK] = BlockDoorIron.class; //71
- list[WOODEN_PRESSURE_PLATE] = BlockPressurePlateWood.class; //72
- list[REDSTONE_ORE] = BlockOreRedstone.class; //73
- list[GLOWING_REDSTONE_ORE] = BlockOreRedstoneGlowing.class; //74
- list[UNLIT_REDSTONE_TORCH] = BlockRedstoneTorchUnlit.class;
- list[REDSTONE_TORCH] = BlockRedstoneTorch.class; //76
- list[STONE_BUTTON] = BlockButtonStone.class; //77
- list[SNOW_LAYER] = BlockSnowLayer.class; //78
- list[ICE] = BlockIce.class; //79
- list[SNOW_BLOCK] = BlockSnow.class; //80
- list[CACTUS] = BlockCactus.class; //81
- list[CLAY_BLOCK] = BlockClay.class; //82
- list[SUGARCANE_BLOCK] = BlockSugarcane.class; //83
- list[JUKEBOX] = BlockJukebox.class; //84
- list[FENCE] = BlockFence.class; //85
- list[PUMPKIN] = BlockPumpkin.class; //86
- list[NETHERRACK] = BlockNetherrack.class; //87
- list[SOUL_SAND] = BlockSoulSand.class; //88
- list[GLOWSTONE_BLOCK] = BlockGlowstone.class; //89
- list[NETHER_PORTAL] = BlockNetherPortal.class; //90
- list[LIT_PUMPKIN] = BlockPumpkinLit.class; //91
- list[CAKE_BLOCK] = BlockCake.class; //92
- list[UNPOWERED_REPEATER] = BlockRedstoneRepeaterUnpowered.class; //93
- list[POWERED_REPEATER] = BlockRedstoneRepeaterPowered.class; //94
- list[INVISIBLE_BEDROCK] = BlockBedrockInvisible.class; //95
- list[TRAPDOOR] = BlockTrapdoor.class; //96
- list[MONSTER_EGG] = BlockMonsterEgg.class; //97
- list[STONE_BRICKS] = BlockBricksStone.class; //98
- list[BROWN_MUSHROOM_BLOCK] = BlockHugeMushroomBrown.class; //99
- list[RED_MUSHROOM_BLOCK] = BlockHugeMushroomRed.class; //100
- list[IRON_BARS] = BlockIronBars.class; //101
- list[GLASS_PANE] = BlockGlassPane.class; //102
- list[MELON_BLOCK] = BlockMelon.class; //103
- list[PUMPKIN_STEM] = BlockStemPumpkin.class; //104
- list[MELON_STEM] = BlockStemMelon.class; //105
- list[VINE] = BlockVine.class; //106
- list[FENCE_GATE] = BlockFenceGate.class; //107
- list[BRICK_STAIRS] = BlockStairsBrick.class; //108
- list[STONE_BRICK_STAIRS] = BlockStairsStoneBrick.class; //109
- list[MYCELIUM] = BlockMycelium.class; //110
- list[WATER_LILY] = BlockWaterLily.class; //111
- list[NETHER_BRICKS] = BlockBricksNether.class; //112
- list[NETHER_BRICK_FENCE] = BlockFenceNetherBrick.class; //113
- list[NETHER_BRICKS_STAIRS] = BlockStairsNetherBrick.class; //114
- list[NETHER_WART_BLOCK] = BlockNetherWart.class; //115
- list[ENCHANTING_TABLE] = BlockEnchantingTable.class; //116
- list[BREWING_STAND_BLOCK] = BlockBrewingStand.class; //117
- list[CAULDRON_BLOCK] = BlockCauldron.class; //118
- list[END_PORTAL] = BlockEndPortal.class; //119
- list[END_PORTAL_FRAME] = BlockEndPortalFrame.class; //120
- list[END_STONE] = BlockEndStone.class; //121
- list[DRAGON_EGG] = BlockDragonEgg.class; //122
- list[REDSTONE_LAMP] = BlockRedstoneLamp.class; //123
- list[LIT_REDSTONE_LAMP] = BlockRedstoneLampLit.class; //124
- list[DROPPER] = BlockDropper.class; //125
- list[ACTIVATOR_RAIL] = BlockRailActivator.class; //126
- list[COCOA] = BlockCocoa.class; //127
- list[SANDSTONE_STAIRS] = BlockStairsSandstone.class; //128
- list[EMERALD_ORE] = BlockOreEmerald.class; //129
- list[ENDER_CHEST] = BlockEnderChest.class; //130
- list[TRIPWIRE_HOOK] = BlockTripWireHook.class;
- list[TRIPWIRE] = BlockTripWire.class; //132
- list[EMERALD_BLOCK] = BlockEmerald.class; //133
- list[SPRUCE_WOOD_STAIRS] = BlockStairsSpruce.class; //134
- list[BIRCH_WOOD_STAIRS] = BlockStairsBirch.class; //135
- list[JUNGLE_WOOD_STAIRS] = BlockStairsJungle.class; //136
- list[COMMAND_BLOCK] = BlockCommandBlock.class; //137
- list[BEACON] = BlockBeacon.class; //138
- list[STONE_WALL] = BlockWall.class; //139
- list[FLOWER_POT_BLOCK] = BlockFlowerPot.class; //140
- list[CARROT_BLOCK] = BlockCarrot.class; //141
- list[POTATO_BLOCK] = BlockPotato.class; //142
- list[WOODEN_BUTTON] = BlockButtonWooden.class; //143
- list[SKULL_BLOCK] = BlockSkull.class; //144
- list[ANVIL] = BlockAnvil.class; //145
- list[TRAPPED_CHEST] = BlockTrappedChest.class; //146
- list[LIGHT_WEIGHTED_PRESSURE_PLATE] = BlockWeightedPressurePlateLight.class; //147
- list[HEAVY_WEIGHTED_PRESSURE_PLATE] = BlockWeightedPressurePlateHeavy.class; //148
- list[UNPOWERED_COMPARATOR] = BlockRedstoneComparatorUnpowered.class; //149
- list[POWERED_COMPARATOR] = BlockRedstoneComparatorPowered.class; //149
- list[DAYLIGHT_DETECTOR] = BlockDaylightDetector.class; //151
- list[REDSTONE_BLOCK] = BlockRedstone.class; //152
- list[QUARTZ_ORE] = BlockOreQuartz.class; //153
- list[HOPPER_BLOCK] = BlockHopper.class; //154
- list[QUARTZ_BLOCK] = BlockQuartz.class; //155
- list[QUARTZ_STAIRS] = BlockStairsQuartz.class; //156
- list[DOUBLE_WOOD_SLAB] = BlockDoubleSlabWood.class; //157
- list[WOOD_SLAB] = BlockSlabWood.class; //158
- list[STAINED_TERRACOTTA] = BlockTerracottaStained.class; //159
- list[STAINED_GLASS_PANE] = BlockGlassPaneStained.class; //160
- list[LEAVES2] = BlockLeaves2.class; //161
- list[WOOD2] = BlockWood2.class; //162
- list[ACACIA_WOOD_STAIRS] = BlockStairsAcacia.class; //163
- list[DARK_OAK_WOOD_STAIRS] = BlockStairsDarkOak.class; //164
- list[SLIME_BLOCK] = BlockSlime.class; //165
- list[GLOW_STICK] = BlockGlowStick.class; //166
- list[IRON_TRAPDOOR] = BlockTrapdoorIron.class; //167
- list[PRISMARINE] = BlockPrismarine.class; //168
- list[SEA_LANTERN] = BlockSeaLantern.class; //169
- list[HAY_BALE] = BlockHayBale.class; //170
- list[CARPET] = BlockCarpet.class; //171
- list[TERRACOTTA] = BlockTerracotta.class; //172
- list[COAL_BLOCK] = BlockCoal.class; //173
- list[PACKED_ICE] = BlockIcePacked.class; //174
- list[DOUBLE_PLANT] = BlockDoublePlant.class; //175
- list[STANDING_BANNER] = BlockBanner.class; //176
- list[WALL_BANNER] = BlockWallBanner.class; //177
- list[DAYLIGHT_DETECTOR_INVERTED] = BlockDaylightDetectorInverted.class; //178
- list[RED_SANDSTONE] = BlockRedSandstone.class; //179
- list[RED_SANDSTONE_STAIRS] = BlockStairsRedSandstone.class; //180
- list[DOUBLE_RED_SANDSTONE_SLAB] = BlockDoubleSlabRedSandstone.class; //181
- list[RED_SANDSTONE_SLAB] = BlockSlabRedSandstone.class; //182
- list[FENCE_GATE_SPRUCE] = BlockFenceGateSpruce.class; //183
- list[FENCE_GATE_BIRCH] = BlockFenceGateBirch.class; //184
- list[FENCE_GATE_JUNGLE] = BlockFenceGateJungle.class; //185
- list[FENCE_GATE_DARK_OAK] = BlockFenceGateDarkOak.class; //186
- list[FENCE_GATE_ACACIA] = BlockFenceGateAcacia.class; //187
- list[REPEATING_COMMAND_BLOCK] = BlockCommandBlockRepeating.class; //188
- list[CHAIN_COMMAND_BLOCK] = BlockCommandBlockChain.class; //189
- list[HARD_GLASS_PANE] = BlockHardGlassPane.class; //190
- list[HARD_STAINED_GLASS_PANE] = BlockHardGlassPaneStained.class; //191
- list[CHEMICAL_HEAT] = BlockChemicalHeat.class; //192
- list[SPRUCE_DOOR_BLOCK] = BlockDoorSpruce.class; //193
- list[BIRCH_DOOR_BLOCK] = BlockDoorBirch.class; //194
- list[JUNGLE_DOOR_BLOCK] = BlockDoorJungle.class; //195
- list[ACACIA_DOOR_BLOCK] = BlockDoorAcacia.class; //196
- list[DARK_OAK_DOOR_BLOCK] = BlockDoorDarkOak.class; //197
- list[GRASS_PATH] = BlockGrassPath.class; //198
- list[ITEM_FRAME_BLOCK] = BlockItemFrame.class; //199
- list[CHORUS_FLOWER] = BlockChorusFlower.class; //200
- list[PURPUR_BLOCK] = BlockPurpur.class; //201
- list[COLORED_TORCH_RG] = BlockColoredTorchRG.class; //202
- list[PURPUR_STAIRS] = BlockStairsPurpur.class; //203
- list[COLORED_TORCH_BP] = BlockColoredTorchBP.class; //204
- list[UNDYED_SHULKER_BOX] = BlockUndyedShulkerBox.class; //205
- list[END_BRICKS] = BlockBricksEndStone.class; //206
- list[FROSTED_ICE] = BlockIceFrosted.class; //207
- list[END_ROD] = BlockEndRod.class; //208
- list[END_GATEWAY] = BlockEndGateway.class; //209
- // 210 Allow in Education Edition
- // 211 Deny in Education Edition
- // 212 Border in Education Edition
- list[MAGMA] = BlockMagma.class; //213
- list[BLOCK_NETHER_WART_BLOCK] = BlockNetherWartBlock.class; //214
- list[RED_NETHER_BRICK] = BlockBricksRedNether.class; //215
- list[BONE_BLOCK] = BlockBone.class; //216
- // 217 not yet in Minecraft
- list[SHULKER_BOX] = BlockShulkerBox.class; //218
- list[PURPLE_GLAZED_TERRACOTTA] = BlockTerracottaGlazedPurple.class; //219
- list[WHITE_GLAZED_TERRACOTTA] = BlockTerracottaGlazedWhite.class; //220
- list[ORANGE_GLAZED_TERRACOTTA] = BlockTerracottaGlazedOrange.class; //221
- list[MAGENTA_GLAZED_TERRACOTTA] = BlockTerracottaGlazedMagenta.class; //222
- list[LIGHT_BLUE_GLAZED_TERRACOTTA] = BlockTerracottaGlazedLightBlue.class; //223
- list[YELLOW_GLAZED_TERRACOTTA] = BlockTerracottaGlazedYellow.class; //224
- list[LIME_GLAZED_TERRACOTTA] = BlockTerracottaGlazedLime.class; //225
- list[PINK_GLAZED_TERRACOTTA] = BlockTerracottaGlazedPink.class; //226
- list[GRAY_GLAZED_TERRACOTTA] = BlockTerracottaGlazedGray.class; //227
- list[SILVER_GLAZED_TERRACOTTA] = BlockTerracottaGlazedSilver.class; //228
- list[CYAN_GLAZED_TERRACOTTA] = BlockTerracottaGlazedCyan.class; //229
- // 230 Chalkboard in Education Edition
- list[BLUE_GLAZED_TERRACOTTA] = BlockTerracottaGlazedBlue.class; //231
- list[BROWN_GLAZED_TERRACOTTA] = BlockTerracottaGlazedBrown.class; //232
- list[GREEN_GLAZED_TERRACOTTA] = BlockTerracottaGlazedGreen.class; //233
- list[RED_GLAZED_TERRACOTTA] = BlockTerracottaGlazedRed.class; //234
- list[BLACK_GLAZED_TERRACOTTA] = BlockTerracottaGlazedBlack.class; //235
- list[CONCRETE] = BlockConcrete.class; //236
- list[CONCRETE_POWDER] = BlockConcretePowder.class; //237
- list[CHEMISTRY_TABLE] = BlockChemistryTable.class; //238
- list[UNDERWATER_TORCH] = BlockUnderwaterTorch.class; //239
- list[CHORUS_PLANT] = BlockChorusPlant.class; //240
- list[STAINED_GLASS] = BlockGlassStained.class; //241
- // 242 Camera in Education Edition
- list[PODZOL] = BlockPodzol.class; //243
- list[BEETROOT_BLOCK] = BlockBeetroot.class; //244
- list[STONECUTTER] = BlockStonecutter.class; //244
- list[GLOWING_OBSIDIAN] = BlockObsidianGlowing.class; //246
- list[NETHER_REACTOR] = BlockNetherReactor.class; //247
- list[INFO_UPDATE] = BlockInfoUpdate.class; //248
- list[INFO_UPDATE2] = BlockInfoUpdate2.class; //249
- list[PISTON_EXTENSION] = BlockPistonExtension.class; //250
- list[OBSERVER] = BlockObserver.class; //251
- list[STRUCTURE_BLOCK] = BlockStructureBlock.class; //252
- list[HARD_GLASS] = BlockHardGlass.class; //253
- list[HARD_STAINED_GLASS] = BlockHardGlassStained.class; //254
- list[RESERVED6] = BlockReserved6.class; //255
-
- for (int id = 0; id < 256; id++) {
- Class> c = list[id];
- if (c != null) {
- Block block;
- try {
- block = (Block) c.newInstance();
- try {
- @SuppressWarnings("rawtypes")
- Constructor constructor = c.getDeclaredConstructor(int.class);
- constructor.setAccessible(true);
- for (int data = 0; data < 16; ++data) {
- fullList[(id << 4) | data] = (Block) constructor.newInstance(data);
- }
- hasMeta[id] = true;
- } catch (NoSuchMethodException ignore) {
- for (int data = 0; data < 16; ++data) {
- fullList[(id << 4) | data] = block;
- }
- }
- } catch (Exception e) {
- Server.getInstance().getLogger().error("Error while registering " + c.getName(), e);
- for (int data = 0; data < 16; ++data) {
- fullList[(id << 4) | data] = new BlockUnknown(id, data);
- }
- return;
- }
-
- solid[id] = block.isSolid();
- transparent[id] = block.isTransparent();
- hardness[id] = block.getHardness();
- light[id] = block.getLightLevel();
-
- if (block.isSolid()) {
- if (block.isTransparent()) {
- if (block instanceof BlockLiquid || block instanceof BlockIce) {
- lightFilter[id] = 2;
- } else {
- lightFilter[id] = 1;
- }
- } else {
- lightFilter[id] = 15;
- }
- } else {
- lightFilter[id] = 1;
- }
- } else {
- lightFilter[id] = 1;
- for (int data = 0; data < 16; ++data) {
- fullList[(id << 4) | data] = new BlockUnknown(id, data);
- }
- }
- }
- }
- }
-
- public static Block get(int id) {
- return fullList[id << 4].clone();
- }
-
- public static Block get(int id, Integer meta) {
- if (meta != null) {
- return fullList[(id << 4) + meta].clone();
- } else {
- return fullList[id << 4].clone();
- }
- }
-
- public static Block get(int id, Integer meta, Position pos) {
- Block block = fullList[(id << 4) | (meta == null ? 0 : meta)].clone();
- if (pos != null) {
- block.x = pos.x;
- block.y = pos.y;
- block.z = pos.z;
- block.level = pos.level;
- }
- return block;
- }
-
- public static Block get(int id, int data) {
- return fullList[(id << 4) + data].clone();
- }
-
- public static Block get(int fullId, Level level, int x, int y, int z) {
- Block block = fullList[fullId].clone();
- block.x = x;
- block.y = y;
- block.z = z;
- block.level = level;
- return block;
- }
-
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- return this.getLevel().setBlock(this, this, true, true);
- }
-
- public boolean canHarvestWithHand() {
- return true;
- }
-
- public boolean isBreakable(Item item) {
- return true;
- }
-
- public int tickRate() {
- return 10;
- }
-
- public boolean onBreak(Item item, Player player) {
- return this.onBreak(item);
- }
-
- public boolean onBreak(Item item) {
- return this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
- }
-
- public int onUpdate(int type) {
- return 0;
- }
-
- public boolean onActivate(Item item) {
- return this.onActivate(item, null);
- }
-
- public boolean onActivate(Item item, Player player) {
- return false;
- }
-
- public double getHardness() {
- return 10;
- }
-
- public double getResistance() {
- return 1;
- }
-
- public int getBurnChance() {
- return 0;
- }
-
- public int getBurnAbility() {
- return 0;
- }
-
- public int getToolType() {
- return ItemTool.TYPE_NONE;
- }
-
- public double getFrictionFactor() {
- return 0.6;
- }
-
- public int getLightLevel() {
- return 0;
- }
-
- public boolean canBePlaced() {
- return true;
- }
-
- public boolean canBeReplaced() {
- return false;
- }
-
- public boolean isTransparent() {
- return false;
- }
-
- public boolean isSolid() {
- return true;
- }
-
- public boolean canBeFlowedInto() {
- return false;
- }
-
- public boolean canBeActivated() {
- return false;
- }
-
- public boolean hasEntityCollision() {
- return false;
- }
-
- public boolean canPassThrough() {
- return false;
- }
-
- public boolean canBePushed() {
- return this.level.getBlockEntity(this) == null;
- }
-
- public boolean breakWhenPushed() {
- return false;
- }
-
- public boolean hasComparatorInputOverride() {
- return false;
- }
-
- public int getComparatorInputOverride() {
- return 0;
- }
-
- public boolean canBeClimbed() {
- return false;
- }
-
- public BlockColor getColor() {
- return BlockColor.VOID_BLOCK_COLOR;
- }
-
- public abstract String getName();
-
- public abstract int getId();
-
- /**
- * The full id is a combination of the id and data.
- * @return full id
- */
- public int getFullId() {
- return (getId() << 4);
- }
-
- public void addVelocityToEntity(Entity entity, Vector3 vector) {
-
- }
-
- public int getDamage() {
- return 0;
- }
-
- public void setDamage(int meta) {
- }
-
- public final void setDamage(Integer meta) {
- setDamage((meta == null ? 0 : meta & 0x0f));
- }
-
- final public void position(Position v) {
- this.x = (int) v.x;
- this.y = (int) v.y;
- this.z = (int) v.z;
- this.level = v.level;
- this.boundingBox = null;
- }
-
- public Item[] getDrops(Item item) {
- if (this.getId() < 0 || this.getId() > list.length) {
- return new Item[0];
- } else {
- return new Item[]{
- this.toItem()
- };
- }
- }
-
- private static double toolBreakTimeBonus0(int toolType, int toolTier, int blockId) {
- if (toolType == ItemTool.TYPE_NONE) return 1.0;
- if (toolType == ItemTool.TYPE_SWORD) return blockId == Block.COBWEB ? 15.0 : 1.0;
- if (toolType == ItemTool.TYPE_SHEARS) {
- if (blockId == Block.WOOL || blockId == LEAVES || blockId == LEAVES2) {
- return 5.0;
- } else if (blockId == COBWEB) {
- return 15.0;
- }
- return 1.0;
- }
- switch (toolTier) {
- case ItemTool.TIER_WOODEN:
- return 2.0;
- case ItemTool.TIER_STONE:
- return 4.0;
- case ItemTool.TIER_IRON:
- return 6.0;
- case ItemTool.TIER_DIAMOND:
- return 8.0;
- case ItemTool.TIER_NETHERITE:
- return 9.0;
- case ItemTool.TIER_GOLD:
- return 12.0;
- default:
- return 1.0;
- }
- }
-
- private static double speedBonusByEfficiencyLore0(int efficiencyLoreLevel) {
- if (efficiencyLoreLevel == 0) return 0;
- return efficiencyLoreLevel * efficiencyLoreLevel + 1;
- }
-
- private static double speedRateByHasteLore0(int hasteLoreLevel) {
- return 1.0 + (0.2 * hasteLoreLevel);
- }
-
- private static int toolType0(Item item) {
- if (item.isSword()) return ItemTool.TYPE_SWORD;
- if (item.isShovel()) return ItemTool.TYPE_SHOVEL;
- if (item.isPickaxe()) return ItemTool.TYPE_PICKAXE;
- if (item.isAxe()) return ItemTool.TYPE_AXE;
- if (item.isHoe()) return ItemTool.TYPE_HOE;
- if (item.isShears()) return ItemTool.TYPE_SHEARS;
- return ItemTool.TYPE_NONE;
- }
-
- private static boolean correctTool0(int blockToolType, Item item) {
- return (blockToolType == ItemTool.TYPE_SWORD && item.isSword()) ||
- (blockToolType == ItemTool.TYPE_SHOVEL && item.isShovel()) ||
- (blockToolType == ItemTool.TYPE_PICKAXE && item.isPickaxe()) ||
- (blockToolType == ItemTool.TYPE_AXE && item.isAxe()) ||
- (blockToolType == ItemTool.TYPE_HOE && item.isHoe()) ||
- (blockToolType == ItemTool.TYPE_SHEARS && item.isShears()) ||
- blockToolType == ItemTool.TYPE_NONE;
- }
-
- private static double breakTime0(double blockHardness, boolean correctTool, boolean canHarvestWithHand,
- int blockId, int toolType, int toolTier, int efficiencyLoreLevel, int hasteEffectLevel,
- boolean insideOfWaterWithoutAquaAffinity, boolean outOfWaterButNotOnGround) {
- double baseTime = ((correctTool || canHarvestWithHand) ? 1.5 : 5.0) * blockHardness;
- double speed = 1.0 / baseTime;
- if (correctTool) speed *= toolBreakTimeBonus0(toolType, toolTier, blockId);
- speed += correctTool ? speedBonusByEfficiencyLore0(efficiencyLoreLevel) : 0;
- speed *= speedRateByHasteLore0(hasteEffectLevel);
- if (insideOfWaterWithoutAquaAffinity || outOfWaterButNotOnGround) speed *= 0.25;
- return 1.0 / speed;
- }
-
- public double getBreakTime(Item item, Player player) {
- Objects.requireNonNull(item, "getBreakTime: Item can not be null");
- Objects.requireNonNull(player, "getBreakTime: Player can not be null");
- double blockHardness = getHardness();
- if (blockHardness == 0) {
- return 0;
- }
- int blockId = getId();
- boolean correctTool = correctTool0(getToolType(), item) || item.isShears() && (blockId == COBWEB || blockId == LEAVES || blockId == LEAVES2);
- boolean canHarvestWithHand = canHarvestWithHand();
- int itemToolType = toolType0(item);
- int itemTier = item.getTier();
- int efficiencyLoreLevel = Optional.ofNullable(item.getEnchantment(Enchantment.ID_EFFICIENCY))
- .map(Enchantment::getLevel).orElse(0);
- int hasteEffectLevel = Optional.ofNullable(player.getEffect(Effect.HASTE))
- .map(Effect::getAmplifier).orElse(0);
- boolean submerged = player.isSubmerged();
- boolean insideOfWaterWithoutAquaAffinity = submerged &&
- Optional.ofNullable(player.getInventory().getHelmetFast().getEnchantment(Enchantment.ID_WATER_WORKER))
- .map(Enchantment::getLevel).map(l -> l >= 1).orElse(false);
- boolean outOfWaterButNotOnGround = !player.isOnGround() && !submerged;
- return breakTime0(blockHardness, correctTool, canHarvestWithHand, blockId, itemToolType, itemTier,
- efficiencyLoreLevel, hasteEffectLevel, insideOfWaterWithoutAquaAffinity, outOfWaterButNotOnGround);
- }
-
- public double getBreakTime(Item item) {
- double base = this.getHardness() * 1.5;
- if (this.canBeBrokenWith(item)) {
- if (this.getToolType() == ItemTool.TYPE_SHEARS && item.isShears()) {
- base /= 15;
- } else if (
- (this.getToolType() == ItemTool.TYPE_PICKAXE && item.isPickaxe()) ||
- (this.getToolType() == ItemTool.TYPE_AXE && item.isAxe()) ||
- (this.getToolType() == ItemTool.TYPE_SHOVEL && item.isShovel()) ||
- (this.getToolType() == ItemTool.TYPE_HOE && item.isHoe())
- ) {
- switch (item.getTier()) {
- case ItemTool.TIER_WOODEN:
- base /= 2;
- break;
- case ItemTool.TIER_STONE:
- base /= 4;
- break;
- case ItemTool.TIER_IRON:
- base /= 6;
- break;
- case ItemTool.TIER_DIAMOND:
- base /= 8;
- break;
- case ItemTool.TIER_NETHERITE:
- base /= 9;
- break;
- case ItemTool.TIER_GOLD:
- base /= 12;
- break;
- }
- }
- } else {
- base *= 3.33;
- }
-
- if (item.isSword()) {
- base *= 0.5;
- }
-
- return base;
- }
-
- public boolean canBeBrokenWith(Item item) {
- return this.getHardness() != -1;
- }
-
- public Block getSide(BlockFace face) {
- return this.getSide(face, 1);
- }
-
- public Block getSide(BlockFace face, int step) {
- if (this.isValid()) {
- return this.getLevel().getBlock(super.getSide(face, step));
- }
- return Block.get(Item.AIR, 0, Position.fromObject(new Vector3(this.x, this.y, this.z).getSide(face, step)));
- }
-
- public Block up() {
- return up(1);
- }
-
- public Block up(int step) {
- return getSide(BlockFace.UP, step);
- }
-
- public Block down() {
- return down(1);
- }
-
- public Block down(int step) {
- return getSide(BlockFace.DOWN, step);
- }
-
- public Block north() {
- return north(1);
- }
-
- public Block north(int step) {
- return getSide(BlockFace.NORTH, step);
- }
-
- public Block south() {
- return south(1);
- }
-
- public Block south(int step) {
- return getSide(BlockFace.SOUTH, step);
- }
-
- public Block east() {
- return east(1);
- }
-
- public Block east(int step) {
- return getSide(BlockFace.EAST, step);
- }
-
- public Block west() {
- return west(1);
- }
-
- public Block west(int step) {
- return getSide(BlockFace.WEST, step);
- }
-
- @Override
- public String toString() {
- return "Block[" + this.getName() + "] (" + this.getId() + ':' + this.getDamage() + ')';
- }
-
- public boolean collidesWithBB(AxisAlignedBB bb) {
- return collidesWithBB(bb, false);
- }
-
- public boolean collidesWithBB(AxisAlignedBB bb, boolean collisionBB) {
- AxisAlignedBB bb1 = collisionBB ? this.getCollisionBoundingBox() : this.getBoundingBox();
- return bb1 != null && bb.intersectsWith(bb1);
- }
-
- public void onEntityCollide(Entity entity) {
- }
-
- public AxisAlignedBB getBoundingBox() {
- if (this.boundingBox == null) {
- this.boundingBox = this.recalculateBoundingBox();
- }
- return this.boundingBox;
- }
-
- public AxisAlignedBB getCollisionBoundingBox() {
- if (this.collisionBoundingBox == null) {
- this.collisionBoundingBox = this.recalculateCollisionBoundingBox();
- }
- return this.collisionBoundingBox;
- }
-
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- }
-
- protected AxisAlignedBB recalculateCollisionBoundingBox() {
- return getBoundingBox();
- }
-
- public MovingObjectPosition calculateIntercept(Vector3 pos1, Vector3 pos2) {
- AxisAlignedBB bb = this.getBoundingBox();
- if (bb == null) {
- return null;
- }
-
- Vector3 v1 = pos1.getIntermediateWithXValue(pos2, bb.minX);
- Vector3 v2 = pos1.getIntermediateWithXValue(pos2, bb.maxX);
- Vector3 v3 = pos1.getIntermediateWithYValue(pos2, bb.minY);
- Vector3 v4 = pos1.getIntermediateWithYValue(pos2, bb.maxY);
- Vector3 v5 = pos1.getIntermediateWithZValue(pos2, bb.minZ);
- Vector3 v6 = pos1.getIntermediateWithZValue(pos2, bb.maxZ);
-
- if (v1 != null && !bb.isVectorInYZ(v1)) {
- v1 = null;
- }
-
- if (v2 != null && !bb.isVectorInYZ(v2)) {
- v2 = null;
- }
-
- if (v3 != null && !bb.isVectorInXZ(v3)) {
- v3 = null;
- }
-
- if (v4 != null && !bb.isVectorInXZ(v4)) {
- v4 = null;
- }
-
- if (v5 != null && !bb.isVectorInXY(v5)) {
- v5 = null;
- }
-
- if (v6 != null && !bb.isVectorInXY(v6)) {
- v6 = null;
- }
-
- Vector3 vector = v1;
-
- if (v2 != null && (vector == null || pos1.distanceSquared(v2) < pos1.distanceSquared(vector))) {
- vector = v2;
- }
-
- if (v3 != null && (vector == null || pos1.distanceSquared(v3) < pos1.distanceSquared(vector))) {
- vector = v3;
- }
-
- if (v4 != null && (vector == null || pos1.distanceSquared(v4) < pos1.distanceSquared(vector))) {
- vector = v4;
- }
-
- if (v5 != null && (vector == null || pos1.distanceSquared(v5) < pos1.distanceSquared(vector))) {
- vector = v5;
- }
-
- if (v6 != null && (vector == null || pos1.distanceSquared(v6) < pos1.distanceSquared(vector))) {
- vector = v6;
- }
-
- if (vector == null) {
- return null;
- }
-
- int f = -1;
-
- if (vector == v1) {
- f = 4;
- } else if (vector == v2) {
- f = 5;
- } else if (vector == v3) {
- f = 0;
- } else if (vector == v4) {
- f = 1;
- } else if (vector == v5) {
- f = 2;
- } else if (vector == v6) {
- f = 3;
- }
-
- return MovingObjectPosition.fromBlock((int) this.x, (int) this.y, (int) this.z, f, vector.add(this.x, this.y, this.z));
- }
-
- public String getSaveId() {
- String name = getClass().getName();
- return name.substring(16);
- }
-
- @Override
- public void setMetadata(String metadataKey, MetadataValue newMetadataValue) throws Exception {
- if (this.getLevel() != null) {
- this.getLevel().getBlockMetadata().setMetadata(this, metadataKey, newMetadataValue);
- }
- }
-
- @Override
- public List getMetadata(String metadataKey) throws Exception {
- if (this.getLevel() != null) {
- return this.getLevel().getBlockMetadata().getMetadata(this, metadataKey);
-
- }
- return null;
- }
-
- @Override
- public boolean hasMetadata(String metadataKey) throws Exception {
- return this.getLevel() != null && this.getLevel().getBlockMetadata().hasMetadata(this, metadataKey);
- }
-
- @Override
- public void removeMetadata(String metadataKey, Plugin owningPlugin) throws Exception {
- if (this.getLevel() != null) {
- this.getLevel().getBlockMetadata().removeMetadata(this, metadataKey, owningPlugin);
- }
- }
-
- public Block clone() {
- return (Block) super.clone();
- }
-
- public int getWeakPower(BlockFace face) {
- return 0;
- }
-
- public int getStrongPower(BlockFace side) {
- return 0;
- }
-
- public boolean isPowerSource() {
- return false;
- }
-
- public String getLocationHash() {
- return this.getFloorX() + ":" + this.getFloorY() + ':' + this.getFloorZ();
- }
-
- public int getDropExp() {
- return 0;
- }
-
- public boolean isNormalBlock() {
- return !isTransparent() && isSolid() && !isPowerSource();
- }
-
- public static boolean equals(Block b1, Block b2) {
- return equals(b1, b2, true);
- }
-
- public static boolean equals(Block b1, Block b2, boolean checkDamage) {
- return b1 != null && b2 != null && b1.getId() == b2.getId() && (!checkDamage || b1.getDamage() == b2.getDamage());
- }
-
- public Item toItem() {
- return new ItemBlock(this, this.getDamage(), 1);
- }
-
- public boolean canSilkTouch() {
- return false;
- }
-
- public double getMinX() {
- return this.x;
- }
-
- public double getMinY() {
- return this.y;
- }
-
- public double getMinZ() {
- return this.z;
- }
-
- public double getMaxX() {
- return this.x + 1;
- }
-
- public double getMaxY() {
- return this.y + 1;
- }
-
- public double getMaxZ() {
- return this.z + 1;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockAir.java b/src/main/java/cn/nukkit/block/BlockAir.java
deleted file mode 100644
index f19ca3032..000000000
--- a/src/main/java/cn/nukkit/block/BlockAir.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockAir extends BlockTransparent {
-
- @Override
- public int getId() {
- return AIR;
- }
-
- @Override
- public String getName() {
- return "Air";
- }
-
- @Override
- public boolean canPassThrough() {
- return true;
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public boolean canBeFlowedInto() {
- return true;
- }
-
- @Override
- public boolean canBePlaced() {
- return false;
- }
-
- @Override
- public boolean canBeReplaced() {
- return true;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- @Override
- public AxisAlignedBB getBoundingBox() {
- return null;
- }
-
- @Override
- public double getHardness() {
- return 0;
- }
-
- @Override
- public double getResistance() {
- return 0;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockAnvil.java b/src/main/java/cn/nukkit/block/BlockAnvil.java
deleted file mode 100644
index 40933579c..000000000
--- a/src/main/java/cn/nukkit/block/BlockAnvil.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.inventory.AnvilInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.sound.AnvilFallSound;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-import java.util.Collection;
-
-/**
- * Created by Pub4Game on 27.12.2015.
- */
-public class BlockAnvil extends BlockFallableMeta implements Faceable {
-
- private static final int[] faces = {1, 2, 3, 0};
-
- private static final String[] NAMES = new String[]{
- "Anvil",
- "Anvil",
- "Anvil",
- "Anvil",
- "Slighty Damaged Anvil",
- "Slighty Damaged Anvil",
- "Slighty Damaged Anvil",
- "Slighty Damaged Anvil",
- "Very Damaged Anvil",
- "Very Damaged Anvil",
- "Very Damaged Anvil",
- "Very Damaged Anvil"
- };
-
- public BlockAnvil() {
- this(0);
- }
-
- public BlockAnvil(int meta) {
- super(meta);
- }
-
- @Override
- public int getFullId() {
- return (2320) + getDamage();
- }
-
- @Override
- public int getId() {
- return ANVIL;
- }
-
- @Override
- public boolean canBeActivated() {
- return Server.getInstance().anvilsEnabled;
- }
-
- @Override
- public boolean isTransparent() {
- return true;
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 6000;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return NAMES[this.getDamage() > 11 ? 0 : this.getDamage()];
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- int damage = this.getDamage();
- this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);
- if (damage >= 4 && damage <= 7) {
- this.setDamage(this.getDamage() | 0x04);
- } else if (damage >= 8 && damage <= 11) {
- this.setDamage(this.getDamage() | 0x08);
- }
- this.getLevel().setBlock(block, this, true);
- if (player == null) {
- this.getLevel().addSound(new AnvilFallSound(this));
- } else {
- Collection players = getLevel().getChunkPlayers(getChunkX(), getChunkZ()).values();
- players.remove(player);
- if (!players.isEmpty()) {
- this.getLevel().addSound(new AnvilFallSound(this));
- }
- }
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null) {
- player.addWindow(new AnvilInventory(player.getUIInventory(), this), Player.ANVIL_WINDOW_ID);
- }
- return true;
- }
-
- @Override
- public Item toItem() {
- int damage = this.getDamage();
- if (damage >= 4 && damage <= 7) {
- return new ItemBlock(this, this.getDamage() & 0x04);
- } else if (damage >= 8 && damage <= 11) {
- return new ItemBlock(this, this.getDamage() & 0x08);
- } else {
- return new ItemBlock(this);
- }
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- this.toItem()
- };
- }
- return new Item[0];
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.IRON_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBanner.java b/src/main/java/cn/nukkit/block/BlockBanner.java
deleted file mode 100644
index 6dc3ad7cc..000000000
--- a/src/main/java/cn/nukkit/block/BlockBanner.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityBanner;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.NukkitMath;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.IntTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.nbt.tag.Tag;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created by PetteriM1
- */
-public class BlockBanner extends BlockTransparentMeta implements Faceable {
-
- public BlockBanner() {
- this(0);
- }
-
- public BlockBanner(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return STANDING_BANNER;
- }
-
- @Override
- public double getHardness() {
- return 1;
- }
-
- @Override
- public double getResistance() {
- return 5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public String getName() {
- return "Banner";
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return null;
- }
-
- @Override
- public boolean canPassThrough() {
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (face != BlockFace.DOWN) {
- if (face == BlockFace.UP) {
- this.setDamage(NukkitMath.floorDouble(((player.yaw + 180) * 16 / 360) + 0.5) & 0x0f);
- this.getLevel().setBlock(block, this, true);
- } else {
- this.setDamage(face.getIndex());
- this.getLevel().setBlock(block, Block.get(WALL_BANNER, this.getDamage()), true);
- }
-
- CompoundTag nbt = BlockEntity.getDefaultCompound(this, BlockEntity.BANNER)
- .putInt("Base", item.getDamage() & 0xf);
-
- Tag type = item.getNamedTagEntry("Type");
-
- if (type instanceof IntTag) {
- nbt.put("Type", type);
- }
-
- Tag patterns = item.getNamedTagEntry("Patterns");
- if (patterns instanceof ListTag) {
- nbt.put("Patterns", patterns);
- }
-
- BlockEntity.createBlockEntity(BlockEntity.BANNER, this.getChunk(), nbt);
- return true;
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().getId() == Block.AIR) {
- this.getLevel().useBreakOn(this);
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
-
- return 0;
- }
-
- @Override
- public Item toItem() {
- BlockEntity blockEntity = this.getLevel().getBlockEntity(this);
- Item item = Item.get(Item.BANNER);
- if (blockEntity instanceof BlockEntityBanner) {
- BlockEntityBanner banner = (BlockEntityBanner) blockEntity;
- item.setDamage(banner.getBaseColor() & 0xf);
- int type = banner.namedTag.getInt("Type");
- if (type > 0) {
- item.setNamedTag((item.hasCompoundTag() ? item.getNamedTag() : new CompoundTag())
- .putInt("Type", type));
- }
- ListTag patterns = banner.namedTag.getList("Patterns", CompoundTag.class);
- if (patterns.size() > 0) {
- item.setNamedTag((item.hasCompoundTag() ? item.getNamedTag() : new CompoundTag())
- .putList(patterns));
- }
- }
- return item;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public BlockColor getColor() {
- return this.getDyeColor().getColor();
- }
-
- public DyeColor getDyeColor() {
- if (this.level != null) {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityBanner) {
- return ((BlockEntityBanner) blockEntity).getDyeColor();
- }
- }
-
- return DyeColor.WHITE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBeacon.java b/src/main/java/cn/nukkit/block/BlockBeacon.java
deleted file mode 100644
index 32105ad6e..000000000
--- a/src/main/java/cn/nukkit/block/BlockBeacon.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityBeacon;
-import cn.nukkit.inventory.BeaconInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Angelic47 Nukkit Project
- */
-public class BlockBeacon extends BlockTransparent {
-
- @Override
- public int getId() {
- return BEACON;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getLightLevel() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Beacon";
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null) {
-
- BlockEntity t = this.getLevel().getBlockEntity(this);
- if (!(t instanceof BlockEntityBeacon)) {
- CompoundTag nbt = new CompoundTag("")
- .putString("id", BlockEntity.BEACON)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- BlockEntity.createBlockEntity(BlockEntity.BEACON, this.getChunk(), nbt);
- }
-
- player.addWindow(new BeaconInventory(player.getUIInventory(), this), Player.BEACON_WINDOW_ID);
- }
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- boolean blockSuccess = super.place(item, block, target, face, fx, fy, fz, player);
-
- if (blockSuccess) {
- CompoundTag nbt = new CompoundTag("")
- .putString("id", BlockEntity.BEACON)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- BlockEntity.createBlockEntity(BlockEntity.BEACON, this.getChunk(), nbt);
- }
-
- return blockSuccess;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.DIAMOND_BLOCK_COLOR;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockBed.java b/src/main/java/cn/nukkit/block/BlockBed.java
deleted file mode 100644
index 4202edbfe..000000000
--- a/src/main/java/cn/nukkit/block/BlockBed.java
+++ /dev/null
@@ -1,263 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityBed;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.item.EntityPrimedTNT;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBed;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.DoubleTag;
-import cn.nukkit.nbt.tag.FloatTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-import cn.nukkit.utils.Faceable;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockBed extends BlockTransparentMeta implements Faceable {
-
- public BlockBed() {
- this(0);
- }
-
- public BlockBed(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return BED_BLOCK;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public double getHardness() {
- return 0.2;
- }
-
- @Override
- public String getName() {
- return this.getDyeColor().getName() + " Bed Block";
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 0.5625,
- this.z + 1
- );
- }
-
- @Override
- public boolean onActivate(Item item) {
- return this.onActivate(item, null);
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (this.level.getDimension() != Level.DIMENSION_OVERWORLD) {
- this.level.useBreakOn(this);
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag("Pos")
- .add(new DoubleTag("", x))
- .add(new DoubleTag("", y))
- .add(new DoubleTag("", z)))
- .putList(new ListTag("Motion")
- .add(new DoubleTag("", 0))
- .add(new DoubleTag("", 0))
- .add(new DoubleTag("", 0)))
- .putList(new ListTag("Rotation")
- .add(new FloatTag("", 0))
- .add(new FloatTag("", 0)))
- .putShort("Fuse", 0); // create an instant explosion
- new EntityPrimedTNT(this.level.getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4), nbt); // we don't even have to spawn the tnt entity for players
- return true;
- }
-
- int time = this.getLevel().getTime() % Level.TIME_FULL;
-
- boolean isNight = (time >= Level.TIME_NIGHT && time < Level.TIME_SUNRISE);
-
- if (player != null && !isNight) {
- player.sendTranslation("§7%tile.bed.noSleep");
- return true;
- }
-
- Block blockNorth = this.north();
- Block blockSouth = this.south();
- Block blockEast = this.east();
- Block blockWest = this.west();
-
- Block b;
- if ((this.getDamage() & 0x08) == 0x08) {
- b = this;
- } else {
- if (blockNorth.getId() == BED_BLOCK && (blockNorth.getDamage() & 0x08) == 0x08) {
- b = blockNorth;
- } else if (blockSouth.getId() == BED_BLOCK && (blockSouth.getDamage() & 0x08) == 0x08) {
- b = blockSouth;
- } else if (blockEast.getId() == BED_BLOCK && (blockEast.getDamage() & 0x08) == 0x08) {
- b = blockEast;
- } else if (blockWest.getId() == BED_BLOCK && (blockWest.getDamage() & 0x08) == 0x08) {
- b = blockWest;
- } else {
- if (player != null) {
- player.sendTranslation("§7%tile.bed.notValid");
- }
-
- return true;
- }
- }
-
- if (player != null) {
- if (player.distanceSquared(this) > 36) {
- player.sendTranslation("§7%tile.bed.tooFar");
- return true;
- }
-
- if (!player.isCreative()) {
- BlockFace secondPart = this.getBlockFace().getOpposite();
- AxisAlignedBB checkArea = new AxisAlignedBB(b.x - 8, b.y - 6.5, b.z - 8, b.x + 9, b.y + 5.5, b.z + 9).addCoord(secondPart.getXOffset(), 0, secondPart.getZOffset());
-
- for (Entity entity : this.getLevel().getCollidingEntities(checkArea)) {
- if (!entity.isClosed() && Utils.monstersList.contains(entity.getNetworkId())) {
- player.sendTranslation("§7%tile.bed.notSafe");
- return true;
- }
- }
- }
-
- if (!player.sleepOn(b)) {
- player.sendTranslation("§7%tile.bed.occupied");
- }
- }
-
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = this.down();
- if (!down.isTransparent() || down instanceof BlockSlab) {
- Block next = this.getSide(player.getHorizontalFacing());
- Block downNext = next.down();
-
- if (next.canBeReplaced() && (!downNext.isTransparent() || downNext instanceof BlockSlab)) {
- int meta = player.getDirection().getHorizontalIndex();
-
- this.getLevel().setBlock(block, Block.get(BED_BLOCK, meta), true, true);
- this.getLevel().setBlock(next, Block.get(BED_BLOCK, meta | 0x08), true, true);
-
- // HACK: Make bed color to update for the player
- Server.getInstance().getScheduler().scheduleDelayedTask(() -> {
- createBlockEntity(this, item.getDamage());
- createBlockEntity(next, item.getDamage());
- }, 2);
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean onBreak(Item item) {
- Block blockNorth = this.north();
- Block blockSouth = this.south();
- Block blockEast = this.east();
- Block blockWest = this.west();
-
- Block secondPart = null;
- if ((this.getDamage() & 0x08) == 0x08) { // Top part of the bed
- if (blockNorth.getId() == BED_BLOCK && (blockNorth.getDamage() & 0x08) != 0x08) { // Check if the block ID & meta are right
- secondPart = blockNorth;
- } else if (blockSouth.getId() == BED_BLOCK && (blockSouth.getDamage() & 0x08) != 0x08) {
- secondPart = blockSouth;
- } else if (blockEast.getId() == BED_BLOCK && (blockEast.getDamage() & 0x08) != 0x08) {
- secondPart = blockEast;
- } else if (blockWest.getId() == BED_BLOCK && (blockWest.getDamage() & 0x08) != 0x08) {
- secondPart = blockWest;
- }
- } else { // Bottom part of the bed
- if (blockNorth.getId() == BED_BLOCK && (blockNorth.getDamage() & 0x08) == 0x08) {
- secondPart = blockNorth;
- } else if (blockSouth.getId() == BED_BLOCK && (blockSouth.getDamage() & 0x08) == 0x08) {
- secondPart = blockSouth;
- } else if (blockEast.getId() == BED_BLOCK && (blockEast.getDamage() & 0x08) == 0x08) {
- secondPart = blockEast;
- } else if (blockWest.getId() == BED_BLOCK && (blockWest.getDamage() & 0x08) == 0x08) {
- secondPart = blockWest;
- }
- }
-
- if (secondPart != null) {
- this.getLevel().setBlock(secondPart, Block.get(BlockID.AIR), true, true);
- }
-
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, false); // Don't update both parts to prevent duplication bug if there are two fallable blocks on top of the bed
-
- for (Entity entity : this.level.getNearbyEntities(new AxisAlignedBB(this, this).grow(2, 1, 2))) {
- if (!(entity instanceof Player)) continue;
- Player player = (Player) entity;
-
- if (player.getSleepingPos() == null) continue;
- if (!player.getSleepingPos().equals(this) && !player.getSleepingPos().equals(secondPart)) continue;
- player.stopSleep();
- }
-
- return true;
- }
-
- private void createBlockEntity(Vector3 pos, int color) {
- CompoundTag nbt = BlockEntity.getDefaultCompound(pos, BlockEntity.BED);
- nbt.putByte("color", color);
-
- BlockEntity.createBlockEntity(BlockEntity.BED, this.level.getChunk(pos.getFloorX() >> 4, pos.getFloorZ() >> 4), nbt);
- }
-
- @Override
- public Item toItem() {
- return new ItemBed(this.getDyeColor().getWoolData());
- }
-
- @Override
- public BlockColor getColor() {
- return this.getDyeColor().getColor();
- }
-
- public DyeColor getDyeColor() {
- if (this.level != null) {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityBed) {
- return ((BlockEntityBed) blockEntity).getDyeColor();
- }
- }
-
- return DyeColor.WHITE;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBedrock.java b/src/main/java/cn/nukkit/block/BlockBedrock.java
deleted file mode 100644
index bde9f7bf0..000000000
--- a/src/main/java/cn/nukkit/block/BlockBedrock.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockBedrock extends BlockSolid {
-
- @Override
- public int getId() {
- return BEDROCK;
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public double getResistance() {
- return 18000000;
- }
-
- @Override
- public String getName() {
- return "Bedrock";
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBedrockInvisible.java b/src/main/java/cn/nukkit/block/BlockBedrockInvisible.java
deleted file mode 100644
index 0077c14a7..000000000
--- a/src/main/java/cn/nukkit/block/BlockBedrockInvisible.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by Pub4Game on 03.01.2016.
- */
-public class BlockBedrockInvisible extends BlockSolid {
-
- @Override
- public int getId() {
- return INVISIBLE_BEDROCK;
- }
-
- @Override
- public String getName() {
- return "Invisible Bedrock";
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public double getResistance() {
- return 18000000;
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.TRANSPARENT_BLOCK_COLOR;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(BlockID.AIR));
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBeetroot.java b/src/main/java/cn/nukkit/block/BlockBeetroot.java
deleted file mode 100644
index 155f69f58..000000000
--- a/src/main/java/cn/nukkit/block/BlockBeetroot.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSeedsBeetroot;
-
-/**
- * Created on 2015/11/22 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockBeetroot extends BlockCrops {
- public BlockBeetroot() {
- this(0);
- }
-
- public BlockBeetroot(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return BEETROOT_BLOCK;
- }
-
- @Override
- public String getName() {
- return "Beetroot Block";
- }
-
- @Override
- public Item toItem() {
- return new ItemSeedsBeetroot();
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (this.getDamage() >= 0x07) {
- return new Item[]{
- Item.get(Item.BEETROOT, 0, 1),
- Item.get(Item.BEETROOT_SEEDS, 0, (int) (4d * Math.random()))
- };
- } else {
- return new Item[]{
- Item.get(Item.BEETROOT_SEEDS, 0, 1)
- };
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBone.java b/src/main/java/cn/nukkit/block/BlockBone.java
deleted file mode 100644
index b8ee934f6..000000000
--- a/src/main/java/cn/nukkit/block/BlockBone.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * @author CreeperFace
- */
-public class BlockBone extends BlockSolid implements Faceable {
-
- private static final int[] faces = {
- 0,
- 0,
- 0b1000,
- 0b1000,
- 0b0100,
- 0b0100
- };
-
- @Override
- public int getId() {
- return BONE_BLOCK;
- }
-
- @Override
- public String getName() {
- return "Bone Block";
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{new ItemBlock(this)};
- }
-
- return new Item[0];
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(((this.getDamage() & 0x3) | faces[face.getIndex()]));
- this.getLevel().setBlock(block, this, true);
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SAND_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBookshelf.java b/src/main/java/cn/nukkit/block/BlockBookshelf.java
deleted file mode 100644
index 1c13a7e17..000000000
--- a/src/main/java/cn/nukkit/block/BlockBookshelf.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBook;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockBookshelf extends BlockSolid {
-
- @Override
- public String getName() {
- return "Bookshelf";
- }
-
- @Override
- public int getId() {
- return BOOKSHELF;
- }
-
- @Override
- public double getHardness() {
- return 1.5D;
- }
-
- @Override
- public double getResistance() {
- return 7.5D;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public int getBurnChance() {
- return 30;
- }
-
- @Override
- public int getBurnAbility() {
- return 20;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- new ItemBook(0, 3)
- };
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBrewingStand.java b/src/main/java/cn/nukkit/block/BlockBrewingStand.java
deleted file mode 100644
index 351a66a1f..000000000
--- a/src/main/java/cn/nukkit/block/BlockBrewingStand.java
+++ /dev/null
@@ -1,163 +0,0 @@
-package cn.nukkit.block;
-
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityBrewingStand;
-import cn.nukkit.inventory.ContainerInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBrewingStand;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-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.BlockColor;
-
-import java.util.Map;
-
-public class BlockBrewingStand extends BlockSolidMeta {
-
- public BlockBrewingStand() {
- this(0);
- }
-
- public BlockBrewingStand(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Brewing Stand";
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public int getId() {
- return BREWING_STAND_BLOCK;
- }
-
- @Override
- public int getLightLevel() {
- return 1;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- getLevel().setBlock(block, this, true, true);
-
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.BREWING_STAND)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (item.hasCustomName()) {
- nbt.putString("CustomName", item.getCustomName());
- }
-
- if (item.hasCustomBlockData()) {
- Map customData = item.getCustomBlockData().getTags();
- for (Map.Entry tag : customData.entrySet()) {
- nbt.put(tag.getKey(), tag.getValue());
- }
- }
-
- BlockEntityBrewingStand brewing = (BlockEntityBrewingStand) BlockEntity.createBlockEntity(BlockEntity.BREWING_STAND, getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
- return brewing != null;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null) {
- BlockEntity t = getLevel().getBlockEntity(this);
- BlockEntityBrewingStand brewing;
- if (t instanceof BlockEntityBrewingStand) {
- brewing = (BlockEntityBrewingStand) t;
- } else {
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.BREWING_STAND)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- brewing = (BlockEntityBrewingStand) BlockEntity.createBlockEntity(BlockEntity.BREWING_STAND, this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4), nbt);
- if (brewing == null) {
- return false;
- }
- }
-
- if (brewing.namedTag.contains("Lock") && brewing.namedTag.get("Lock") instanceof StringTag) {
- if (!brewing.namedTag.getString("Lock").equals(item.getCustomName())) {
- return false;
- }
- }
-
- player.addWindow(brewing.getInventory());
- }
-
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBrewingStand();
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.IRON_BLOCK_COLOR;
- }
-
- public boolean hasComparatorInputOverride() {
- return true;
- }
-
- @Override
- public int getComparatorInputOverride() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityBrewingStand) {
- return ContainerInventory.calculateRedstone(((BlockEntityBrewingStand) blockEntity).getInventory());
- }
-
- return super.getComparatorInputOverride();
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBricks.java b/src/main/java/cn/nukkit/block/BlockBricks.java
deleted file mode 100644
index fadb8d552..000000000
--- a/src/main/java/cn/nukkit/block/BlockBricks.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockBricks extends BlockSolid {
-
- @Override
- public String getName() {
- return "Bricks";
- }
-
- @Override
- public int getId() {
- return BRICKS_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- Item.get(Item.BRICKS_BLOCK, 0, 1)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.RED_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBricksEndStone.java b/src/main/java/cn/nukkit/block/BlockBricksEndStone.java
deleted file mode 100644
index abc6095e4..000000000
--- a/src/main/java/cn/nukkit/block/BlockBricksEndStone.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockBricksEndStone extends BlockSolid {
-
- @Override
- public String getName() {
- return "End Stone Bricks";
- }
-
- @Override
- public int getId() {
- return END_BRICKS;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 0.8;
- }
-
- @Override
- public double getResistance() {
- return 4;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- Item.get(Item.END_BRICKS, 0, 1)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SAND_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBricksNether.java b/src/main/java/cn/nukkit/block/BlockBricksNether.java
deleted file mode 100644
index ac533f6f1..000000000
--- a/src/main/java/cn/nukkit/block/BlockBricksNether.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/7 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockBricksNether extends BlockSolid {
-
- @Override
- public String getName() {
- return "Nether Brick";
- }
-
- @Override
- public int getId() {
- return NETHER_BRICKS;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- Item.get(Item.NETHER_BRICKS, 0, 1)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBricksRedNether.java b/src/main/java/cn/nukkit/block/BlockBricksRedNether.java
deleted file mode 100644
index 8ce2ad7ca..000000000
--- a/src/main/java/cn/nukkit/block/BlockBricksRedNether.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockBricksRedNether extends BlockNetherBrick {
-
- @Override
- public String getName() {
- return "Red Nether Bricks";
- }
-
- @Override
- public int getId() {
- return RED_NETHER_BRICK;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- Item.get(Item.RED_NETHER_BRICK, 0, 1)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockBricksStone.java b/src/main/java/cn/nukkit/block/BlockBricksStone.java
deleted file mode 100644
index 0de4d334a..000000000
--- a/src/main/java/cn/nukkit/block/BlockBricksStone.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockBricksStone extends BlockSolidMeta {
- public static final int NORMAL = 0;
- public static final int MOSSY = 1;
- public static final int CRACKED = 2;
- public static final int CHISELED = 3;
-
-
- public BlockBricksStone() {
- this(0);
- }
-
- public BlockBricksStone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return STONE_BRICKS;
- }
-
- @Override
- public double getHardness() {
- return 1.5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Stone Bricks",
- "Mossy Stone Bricks",
- "Cracked Stone Bricks",
- "Chiseled Stone Bricks"
- };
-
- return names[this.getDamage() & 0x03];
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- Item.get(Item.STONE_BRICKS, this.getDamage() & 0x03, 1)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockButton.java b/src/main/java/cn/nukkit/block/BlockButton.java
deleted file mode 100644
index 9f299f9f7..000000000
--- a/src/main/java/cn/nukkit/block/BlockButton.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.block.BlockRedstoneEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.sound.ButtonClickSound;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created by CreeperFace on 27. 11. 2016.
- */
-public abstract class BlockButton extends BlockFlowable implements Faceable {
-
- public BlockButton() {
- this(0);
- }
-
- public BlockButton(int meta) {
- super(meta);
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (target.isTransparent()) {
- return false;
- }
-
- this.setDamage(face.getIndex());
- this.level.setBlock(block, this, true, true);
- return true;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (this.isActivated()) {
- return false;
- }
-
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 0, 15));
- this.setDamage(this.getDamage() ^ 0x08);
- this.level.setBlock(this, this, true, false);
- this.level.addSound(new ButtonClickSound(this.add(0.5, 0.5, 0.5)));
- this.level.scheduleUpdate(this, 30);
-
- level.updateAroundRedstone(getLocation(), null);
- level.updateAroundRedstone(getLocation().getSide(getFacing().getOpposite()), null);
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.getSide(getFacing().getOpposite()).isTransparent()) {
- this.level.useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- if (this.isActivated()) {
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0));
-
- this.setDamage(this.getDamage() ^ 0x08);
- this.level.setBlock(this, this, true, false);
- this.level.addSound(new ButtonClickSound(this.add(0.5, 0.5, 0.5)));
-
- level.updateAroundRedstone(getLocation(), null);
- level.updateAroundRedstone(getLocation().getSide(getFacing().getOpposite()), null);
- }
-
- return Level.BLOCK_UPDATE_SCHEDULED;
- }
-
- return 0;
- }
-
- public boolean isActivated() {
- return ((this.getDamage() & 0x08) == 0x08);
- }
-
- @Override
- public boolean isPowerSource() {
- return true;
- }
-
- public int getWeakPower(BlockFace side) {
- return isActivated() ? 15 : 0;
- }
-
- public int getStrongPower(BlockFace side) {
- return !isActivated() ? 0 : (getFacing() == side ? 15 : 0);
- }
-
- public BlockFace getFacing() {
- int side = isActivated() ? getDamage() ^ 0x08 : getDamage();
- return BlockFace.fromIndex(side);
- }
-
- @Override
- public boolean onBreak(Item item) {
- if (isActivated()) {
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0));
- }
-
- return super.onBreak(item);
- }
-
- @Override
- public Item toItem() {
- return Item.get(this.getId(), 0);
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockButtonStone.java b/src/main/java/cn/nukkit/block/BlockButtonStone.java
deleted file mode 100644
index 2583cf077..000000000
--- a/src/main/java/cn/nukkit/block/BlockButtonStone.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-
-/**
- * Created by CreeperFace on 27. 11. 2016.
- */
-public class BlockButtonStone extends BlockButton {
-
- public BlockButtonStone() {
- this(0);
- }
-
- public BlockButtonStone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return STONE_BUTTON;
- }
-
- @Override
- public String getName() {
- return "Stone Button";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockButtonWooden.java b/src/main/java/cn/nukkit/block/BlockButtonWooden.java
deleted file mode 100644
index b5d8fb294..000000000
--- a/src/main/java/cn/nukkit/block/BlockButtonWooden.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-
-/**
- * Created by CreeperFace on 27. 11. 2016.
- */
-public class BlockButtonWooden extends BlockButton {
-
- public BlockButtonWooden() {
- this(0);
- }
-
- public BlockButtonWooden(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return WOODEN_BUTTON;
- }
-
- @Override
- public String getName() {
- return "Wooden Button";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCactus.java b/src/main/java/cn/nukkit/block/BlockCactus.java
deleted file mode 100644
index 550a4088a..000000000
--- a/src/main/java/cn/nukkit/block/BlockCactus.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.event.block.BlockGrowEvent;
-import cn.nukkit.event.entity.EntityDamageByBlockEvent;
-import cn.nukkit.event.entity.EntityDamageEvent.DamageCause;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemCactus;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockCactus extends BlockTransparentMeta {
-
- public BlockCactus(int meta) {
- super(meta);
- }
-
- public BlockCactus() {
- this(0);
- }
-
- @Override
- public int getId() {
- return CACTUS;
- }
-
- @Override
- public double getHardness() {
- return 0.4;
- }
-
- @Override
- public double getResistance() {
- return 2;
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x + 0.0625,
- this.y + 0.0625,
- this.z + 0.0625,
- this.x + 0.9375,
- this.y + 0.9375,
- this.z + 0.9375
- );
- }
-
- @Override
- protected AxisAlignedBB recalculateCollisionBoundingBox() {
- return new AxisAlignedBB(this.x, this.y, this.z, this.x + 1, this.y + 1, this.z + 1);
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.CONTACT, 1));
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- Block down = down();
- if (down.getId() != SAND && down.getId() != CACTUS) {
- this.getLevel().useBreakOn(this);
- } else {
- for (int side = 2; side <= 5; ++side) {
- Block block = getSide(BlockFace.fromIndex(side));
- if (!block.canBeFlowedInto()) {
- this.getLevel().useBreakOn(this);
- }
- }
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- if (down().getId() != CACTUS) {
- if (this.getDamage() == 0x0F) {
- for (int y = 1; y < 3; ++y) {
- Block b = this.getLevel().getBlock(new Vector3(this.x, this.y + y, this.z));
- if (b.getId() == AIR) {
- BlockGrowEvent event = new BlockGrowEvent(b, Block.get(CACTUS));
- Server.getInstance().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- this.getLevel().setBlock(b, event.getNewState(), true, true);
- }
- }
- }
- this.setDamage(0);
- this.getLevel().setBlock(this, this);
- } else {
- this.setDamage(this.getDamage() + 1);
- this.getLevel().setBlock(this, this);
- }
- }
- }
-
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = this.down();
- if (down.getId() == SAND || down.getId() == CACTUS) {
- Block block0 = north();
- Block block1 = south();
- Block block2 = west();
- Block block3 = east();
- if (block0.canBeFlowedInto() && block1.canBeFlowedInto() && block2.canBeFlowedInto() && block3.canBeFlowedInto()) {
- this.getLevel().setBlock(this, this, true);
-
- return true;
- }
- }
- return false;
- }
-
- @Override
- public String getName() {
- return "Cactus";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- new ItemCactus(0, 1)
- };
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCake.java b/src/main/java/cn/nukkit/block/BlockCake.java
deleted file mode 100644
index 042258da0..000000000
--- a/src/main/java/cn/nukkit/block/BlockCake.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemCake;
-import cn.nukkit.item.food.Food;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockCake extends BlockTransparentMeta {
-
- public BlockCake(int meta) {
- super(meta);
- }
-
- public BlockCake() {
- this(0);
- }
-
- @Override
- public String getName() {
- return "Cake Block";
- }
-
- @Override
- public int getId() {
- return CAKE_BLOCK;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getResistance() {
- return 0.5;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- x + ((1 + (getDamage() << 1)) >> 4),
- y,
- z + 0.0625,
- x - 0.0625 + 1,
- y + 0.5,
- z - 0.0625 + 1
- );
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (down().getId() != Block.AIR) {
- getLevel().setBlock(block, this, true, true);
-
- return true;
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (down().getId() == Block.AIR) {
- getLevel().setBlock(this, Block.get(BlockID.AIR), true);
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
-
- return 0;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public Item toItem() {
- return new ItemCake();
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null && player.getFoodData().getLevel() < player.getFoodData().getMaxLevel()) {
- if (getDamage() <= 0x06) setDamage(getDamage() + 1);
- if (getDamage() >= 0x06) {
- getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- } else {
- Food.getByRelative(this).eatenBy(player);
- getLevel().setBlock(this, this, true);
- }
- return true;
- }
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- public int getComparatorInputOverride() {
- return (7 - this.getDamage()) << 1;
- }
-
- public boolean hasComparatorInputOverride() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCarpet.java b/src/main/java/cn/nukkit/block/BlockCarpet.java
deleted file mode 100644
index 5b7d9c9de..000000000
--- a/src/main/java/cn/nukkit/block/BlockCarpet.java
+++ /dev/null
@@ -1,103 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created on 2015/11/24 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockCarpet extends BlockFlowable {
-
- public BlockCarpet() {
- this(0);
- }
-
- public BlockCarpet(int meta) {
- super(meta);
- }
-
- public BlockCarpet(DyeColor dyeColor) {
- this(dyeColor.getWoolData());
- }
-
- @Override
- public int getId() {
- return CARPET;
- }
-
- @Override
- public double getHardness() {
- return 0.1;
- }
-
- @Override
- public double getResistance() {
- return 0.5;
- }
-
- @Override
- public boolean isSolid() {
- return true;
- }
-
- @Override
- public String getName() {
- return DyeColor.getByWoolData(getDamage()) + " Carpet";
- }
-
- @Override
- public boolean canPassThrough() {
- return false;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
-
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 0.0625,
- this.z + 1
- );
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = this.down();
- if (down.getId() != Item.AIR) {
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().getId() == Item.AIR) {
- this.getLevel().useBreakOn(this);
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
-
- return 0;
- }
-
- @Override
- public BlockColor getColor() {
- return DyeColor.getByWoolData(getDamage()).getColor();
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(getDamage());
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCarrot.java b/src/main/java/cn/nukkit/block/BlockCarrot.java
deleted file mode 100644
index 2b669b717..000000000
--- a/src/main/java/cn/nukkit/block/BlockCarrot.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemCarrot;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockCarrot extends BlockCrops {
-
- public BlockCarrot(int meta) {
- super(meta);
- }
-
- public BlockCarrot() {
- this(0);
- }
-
- @Override
- public String getName() {
- return "Carrot Block";
- }
-
- @Override
- public int getId() {
- return CARROT_BLOCK;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (getDamage() >= 0x07) {
- return new Item[]{
- new ItemCarrot(0, Utils.rand(1, 5))
- };
- }
- return new Item[]{
- new ItemCarrot()
- };
- }
-
- @Override
- public Item toItem() {
- return new ItemCarrot();
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCauldron.java b/src/main/java/cn/nukkit/block/BlockCauldron.java
deleted file mode 100644
index 70f28a857..000000000
--- a/src/main/java/cn/nukkit/block/BlockCauldron.java
+++ /dev/null
@@ -1,392 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityCauldron;
-import cn.nukkit.event.player.PlayerBucketEmptyEvent;
-import cn.nukkit.event.player.PlayerBucketFillEvent;
-import cn.nukkit.item.*;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.Sound;
-import cn.nukkit.level.particle.SmokeParticle;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.MathHelper;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.Tag;
-import cn.nukkit.network.protocol.LevelSoundEventPacket;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-import java.util.Map;
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * @author CreeperFace
- * Nukkit Project
- */
-public class BlockCauldron extends BlockSolidMeta {
-
- /**
- * Used to cache biome check for freezing
- * 1 = can't freeze, 2 = can freeze
- */
- private byte freezing;
-
- public BlockCauldron() {
- super(0);
- }
-
- public BlockCauldron(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return CAULDRON_BLOCK;
- }
-
- public String getName() {
- return "Cauldron Block";
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- public boolean isFull() {
- return (this.getDamage() & 0x06) == 0x06;
- }
-
- public boolean isEmpty() {
- return this.getDamage() == 0x00;
- }
-
- public int getFillLevel() {
- return (getDamage() & 0x6) >> 1;
- }
-
- public void setFillLevel(int fillLevel) {
- fillLevel = MathHelper.clamp(fillLevel, 0, 3);
- setDamage(fillLevel << 1);
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- BlockEntity be = this.level.getBlockEntity(this);
-
- if (!(be instanceof BlockEntityCauldron)) {
- return false;
- }
-
- BlockEntityCauldron cauldron = (BlockEntityCauldron) be;
-
- switch (item.getId()) {
- case Item.BUCKET:
- if (item.getDamage() == 0) {//empty bucket
- if (!isFull() || cauldron.isCustomColor() || cauldron.hasPotion()) {
- break;
- }
-
- ItemBucket bucket = (ItemBucket) item.clone();
- bucket.setCount(1);
- bucket.setDamage(8);//water bucket
-
- PlayerBucketFillEvent ev = new PlayerBucketFillEvent(player, this, null, item, bucket);
- this.level.getServer().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- replaceBucket(item, player, ev.getItem());
- this.setFillLevel(0);//empty
- this.level.setBlock(this, this, true);
- cauldron.clearCustomColor();
- this.getLevel().addSoundToViewers(this, Sound.CAULDRON_TAKEWATER);
- }
- } else if (item.getDamage() == 8 || item.getDamage() == 10) {//water and lava buckets
- if (isFull() && !cauldron.isCustomColor() && !cauldron.hasPotion() && item.getDamage() == 8) {
- break;
- }
-
- ItemBucket bucket = (ItemBucket) item.clone();
- bucket.setCount(1);
- bucket.setDamage(0);//empty bucket
-
- PlayerBucketEmptyEvent ev = new PlayerBucketEmptyEvent(player, this, null, item, bucket);
- this.level.getServer().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- if (player.isSurvival() || player.isAdventure()) {
- replaceBucket(item, player, ev.getItem());
- }
- if (cauldron.hasPotion()) {//if has potion
- clearWithFizz(cauldron);
- } else if (item.getDamage() == 8) { //water bucket
- this.setFillLevel(3);//fill
- cauldron.clearCustomColor();
- this.level.setBlock(this, this, true);
- this.getLevel().addSoundToViewers(this, Sound.CAULDRON_FILLWATER);
- } else { // lava bucket
- if (!isEmpty()) {
- clearWithFizz(cauldron);
- }
- }
- //this.update();
- }
- }
- break;
- case Item.DYE:
- if (isEmpty() || cauldron.hasPotion()) {
- break;
- }
-
- if (player.isSurvival() || player.isAdventure()) {
- item.setCount(item.getCount() - 1);
- player.getInventory().setItemInHand(item);
- }
-
- BlockColor color = new ItemDye(item.getDamage()).getDyeColor().getColor();
- if (!cauldron.isCustomColor()) {
- cauldron.setCustomColor(color);
- } else {
- BlockColor current = cauldron.getCustomColor();
- BlockColor mixed = new BlockColor(
- current.getRed() + (color.getRed() - current.getRed()) / 2,
- current.getGreen() + (color.getGreen() - current.getGreen()) / 2,
- current.getBlue() + (color.getBlue() - current.getBlue()) / 2
- );
- cauldron.setCustomColor(mixed);
- }
- this.level.addSoundToViewers(this, Sound.CAULDRON_ADDDYE);
- break;
- case Item.LEATHER_CAP:
- case Item.LEATHER_TUNIC:
- case Item.LEATHER_PANTS:
- case Item.LEATHER_BOOTS:
- case Item.LEATHER_HORSE_ARMOR:
- if (isEmpty() || cauldron.hasPotion()) {
- break;
- }
-
- CompoundTag compoundTag = item.hasCompoundTag() ? item.getNamedTag() : new CompoundTag();
- compoundTag.putInt("customColor", cauldron.getCustomColor().getRGB());
- item.setCompoundTag(compoundTag);
- player.getInventory().setItemInHand(item);
-
- setFillLevel(getFillLevel() - 1);
- this.level.setBlock(this, this, true, true);
- this.level.addSoundToViewers(this, Sound.CAULDRON_DYEARMOR);
- break;
- case Item.POTION:
- case Item.SPLASH_POTION:
- case Item.LINGERING_POTION:
- if (!isEmpty() && (cauldron.hasPotion() ? cauldron.getPotionId() != item.getDamage() : item.getDamage() != 0)) {
- clearWithFizz(cauldron);
- consumePotion(item, player);
- break;
- }
- if (isFull()) {
- break;
- }
- if (item.getDamage() != 0 && isEmpty()) {
- cauldron.setPotionId(item.getDamage());
- }
- cauldron.setPotionType(
- item.getId() == Item.POTION ? BlockEntityCauldron.POTION_TYPE_NORMAL :
- item.getId() == Item.SPLASH_POTION ? BlockEntityCauldron.POTION_TYPE_SPLASH :
- BlockEntityCauldron.POTION_TYPE_LINGERING
- );
- cauldron.spawnToAll();
-
- setFillLevel(getFillLevel() + 1);
- this.level.setBlock(this, this, true);
- consumePotion(item, player);
- this.getLevel().addSoundToViewers(this, Sound.CAULDRON_FILLPOTION);
- break;
- case Item.GLASS_BOTTLE:
- if (isEmpty()) {
- break;
- }
-
- int meta = cauldron.hasPotion() ? cauldron.getPotionId() : 0;
- Item potion;
- if (meta == 0) {
- potion = new ItemPotion();
- } else {
- switch (cauldron.getPotionType()) {
- case BlockEntityCauldron.POTION_TYPE_SPLASH:
- potion = new ItemPotionSplash(meta);
- break;
- case BlockEntityCauldron.POTION_TYPE_LINGERING:
- potion = new ItemPotionLingering(meta);
- break;
- case BlockEntityCauldron.POTION_TYPE_NORMAL:
- default:
- potion = new ItemPotion(meta);
- break;
- }
- }
-
- setFillLevel(getFillLevel() - 1);
- if (isEmpty()) {
- cauldron.setPotionId(0xffff);//reset potion
- cauldron.clearCustomColor();
- }
- this.level.setBlock(this, this, true);
-
- boolean consumeBottle = player.isSurvival() || player.isAdventure();
- if (consumeBottle && item.getCount() == 1) {
- player.getInventory().setItemInHand(potion);
- } else if (item.getCount() > 1) {
- if (consumeBottle) {
- item.setCount(item.getCount() - 1);
- player.getInventory().setItemInHand(item);
- }
-
- if (player.getInventory().canAddItem(potion)) {
- player.getInventory().addItem(potion);
- } else {
- player.getLevel().dropItem(player.add(0, 1.3, 0), potion, player.getDirectionVector().multiply(0.4));
- }
- }
-
- this.getLevel().addSoundToViewers(this, Sound.CAULDRON_TAKEPOTION);
- break;
- case BlockID.SHULKER_BOX:
- if (isEmpty() || cauldron.isCustomColor() || cauldron.hasPotion()) {
- break;
- }
-
- player.getInventory().setItemInHand(Item.get(Item.UNDYED_SHULKER_BOX).setCompoundTag(item.getCompoundTag()));
- setFillLevel(getFillLevel() - 1);
- this.level.setBlock(this, this, true);
- this.getLevel().addSoundToViewers(this, Sound.CAULDRON_TAKEPOTION);
- break;
- default:
- return true;
- }
-
- this.level.updateComparatorOutputLevel(this);
- return true;
- }
-
- protected void replaceBucket(Item oldBucket, Player player, Item newBucket) {
- if (player.isSurvival() || player.isAdventure()) {
- if (oldBucket.getCount() == 1) {
- player.getInventory().setItemInHand(newBucket);
- } else {
- oldBucket.setCount(oldBucket.getCount() - 1);
- if (player.getInventory().canAddItem(newBucket)) {
- player.getInventory().addItem(newBucket);
- } else {
- player.getLevel().dropItem(player.add(0, 1.3, 0), newBucket, player.getDirectionVector().multiply(0.4));
- }
- }
- }
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- CompoundTag nbt = new CompoundTag("")
- .putString("id", BlockEntity.CAULDRON)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putShort("PotionId", 0xffff)
- .putByte("SplashPotion", 0);
-
- if (item.hasCustomBlockData()) {
- Map customData = item.getCustomBlockData().getTags();
- for (Map.Entry tag : customData.entrySet()) {
- nbt.put(tag.getKey(), tag.getValue());
- }
- }
-
- BlockEntity.createBlockEntity(BlockEntity.CAULDRON, this.getChunk(), nbt);
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.getTier() >= ItemTool.TIER_WOODEN) {
- return new Item[]{new ItemCauldron()};
- }
-
- return new Item[0];
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_RANDOM && level.isRaining() && !this.isFull()) {
- if (freezing < 1) {
- freezing = Utils.freezingBiomes.contains(level.getBiomeId((int) this.x, (int) this.z)) ? (byte) 2 : (byte) 1;
- }
- if (freezing == 1 && ThreadLocalRandom.current().nextInt(20) == 0 && level.canBlockSeeSky(this)) {
- this.setFillLevel(this.getFillLevel() + 1);
- this.getLevel().setBlock(this, this, true, true);
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- return super.onUpdate(type);
- }
-
- @Override
- public Item toItem() {
- return new ItemCauldron();
- }
-
- public boolean hasComparatorInputOverride() {
- return true;
- }
-
- public int getComparatorInputOverride() {
- return getFillLevel();
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- // Source: PN/#666
- private void consumePotion(Item item, Player player) {
- if (player.isSurvival() || player.isAdventure()) {
- if (item.getCount() == 1) {
- player.getInventory().setItemInHand(new ItemBlock(new BlockAir()));
- } else if (item.getCount() > 1) {
- item.setCount(item.getCount() - 1);
- player.getInventory().setItemInHand(item);
- Item bottle = new ItemGlassBottle();
- if (player.getInventory().canAddItem(bottle)) {
- player.getInventory().addItem(bottle);
- } else {
- player.getLevel().dropItem(player.add(0, 1.3, 0), bottle, player.getDirectionVector().multiply(0.4));
- }
- }
- }
- }
-
- // Source: PN/#666
- public void clearWithFizz(BlockEntityCauldron cauldron) {
- this.setFillLevel(0);
- cauldron.setPotionId(0xffff);
- cauldron.setSplashPotion(false);
- cauldron.clearCustomColor();
- this.level.setBlock(this, new BlockCauldron(0), true);
- this.level.addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_FIZZ);
- this.getLevel().addParticle(new SmokeParticle(add(Math.random(), 1.2, Math.random())), null, 8);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockChemicalHeat.java b/src/main/java/cn/nukkit/block/BlockChemicalHeat.java
deleted file mode 100644
index 3b1d7c877..000000000
--- a/src/main/java/cn/nukkit/block/BlockChemicalHeat.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-
-/**
- * Created by PetteriM1
- */
-public class BlockChemicalHeat extends BlockSolid {
-
- @Override
- public int getId() {
- return CHEMICAL_HEAT;
- }
-
- @Override
- public String getName() {
- return "Heat Block";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 2.5;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- this.toItem()
- };
- }
- return new Item[0];
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockChemistryTable.java b/src/main/java/cn/nukkit/block/BlockChemistryTable.java
deleted file mode 100644
index 6519a8349..000000000
--- a/src/main/java/cn/nukkit/block/BlockChemistryTable.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created by PetteriM1
- */
-public class BlockChemistryTable extends BlockSolidMeta {
-
- public BlockChemistryTable() {
- this(0);
- }
-
- public BlockChemistryTable(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return CHEMISTRY_TABLE;
- }
-
- @Override
- public String getName() {
- int meta = this.getDamage();
- if (meta >= 12) {
- return "Lab Table";
- } else if (meta >= 8) {
- return "Element Constructor";
- } else if (meta >= 4) {
- return "Material Reducer";
- }
- return "Compound Creator";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getResistance() {
- return this.getDamage() >= 12 ? 3 : 2;
- }
-
- @Override
- public double getHardness() {
- return 2.5;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, (this.getDamage() >> 2) << 2);
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(((this.getDamage() >> 2) << 2) + (player != null ? player.getDirection().getHorizontalIndex() : 0));
- return this.getLevel().setBlock(block, this, true);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockChest.java b/src/main/java/cn/nukkit/block/BlockChest.java
deleted file mode 100644
index 1a5e51b95..000000000
--- a/src/main/java/cn/nukkit/block/BlockChest.java
+++ /dev/null
@@ -1,225 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityChest;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.mob.EntityPiglin;
-import cn.nukkit.inventory.ContainerInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-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.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-import java.util.Map;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockChest extends BlockTransparentMeta implements Faceable {
-
- private static final int[] faces = {2, 5, 3, 4};
-
- public BlockChest() {
- this(0);
- }
-
- public BlockChest(int meta) {
- super(meta);
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public int getId() {
- return CHEST;
- }
-
- @Override
- public String getName() {
- return "Chest";
- }
-
- @Override
- public double getHardness() {
- return 2.5;
- }
-
- @Override
- public double getResistance() {
- return 12.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x + 0.0625,
- this.y,
- this.z + 0.0625,
- this.x + 0.9375,
- this.y + 0.9475,
- this.z + 0.9375
- );
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- BlockEntityChest chest = null;
- this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);
-
- for (int side = 2; side <= 5; ++side) {
- if ((this.getDamage() == 4 || this.getDamage() == 5) && (side == 4 || side == 5)) {
- continue;
- } else if ((this.getDamage() == 3 || this.getDamage() == 2) && (side == 2 || side == 3)) {
- continue;
- }
- Block c = this.getSide(BlockFace.fromIndex(side));
- if (c instanceof BlockChest && c.getDamage() == this.getDamage()) {
- BlockEntity blockEntity = this.getLevel().getBlockEntity(c);
- if (blockEntity instanceof BlockEntityChest && !((BlockEntityChest) blockEntity).isPaired()) {
- chest = (BlockEntityChest) blockEntity;
- break;
- }
- }
- }
-
- this.getLevel().setBlock(block, this, true, true);
- CompoundTag nbt = new CompoundTag("")
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.CHEST)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (item.hasCustomName()) {
- nbt.putString("CustomName", item.getCustomName());
- }
-
- if (item.hasCustomBlockData()) {
- Map customData = item.getCustomBlockData().getTags();
- for (Map.Entry tag : customData.entrySet()) {
- nbt.put(tag.getKey(), tag.getValue());
- }
- }
-
- BlockEntityChest blockEntity = (BlockEntityChest) BlockEntity.createBlockEntity(BlockEntity.CHEST, this.getChunk(), nbt);
-
- if (chest != null) {
- chest.pairWith(blockEntity);
- blockEntity.pairWith(chest);
- }
-
- return true;
- }
-
- @Override
- public boolean onBreak(Item item) {
- BlockEntity t = this.getLevel().getBlockEntity(this);
- if (t instanceof BlockEntityChest) {
- ((BlockEntityChest) t).unpair();
- }
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
-
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null) {
- Block top = this.up();
- if (!top.isTransparent() && !(top instanceof BlockSlab && (top.getDamage() & 0x07) <= 0)) { // avoid issues with the slab hack
- return true;
- }
-
- BlockEntity t = this.getLevel().getBlockEntity(this);
- BlockEntityChest chest;
- if (t instanceof BlockEntityChest) {
- chest = (BlockEntityChest) t;
- } else {
- CompoundTag nbt = new CompoundTag("")
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.CHEST)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- chest = (BlockEntityChest) BlockEntity.createBlockEntity(BlockEntity.CHEST, this.getChunk(), nbt);
- }
-
- if (chest.namedTag.contains("Lock") && chest.namedTag.get("Lock") instanceof StringTag) {
- if (!chest.namedTag.getString("Lock").equals(item.getCustomName())) {
- return true;
- }
- }
-
- player.addWindow(chest.getInventory());
-
- for (Entity e : this.getChunk().getEntities().values()) {
- if (e instanceof EntityPiglin) {
- ((EntityPiglin) e).setAngry(600);
- }
- }
- }
-
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-
- public boolean hasComparatorInputOverride() {
- return true;
- }
-
- public int getComparatorInputOverride() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityChest) {
- return ContainerInventory.calculateRedstone(((BlockEntityChest) blockEntity).getInventory());
- }
-
- return super.getComparatorInputOverride();
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public boolean onBreak(Item item, Player player) {
- boolean broken = this.onBreak(item);
-
- if (broken && player != null) {
- for (Entity e : this.getChunk().getEntities().values()) {
- if (e instanceof EntityPiglin) {
- ((EntityPiglin) e).setAngry(600);
- }
- }
- }
-
- return broken;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockChorusFlower.java b/src/main/java/cn/nukkit/block/BlockChorusFlower.java
deleted file mode 100644
index e00516280..000000000
--- a/src/main/java/cn/nukkit/block/BlockChorusFlower.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-public class BlockChorusFlower extends BlockChorusPlant {
-
- @Override
- public int getId() {
- return CHORUS_FLOWER;
- }
-
- @Override
- public String getName() {
- return "Chorus Flower";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{this.toItem()};
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockChorusPlant.java b/src/main/java/cn/nukkit/block/BlockChorusPlant.java
deleted file mode 100644
index 6840aefaf..000000000
--- a/src/main/java/cn/nukkit/block/BlockChorusPlant.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemID;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-public class BlockChorusPlant extends BlockTransparent {
-
- @Override
- public int getId() {
- return CHORUS_PLANT;
- }
-
- @Override
- public String getName() {
- return "Chorus Plant";
- }
-
- @Override
- public double getHardness() {
- return 0.4;
- }
-
- @Override
- public double getResistance() {
- return 0.4;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = block.down();
- if (!(down instanceof BlockEndStone) &&
- !(down instanceof BlockChorusPlant) &&
- !(block.north() instanceof BlockChorusPlant) &&
- !(block.east() instanceof BlockChorusPlant) &&
- !(block.south() instanceof BlockChorusPlant) &&
- !(block.west() instanceof BlockChorusPlant)) {
- return false;
- }
-
- this.level.setBlock(block, this, true, true);
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().isTransparent() &&
- !(this.down() instanceof BlockChorusPlant) &&
- !(this.north() instanceof BlockChorusPlant) &&
- !(this.east() instanceof BlockChorusPlant) &&
- !(this.south() instanceof BlockChorusPlant) &&
- !(this.west() instanceof BlockChorusPlant)) {
- this.getLevel().useBreakOn(this);
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
-
- return 0;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.PURPLE_BLOCK_COLOR;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return Utils.rand() ? new Item[]{Item.get(ItemID.CHORUS_FRUIT, 0, 1)} : new Item[0];
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockClay.java b/src/main/java/cn/nukkit/block/BlockClay.java
deleted file mode 100644
index f09a7ed35..000000000
--- a/src/main/java/cn/nukkit/block/BlockClay.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemClay;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockClay extends BlockSolid {
-
- @Override
- public double getHardness() {
- return 0.6;
- }
-
- @Override
- public double getResistance() {
- return 3;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- public int getId() {
- return CLAY_BLOCK;
- }
-
- @Override
- public String getName() {
- return "Clay Block";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return new Item[]{
- new ItemClay(0, 4)
- };
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.CLAY_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCoal.java b/src/main/java/cn/nukkit/block/BlockCoal.java
deleted file mode 100644
index 9df6085b5..000000000
--- a/src/main/java/cn/nukkit/block/BlockCoal.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/24 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockCoal extends BlockSolid {
-
- @Override
- public int getId() {
- return COAL_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public int getBurnChance() {
- return 5;
- }
-
- @Override
- public int getBurnAbility() {
- return 5;
- }
-
- @Override
- public String getName() {
- return "Block of Coal";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.BLACK_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCobblestone.java b/src/main/java/cn/nukkit/block/BlockCobblestone.java
deleted file mode 100644
index bdf270cb1..000000000
--- a/src/main/java/cn/nukkit/block/BlockCobblestone.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockCobblestone extends BlockSolid {
-
- @Override
- public int getId() {
- return COBBLESTONE;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Cobblestone";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCobweb.java b/src/main/java/cn/nukkit/block/BlockCobweb.java
deleted file mode 100644
index 8cee81d3e..000000000
--- a/src/main/java/cn/nukkit/block/BlockCobweb.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.entity.Entity;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemString;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockCobweb extends BlockFlowable {
-
- public BlockCobweb() {
- this(0);
- }
-
- public BlockCobweb(int meta) {
- super(0);
- }
-
- @Override
- public String getName() {
- return "Cobweb";
- }
-
- @Override
- public int getId() {
- return COBWEB;
- }
-
- @Override
- public double getHardness() {
- return 4;
- }
-
- @Override
- public double getResistance() {
- return 20;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SWORD;
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- entity.resetFallDistance();
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isShears()) {
- return new Item[]{
- this.toItem()
- };
- } else if (item.isSword()) {
- return new Item[]{
- new ItemString()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.CLOTH_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCocoa.java b/src/main/java/cn/nukkit/block/BlockCocoa.java
deleted file mode 100644
index 4363c84bc..000000000
--- a/src/main/java/cn/nukkit/block/BlockCocoa.java
+++ /dev/null
@@ -1,212 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.event.block.BlockGrowEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDye;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.particle.BoneMealParticle;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.DyeColor;
-import cn.nukkit.utils.Faceable;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created by CreeperFace on 27. 10. 2016.
- */
-public class BlockCocoa extends BlockTransparentMeta implements Faceable {
-
- protected static final AxisAlignedBB[] EAST = new AxisAlignedBB[]{new AxisAlignedBB(0.6875D, 0.4375D, 0.375D, 0.9375D, 0.75D, 0.625D), new AxisAlignedBB(0.5625D, 0.3125D, 0.3125D, 0.9375D, 0.75D, 0.6875D), new AxisAlignedBB(0.5625D, 0.3125D, 0.3125D, 0.9375D, 0.75D, 0.6875D)};
- protected static final AxisAlignedBB[] WEST = new AxisAlignedBB[]{new AxisAlignedBB(0.0625D, 0.4375D, 0.375D, 0.3125D, 0.75D, 0.625D), new AxisAlignedBB(0.0625D, 0.3125D, 0.3125D, 0.4375D, 0.75D, 0.6875D), new AxisAlignedBB(0.0625D, 0.3125D, 0.3125D, 0.4375D, 0.75D, 0.6875D)};
- protected static final AxisAlignedBB[] NORTH = new AxisAlignedBB[]{new AxisAlignedBB(0.375D, 0.4375D, 0.0625D, 0.625D, 0.75D, 0.3125D), new AxisAlignedBB(0.3125D, 0.3125D, 0.0625D, 0.6875D, 0.75D, 0.4375D), new AxisAlignedBB(0.3125D, 0.3125D, 0.0625D, 0.6875D, 0.75D, 0.4375D)};
- protected static final AxisAlignedBB[] SOUTH = new AxisAlignedBB[]{new AxisAlignedBB(0.375D, 0.4375D, 0.6875D, 0.625D, 0.75D, 0.9375D), new AxisAlignedBB(0.3125D, 0.3125D, 0.5625D, 0.6875D, 0.75D, 0.9375D), new AxisAlignedBB(0.3125D, 0.3125D, 0.5625D, 0.6875D, 0.75D, 0.9375D)};
-
- private static final short[] faces = new short[]{
- 0,
- 0,
- 0,
- 2,
- 3,
- 1,
- };
-
- private static final short[] faces2 = new short[]{
- 3, 4, 2, 5, 3, 4, 2, 5, 3, 4, 2, 5
- };
-
- public BlockCocoa() {
- this(0);
- }
-
- public BlockCocoa(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return COCOA;
- }
-
- @Override
- public String getName() {
- return "Cocoa";
- }
-
- @Override
- public AxisAlignedBB getBoundingBox() {
- if (boundingBox == null) {
- this.boundingBox = recalculateBoundingBox();
- }
-
- return this.boundingBox;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- AxisAlignedBB[] bbs;
-
- int damage = this.getDamage();
- if (damage > 11) {
- this.setDamage(11);
- }
-
- switch (getDamage()) {
- case 1:
- case 5:
- case 9:
- bbs = EAST;
- break;
- case 2:
- case 6:
- case 10:
- bbs = SOUTH;
- break;
- case 3:
- case 7:
- case 11:
- bbs = WEST;
- break;
- default:
- bbs = NORTH;
- break;
- }
-
- return bbs[(this.getDamage() >> 2)].getOffsetBoundingBox(x, y, z);
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (target.getId() == Block.WOOD && (target.getDamage() & 0x03) == BlockWood.JUNGLE) {
- if (face != BlockFace.DOWN && face != BlockFace.UP) {
- this.setDamage(faces[face.getIndex()]);
- this.level.setBlock(block, this, true, true);
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- Block side = this.getSide(BlockFace.fromIndex(faces2[this.getDamage()]));
-
- if (side.getId() != Block.WOOD && (side.getDamage() & 0x03) != BlockWood.JUNGLE) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- if (Utils.random.nextInt(2) == 1) {
- if (this.getDamage() >> 2 < 2) {
- BlockCocoa block = (BlockCocoa) this.clone();
- block.setDamage(block.getDamage() + 4);
- BlockGrowEvent ev = new BlockGrowEvent(this, block);
- Server.getInstance().getPluginManager().callEvent(ev);
-
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(this, ev.getNewState(), true, true);
- } else {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- } else {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
-
- return 0;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.getId() == Item.DYE && item.getDamage() == 0x0f) {
- Block block = this.clone();
- if (this.getDamage() >> 2 < 2) {
- block.setDamage(block.getDamage() + 4);
- BlockGrowEvent ev = new BlockGrowEvent(this, block);
- Server.getInstance().getPluginManager().callEvent(ev);
-
- if (ev.isCancelled()) {
- return false;
- }
-
- this.getLevel().setBlock(this, ev.getNewState(), true, true);
- this.level.addParticle(new BoneMealParticle(this));
-
- if (player != null && !player.isCreative()) {
- item.count--;
- }
- }
-
- return true;
- }
-
- return false;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public double getHardness() {
- return 0.2;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public Item toItem() {
- return new ItemDye(DyeColor.BROWN.getDyeData());
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (this.getDamage() >= 8) {
- return new Item[]{
- new ItemDye(3, Utils.rand(2, 3))
- };
- } else {
- return new Item[]{
- new ItemDye(3, 1)
- };
- }
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockColoredTorchBP.java b/src/main/java/cn/nukkit/block/BlockColoredTorchBP.java
deleted file mode 100644
index 387683d47..000000000
--- a/src/main/java/cn/nukkit/block/BlockColoredTorchBP.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * Created by PetteriM1
- */
-public class BlockColoredTorchBP extends BlockTorch {
-
- public BlockColoredTorchBP() {
- this(0);
- }
-
- public BlockColoredTorchBP(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Blue Torch";
- }
-
- @Override
- public int getId() {
- return COLORED_TORCH_BP;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockColoredTorchRG.java b/src/main/java/cn/nukkit/block/BlockColoredTorchRG.java
deleted file mode 100644
index 10acc5471..000000000
--- a/src/main/java/cn/nukkit/block/BlockColoredTorchRG.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * Created by PetteriM1
- */
-public class BlockColoredTorchRG extends BlockTorch {
-
- public BlockColoredTorchRG() {
- this(0);
- }
-
- public BlockColoredTorchRG(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Red Torch";
- }
-
- @Override
- public int getId() {
- return COLORED_TORCH_RG;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCommandBlock.java b/src/main/java/cn/nukkit/block/BlockCommandBlock.java
deleted file mode 100644
index 4f727d3d0..000000000
--- a/src/main/java/cn/nukkit/block/BlockCommandBlock.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-public class BlockCommandBlock extends BlockSolid {
-
- @Override
- public int getId() {
- return COMMAND_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public double getResistance() {
- return 18000000;
- }
-
- @Override
- public String getName() {
- return "Command Block";
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCommandBlockChain.java b/src/main/java/cn/nukkit/block/BlockCommandBlockChain.java
deleted file mode 100644
index 5f11fc8c5..000000000
--- a/src/main/java/cn/nukkit/block/BlockCommandBlockChain.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-public class BlockCommandBlockChain extends BlockSolid {
-
- @Override
- public int getId() {
- return CHAIN_COMMAND_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public double getResistance() {
- return 18000000;
- }
-
- @Override
- public String getName() {
- return "Chain Command Block";
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCommandBlockRepeating.java b/src/main/java/cn/nukkit/block/BlockCommandBlockRepeating.java
deleted file mode 100644
index 179badce4..000000000
--- a/src/main/java/cn/nukkit/block/BlockCommandBlockRepeating.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-public class BlockCommandBlockRepeating extends BlockSolid {
-
- @Override
- public int getId() {
- return REPEATING_COMMAND_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public double getResistance() {
- return 18000000;
- }
-
- @Override
- public String getName() {
- return "Repeating Command Block";
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockConcrete.java b/src/main/java/cn/nukkit/block/BlockConcrete.java
deleted file mode 100644
index 115f54301..000000000
--- a/src/main/java/cn/nukkit/block/BlockConcrete.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockConcrete extends BlockSolidMeta {
-
- public BlockConcrete() {
- this(0);
- }
-
- public BlockConcrete(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return CONCRETE;
- }
-
- @Override
- public double getResistance() {
- return 9;
- }
-
- @Override
- public double getHardness() {
- return 1.8;
- }
-
- @Override
- public String getName() {
- return "Concrete";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return item.getTier() >= ItemTool.TIER_WOODEN ? new Item[]{toItem()} : new Item[0];
- }
-
- @Override
- public BlockColor getColor() {
- return DyeColor.getByWoolData(getDamage()).getColor();
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(getDamage());
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockConcretePowder.java b/src/main/java/cn/nukkit/block/BlockConcretePowder.java
deleted file mode 100644
index 502cd6564..000000000
--- a/src/main/java/cn/nukkit/block/BlockConcretePowder.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockConcretePowder extends BlockFallableMeta {
-
- public BlockConcretePowder() {
- super(0);
- }
-
- public BlockConcretePowder(int meta) {
- super(meta);
- }
-
- @Override
- public int getFullId() {
- return (3792) + getDamage();
- }
-
- @Override
- public int getId() {
- return CONCRETE_POWDER;
- }
-
- @Override
- public String getName() {
- return "Concrete Powder";
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- super.onUpdate(Level.BLOCK_UPDATE_NORMAL);
-
- for (int side = 1; side <= 5; side++) {
- Block block = this.getSide(BlockFace.fromIndex(side));
- if (block.getId() == Block.WATER || block.getId() == Block.STILL_WATER) {
- this.level.setBlock(this, Block.get(Block.CONCRETE, this.getDamage()), true, true);
- }
- }
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block b, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- boolean concrete = false;
-
- for (int side = 1; side <= 5; side++) {
- Block block = this.getSide(BlockFace.fromIndex(side));
- if (block.getId() == Block.WATER || block.getId() == Block.STILL_WATER) {
- concrete = true;
- break;
- }
- }
-
- if (concrete) {
- this.level.setBlock(this, Block.get(Block.CONCRETE, this.getDamage()), true, true);
- } else {
- this.level.setBlock(this, this, true, true);
- }
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockCraftingTable.java b/src/main/java/cn/nukkit/block/BlockCraftingTable.java
deleted file mode 100644
index 1cc08b443..000000000
--- a/src/main/java/cn/nukkit/block/BlockCraftingTable.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.player.CraftingTableOpenEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.network.protocol.ContainerOpenPacket;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/5 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockCraftingTable extends BlockSolid {
-
- @Override
- public String getName() {
- return "Crafting Table";
- }
-
- @Override
- public int getId() {
- return WORKBENCH;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public double getHardness() {
- return 2.5;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null) {
- CraftingTableOpenEvent ev = new CraftingTableOpenEvent(player, this);
- player.getServer().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- player.craftingType = Player.CRAFTING_BIG;
- player.setCraftingGrid(player.getUIInventory().getBigCraftingGrid());
- if (player.protocol >= 407) {
- ContainerOpenPacket pk = new ContainerOpenPacket();
- pk.windowId = -1;
- pk.type = 1;
- pk.x = (int) x;
- pk.y = (int) y;
- pk.z = (int) z;
- pk.entityId = player.getId();
- player.dataPacket(pk);
- }
- }
- }
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockCrops.java b/src/main/java/cn/nukkit/block/BlockCrops.java
deleted file mode 100644
index 17579d200..000000000
--- a/src/main/java/cn/nukkit/block/BlockCrops.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.event.block.BlockGrowEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.particle.BoneMealParticle;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockCrops extends BlockFlowable {
-
- protected BlockCrops(int meta) {
- super(meta);
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (block.down().getId() == FARMLAND) {
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- // Bone meal
- if (item.getId() == Item.DYE && item.getDamage() == 0x0f) {
- if (this.getDamage() < 7) {
- BlockCrops block = (BlockCrops) this.clone();
- block.setDamage(block.getDamage() + Utils.random.nextInt(3) + 2);
- if (block.getDamage() > 7) {
- block.setDamage(7);
- }
- BlockGrowEvent ev = new BlockGrowEvent(this, block);
- Server.getInstance().getPluginManager().callEvent(ev);
-
- if (ev.isCancelled()) {
- return false;
- }
-
- this.getLevel().setBlock(this, ev.getNewState(), false, true);
-
- this.level.addParticle(new BoneMealParticle(this));
-
- if (player != null && !player.isCreative()) {
- item.count--;
- }
- }
-
- return true;
- }
-
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().getId() != FARMLAND) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- if (Utils.random.nextInt(2) == 1) {
- if (this.getDamage() < 0x07) {
- BlockCrops block = (BlockCrops) this.clone();
- block.setDamage(block.getDamage() + 1);
- BlockGrowEvent ev = new BlockGrowEvent(this, block);
- Server.getInstance().getPluginManager().callEvent(ev);
-
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(this, ev.getNewState(), false, true);
- } else {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- } else {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
-
- return 0;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDandelion.java b/src/main/java/cn/nukkit/block/BlockDandelion.java
deleted file mode 100644
index 965f7ff4d..000000000
--- a/src/main/java/cn/nukkit/block/BlockDandelion.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockDandelion extends BlockFlower {
-
- public BlockDandelion() {
- this(0);
- }
-
- public BlockDandelion(int meta) {
- super(0);
- }
-
- @Override
- public String getName() {
- return "Dandelion";
- }
-
- @Override
- public int getId() {
- return DANDELION;
- }
-
- @Override
- protected Block getUncommonFlower() {
- return get(POPPY);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDaylightDetector.java b/src/main/java/cn/nukkit/block/BlockDaylightDetector.java
deleted file mode 100644
index c6b511ded..000000000
--- a/src/main/java/cn/nukkit/block/BlockDaylightDetector.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/22 by CreeperFace.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockDaylightDetector extends BlockTransparent {
-
- @Override
- public int getId() {
- return DAYLIGHT_DETECTOR;
- }
-
- @Override
- public String getName() {
- return "Daylight Detector";
- }
-
- @Override
- public double getHardness() {
- return 0.2;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- this.getLevel().setBlock(this, Block.get(DAYLIGHT_DETECTOR_INVERTED));
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public boolean isPowerSource() {
- return this.level.isAnimalSpawningAllowedByTime();
- }
-
- @Override
- public int getWeakPower(BlockFace face) {
- return this.level.isAnimalSpawningAllowedByTime() ? 15 : 0;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 0.625,
- this.z + 1
- );
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDaylightDetectorInverted.java b/src/main/java/cn/nukkit/block/BlockDaylightDetectorInverted.java
deleted file mode 100644
index 5725949f0..000000000
--- a/src/main/java/cn/nukkit/block/BlockDaylightDetectorInverted.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created on 2015/11/22 by CreeperFace.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockDaylightDetectorInverted extends BlockDaylightDetector {
-
- @Override
- public int getId() {
- return DAYLIGHT_DETECTOR_INVERTED;
- }
-
- @Override
- public String getName() {
- return "Daylight Detector Inverted";
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- this.getLevel().setBlock(this, Block.get(DAYLIGHT_DETECTOR));
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(DAYLIGHT_DETECTOR), 0);
- }
-
- @Override
- public boolean isPowerSource() {
- return !this.level.isAnimalSpawningAllowedByTime();
- }
-
- @Override
- public int getWeakPower(BlockFace face) {
- return this.level.isAnimalSpawningAllowedByTime() ? 0 : 15;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDeadBush.java b/src/main/java/cn/nukkit/block/BlockDeadBush.java
deleted file mode 100644
index 3542944fd..000000000
--- a/src/main/java/cn/nukkit/block/BlockDeadBush.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemStick;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockDeadBush extends BlockFlowable {
-
- public BlockDeadBush() {
- this(0);
- }
-
- public BlockDeadBush(int meta) {
- super(0);
- }
-
- @Override
- public String getName() {
- return "Dead Bush";
- }
-
- @Override
- public int getId() {
- return DEAD_BUSH;
- }
-
- @Override
- public boolean canBeReplaced() {
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = this.down();
- if (down.getId() == SAND || down.getId() == TERRACOTTA || down.getId() == STAINED_TERRACOTTA || down.getId() == DIRT || down.getId() == PODZOL) {
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
- return false;
- }
-
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().isTransparent()) {
- this.getLevel().useBreakOn(this);
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isShears()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[]{
- new ItemStick(0, Utils.random.nextInt(3))
- };
- }
- }
-
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDiamond.java b/src/main/java/cn/nukkit/block/BlockDiamond.java
deleted file mode 100644
index 61f95a42c..000000000
--- a/src/main/java/cn/nukkit/block/BlockDiamond.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockDiamond extends BlockSolid {
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public int getId() {
- return DIAMOND_BLOCK;
- }
-
- @Override
- public String getName() {
- return "Block of Diamond";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.DIAMOND_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDirt.java b/src/main/java/cn/nukkit/block/BlockDirt.java
deleted file mode 100644
index ad492855f..000000000
--- a/src/main/java/cn/nukkit/block/BlockDirt.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Sound;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * AMAZING COARSE DIRT added by kvetinac97
- * Nukkit Project
- */
-public class BlockDirt extends BlockSolidMeta {
-
- public BlockDirt() {
- this(0);
- }
-
- public BlockDirt(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return DIRT;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- public String getName() {
- return this.getDamage() == 0 ? "Dirt" : "Coarse Dirt";
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.isHoe()) {
- Block up = this.up();
- if (up instanceof BlockAir || up instanceof BlockFlowable) {
- item.useOn(this);
- this.getLevel().setBlock(this, this.getDamage() == 0 ? get(FARMLAND) : get(DIRT), true);
- if (player != null) {
- player.getLevel().addSoundToViewers(player, Sound.STEP_GRASS);
- }
- return true;
- }
- } else if (item.isShovel()) {
- Block up = this.up();
- if (up instanceof BlockAir || up instanceof BlockFlowable) {
- item.useOn(this);
- this.getLevel().setBlock(this, Block.get(GRASS_PATH));
- if (player != null) {
- player.getLevel().addSoundToViewers(player, Sound.STEP_GRASS);
- }
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{new ItemBlock(Block.get(BlockID.DIRT))};
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.DIRT_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDispenser.java b/src/main/java/cn/nukkit/block/BlockDispenser.java
deleted file mode 100644
index 4b95d9d36..000000000
--- a/src/main/java/cn/nukkit/block/BlockDispenser.java
+++ /dev/null
@@ -1,213 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityDispenser;
-import cn.nukkit.dispenser.DispenseBehavior;
-import cn.nukkit.dispenser.DispenseBehaviorRegister;
-import cn.nukkit.inventory.ContainerInventory;
-import cn.nukkit.inventory.Inventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.Faceable;
-import cn.nukkit.utils.Utils;
-
-import java.util.Map.Entry;
-
-/**
- * Created by CreeperFace on 15.4.2017.
- */
-public class BlockDispenser extends BlockSolidMeta implements Faceable {
-
- public BlockDispenser() {
- this(0);
- }
-
- public BlockDispenser(int meta) {
- super(meta);
- }
-
- @Override
- public boolean hasComparatorInputOverride() {
- return true;
- }
-
- @Override
- public String getName() {
- return "Dispenser";
- }
-
- @Override
- public int getId() {
- return DISPENSER;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public int getComparatorInputOverride() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityDispenser) {
- return ContainerInventory.calculateRedstone(((BlockEntityDispenser) blockEntity).getInventory());
- }
-
- return 0;
- }
-
- public boolean isTriggered() {
- return (this.getDamage() & 8) > 0;
- }
-
- public void setTriggered(boolean value) {
- int i = 0;
- i |= getBlockFace().getIndex();
-
- if (value) {
- i |= 8;
- }
-
- this.setDamage(i);
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player == null) {
- return false;
- }
-
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (!(blockEntity instanceof BlockEntityDispenser)) {
- return false;
- }
-
- player.addWindow(((BlockEntityDispenser) blockEntity).getInventory());
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (player != null) {
- if (Math.abs(player.x - this.x) < 2 && Math.abs(player.z - this.z) < 2) {
- double y = player.y + player.getEyeHeight();
-
- if (y - this.y > 2) {
- this.setDamage(BlockFace.UP.getIndex());
- } else if (this.y - y > 0) {
- this.setDamage(BlockFace.DOWN.getIndex());
- } else {
- this.setDamage(player.getHorizontalFacing().getOpposite().getIndex());
- }
- } else {
- this.setDamage(player.getHorizontalFacing().getOpposite().getIndex());
- }
- }
-
- this.getLevel().setBlock(block, this, true);
-
- BlockEntity.createBlockEntity(BlockEntity.DISPENSER, this.getChunk(), BlockEntity.getDefaultCompound(this, BlockEntity.DISPENSER));
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- this.setTriggered(false);
- this.level.setBlock(this, this, false, false);
-
- dispense();
- return type;
- } else if (type == Level.BLOCK_UPDATE_REDSTONE) {
- if ((level.isBlockPowered(this) || level.isBlockPowered(this.up())) && !isTriggered()) {
- this.setTriggered(true);
- this.level.setBlock(this, this, false, false);
- level.scheduleUpdate(this, this, 4);
- }
-
- return type;
- }
-
- return 0;
- }
-
- public void dispense() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (!(blockEntity instanceof BlockEntityDispenser)) {
- return;
- }
-
- int r = 1;
- int slot = -1;
- Item target = null;
-
- Inventory inv = ((BlockEntityDispenser) blockEntity).getInventory();
- for (Entry entry : inv.getContents().entrySet()) {
- Item item = entry.getValue();
-
- if (!item.isNull() && Utils.random.nextInt(r++) == 0) {
- target = item;
- slot = entry.getKey();
- }
- }
-
- if (target == null) {
- //this.level.addLevelSoundEvent(this); //TODO: sound
- return;
- }
- //Item origin = target;
- target = target.clone();
-
- DispenseBehavior behavior = DispenseBehaviorRegister.getBehavior(target.getId());
- Item result = behavior.dispense(this, getBlockFace(), target);
-
- if (result == null) {
- target.count--;
- inv.setItem(slot, target);
- } else {
- /*if (result.getId() != origin.getId() || result.getDamage() != origin.getDamage()) {
- Item[] fit = inv.addItem(result);
-
- if (fit.length > 0) {
- for (Item drop : fit) {
- this.level.dropItem(this, drop);
- }
- }
- } else {
- inv.setItem(slot, result);
- }*/
- inv.setItem(slot, result);
- }
- }
-
- public Vector3 getDispensePosition() {
- BlockFace facing = getBlockFace();
- return this.add(
- 0.5 + 0.7 * facing.getXOffset(),
- 0.5 + 0.7 * facing.getYOffset(),
- 0.5 + 0.7 * facing.getZOffset()
- );
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromIndex(this.getDamage() & 0x07);
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoor.java b/src/main/java/cn/nukkit/block/BlockDoor.java
deleted file mode 100644
index bca10fd19..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoor.java
+++ /dev/null
@@ -1,353 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.block.BlockRedstoneEvent;
-import cn.nukkit.event.block.DoorToggleEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemID;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.sound.DoorSound;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.Faceable;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockDoor extends BlockTransparentMeta implements Faceable {
-
- public static int DOOR_OPEN_BIT = 0x04;
- public static int DOOR_TOP_BIT = 0x08;
- public static int DOOR_HINGE_BIT = 0x01;
- public static int DOOR_POWERED_BIT = 0x02;
-
- private static final int[] faces = {1, 2, 3, 0};
-
- protected BlockDoor(int meta) {
- super(meta);
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- private int getFullDamage() {
- int up;
- int down;
- if (isTop()) {
- down = this.down().getDamage();
- up = this.getDamage();
- } else {
- down = this.getDamage();
- up = this.up().getDamage();
- }
-
- boolean isRight = (up & DOOR_HINGE_BIT) > 0;
-
- return down & 0x07 | (isTop() ? 0x08 : 0) | (isRight ? 0x10 : 0);
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
-
- double f = 0.1875;
- int damage = this.getFullDamage();
-
- AxisAlignedBB bb = new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 2,
- this.z + 1
- );
-
- int j = damage & 0x03;
- boolean isOpen = ((damage & 0x04) > 0);
- boolean isRight = ((damage & 0x10) > 0);
-
- if (j == 0) {
- if (isOpen) {
- if (!isRight) {
- bb.setBounds(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + f
- );
- } else {
- bb.setBounds(
- this.x,
- this.y,
- this.z + 1 - f,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- }
- } else {
- bb.setBounds(
- this.x,
- this.y,
- this.z,
- this.x + f,
- this.y + 1,
- this.z + 1
- );
- }
- } else if (j == 1) {
- if (isOpen) {
- if (!isRight) {
- bb.setBounds(
- this.x + 1 - f,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- } else {
- bb.setBounds(
- this.x,
- this.y,
- this.z,
- this.x + f,
- this.y + 1,
- this.z + 1
- );
- }
- } else {
- bb.setBounds(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + f
- );
- }
- } else if (j == 2) {
- if (isOpen) {
- if (!isRight) {
- bb.setBounds(
- this.x,
- this.y,
- this.z + 1 - f,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- } else {
- bb.setBounds(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + f
- );
- }
- } else {
- bb.setBounds(
- this.x + 1 - f,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- }
- } else if (j == 3) {
- if (isOpen) {
- if (!isRight) {
- bb.setBounds(
- this.x,
- this.y,
- this.z,
- this.x + f,
- this.y + 1,
- this.z + 1
- );
- } else {
- bb.setBounds(
- this.x + 1 - f,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- }
- } else {
- bb.setBounds(
- this.x,
- this.y,
- this.z + 1 - f,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- }
- }
-
- return bb;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().getId() == AIR) {
- Block up = this.up();
-
- if (up instanceof BlockDoor) {
- this.getLevel().setBlock(up, Block.get(BlockID.AIR), false);
- this.getLevel().useBreakOn(this, getToolType() == ItemTool.TYPE_PICKAXE ? Item.get(ItemID.DIAMOND_PICKAXE) : null); // Drop iron doors
- }
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
-
- if (type == Level.BLOCK_UPDATE_REDSTONE) {
- if ((!isOpen() && this.level.isBlockPowered(this.getLocation())) || (isOpen() && !this.level.isBlockPowered(this.getLocation()))) {
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, isOpen() ? 15 : 0, isOpen() ? 0 : 15));
-
- this.toggle(null);
- }
- }
-
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (this.y > 254) return false;
- if (face == BlockFace.UP) {
- Block blockUp = this.up();
- Block blockDown = this.down();
- if (!blockUp.canBeReplaced() || blockDown.isTransparent()) {
- return false;
- }
-
- int direction = faces[player != null ? player.getDirection().getHorizontalIndex() : 0];
-
- Block left = this.getSide(player.getDirection().rotateYCCW());
- Block right = this.getSide(player.getDirection().rotateY());
- int metaUp = DOOR_TOP_BIT;
- if (left.getId() == this.getId() || (!right.isTransparent() && left.isTransparent())) { //Door hinge
- metaUp |= DOOR_HINGE_BIT;
- }
-
- this.setDamage(direction);
- this.getLevel().setBlock(block, this, true, true); //Bottom
- this.getLevel().setBlock(blockUp, Block.get(this.getId(), metaUp), true); //Top
-
- if (!this.isOpen() && this.level.isBlockPowered(this.getLocation())) {
- this.toggle(null);
- metaUp |= DOOR_POWERED_BIT;
- this.getLevel().setBlockDataAt(blockUp.getFloorX(), blockUp.getFloorY(), blockUp.getFloorZ(), metaUp);
- }
-
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean onBreak(Item item) {
- if (isTop(this.getDamage())) {
- Block down = this.down();
- if (down.getId() == this.getId()) {
- this.getLevel().setBlock(down, Block.get(BlockID.AIR), true);
- }
- } else {
- Block up = this.up();
- if (up.getId() == this.getId()) {
- this.getLevel().setBlock(up, Block.get(BlockID.AIR), true);
- }
- }
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
-
- return true;
- }
-
- @Override
- public boolean onActivate(Item item) {
- return this.onActivate(item, null);
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (!this.toggle(player)) {
- return false;
- }
-
- this.level.addSound(new DoorSound(this));
- return true;
- }
-
- public boolean toggle(Player player) {
- DoorToggleEvent event = new DoorToggleEvent(this, player);
- this.getLevel().getServer().getPluginManager().callEvent(event);
-
- if (event.isCancelled()) {
- return false;
- }
-
- Block down;
- Block up;
- if (isTop(this.getDamage())) {
- down = this.down();
- up = this;
- } else {
- down = this;
- up = this.up();
- }
-
- if (up.getId() != down.getId()) {
- return false;
- }
-
- this.level.setBlockDataAt(down.getFloorX(), down.getFloorY(), down.getFloorZ(), down.getDamage() ^ 0x04);
- this.level.addSound(new DoorSound(this));
- return true;
- }
-
- public boolean isOpen() {
- if (isTop(this.getDamage())) {
- return (this.down().getDamage() & DOOR_OPEN_BIT) > 0;
- } else {
- return (this.getDamage() & DOOR_OPEN_BIT) > 0;
- }
- }
- public boolean isTop() {
- return isTop(this.getDamage());
- }
-
- public boolean isTop(int meta) {
- return (meta & DOOR_TOP_BIT) != 0;
- }
-
- public boolean isRightHinged() {
- if (isTop()) {
- return (this.getDamage() & DOOR_HINGE_BIT ) > 0;
- }
- return (this.up().getDamage() & DOOR_HINGE_BIT) > 0;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoorAcacia.java b/src/main/java/cn/nukkit/block/BlockDoorAcacia.java
deleted file mode 100644
index 0ca8279bb..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoorAcacia.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDoorAcacia;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockDoorAcacia extends BlockDoorWood {
-
- public BlockDoorAcacia() {
- this(0);
- }
-
- public BlockDoorAcacia(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Acacia Door Block";
- }
-
- @Override
- public int getId() {
- return ACACIA_DOOR_BLOCK;
- }
-
- @Override
- public Item toItem() {
- return new ItemDoorAcacia();
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.ORANGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoorBirch.java b/src/main/java/cn/nukkit/block/BlockDoorBirch.java
deleted file mode 100644
index 6556596f8..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoorBirch.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDoorBirch;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockDoorBirch extends BlockDoorWood {
-
- public BlockDoorBirch() {
- this(0);
- }
-
- public BlockDoorBirch(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Birch Door Block";
- }
-
- @Override
- public int getId() {
- return BIRCH_DOOR_BLOCK;
- }
-
- @Override
- public Item toItem() {
- return new ItemDoorBirch();
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SAND_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoorDarkOak.java b/src/main/java/cn/nukkit/block/BlockDoorDarkOak.java
deleted file mode 100644
index 4da32f31c..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoorDarkOak.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDoorDarkOak;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockDoorDarkOak extends BlockDoorWood {
-
- public BlockDoorDarkOak() {
- this(0);
- }
-
- public BlockDoorDarkOak(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Dark Oak Door Block";
- }
-
- @Override
- public int getId() {
- return DARK_OAK_DOOR_BLOCK;
- }
-
- @Override
- public Item toItem() {
- return new ItemDoorDarkOak();
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.BROWN_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoorIron.java b/src/main/java/cn/nukkit/block/BlockDoorIron.java
deleted file mode 100644
index df813f7a8..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoorIron.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDoorIron;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockDoorIron extends BlockDoor {
-
- public BlockDoorIron() {
- this(0);
- }
-
- public BlockDoorIron(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Iron Door Block";
- }
-
- @Override
- public int getId() {
- return IRON_DOOR_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 25;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemDoorIron();
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.IRON_BLOCK_COLOR;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoorJungle.java b/src/main/java/cn/nukkit/block/BlockDoorJungle.java
deleted file mode 100644
index 5f6cb1fed..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoorJungle.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDoorJungle;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockDoorJungle extends BlockDoorWood {
-
- public BlockDoorJungle() {
- this(0);
- }
-
- public BlockDoorJungle(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Jungle Door Block";
- }
-
- @Override
- public int getId() {
- return JUNGLE_DOOR_BLOCK;
- }
-
- @Override
- public Item toItem() {
- return new ItemDoorJungle();
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.DIRT_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoorSpruce.java b/src/main/java/cn/nukkit/block/BlockDoorSpruce.java
deleted file mode 100644
index 1f9accf6e..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoorSpruce.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDoorSpruce;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockDoorSpruce extends BlockDoorWood {
-
- public BlockDoorSpruce() {
- this(0);
- }
-
- public BlockDoorSpruce(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Spruce Door Block";
- }
-
- @Override
- public int getId() {
- return SPRUCE_DOOR_BLOCK;
- }
-
- @Override
- public Item toItem() {
- return new ItemDoorSpruce();
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SPRUCE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoorWood.java b/src/main/java/cn/nukkit/block/BlockDoorWood.java
deleted file mode 100644
index 3aa05917f..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoorWood.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDoorWood;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockDoorWood extends BlockDoor {
-
- public BlockDoorWood() {
- this(0);
- }
-
- public BlockDoorWood(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Wood Door Block";
- }
-
- @Override
- public int getId() {
- return WOOD_DOOR_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public Item toItem() {
- return new ItemDoorWood();
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoublePlant.java b/src/main/java/cn/nukkit/block/BlockDoublePlant.java
deleted file mode 100644
index 8f07ffd2e..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoublePlant.java
+++ /dev/null
@@ -1,174 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemSeedsWheat;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.particle.BoneMealParticle;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created on 2015/11/23 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockDoublePlant extends BlockFlowable {
-
- public static final int SUNFLOWER = 0;
- public static final int LILAC = 1;
- public static final int TALL_GRASS = 2;
- public static final int LARGE_FERN = 3;
- public static final int ROSE_BUSH = 4;
- public static final int PEONY = 5;
- public static final int TOP_HALF_BITMASK = 0x8;
-
- private static final String[] NAMES = new String[]{
- "Sunflower",
- "Lilac",
- "Double Tallgrass",
- "Large Fern",
- "Rose Bush",
- "Peony"
- };
-
- public BlockDoublePlant() {
- this(0);
- }
-
- public BlockDoublePlant(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return DOUBLE_PLANT;
- }
-
- @Override
- public boolean canBeReplaced() {
- return this.getDamage() == TALL_GRASS || this.getDamage() == LARGE_FERN;
- }
-
- @Override
- public String getName() {
- return NAMES[this.getDamage() > 5 ? 0 : this.getDamage()];
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if ((this.getDamage() & TOP_HALF_BITMASK) == TOP_HALF_BITMASK) {
- // Top
- if (!(this.down().getId() == DOUBLE_PLANT)) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), false, true);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else {
- // Bottom
- Block down = this.down();
- if ((down.isTransparent() && down.getId() != FARMLAND) || this.up().getId() != DOUBLE_PLANT) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- }
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = down();
- Block up = up();
-
- if (up.getId() == AIR && (down.getId() == GRASS || down.getId() == DIRT || down.getId() == PODZOL || down.getId() == FARMLAND)) {
- this.getLevel().setBlock(block, this, true, false); // If we update the bottom half, it will drop the item because there isn't a flower block above
- this.getLevel().setBlock(up, Block.get(DOUBLE_PLANT, getDamage() ^ TOP_HALF_BITMASK), true, true);
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean onBreak(Item item) {
- Block down = down();
-
- if ((this.getDamage() & TOP_HALF_BITMASK) == TOP_HALF_BITMASK) { // Top half
- this.getLevel().useBreakOn(down);
- } else {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
- }
-
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if ((this.getDamage() & TOP_HALF_BITMASK) != TOP_HALF_BITMASK) {
- switch (this.getDamage() & 0x07) {
- case TALL_GRASS:
- case LARGE_FERN:
- boolean dropSeeds = Utils.random.nextInt(10) == 0;
- if (item.isShears()) {
- //todo enchantment
- if (dropSeeds) {
- return new Item[]{
- new ItemSeedsWheat(0, 1),
- toItem()
- };
- } else {
- return new Item[]{
- toItem()
- };
- }
- }
-
- if (dropSeeds) {
- return new Item[]{
- new ItemSeedsWheat()
- };
- } else {
- return new Item[0];
- }
- }
-
- return new Item[]{toItem()};
- }
-
- return new Item[0];
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.getId() == Item.DYE && item.getDamage() == 0x0f) { // Bone meal
- int type = this.getDamage() & 0x07;
- if (type == SUNFLOWER || type == LILAC || type == ROSE_BUSH || type == PEONY) { // Flower
- if (player != null && !player.isCreative()) {
- item.count--;
- }
-
- this.level.addParticle(new BoneMealParticle(this));
- this.level.dropItem(this, this.toItem());
- }
- return true;
- }
-
- return false;
- }
-
- public Item toItem() {
- return new ItemBlock(this, this.getDamage() & 0x07, 1);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoubleSlab.java b/src/main/java/cn/nukkit/block/BlockDoubleSlab.java
deleted file mode 100644
index 80f8e5c46..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoubleSlab.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockDoubleSlab extends BlockSolidMeta {
-
- public static final int STONE = 0;
- public static final int SANDSTONE = 1;
- public static final int WOODEN = 2;
- public static final int COBBLESTONE = 3;
- public static final int BRICK = 4;
- public static final int STONE_BRICK = 5;
- public static final int QUARTZ = 6;
- public static final int NETHER_BRICK = 7;
-
- public BlockDoubleSlab() {
- this(0);
- }
-
- public BlockDoubleSlab(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return DOUBLE_SLAB;
- }
-
- //todo hardness and residence
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Stone",
- "Sandstone",
- "Wooden",
- "Cobblestone",
- "Brick",
- "Stone Brick",
- "Quartz",
- "Nether Brick"
- };
- return "Double " + names[this.getDamage() & 0x07] + " Slab";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- Item.get(Item.SLAB, this.getDamage() & 0x07, 2)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- switch (this.getDamage() & 0x07) {
- case BlockDoubleSlab.WOODEN:
- return BlockColor.WOOD_BLOCK_COLOR;
- default:
- case BlockDoubleSlab.COBBLESTONE:
- case BlockDoubleSlab.BRICK:
- case BlockDoubleSlab.STONE_BRICK:
- case BlockDoubleSlab.STONE:
- return BlockColor.STONE_BLOCK_COLOR;
- case BlockDoubleSlab.SANDSTONE:
- return BlockColor.SAND_BLOCK_COLOR;
- case BlockDoubleSlab.QUARTZ:
- return BlockColor.QUARTZ_BLOCK_COLOR;
- case BlockDoubleSlab.NETHER_BRICK:
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoubleSlabRedSandstone.java b/src/main/java/cn/nukkit/block/BlockDoubleSlabRedSandstone.java
deleted file mode 100644
index f427ddcee..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoubleSlabRedSandstone.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by CreeperFace on 26. 11. 2016.
- */
-public class BlockDoubleSlabRedSandstone extends BlockSolidMeta {
-
- public BlockDoubleSlabRedSandstone() {
- this(0);
- }
-
- public BlockDoubleSlabRedSandstone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return DOUBLE_RED_SANDSTONE_SLAB;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Red Sandstone",
- "Purpur",
- "",
- "",
- "",
- "",
- "",
- ""
- };
-
- return "Double " + names[this.getDamage() & 0x07] + " Slab";
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(RED_SANDSTONE_SLAB), this.getDamage() & 0x07);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- Item.get(Item.RED_SANDSTONE_SLAB, this.getDamage() & 0x07, 2)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- switch (this.getDamage() & 0x07) {
- case 0:
- return BlockColor.ORANGE_BLOCK_COLOR;
- case 1:
- return BlockColor.PURPLE_BLOCK_COLOR;
- default:
- return BlockColor.STONE_BLOCK_COLOR;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoubleSlabStone.java b/src/main/java/cn/nukkit/block/BlockDoubleSlabStone.java
deleted file mode 100644
index 2c97476b6..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoubleSlabStone.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockDoubleSlabStone extends BlockSolidMeta {
-
- public static final int STONE = 0;
- public static final int SANDSTONE = 1;
- public static final int WOODEN = 2;
- public static final int COBBLESTONE = 3;
- public static final int BRICK = 4;
- public static final int STONE_BRICK = 5;
- public static final int QUARTZ = 6;
- public static final int NETHER_BRICK = 7;
-
- public BlockDoubleSlabStone() {
- this(0);
- }
-
- public BlockDoubleSlabStone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return DOUBLE_SLAB;
- }
-
- @Override
- public double getResistance() {
- return getToolType() > ItemTool.TIER_WOODEN ? 30 : 15;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Stone",
- "Sandstone",
- "Wooden",
- "Cobblestone",
- "Brick",
- "Stone Brick",
- "Quartz",
- "Nether Brick"
- };
- return "Double " + names[this.getDamage() & 0x07] + " Slab";
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(STONE_SLAB), this.getDamage() & 0x07);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- Item.get(Item.SLAB, this.getDamage() & 0x07, 2)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- switch (this.getDamage() & 0x07) {
- default:
- case BlockDoubleSlabStone.STONE:
- case BlockDoubleSlabStone.COBBLESTONE:
- case BlockDoubleSlabStone.BRICK:
- case BlockDoubleSlabStone.STONE_BRICK:
- return BlockColor.STONE_BLOCK_COLOR;
- case BlockDoubleSlabStone.SANDSTONE:
- return BlockColor.SAND_BLOCK_COLOR;
- case BlockDoubleSlabStone.WOODEN:
- return BlockColor.WOOD_BLOCK_COLOR;
- case BlockDoubleSlabStone.QUARTZ:
- return BlockColor.QUARTZ_BLOCK_COLOR;
- case BlockDoubleSlabStone.NETHER_BRICK:
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDoubleSlabWood.java b/src/main/java/cn/nukkit/block/BlockDoubleSlabWood.java
deleted file mode 100644
index b75ff56d1..000000000
--- a/src/main/java/cn/nukkit/block/BlockDoubleSlabWood.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockDoubleSlabWood extends BlockSolidMeta {
-
- public BlockDoubleSlabWood() {
- this(0);
- }
-
- public BlockDoubleSlabWood(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return DOUBLE_WOOD_SLAB;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Oak",
- "Spruce",
- "Birch",
- "Jungle",
- "Acacia",
- "Dark Oak",
- "",
- ""
- };
- return "Double " + names[this.getDamage() & 0x07] + " Slab";
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(WOOD_SLAB), this.getDamage() & 0x07);
- }
-
- public Item[] getDrops(Item item) {
- return new Item[]{
- Item.get(Item.WOOD_SLAB, this.getDamage() & 0x07, 2)
- };
- }
-
- @Override
- public BlockColor getColor() {
- switch (this.getDamage() & 0x07) {
- default:
- case 0: //OAK
- return BlockColor.WOOD_BLOCK_COLOR;
- case 1: //SPRUCE
- return BlockColor.SPRUCE_BLOCK_COLOR;
- case 2: //BIRCH
- return BlockColor.SAND_BLOCK_COLOR;
- case 3: //JUNGLE
- return BlockColor.DIRT_BLOCK_COLOR;
- case 4: //Acacia
- return BlockColor.ORANGE_BLOCK_COLOR;
- case 5: //DARK OAK
- return BlockColor.BROWN_BLOCK_COLOR;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDragonEgg.java b/src/main/java/cn/nukkit/block/BlockDragonEgg.java
deleted file mode 100644
index a94cab1c3..000000000
--- a/src/main/java/cn/nukkit/block/BlockDragonEgg.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.event.block.BlockFromToEvent;
-import cn.nukkit.level.Level;
-import cn.nukkit.network.protocol.LevelEventPacket;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-public class BlockDragonEgg extends BlockFallable {
-
- @Override
- public String getName() {
- return "Dragon Egg";
- }
-
- @Override
- public int getId() {
- return DRAGON_EGG;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 45;
- }
-
- @Override
- public int getLightLevel() {
- return 1;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.OBSIDIAN_BLOCK_COLOR;
- }
-
- @Override
- public boolean isTransparent() {
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_TOUCH) {
- this.teleport();
- }
- return super.onUpdate(type);
- }
-
- public void teleport() {
- if (!level.randomTickingEnabled()) return;
- for (int i = 0; i < 1000; ++i) {
- Block to = this.getLevel().getBlock(this.add(Utils.random.nextInt(-16, 16), Utils.random.nextInt(-16, 16), Utils.random.nextInt(-16, 16)));
- if (to.getId() == AIR) {
- BlockFromToEvent event = new BlockFromToEvent(this, to);
- this.level.getServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) return;
- to = event.getTo();
- int diffX = this.getFloorX() - to.getFloorX();
- int diffY = this.getFloorY() - to.getFloorY();
- int diffZ = this.getFloorZ() - to.getFloorZ();
- LevelEventPacket pk = new LevelEventPacket();
- pk.evid = LevelEventPacket.EVENT_PARTICLE_DRAGON_EGG_TELEPORT;
- pk.data = (((((Math.abs(diffX) << 16) | (Math.abs(diffY) << 8)) | Math.abs(diffZ)) | ((diffX < 0 ? 1 : 0) << 24)) | ((diffY < 0 ? 1 : 0) << 25)) | ((diffZ < 0 ? 1 : 0) << 26);
- pk.x = this.getFloorX();
- pk.y = this.getFloorY();
- pk.z = this.getFloorZ();
- this.getLevel().addChunkPacket(this.getFloorX() >> 4, this.getFloorZ() >> 4, pk);
- this.getLevel().setBlock(this, get(AIR), true);
- this.getLevel().setBlock(to, this, true);
- return;
- }
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockDropper.java b/src/main/java/cn/nukkit/block/BlockDropper.java
deleted file mode 100644
index 1da1e16a5..000000000
--- a/src/main/java/cn/nukkit/block/BlockDropper.java
+++ /dev/null
@@ -1,224 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityDropper;
-import cn.nukkit.inventory.ContainerInventory;
-import cn.nukkit.inventory.Inventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.Faceable;
-import cn.nukkit.utils.Utils;
-
-import java.util.Map;
-import java.util.concurrent.ThreadLocalRandom;
-
-public class BlockDropper extends BlockSolidMeta implements Faceable {
-
- protected boolean triggered = false;
-
- public BlockDropper() {
- this(0);
- }
-
- public BlockDropper(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return DROPPER;
- }
-
- @Override
- public String getName() {
- return "Dropper";
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getResistance() {
- return 17.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (player != null) {
- if (Math.abs(player.x - this.x) < 2 && Math.abs(player.z - this.z) < 2) {
- double y = player.y + player.getEyeHeight();
-
- if (y - this.y > 2) {
- this.setDamage(BlockFace.UP.getIndex());
- } else if (this.y - y > 0) {
- this.setDamage(BlockFace.DOWN.getIndex());
- } else {
- this.setDamage(player.getHorizontalFacing().getOpposite().getIndex());
- }
- } else {
- this.setDamage(player.getHorizontalFacing().getOpposite().getIndex());
- }
- }
-
- this.getLevel().setBlock(block, this, true);
-
- BlockEntity.createBlockEntity(BlockEntity.DROPPER, this.getChunk(), BlockEntity.getDefaultCompound(this, BlockEntity.DROPPER));
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player == null) {
- return false;
- }
-
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (!(blockEntity instanceof BlockEntityDropper)) {
- return false;
- }
-
- player.addWindow(((BlockEntityDropper) blockEntity).getInventory());
- return true;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- public Vector3 getDispensePosition() {
- BlockFace facing = getBlockFace();
- return this.add(
- 0.5 + 0.7 * facing.getXOffset(),
- 0.5 + 0.7 * facing.getYOffset(),
- 0.5 + 0.7 * facing.getZOffset()
- );
- }
-
- public void dispense() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (!(blockEntity instanceof BlockEntityDropper)) {
- return;
- }
-
- int r = 1;
- int slot = -1;
- Item target = null;
-
- Inventory inv = ((BlockEntityDropper) blockEntity).getInventory();
- for (Map.Entry entry : inv.getContents().entrySet()) {
- Item item = entry.getValue();
-
- if (!item.isNull() && Utils.random.nextInt(r++) == 0) {
- target = item;
- slot = entry.getKey();
- }
- }
-
- if (target != null) {
- target = target.clone();
- drop(target);
-
- target.count--;
- inv.setItem(slot, target);
- }
- }
-
- public void drop(Item item) {
- BlockFace face = this.getBlockFace();
- Vector3 dispensePos = this.getDispensePosition();
-
- if (face.getAxis() == BlockFace.Axis.Y) {
- dispensePos.y -= 0.125;
- } else {
- dispensePos.y -= 0.15625;
- }
-
- ThreadLocalRandom rand = ThreadLocalRandom.current();
- Vector3 motion = new Vector3();
-
- double offset = rand.nextDouble() * 0.1 + 0.2;
-
- motion.x = face.getXOffset() * offset;
- motion.y = 0.1;
- motion.z = face.getZOffset() * offset;
-
- motion.x += rand.nextGaussian() * 0.007499999832361937 * 6;
- motion.y += rand.nextGaussian() * 0.007499999832361937 * 6;
- motion.z += rand.nextGaussian() * 0.007499999832361937 * 6;
-
- Item i = item.clone();
- i.setCount(1);
- this.level.dropItem(dispensePos, i, motion);
- }
-
- @Override
- public int getComparatorInputOverride() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityDropper) {
- return ContainerInventory.calculateRedstone(((BlockEntityDropper) blockEntity).getInventory());
- }
-
- return 0;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- triggered = false;
- dispense();
-
- return type;
- } else if (type == Level.BLOCK_UPDATE_REDSTONE) {
- if ((level.isBlockPowered(this) || level.isBlockPowered(this.up())) && !triggered) {
- triggered = true;
- level.scheduleUpdate(this, this, 4);
- }
-
- return type;
- }
-
- return 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockEmerald.java b/src/main/java/cn/nukkit/block/BlockEmerald.java
deleted file mode 100644
index e31af8631..000000000
--- a/src/main/java/cn/nukkit/block/BlockEmerald.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/1 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockEmerald extends BlockSolid {
-
- @Override
- public String getName() {
- return "Block of Emerald";
- }
-
- @Override
- public int getId() {
- return EMERALD_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.EMERALD_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockEnchantingTable.java b/src/main/java/cn/nukkit/block/BlockEnchantingTable.java
deleted file mode 100644
index 10604a506..000000000
--- a/src/main/java/cn/nukkit/block/BlockEnchantingTable.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityEnchantTable;
-import cn.nukkit.inventory.EnchantInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-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.BlockColor;
-
-import java.util.Map;
-
-/**
- * Created on 2015/11/22 by CreeperFace.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockEnchantingTable extends BlockTransparent {
-
- @Override
- public int getId() {
- return ENCHANTING_TABLE;
- }
-
- @Override
- public String getName() {
- return "Enchanting Table";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 6000;
- }
-
- @Override
- public int getLightLevel() {
- return 12;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.getLevel().setBlock(block, this, true, true);
-
- CompoundTag nbt = new CompoundTag()
- .putString("id", BlockEntity.ENCHANT_TABLE)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (item.hasCustomName()) {
- nbt.putString("CustomName", item.getCustomName());
- }
-
- if (item.hasCustomBlockData()) {
- Map customData = item.getCustomBlockData().getTags();
- for (Map.Entry tag : customData.entrySet()) {
- nbt.put(tag.getKey(), tag.getValue());
- }
- }
-
- BlockEntity.createBlockEntity(BlockEntity.ENCHANT_TABLE, getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
-
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null) {
- BlockEntity t = this.getLevel().getBlockEntity(this);
- BlockEntityEnchantTable enchantTable;
- if (t instanceof BlockEntityEnchantTable) {
- enchantTable = (BlockEntityEnchantTable) t;
- } else {
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.ENCHANT_TABLE)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- enchantTable = (BlockEntityEnchantTable) BlockEntity.createBlockEntity(BlockEntity.ENCHANT_TABLE, this.getChunk(), nbt);
- }
-
- if (enchantTable.namedTag.contains("Lock") && enchantTable.namedTag.get("Lock") instanceof StringTag) {
- if (!enchantTable.namedTag.getString("Lock").equals(item.getCustomName())) {
- return true;
- }
- }
-
- player.addWindow(new EnchantInventory(player.getUIInventory(), this.getLocation()), Player.ENCHANT_WINDOW_ID);
- }
-
- return true;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.RED_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockEndGateway.java b/src/main/java/cn/nukkit/block/BlockEndGateway.java
deleted file mode 100644
index 7202f2eaa..000000000
--- a/src/main/java/cn/nukkit/block/BlockEndGateway.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author PikyCZ
- */
-public class BlockEndGateway extends BlockSolid {
-
- @Override
- public String getName() {
- return "End Gateway";
- }
-
- @Override
- public int getId() {
- return END_GATEWAY;
- }
-
- @Override
- public boolean canPassThrough() {
- return true;
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public double getResistance() {
- return 18000000;
- }
-
- @Override
- public int getLightLevel() {
- return 15;
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.BLACK_BLOCK_COLOR;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(BlockID.AIR));
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockEndPortal.java b/src/main/java/cn/nukkit/block/BlockEndPortal.java
deleted file mode 100644
index e6b7afe54..000000000
--- a/src/main/java/cn/nukkit/block/BlockEndPortal.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockEndPortal extends BlockFlowable {
-
- public BlockEndPortal() {
- this(0);
- }
-
- public BlockEndPortal(int meta) {
- super(0);
- }
-
- @Override
- public String getName() {
- return "End Portal Block";
- }
-
- @Override
- public int getId() {
- return END_PORTAL;
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public double getResistance() {
- return 18000000;
- }
-
- @Override
- public int getLightLevel() {
- return 15;
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.BLACK_BLOCK_COLOR;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canBeFlowedInto() {
- return false;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(BlockID.AIR));
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockEndPortalFrame.java b/src/main/java/cn/nukkit/block/BlockEndPortalFrame.java
deleted file mode 100644
index 79671e513..000000000
--- a/src/main/java/cn/nukkit/block/BlockEndPortalFrame.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.network.protocol.LevelSoundEventPacket;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created by Pub4Game on 26.12.2015.
- */
-public class BlockEndPortalFrame extends BlockTransparentMeta implements Faceable {
-
- private static final int[] faces = {2, 3, 0, 1};
-
- public BlockEndPortalFrame() {
- this(0);
- }
-
- public BlockEndPortalFrame(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return END_PORTAL_FRAME;
- }
-
- @Override
- public double getResistance() {
- return 18000000;
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public int getLightLevel() {
- return 1;
- }
-
- @Override
- public String getName() {
- return "End Portal Frame";
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- x,
- y,
- z,
- x + 1,
- y + ((this.getDamage() & 0x04) > 0 ? 1 : 0.8125),
- z + 1
- );
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- public boolean hasComparatorInputOverride() {
- return true;
- }
-
- public int getComparatorInputOverride() {
- return (getDamage() & 4) != 0 ? 15 : 0;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if ((this.getDamage() & 0x04) == 0 && player != null && item.getId() == Item.ENDER_EYE && !player.isSneaking()) {
- this.setDamage(this.getDamage() + 4);
- this.getLevel().setBlock(this, this, true, false);
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_BLOCK_END_PORTAL_FRAME_FILL);
- for (int i = 0; i < 4; i++) {
- for (int j = -1; j <= 1; j++) {
- Block t = this.getSide(BlockFace.fromHorizontalIndex(i), 2).getSide(BlockFace.fromHorizontalIndex((i + 1) % 4), j);
- if (isCompletedPortal(t)) {
- for (int k = -1; k <= 1; k++) {
- for (int l = -1; l <= 1; l++) {
- this.getLevel().setBlock(t.add(k, 0, l), Block.get(Block.END_PORTAL), true);
- }
- }
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_BLOCK_END_PORTAL_SPAWN);
- return true;
- }
- }
- }
- return true;
- }
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
-
- private static boolean isCompletedPortal(Block center) {
- for (int i = 0; i < 4; i++) {
- for (int j = -1; j <= 1; j++) {
- Block block = center.getSide(BlockFace.fromHorizontalIndex(i), 2).getSide(BlockFace.fromHorizontalIndex((i + 1) % 4), j);
- if (block.getId() != Block.END_PORTAL_FRAME || (block.getDamage() & 0x4) == 0) {
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.GREEN_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockEndRod.java b/src/main/java/cn/nukkit/block/BlockEndRod.java
deleted file mode 100644
index e34b1becf..000000000
--- a/src/main/java/cn/nukkit/block/BlockEndRod.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.Faceable;
-
-/**
- * http://minecraft.gamepedia.com/End_Rod
- *
- * @author PikyCZ
- */
-public class BlockEndRod extends BlockTransparentMeta implements Faceable {
-
- private static final int[] faces = {0, 1, 3, 2, 5, 4};
-
- public BlockEndRod() {
- this(0);
- }
-
- public BlockEndRod(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "End Rod";
- }
-
- @Override
- public int getId() {
- return END_ROD;
- }
-
- @Override
- public double getHardness() {
- return 0;
- }
-
- @Override
- public double getResistance() {
- return 0;
- }
-
- @Override
- public int getLightLevel() {
- return 14;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x + 0.4,
- this.y,
- this.z + 0.4,
- this.x + 0.6,
- this.y + 1,
- this.z + 0.6
- );
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(faces[player != null ? face.getIndex() : 0]);
- this.getLevel().setBlock(block, this, true, true);
-
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockEndStone.java b/src/main/java/cn/nukkit/block/BlockEndStone.java
deleted file mode 100644
index 1956362e9..000000000
--- a/src/main/java/cn/nukkit/block/BlockEndStone.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/1 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockEndStone extends BlockSolid {
-
- @Override
- public String getName() {
- return "End Stone";
- }
-
- @Override
- public int getId() {
- return END_STONE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 45;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SAND_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockEnderChest.java b/src/main/java/cn/nukkit/block/BlockEnderChest.java
deleted file mode 100644
index 8798e2204..000000000
--- a/src/main/java/cn/nukkit/block/BlockEnderChest.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityEnderChest;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.mob.EntityPiglin;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.StringTag;
-import cn.nukkit.nbt.tag.Tag;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-public class BlockEnderChest extends BlockTransparentMeta implements Faceable {
-
- private static final int[] faces = {2, 5, 3, 4};
-
- private final Set viewers = new HashSet<>();
-
- public BlockEnderChest() {
- this(0);
- }
-
- public BlockEnderChest(int meta) {
- super(meta);
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public int getId() {
- return ENDER_CHEST;
- }
-
- @Override
- public int getLightLevel() {
- return 7;
- }
-
- @Override
- public String getName() {
- return "Chest";
- }
-
- @Override
- public double getHardness() {
- return 22.5;
- }
-
- @Override
- public double getResistance() {
- return 3000;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x + 0.0625,
- this.y,
- this.z + 0.0625,
- this.x + 0.9375,
- this.y + 0.9475,
- this.z + 0.9375
- );
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);
-
- this.getLevel().setBlock(block, this, true, true);
- CompoundTag nbt = new CompoundTag("")
- .putString("id", BlockEntity.ENDER_CHEST)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (item.hasCustomName()) {
- nbt.putString("CustomName", item.getCustomName());
- }
-
- if (item.hasCustomBlockData()) {
- Map customData = item.getCustomBlockData().getTags();
- for (Map.Entry tag : customData.entrySet()) {
- nbt.put(tag.getKey(), tag.getValue());
- }
- }
-
- BlockEntity.createBlockEntity(BlockEntity.ENDER_CHEST, this.getChunk(), nbt);
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null) {
- Block top = this.up();
- if (!top.isTransparent() && !(top instanceof BlockSlab && (top.getDamage() & 0x07) <= 0)) { // avoid issues with the slab hack
- return true;
- }
-
- BlockEntity t = this.getLevel().getBlockEntity(this);
- BlockEntityEnderChest chest;
- if (t instanceof BlockEntityEnderChest) {
- chest = (BlockEntityEnderChest) t;
- } else {
- CompoundTag nbt = new CompoundTag("")
- .putString("id", BlockEntity.ENDER_CHEST)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- chest = (BlockEntityEnderChest) BlockEntity.createBlockEntity(BlockEntity.ENDER_CHEST, this.getChunk(), nbt);
- }
-
- if (chest.namedTag.contains("Lock") && chest.namedTag.get("Lock") instanceof StringTag) {
- if (!chest.namedTag.getString("Lock").equals(item.getCustomName())) {
- return true;
- }
- }
-
- player.setViewingEnderChest(this);
- player.addWindow(player.getEnderChestInventory());
-
- for (Entity e : this.getChunk().getEntities().values()) {
- if (e instanceof EntityPiglin) {
- ((EntityPiglin) e).setAngry(600);
- }
- }
- }
-
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return new Item[]{
- Item.get(Item.OBSIDIAN, 0, 8)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.OBSIDIAN_BLOCK_COLOR;
- }
-
- public Set getViewers() {
- return viewers;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFallable.java b/src/main/java/cn/nukkit/block/BlockFallable.java
deleted file mode 100644
index 08d5b43ee..000000000
--- a/src/main/java/cn/nukkit/block/BlockFallable.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.entity.item.EntityFallingBlock;
-import cn.nukkit.event.block.BlockFallEvent;
-import cn.nukkit.level.Level;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.DoubleTag;
-import cn.nukkit.nbt.tag.FloatTag;
-import cn.nukkit.nbt.tag.ListTag;
-
-/**
- * @author rcsuperman
- * Nukkit Project
- */
-public abstract class BlockFallable extends BlockSolid {
-
- protected BlockFallable() {
- }
-
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (!this.getLevel().randomTickingEnabled()) return type;
- Block down = this.down();
- if (down.getId() == AIR || down instanceof BlockLiquid || down instanceof BlockFire) {
- BlockFallEvent event = new BlockFallEvent(this);
- this.level.getServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- return type;
- }
- this.level.setBlock(this, Block.get(Block.AIR), true, true);
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag("Pos")
- .add(new DoubleTag("", this.x + 0.5))
- .add(new DoubleTag("", this.y))
- .add(new DoubleTag("", this.z + 0.5)))
- .putList(new ListTag("Motion")
- .add(new DoubleTag("", 0))
- .add(new DoubleTag("", 0))
- .add(new DoubleTag("", 0)))
-
- .putList(new ListTag("Rotation")
- .add(new FloatTag("", 0))
- .add(new FloatTag("", 0)))
- .putInt("TileID", this.getId())
- .putByte("Data", this.getDamage());
-
- EntityFallingBlock fall = new EntityFallingBlock(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
-
- fall.spawnToAll();
- }
- }
- return type;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFallableMeta.java b/src/main/java/cn/nukkit/block/BlockFallableMeta.java
deleted file mode 100644
index 3f3797418..000000000
--- a/src/main/java/cn/nukkit/block/BlockFallableMeta.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.entity.item.EntityFallingBlock;
-import cn.nukkit.event.block.BlockFallEvent;
-import cn.nukkit.level.Level;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.DoubleTag;
-import cn.nukkit.nbt.tag.FloatTag;
-import cn.nukkit.nbt.tag.ListTag;
-
-/**
- * @author rcsuperman
- * Nukkit Project
- */
-public abstract class BlockFallableMeta extends BlockSolidMeta {
-
- protected BlockFallableMeta(int meta) {
- super(meta);
- }
-
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (!this.getLevel().randomTickingEnabled()) return type;
- Block down = this.down();
- if (down.getId() == AIR || down instanceof BlockLiquid || down instanceof BlockFire) {
- BlockFallEvent event = new BlockFallEvent(this);
- this.level.getServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- return type;
- }
- this.level.setBlock(this, Block.get(Block.AIR), true, true);
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag("Pos")
- .add(new DoubleTag("", this.x + 0.5))
- .add(new DoubleTag("", this.y))
- .add(new DoubleTag("", this.z + 0.5)))
- .putList(new ListTag("Motion")
- .add(new DoubleTag("", 0))
- .add(new DoubleTag("", 0))
- .add(new DoubleTag("", 0)))
-
- .putList(new ListTag("Rotation")
- .add(new FloatTag("", 0))
- .add(new FloatTag("", 0)))
- .putInt("TileID", this.getId())
- .putByte("Data", this.getDamage());
-
- EntityFallingBlock fall = new EntityFallingBlock(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
-
- fall.spawnToAll();
- }
- }
- return type;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFarmland.java b/src/main/java/cn/nukkit/block/BlockFarmland.java
deleted file mode 100644
index c0715f2f8..000000000
--- a/src/main/java/cn/nukkit/block/BlockFarmland.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFarmland extends BlockTransparentMeta {
-
- public BlockFarmland() {
- this(0);
- }
-
- public BlockFarmland(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Farmland";
- }
-
- @Override
- public int getId() {
- return FARMLAND;
- }
-
- @Override
- public double getResistance() {
- return 3;
- }
-
- @Override
- public double getHardness() {
- return 0.6;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1, // the actual bounding box is a normal cube
- this.z + 1
- );
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_RANDOM) {
- Block up = this.up();
-
- if (up instanceof BlockCrops) {
- return 0;
- }
-
- if (up.isSolid()) {
- this.level.setBlock(this, Block.get(BlockID.DIRT), false, true);
- return Level.BLOCK_UPDATE_RANDOM;
- }
-
- boolean found = false;
- Vector3 v = new Vector3();
-
- if (this.level.isRaining()) {
- found = true;
- } else {
- for (int x = (int) this.x - 4; x <= this.x + 4; x++) {
- for (int z = (int) this.z - 4; z <= this.z + 4; z++) {
- for (int y = (int) this.y; y <= this.y + 1; y++) {
- if (z == this.z && x == this.x && y == this.y) {
- continue;
- }
-
- v.setComponents(x, y, z);
- int block = this.level.getBlockIdAt(v.getFloorX(), v.getFloorY(), v.getFloorZ());
-
- if (block == WATER || block == STILL_WATER || block == FROSTED_ICE) {
- found = true;
- break;
- }
- }
- }
- }
- }
-
- Block block = this.level.getBlock(v.setComponents(x, y - 1, z));
- if (found || block instanceof BlockWater || block instanceof BlockIceFrosted) {
- if (this.getDamage() < 7) {
- this.setDamage(7);
- this.level.setBlock(this, this, false, false);
- }
- return Level.BLOCK_UPDATE_RANDOM;
- }
-
- if (this.getDamage() > 0) {
- this.setDamage(this.getDamage() - 1);
- this.level.setBlock(this, this, false, false);
- } else {
- this.level.setBlock(this, Block.get(Block.DIRT), false, true);
- }
-
- return Level.BLOCK_UPDATE_RANDOM;
- } else if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.up().isSolid()) {
- this.level.setBlock(this, Block.get(DIRT), false, false);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
-
- return 0;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(BlockID.DIRT));
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.DIRT_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFence.java b/src/main/java/cn/nukkit/block/BlockFence.java
deleted file mode 100644
index 8580a0736..000000000
--- a/src/main/java/cn/nukkit/block/BlockFence.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/7 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFence extends BlockTransparentMeta {
-
- public static final int FENCE_OAK = 0;
- public static final int FENCE_SPRUCE = 1;
- public static final int FENCE_BIRCH = 2;
- public static final int FENCE_JUNGLE = 3;
- public static final int FENCE_ACACIA = 4;
- public static final int FENCE_DARK_OAK = 5;
-
- public BlockFence() {
- this(0);
- }
-
- public BlockFence(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return FENCE;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Oak Fence",
- "Spruce Fence",
- "Birch Fence",
- "Jungle Fence",
- "Acacia Fence",
- "Dark Oak Fence",
- "",
- ""
- };
- return names[this.getDamage() & 0x07];
- }
-
- protected AxisAlignedBB recalculateBoundingBox() {
- boolean north = this.canConnect(this.north());
- boolean south = this.canConnect(this.south());
- boolean west = this.canConnect(this.west());
- boolean east = this.canConnect(this.east());
- double n = north ? 0 : 0.375;
- double s = south ? 1 : 0.625;
- double w = west ? 0 : 0.375;
- double e = east ? 1 : 0.625;
- return new AxisAlignedBB(
- this.x + w,
- this.y,
- this.z + n,
- this.x + e,
- this.y + 1.5,
- this.z + s
- );
- }
-
- @Override
- public int getBurnChance() {
- return 5;
- }
-
- @Override
- public int getBurnAbility() {
- return 20;
- }
-
- public boolean canConnect(Block block) {
- return (block instanceof BlockFence || block instanceof BlockFenceGate) || block.isSolid() && !block.isTransparent();
- }
-
- @Override
- public BlockColor getColor() {
- switch (this.getDamage() & 0x07) {
- default:
- case FENCE_OAK: //OAK
- return BlockColor.WOOD_BLOCK_COLOR;
- case FENCE_SPRUCE: //SPRUCE
- return BlockColor.SPRUCE_BLOCK_COLOR;
- case FENCE_BIRCH: //BIRCH
- return BlockColor.SAND_BLOCK_COLOR;
- case FENCE_JUNGLE: //JUNGLE
- return BlockColor.DIRT_BLOCK_COLOR;
- case FENCE_ACACIA: //ACACIA
- return BlockColor.ORANGE_BLOCK_COLOR;
- case FENCE_DARK_OAK: //DARK OAK
- return BlockColor.BROWN_BLOCK_COLOR;
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, this.getDamage());
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFenceGate.java b/src/main/java/cn/nukkit/block/BlockFenceGate.java
deleted file mode 100644
index b750161a4..000000000
--- a/src/main/java/cn/nukkit/block/BlockFenceGate.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.block.DoorToggleEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.sound.DoorSound;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created on 2015/11/23 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFenceGate extends BlockTransparentMeta implements Faceable {
-
- public BlockFenceGate() {
- this(0);
- }
-
- public BlockFenceGate(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return FENCE_GATE_OAK;
- }
-
- @Override
- public String getName() {
- return "Oak Fence Gate";
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- if ((this.getDamage() & 0x04) > 0) {
- return null;
- }
- int i = this.getDamage() & 0x03;
- if (i == 2 || i == 0) {
- return new AxisAlignedBB(
- x,
- y,
- z + 0.375,
- x + 1,
- y + 1.5,
- z + 0.625
- );
- } else {
- return new AxisAlignedBB(
- x + 0.375,
- y,
- z,
- x + 0.625,
- y + 1.5,
- z + 1
- );
- }
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(player != null ? player.getDirection().getHorizontalIndex() : 0);
- this.getLevel().setBlock(block, this, true, true);
-
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player == null) {
- return false;
- }
-
- if (!this.toggle(player)) {
- return false;
- }
-
- this.getLevel().setBlock(this, this, true);
- this.getLevel().addSound(new DoorSound(this));
-
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-
- public boolean toggle(Player player) {
- DoorToggleEvent event = new DoorToggleEvent(this, player);
- this.getLevel().getServer().getPluginManager().callEvent(event);
-
- if (event.isCancelled()) {
- return false;
- }
-
- player = event.getPlayer();
-
- int direction;
-
- if (player != null) {
- double yaw = player.yaw;
- double rotation = (yaw - 90) % 360;
-
- if (rotation < 0) {
- rotation += 360.0;
- }
-
- int originDirection = this.getDamage() & 0x01;
-
- if (originDirection == 0) {
- if (rotation >= 0 && rotation < 180) {
- direction = 2;
- } else {
- direction = 0;
- }
- } else {
- if (rotation >= 90 && rotation < 270) {
- direction = 3;
- } else {
- direction = 1;
- }
- }
- } else {
- int originDirection = this.getDamage() & 0x01;
-
- if (originDirection == 0) {
- direction = 0;
- } else {
- direction = 1;
- }
- }
-
- this.setDamage(direction | ((~this.getDamage()) & 0x04));
- this.level.addSound(new DoorSound(this));
- this.level.setBlock(this, this, false, false);
- return true;
- }
-
- public boolean isOpen() {
- return (this.getDamage() & 0x04) > 0;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_REDSTONE) {
- if ((!isOpen() && this.level.isBlockPowered(this.getLocation())) || (isOpen() && !this.level.isBlockPowered(this.getLocation()))) {
- this.toggle(null);
- return type;
- }
- }
-
- return 0;
- }
-
- @Override
- public Item toItem() {
- return Item.get(Item.FENCE_GATE, 0, 1);
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public boolean canPassThrough() {
- return this.isOpen();
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFenceGateAcacia.java b/src/main/java/cn/nukkit/block/BlockFenceGateAcacia.java
deleted file mode 100644
index 69663971f..000000000
--- a/src/main/java/cn/nukkit/block/BlockFenceGateAcacia.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/23 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFenceGateAcacia extends BlockFenceGate {
-
- public BlockFenceGateAcacia() {
- this(0);
- }
-
- public BlockFenceGateAcacia(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return FENCE_GATE_ACACIA;
- }
-
- @Override
- public String getName() {
- return "Acacia Fence Gate";
- }
-
- @Override
- public Item toItem() {
- return Item.get(Item.FENCE_GATE_ACACIA, 0, 1);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.ORANGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFenceGateBirch.java b/src/main/java/cn/nukkit/block/BlockFenceGateBirch.java
deleted file mode 100644
index 97654be29..000000000
--- a/src/main/java/cn/nukkit/block/BlockFenceGateBirch.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/23 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFenceGateBirch extends BlockFenceGate {
-
- public BlockFenceGateBirch() {
- this(0);
- }
-
- public BlockFenceGateBirch(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return FENCE_GATE_BIRCH;
- }
-
- @Override
- public String getName() {
- return "Birch Fence Gate";
- }
-
- @Override
- public Item toItem() {
- return Item.get(Item.FENCE_GATE_BIRCH, 0, 1);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SAND_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFenceGateDarkOak.java b/src/main/java/cn/nukkit/block/BlockFenceGateDarkOak.java
deleted file mode 100644
index 04ca651b2..000000000
--- a/src/main/java/cn/nukkit/block/BlockFenceGateDarkOak.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/23 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFenceGateDarkOak extends BlockFenceGate {
-
- public BlockFenceGateDarkOak() {
- this(0);
- }
-
- public BlockFenceGateDarkOak(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return FENCE_GATE_DARK_OAK;
- }
-
- @Override
- public String getName() {
- return "Dark Oak Fence Gate";
- }
-
- @Override
- public Item toItem() {
- return Item.get(Item.FENCE_GATE_DARK_OAK, 0, 1);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.BROWN_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFenceGateJungle.java b/src/main/java/cn/nukkit/block/BlockFenceGateJungle.java
deleted file mode 100644
index eb5e17648..000000000
--- a/src/main/java/cn/nukkit/block/BlockFenceGateJungle.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/23 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFenceGateJungle extends BlockFenceGate {
-
- public BlockFenceGateJungle() {
- this(0);
- }
-
- public BlockFenceGateJungle(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return FENCE_GATE_JUNGLE;
- }
-
- @Override
- public String getName() {
- return "Jungle Fence Gate";
- }
-
- @Override
- public Item toItem() {
- return Item.get(Item.FENCE_GATE_JUNGLE, 0, 1);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.DIRT_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFenceGateSpruce.java b/src/main/java/cn/nukkit/block/BlockFenceGateSpruce.java
deleted file mode 100644
index 8b38f74df..000000000
--- a/src/main/java/cn/nukkit/block/BlockFenceGateSpruce.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/23 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFenceGateSpruce extends BlockFenceGate {
-
- public BlockFenceGateSpruce() {
- this(0);
- }
-
- public BlockFenceGateSpruce(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return FENCE_GATE_SPRUCE;
- }
-
- @Override
- public String getName() {
- return "Spruce Fence Gate";
- }
-
- @Override
- public Item toItem() {
- return Item.get(Item.FENCE_GATE_SPRUCE,0, 1);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SPRUCE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFenceNetherBrick.java b/src/main/java/cn/nukkit/block/BlockFenceNetherBrick.java
deleted file mode 100644
index baa16ba4c..000000000
--- a/src/main/java/cn/nukkit/block/BlockFenceNetherBrick.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/7 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFenceNetherBrick extends BlockFence {
-
- public BlockFenceNetherBrick() {
- this(0);
- }
-
- public BlockFenceNetherBrick(int meta) {
- super(meta);
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Nether Brick Fence";
- }
-
- @Override
- public int getId() {
- return NETHER_BRICK_FENCE;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canConnect(Block block) {
- return (block instanceof BlockFenceNetherBrick || block instanceof BlockFenceGate) || block.isSolid() && !block.isTransparent();
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public int getBurnChance() {
- return 0;
- }
-
- @Override
- public int getBurnAbility() {
- return 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFire.java b/src/main/java/cn/nukkit/block/BlockFire.java
deleted file mode 100644
index fe05311a2..000000000
--- a/src/main/java/cn/nukkit/block/BlockFire.java
+++ /dev/null
@@ -1,304 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Server;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.item.EntityPotion;
-import cn.nukkit.entity.projectile.EntityArrow;
-import cn.nukkit.event.block.BlockBurnEvent;
-import cn.nukkit.event.block.BlockIgniteEvent;
-import cn.nukkit.event.entity.EntityCombustByBlockEvent;
-import cn.nukkit.event.entity.EntityDamageByBlockEvent;
-import cn.nukkit.event.entity.EntityDamageEvent.DamageCause;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.GameRule;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.potion.Effect;
-import cn.nukkit.potion.Potion;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockFire extends BlockFlowable {
-
- public BlockFire() {
- this(0);
- }
-
- public BlockFire(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return FIRE;
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public String getName() {
- return "Fire Block";
- }
-
- @Override
- public int getLightLevel() {
- return 15;
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public boolean canBeReplaced() {
- return true;
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- if (entity instanceof EntityPotion) {
- if (((EntityPotion) entity).potionId == Potion.WATER) {
- this.level.setBlock(this, Block.get(AIR));
- }
- return;
- }
-
- if (!entity.hasEffect(Effect.FIRE_RESISTANCE) && this.level.getGameRules().getBoolean(GameRule.FIRE_DAMAGE)) {
- entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.FIRE, 1));
- }
-
- EntityCombustByBlockEvent ev = new EntityCombustByBlockEvent(this, entity, 8);
- if (entity instanceof EntityArrow) {
- ev.setCancelled();
- }
- Server.getInstance().getPluginManager().callEvent(ev);
- if (!ev.isCancelled() && entity.isAlive() && entity.noDamageTicks == 0) {
- entity.setOnFire(ev.getDuration());
- }
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_RANDOM) {
- if (!this.isBlockTopFacingSurfaceSolid(this.down()) && !this.canNeighborBurn()) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- } else if (!Server.getInstance().suomiCraftPEMode() && this.level.gameRules.getBoolean(GameRule.DO_FIRE_TICK) && !level.isUpdateScheduled(this, this)) {
- level.scheduleUpdate(this, tickRate());
- }
-
- return Level.BLOCK_UPDATE_NORMAL;
- } else if (type == Level.BLOCK_UPDATE_SCHEDULED && this.level.gameRules.getBoolean(GameRule.DO_FIRE_TICK)) {
- Block down = this.down();
- boolean forever = down.getId() == NETHERRACK || down.getId() == MAGMA || (down.getId() == BEDROCK && level.getDimension() == Level.DIMENSION_THE_END);
-
- if (!forever && this.getLevel().isRaining() &&
- (this.getLevel().canBlockSeeSky(this) ||
- this.getLevel().canBlockSeeSky(this.east()) ||
- this.getLevel().canBlockSeeSky(this.west()) ||
- this.getLevel().canBlockSeeSky(this.south()) ||
- this.getLevel().canBlockSeeSky(this.north()))
- ) {
-
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- }
-
- if (Server.getInstance().suomiCraftPEMode()) {
- if (forever) return 0;
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- return 0;
- }
-
- if (!this.isBlockTopFacingSurfaceSolid(down) && !this.canNeighborBurn()) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- return 0;
- }
-
- int meta = this.getDamage();
-
- if (meta < 15) {
- int newMeta = meta + Utils.random.nextInt(3);
- if (newMeta > 15) newMeta = 15;
- this.setDamage(newMeta);
- this.getLevel().setBlock(this, this, true);
- }
-
- this.getLevel().scheduleUpdate(this, this.tickRate() + Utils.random.nextInt(10));
-
- if (!forever && !this.canNeighborBurn()) {
- if (!this.isBlockTopFacingSurfaceSolid(this.down()) || meta > 3) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- }
- } else if (!forever && !(this.down().getBurnAbility() > 0) && meta == 15 && Utils.random.nextInt(4) == 0) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- } else {
- int o = 0;
-
- //TODO: decrease the o if the rainfall values are high
-
- this.tryToCatchBlockOnFire(this.east(), 300 + o, meta);
- this.tryToCatchBlockOnFire(this.west(), 300 + o, meta);
- this.tryToCatchBlockOnFire(this.down(), 250 + o, meta);
- this.tryToCatchBlockOnFire(this.up(), 250 + o, meta);
- this.tryToCatchBlockOnFire(this.south(), 300 + o, meta);
- this.tryToCatchBlockOnFire(this.north(), 300 + o, meta);
-
- for (int x = (int) (this.x - 1); x <= (int) (this.x + 1); ++x) {
- for (int z = (int) (this.z - 1); z <= (int) (this.z + 1); ++z) {
- for (int y = (int) (this.y - 1); y <= (int) (this.y + 4); ++y) {
- if (x != (int) this.x || y != (int) this.y || z != (int) this.z) {
- int k = 100;
-
- if (y > this.y + 1) {
- k += (y - (this.y + 1)) * 100;
- }
-
- Block block = this.getLevel().getBlock(new Vector3(x, y, z));
- int chance = getChanceOfNeighborsEncouragingFire(block);
-
- if (chance > 0) {
- int t = (chance + 40 + this.getLevel().getServer().getDifficulty() * 7) / (meta + 30);
-
- //TODO: decrease the t if the rainfall values are high
-
- if (t > 0 && Utils.random.nextInt(k) <= t) {
- int damage = meta + (Utils.random.nextInt(5) >> 2);
-
- if (damage > 15) {
- damage = 15;
- }
-
- BlockIgniteEvent e = new BlockIgniteEvent(block, this, null, BlockIgniteEvent.BlockIgniteCause.SPREAD);
- this.level.getServer().getPluginManager().callEvent(e);
-
- if (!e.isCancelled()) {
- this.getLevel().setBlock(block, Block.get(FIRE, damage), true);
- this.getLevel().scheduleUpdate(block, this.tickRate());
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- return 0;
- }
-
- private void tryToCatchBlockOnFire(Block block, int bound, int damage) {
- if (Utils.random.nextInt(bound) < block.getBurnAbility()) {
-
- if (Utils.random.nextInt(damage + 10) < 5) {
- int meta = damage + (Utils.random.nextInt(5) >> 2);
-
- if (meta > 15) {
- meta = 15;
- }
-
- BlockIgniteEvent e = new BlockIgniteEvent(block, this, null, BlockIgniteEvent.BlockIgniteCause.SPREAD);
- this.level.getServer().getPluginManager().callEvent(e);
-
- if (!e.isCancelled()) {
- this.getLevel().setBlock(block, Block.get(FIRE, meta), true);
- this.getLevel().scheduleUpdate(block, this.tickRate());
- }
- } else {
- BlockBurnEvent ev = new BlockBurnEvent(block);
- this.getLevel().getServer().getPluginManager().callEvent(ev);
-
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(block, Block.get(BlockID.AIR), true);
- }
- }
-
- if (block instanceof BlockTNT) {
- ((BlockTNT) block).prime();
- }
- }
- }
-
- private static int getChanceOfNeighborsEncouragingFire(Block block) {
- if (block.getId() != AIR) {
- return 0;
- } else {
- int chance = 0;
- chance = Math.max(chance, block.east().getBurnChance());
- chance = Math.max(chance, block.west().getBurnChance());
- chance = Math.max(chance, block.down().getBurnChance());
- chance = Math.max(chance, block.up().getBurnChance());
- chance = Math.max(chance, block.south().getBurnChance());
- chance = Math.max(chance, block.north().getBurnChance());
- return chance;
- }
- }
-
- public boolean canNeighborBurn() {
- for (BlockFace face : BlockFace.values()) {
- if (this.getSide(face).getBurnChance() > 0) {
- return true;
- }
- }
-
- return false;
- }
-
- public boolean isBlockTopFacingSurfaceSolid(Block block) {
- if (block != null) {
- if (block.isSolid()) {
- return true;
- } else {
- if (block instanceof BlockStairs && (block.getDamage() & 4) == 4) {
- return true;
- } else if (block instanceof BlockSlab && (block.getDamage() & 8) == 8) {
- return true;
- } else return block instanceof BlockSnowLayer && (block.getDamage() & 7) == 7;
- }
- }
-
- return false;
- }
-
- @Override
- public int tickRate() {
- return 30;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- @Override
- protected AxisAlignedBB recalculateCollisionBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(BlockID.AIR));
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFlowable.java b/src/main/java/cn/nukkit/block/BlockFlowable.java
deleted file mode 100644
index 55cf44d99..000000000
--- a/src/main/java/cn/nukkit/block/BlockFlowable.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.math.AxisAlignedBB;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockFlowable extends BlockTransparentMeta {
-
- protected BlockFlowable(int meta) {
- super(meta);
- }
-
- @Override
- public boolean canBeFlowedInto() {
- return true;
- }
-
- @Override
- public boolean canPassThrough() {
- return true;
- }
-
- @Override
- public double getHardness() {
- return 0;
- }
-
- @Override
- public double getResistance() {
- return 0;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return null;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFlower.java b/src/main/java/cn/nukkit/block/BlockFlower.java
deleted file mode 100644
index f5aaa83ab..000000000
--- a/src/main/java/cn/nukkit/block/BlockFlower.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.particle.BoneMealParticle;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created on 2015/11/23 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockFlower extends BlockFlowable {
-
- public static final int TYPE_POPPY = 0;
- public static final int TYPE_BLUE_ORCHID = 1;
- public static final int TYPE_ALLIUM = 2;
- public static final int TYPE_AZURE_BLUET = 3;
- public static final int TYPE_RED_TULIP = 4;
- public static final int TYPE_ORANGE_TULIP = 5;
- public static final int TYPE_WHITE_TULIP = 6;
- public static final int TYPE_PINK_TULIP = 7;
- public static final int TYPE_OXEYE_DAISY = 8;
- public static final int CORNFLOWER = 9;
- public static final int LILY_OF_THE_VALLEY = 10;
-
- private static final String[] names = new String[]{
- "Poppy",
- "Blue Orchid",
- "Allium",
- "Azure Bluet",
- "Red Tulip",
- "Orange Tulip",
- "White Tulip",
- "Pink Tulip",
- "Oxeye Daisy",
- "Cornflower",
- "Lily of the Valley",
- "Unknown",
- "Unknown",
- "Unknown",
- "Unknown",
- "Unknown"
- };
-
- public BlockFlower() {
- this(0);
- }
-
- public BlockFlower(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return FLOWER;
- }
-
- @Override
- public String getName() {
- return names[this.getDamage() & 0x0f];
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = this.down();
- if (down.getId() == Block.GRASS || down.getId() == Block.DIRT || down.getId() == Block.FARMLAND || down.getId() == Block.PODZOL) {
- this.getLevel().setBlock(block, this, true);
-
- return true;
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().isTransparent()) {
- this.getLevel().useBreakOn(this);
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
-
- return 0;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.getId() == Item.DYE && item.getDamage() == 0x0f) { // Bone meal
- if (player != null && !player.isCreative()) {
- item.count--;
- }
-
- this.level.addParticle(new BoneMealParticle(this));
-
- for (int i = 0; i < 8; i++) {
- Vector3 vec = this.add(
- Utils.random.nextInt(-3, 4),
- Utils.random.nextInt(-1, 2),
- Utils.random.nextInt(-3, 4));
-
- if (level.getBlock(vec).getId() == AIR && level.getBlock(vec.down()).getId() == GRASS && vec.getY() >= 0 && vec.getY() < 256) {
- if (Utils.random.nextInt(10) == 0) {
- this.level.setBlock(vec, this.getUncommonFlower(), true);
- } else {
- this.level.setBlock(vec, get(this.getId()), true);
- }
- }
- }
-
- return true;
- }
-
- return false;
- }
-
- protected Block getUncommonFlower() {
- return get(DANDELION);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFlowerPot.java b/src/main/java/cn/nukkit/block/BlockFlowerPot.java
deleted file mode 100644
index 8ad321494..000000000
--- a/src/main/java/cn/nukkit/block/BlockFlowerPot.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityFlowerPot;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemFlowerPot;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.Tag;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockFlowerPot extends BlockFlowable {
-
- public BlockFlowerPot() {
- this(0);
- }
-
- public BlockFlowerPot(int meta) {
- super(meta);
- }
-
- protected static boolean canPlaceIntoFlowerPot(int id, int dmg) {
- switch (id) {
- case SAPLING:
- case DEAD_BUSH:
- case DANDELION:
- case ROSE:
- case RED_MUSHROOM:
- case BROWN_MUSHROOM:
- case CACTUS:
- return true;
- case TALL_GRASS:
- if (dmg == 2 || dmg == 3) {
- return true;
- }
- default:
- return false;
- }
- }
-
- @Override
- public String getName() {
- return "Flower Pot";
- }
-
- @Override
- public int getId() {
- return FLOWER_POT_BLOCK;
- }
-
- private boolean isSupportValid(Block block) {
- return block.isSolid() || block instanceof BlockFence || block instanceof BlockWall || block instanceof BlockHopper;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (!isSupportValid(down())) {
- level.useBreakOn(this);
- return type;
- }
- }
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (!isSupportValid(down())) return false;
- CompoundTag nbt = new CompoundTag()
- .putString("id", BlockEntity.FLOWER_POT)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putShort("item", 0)
- .putInt("data", 0);
- if (item.hasCustomBlockData()) {
- for (Tag aTag : item.getCustomBlockData().getAllTags()) {
- nbt.put(aTag.getName(), aTag);
- }
- }
- BlockEntity.createBlockEntity(BlockEntity.FLOWER_POT, this.level.getChunk(block.getChunkX(), block.getChunkZ()), nbt);
-
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item) {
- return this.onActivate(item, null);
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- BlockEntity blockEntity = getLevel().getBlockEntity(this);
- if (!(blockEntity instanceof BlockEntityFlowerPot)) return false;
- if (blockEntity.namedTag.getShort("item") != AIR || blockEntity.namedTag.getInt("mData") != AIR) {
- if (!canPlaceIntoFlowerPot(item.getId(), item.getDamage())) {
- int id = blockEntity.namedTag.getShort("item");
- if (id == AIR) id = blockEntity.namedTag.getInt("mData");
- for (Item drop : player.getInventory().addItem(Item.get(id, blockEntity.namedTag.getInt("data")))) {
- player.dropItem(drop);
- }
-
- blockEntity.namedTag.putShort("item", AIR);
- blockEntity.namedTag.putInt("data", 0);
- this.setDamage(0);
- this.level.setBlock(this, this, true);
- ((BlockEntityFlowerPot) blockEntity).spawnToAll();
- return true;
- }
- return false;
- }
- int itemID;
- if (!canPlaceIntoFlowerPot(item.getId(), item.getDamage())) {
- Block b = item.getBlock();
- if (!canPlaceIntoFlowerPot(b.getId(), b.getDamage())) {
- return true;
- }
- itemID = b.getId();
- } else {
- itemID = item.getId();
- }
- blockEntity.namedTag.putShort("item", itemID);
- blockEntity.namedTag.putInt("data", item.getDamage());
-
- this.setDamage(1);
- this.getLevel().setBlock(this, this, true);
- ((BlockEntityFlowerPot) blockEntity).spawnToAll();
-
- if (!player.isCreative()) {
- item.setCount(item.getCount() - 1);
- player.getInventory().setItemInHand(item.getCount() > 0 ? item : Item.get(Item.AIR));
- }
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- boolean dropInside = false;
- int insideID = 0;
- int insideMeta = 0;
- BlockEntity blockEntity = getLevel().getBlockEntity(this);
- if (blockEntity instanceof BlockEntityFlowerPot) {
- dropInside = true;
- insideID = blockEntity.namedTag.getShort("item");
- insideMeta = blockEntity.namedTag.getInt("data");
- }
-
- if (dropInside) {
- return new Item[]{
- new ItemFlowerPot(),
- Item.get(insideID, insideMeta, 1)
- };
- } else {
- return new Item[]{
- new ItemFlowerPot()
- };
- }
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(this.x + 0.3125, this.y, this.z + 0.3125, this.x + 0.6875, this.y + 0.375, this.z + 0.6875);
- }
-
- @Override
- public boolean canPassThrough() {
- return false;
- }
-
- @Override
- public Item toItem() {
- return new ItemFlowerPot();
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockFurnace.java b/src/main/java/cn/nukkit/block/BlockFurnace.java
deleted file mode 100644
index ac7ba3988..000000000
--- a/src/main/java/cn/nukkit/block/BlockFurnace.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.Faceable;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockFurnace extends BlockFurnaceBurning implements Faceable {
-
- public BlockFurnace() {
- this(0);
- }
-
- public BlockFurnace(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Furnace";
- }
-
- @Override
- public int getId() {
- return FURNACE;
- }
-
- @Override
- public int getLightLevel() {
- return 0;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockFurnaceBurning.java b/src/main/java/cn/nukkit/block/BlockFurnaceBurning.java
deleted file mode 100644
index 0ff9d2c6a..000000000
--- a/src/main/java/cn/nukkit/block/BlockFurnaceBurning.java
+++ /dev/null
@@ -1,165 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityFurnace;
-import cn.nukkit.inventory.ContainerInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-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 java.util.Map;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockFurnaceBurning extends BlockSolidMeta {
-
- private static final int[] faces = {2, 5, 3, 4};
-
- public BlockFurnaceBurning() {
- this(0);
- }
-
- public BlockFurnaceBurning(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return BURNING_FURNACE;
- }
-
- @Override
- public String getName() {
- return "Burning Furnace";
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public double getHardness() {
- return 3.5;
- }
-
- @Override
- public double getResistance() {
- return 17.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public int getLightLevel() {
- return 13;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);
- this.getLevel().setBlock(block, this, true, true);
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.FURNACE)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (item.hasCustomName()) {
- nbt.putString("CustomName", item.getCustomName());
- }
-
- if (item.hasCustomBlockData()) {
- Map customData = item.getCustomBlockData().getTags();
- for (Map.Entry tag : customData.entrySet()) {
- nbt.put(tag.getKey(), tag.getValue());
- }
- }
-
- BlockEntity.createBlockEntity(BlockEntity.FURNACE, this.getChunk(), nbt);
- return true;
- }
-
- @Override
- public boolean onBreak(Item item) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null) {
- BlockEntity t = this.getLevel().getBlockEntity(this);
- BlockEntityFurnace furnace;
- if (t instanceof BlockEntityFurnace) {
- furnace = (BlockEntityFurnace) t;
- } else {
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.FURNACE)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- furnace = (BlockEntityFurnace) BlockEntity.createBlockEntity(BlockEntity.FURNACE, this.getChunk(), nbt);
- }
-
- if (furnace.namedTag.contains("Lock") && furnace.namedTag.get("Lock") instanceof StringTag) {
- if (!furnace.namedTag.getString("Lock").equals(item.getCustomName())) {
- return true;
- }
- }
-
- player.addWindow(furnace.getInventory());
- }
-
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(FURNACE));
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- this.toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- public boolean hasComparatorInputOverride() {
- return true;
- }
-
- @Override
- public int getComparatorInputOverride() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityFurnace) {
- return ContainerInventory.calculateRedstone(((BlockEntityFurnace) blockEntity).getInventory());
- }
-
- return super.getComparatorInputOverride();
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockGlass.java b/src/main/java/cn/nukkit/block/BlockGlass.java
deleted file mode 100644
index c754c9c81..000000000
--- a/src/main/java/cn/nukkit/block/BlockGlass.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockGlass extends BlockTransparent {
-
- @Override
- public int getId() {
- return GLASS;
- }
-
- @Override
- public String getName() {
- return "Glass";
- }
-
- @Override
- public double getResistance() {
- return 1.5;
- }
-
- @Override
- public double getHardness() {
- return 0.3;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockGlassPane.java b/src/main/java/cn/nukkit/block/BlockGlassPane.java
deleted file mode 100644
index 4470d48e4..000000000
--- a/src/main/java/cn/nukkit/block/BlockGlassPane.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/6 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockGlassPane extends BlockThin {
-
- @Override
- public String getName() {
- return "Glass Pane";
- }
-
- @Override
- public int getId() {
- return GLASS_PANE;
- }
-
- @Override
- public double getResistance() {
- return 1.5;
- }
-
- @Override
- public double getHardness() {
- return 0.3;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockGlassPaneStained.java b/src/main/java/cn/nukkit/block/BlockGlassPaneStained.java
deleted file mode 100644
index 2c30f4ec5..000000000
--- a/src/main/java/cn/nukkit/block/BlockGlassPaneStained.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 7.8.2017.
- */
-public class BlockGlassPaneStained extends BlockGlassPane {
-
- private int meta;
-
- public BlockGlassPaneStained() {
- this(0);
- }
-
- public BlockGlassPaneStained(int meta) {
- this.meta = meta;
- }
-
- @Override
- public int getFullId() {
- return (2560) + meta;
- }
-
- @Override
- public int getId() {
- return STAINED_GLASS_PANE;
- }
-
- @Override
- public String getName() {
- return getDyeColor().getName() + " Stained Glass Pane";
- }
-
- @Override
- public BlockColor getColor() {
- return getDyeColor().getColor();
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(meta);
- }
-
- @Override
- public final int getDamage() {
- return this.meta;
- }
-
- @Override
- public final void setDamage(int meta) {
- this.meta = meta;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockGlassStained.java b/src/main/java/cn/nukkit/block/BlockGlassStained.java
deleted file mode 100644
index 151414aa8..000000000
--- a/src/main/java/cn/nukkit/block/BlockGlassStained.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 7.8.2017.
- */
-public class BlockGlassStained extends BlockGlass {
-
- private int meta;
-
- public BlockGlassStained() {
- this(0);
- }
-
- public BlockGlassStained(int meta) {
- this.meta = meta;
- }
-
- @Override
- public int getFullId() {
- return (3856) + meta;
- }
-
- @Override
- public int getId() {
- return STAINED_GLASS;
- }
-
- @Override
- public String getName() {
- return getDyeColor().getName() + " Stained Glass";
- }
-
- @Override
- public BlockColor getColor() {
- return DyeColor.getByWoolData(meta).getColor();
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(meta);
- }
-
- @Override
- public final int getDamage() {
- return this.meta;
- }
-
- @Override
- public final void setDamage(int meta) {
- this.meta = meta;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockGlowStick.java b/src/main/java/cn/nukkit/block/BlockGlowStick.java
deleted file mode 100644
index 2c153ab91..000000000
--- a/src/main/java/cn/nukkit/block/BlockGlowStick.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-/**
- * Created by PetteriM1
- */
-public class BlockGlowStick extends BlockTransparentMeta {
-
- public BlockGlowStick() {
- this(0);
- }
-
- public BlockGlowStick(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return GLOW_STICK;
- }
-
- @Override
- public String getName() {
- return "Glow Stick";
- }
-
- @Override
- public Item toItem() {
- return Item.get(AIR);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockGlowstone.java b/src/main/java/cn/nukkit/block/BlockGlowstone.java
deleted file mode 100644
index 06b53bbf8..000000000
--- a/src/main/java/cn/nukkit/block/BlockGlowstone.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemGlowstoneDust;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.math.MathHelper;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created on 2015/12/6 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockGlowstone extends BlockTransparent {
-
- @Override
- public String getName() {
- return "Glowstone";
- }
-
- @Override
- public int getId() {
- return GLOWSTONE_BLOCK;
- }
-
- @Override
- public double getResistance() {
- return 1.5;
- }
-
- @Override
- public double getHardness() {
- return 0.3;
- }
-
- @Override
- public int getLightLevel() {
- return 15;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
-
- int count = 2 + Utils.random.nextInt(3);
-
- Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
- if (fortune != null && fortune.getLevel() >= 1) {
- count += Utils.random.nextInt(fortune.getLevel() + 1);
- }
-
- return new Item[]{
- new ItemGlowstoneDust(0, MathHelper.clamp(count, 1, 4))
- };
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SAND_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockGold.java b/src/main/java/cn/nukkit/block/BlockGold.java
deleted file mode 100644
index 7124c8445..000000000
--- a/src/main/java/cn/nukkit/block/BlockGold.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockGold extends BlockSolid {
-
- @Override
- public int getId() {
- return GOLD_BLOCK;
- }
-
- @Override
- public String getName() {
- return "Block of Gold";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.GOLD_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockGrass.java b/src/main/java/cn/nukkit/block/BlockGrass.java
deleted file mode 100644
index 4a2bf4ac8..000000000
--- a/src/main/java/cn/nukkit/block/BlockGrass.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.event.block.BlockSpreadEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.Sound;
-import cn.nukkit.level.generator.object.ObjectTallGrass;
-import cn.nukkit.level.particle.BoneMealParticle;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockGrass extends BlockDirt {
-
- public BlockGrass() {
- this(0);
- }
-
- public BlockGrass(int meta) {
- super(0);
- }
-
- @Override
- public int getId() {
- return GRASS;
- }
-
- @Override
- public double getHardness() {
- return 0.6;
- }
-
- @Override
- public double getResistance() {
- return 3;
- }
-
- @Override
- public String getName() {
- return "Grass Block";
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.getId() == Item.DYE && item.getDamage() == 0x0F) {
- ObjectTallGrass.growGrass(this.getLevel(), this, Utils.nukkitRandom);
- this.level.addParticle(new BoneMealParticle(this));
- if (player != null) {
- if (!player.isCreative()) {
- item.count--;
- }
- player.getLevel().addSoundToViewers(player, Sound.STEP_GRASS);
- }
- return true;
- } else if (item.isHoe()) {
- Block up = this.up();
- if (up instanceof BlockAir || up instanceof BlockFlowable) {
- item.useOn(this);
- this.getLevel().setBlock(this, Block.get(FARMLAND));
- if (player != null) {
- player.getLevel().addSoundToViewers(player, Sound.STEP_GRASS);
- }
- return true;
- }
- } else if (item.isShovel()) {
- Block up = this.up();
- if (up instanceof BlockAir || up instanceof BlockFlowable) {
- item.useOn(this);
- this.getLevel().setBlock(this, Block.get(GRASS_PATH));
- if (player != null) {
- player.getLevel().addSoundToViewers(player, Sound.STEP_GRASS);
- }
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_RANDOM) {
- x = Utils.rand((int) x - 1, (int) x + 1);
- y = Utils.rand((int) y - 2, (int) y + 2);
- z = Utils.rand((int) z - 1, (int) z + 1);
- Block block = this.getLevel().getBlock(new Vector3(x, y, z));
- if (block.getId() == Block.DIRT && block.getDamage() == 0) {
- if (block.up() instanceof BlockAir) {
- BlockSpreadEvent ev = new BlockSpreadEvent(block, this, Block.get(GRASS));
- Server.getInstance().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(block, ev.getNewState());
- }
- }
- } else if (block.getId() == Block.GRASS) {
- if (block.up() instanceof BlockSolid) {
- BlockSpreadEvent ev = new BlockSpreadEvent(block, this, Block.get(DIRT));
- Server.getInstance().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(block, ev.getNewState());
- }
- }
- }
- }
- return 0;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.GRASS_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- @Override
- public int getFullId() {
- return this.getId() << 4;
- }
-
- @Override
- public void setDamage(int meta) {
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return new Item[]{new ItemBlock(Block.get(BlockID.DIRT))};
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockGrassPath.java b/src/main/java/cn/nukkit/block/BlockGrassPath.java
deleted file mode 100644
index 6961c6e98..000000000
--- a/src/main/java/cn/nukkit/block/BlockGrassPath.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Sound;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/22 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockGrassPath extends BlockGrass {
-
- @Override
- public int getId() {
- return GRASS_PATH;
- }
-
- @Override
- public String getName() {
- return "Grass Path";
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1, // the actual bounding box is a normal cube
- this.z + 1
- );
- }
-
- @Override
- public double getResistance() {
- return 3.25;
- }
-
- @Override
- public int onUpdate(int type) {
- return 0;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.isHoe()) {
- Block up = this.up();
- if (up instanceof BlockAir || up instanceof BlockFlowable) {
- item.useOn(this);
- this.getLevel().setBlock(this, get(FARMLAND), true);
- if (player != null) {
- player.getLevel().addSoundToViewers(player, Sound.STEP_GRASS);
- }
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.DIRT_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockGravel.java b/src/main/java/cn/nukkit/block/BlockGravel.java
deleted file mode 100644
index 33dea3af0..000000000
--- a/src/main/java/cn/nukkit/block/BlockGravel.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemFlint;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockGravel extends BlockFallable {
-
- @Override
- public int getId() {
- return GRAVEL;
- }
-
- @Override
- public double getHardness() {
- return 0.6;
- }
-
- @Override
- public double getResistance() {
- return 3;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- public String getName() {
- return "Gravel";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (Utils.random.nextInt(9) == 0 && !item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{
- new ItemFlint()
- };
- } else {
- return new Item[]{
- toItem()
- };
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.GRAY_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockHardGlass.java b/src/main/java/cn/nukkit/block/BlockHardGlass.java
deleted file mode 100644
index 6d0215f97..000000000
--- a/src/main/java/cn/nukkit/block/BlockHardGlass.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-/**
- * Created by PetteriM1
- */
-public class BlockHardGlass extends BlockTransparent {
-
- @Override
- public int getId() {
- return HARD_GLASS;
- }
-
- @Override
- public String getName() {
- return "Hardened Glass";
- }
-
- @Override
- public double getResistance() {
- return 1.5;
- }
-
- @Override
- public double getHardness() {
- return 0.3;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockHardGlassPane.java b/src/main/java/cn/nukkit/block/BlockHardGlassPane.java
deleted file mode 100644
index 8965d9bf7..000000000
--- a/src/main/java/cn/nukkit/block/BlockHardGlassPane.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by PetteriM1
- */
-public class BlockHardGlassPane extends BlockThin {
-
- @Override
- public String getName() {
- return "Hardened Glass Pane";
- }
-
- @Override
- public int getId() {
- return HARD_GLASS_PANE;
- }
-
- @Override
- public double getResistance() {
- return 1.5;
- }
-
- @Override
- public double getHardness() {
- return 0.3;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockHardGlassPaneStained.java b/src/main/java/cn/nukkit/block/BlockHardGlassPaneStained.java
deleted file mode 100644
index 71156390c..000000000
--- a/src/main/java/cn/nukkit/block/BlockHardGlassPaneStained.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by PetteriM1
- */
-public class BlockHardGlassPaneStained extends BlockHardGlassPane {
-
- private int meta;
-
- public BlockHardGlassPaneStained() {
- this(0);
- }
-
- public BlockHardGlassPaneStained(int meta) {
- this.meta = meta;
- }
-
- @Override
- public int getFullId() {
- return (3056) + meta;
- }
-
- @Override
- public int getId() {
- return HARD_STAINED_GLASS_PANE;
- }
-
- @Override
- public String getName() {
- return getDyeColor().getName() + " Hardened Stained Glass Pane";
- }
-
- @Override
- public BlockColor getColor() {
- return getDyeColor().getColor();
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(meta);
- }
-
- @Override
- public final int getDamage() {
- return this.meta;
- }
-
- @Override
- public final void setDamage(int meta) {
- this.meta = meta;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockHardGlassStained.java b/src/main/java/cn/nukkit/block/BlockHardGlassStained.java
deleted file mode 100644
index b5fdadde6..000000000
--- a/src/main/java/cn/nukkit/block/BlockHardGlassStained.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-/**
- * Created by PetteriM1
- */
-public class BlockHardGlassStained extends BlockTransparentMeta {
-
- public BlockHardGlassStained() {
- this(0);
- }
-
- public BlockHardGlassStained(int meta) {
- super(meta);
- }
- @Override
- public int getId() {
- return HARD_STAINED_GLASS;
- }
-
- @Override
- public String getName() {
- return "Hardened Stained Glass";
- }
-
- @Override
- public double getResistance() {
- return 1.5;
- }
-
- @Override
- public double getHardness() {
- return 0.3;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockHayBale.java b/src/main/java/cn/nukkit/block/BlockHayBale.java
deleted file mode 100644
index cc7b945a2..000000000
--- a/src/main/java/cn/nukkit/block/BlockHayBale.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created on 2015/11/24 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockHayBale extends BlockSolidMeta implements Faceable {
-
- private static final short[] faces = new short[]{
- 0,
- 0,
- 0b1000,
- 0b1000,
- 0b0100,
- 0b0100,
- };
-
- public BlockHayBale() {
- this(0);
- }
-
- public BlockHayBale(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return HAY_BALE;
- }
-
- @Override
- public String getName() {
- return "Hay Bale";
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public int getBurnChance() {
- return 60;
- }
-
- @Override
- public int getBurnAbility() {
- return 20;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_HOE;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage((this.getDamage() & 0x03) | faces[face.getIndex()]);
- this.getLevel().setBlock(block, this, true, true);
-
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.YELLOW_BLOCK_COLOR;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockHopper.java b/src/main/java/cn/nukkit/block/BlockHopper.java
deleted file mode 100644
index bf90df59f..000000000
--- a/src/main/java/cn/nukkit/block/BlockHopper.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityHopper;
-import cn.nukkit.inventory.ContainerInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemHopper;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.utils.Faceable;
-
-/**
- * @author CreeperFace
- */
-public class BlockHopper extends BlockTransparentMeta implements Faceable {
-
- public BlockHopper() {
- this(0);
- }
-
- public BlockHopper(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return HOPPER_BLOCK;
- }
-
- @Override
- public String getName() {
- return "Hopper Block";
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 24;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- BlockFace facing = face.getOpposite();
-
- if (facing == BlockFace.UP) {
- facing = BlockFace.DOWN;
- }
-
- this.setDamage(facing.getIndex());
-
- boolean powered = this.level.isBlockPowered(this);
-
- if (powered == this.isEnabled()) {
- this.setEnabled(!powered);
- }
-
- this.level.setBlock(this, this);
-
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.HOPPER)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- BlockEntity.createBlockEntity(BlockEntity.HOPPER, this.getChunk(), nbt);
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityHopper) {
- return player.addWindow(((BlockEntityHopper) blockEntity).getInventory()) != -1;
- }
-
- return false;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- public boolean hasComparatorInputOverride() {
- return true;
- }
-
- @Override
- public int getComparatorInputOverride() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityHopper) {
- return ContainerInventory.calculateRedstone(((BlockEntityHopper) blockEntity).getInventory());
- }
-
- return super.getComparatorInputOverride();
- }
-
- public BlockFace getFacing() {
- return BlockFace.fromIndex(this.getDamage() & 7);
- }
-
- public boolean isEnabled() {
- return (this.getDamage() & 0x08) != 8;
- }
-
- public void setEnabled(boolean enabled) {
- if (isEnabled() != enabled) {
- this.setDamage(this.getDamage() ^ 0x08);
- }
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- boolean powered = this.level.isBlockPowered(this);
-
- if (powered == this.isEnabled()) {
- this.setEnabled(!powered);
- this.level.setBlock(this, this, true, false);
- }
-
- return type;
- }
-
- return 0;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.getTier() >= ItemTool.TIER_WOODEN) {
- return new Item[]{toItem()};
- }
-
- return new Item[0];
- }
-
- @Override
- public Item toItem() {
- return new ItemHopper();
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockHugeMushroomBrown.java b/src/main/java/cn/nukkit/block/BlockHugeMushroomBrown.java
deleted file mode 100644
index e11e9ffac..000000000
--- a/src/main/java/cn/nukkit/block/BlockHugeMushroomBrown.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created by Pub4Game on 28.01.2016.
- */
-public class BlockHugeMushroomBrown extends BlockSolidMeta {
-
- public BlockHugeMushroomBrown() {
- this(0);
- }
-
- public BlockHugeMushroomBrown(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Brown Mushroom Block";
- }
-
- @Override
- public int getId() {
- return BROWN_MUSHROOM_BLOCK;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public double getHardness() {
- return 0.2;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item != null && item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return new Item[]{new ItemBlock(Block.get(BROWN_MUSHROOM), 0, Utils.rand() ? Utils.rand(0, 2) : 0)};
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.BROWN_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockHugeMushroomRed.java b/src/main/java/cn/nukkit/block/BlockHugeMushroomRed.java
deleted file mode 100644
index 08d19cbff..000000000
--- a/src/main/java/cn/nukkit/block/BlockHugeMushroomRed.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created by Pub4Game on 28.01.2016.
- */
-public class BlockHugeMushroomRed extends BlockSolidMeta {
-
- public BlockHugeMushroomRed() {
- this(0);
- }
-
- public BlockHugeMushroomRed(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Red Mushroom Block";
- }
-
- @Override
- public int getId() {
- return RED_MUSHROOM_BLOCK;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public double getHardness() {
- return 0.2;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item != null && item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return new Item[]{new ItemBlock(Block.get(RED_MUSHROOM), 0, Utils.rand() ? Utils.rand(0, 2) : 0)};
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.RED_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockID.java b/src/main/java/cn/nukkit/block/BlockID.java
deleted file mode 100644
index 8f157599d..000000000
--- a/src/main/java/cn/nukkit/block/BlockID.java
+++ /dev/null
@@ -1,326 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * List of block IDs
- */
-public interface BlockID {
-
- int AIR = 0;
- int STONE = 1;
- int GRASS = 2;
- int DIRT = 3;
- int COBBLESTONE = 4;
- int COBBLE = 4;
- int PLANK = 5;
- int PLANKS = 5;
- int WOODEN_PLANK = 5;
- int WOODEN_PLANKS = 5;
- int SAPLING = 6;
- int SAPLINGS = 6;
- int BEDROCK = 7;
- int WATER = 8;
- int STILL_WATER = 9;
- int LAVA = 10;
- int STILL_LAVA = 11;
- int SAND = 12;
- int GRAVEL = 13;
- int GOLD_ORE = 14;
- int IRON_ORE = 15;
- int COAL_ORE = 16;
- int LOG = 17;
- int WOOD = 17;
- int TRUNK = 17;
- int LEAVES = 18;
- int LEAVE = 18;
- int SPONGE = 19;
- int GLASS = 20;
- int LAPIS_ORE = 21;
- int LAPIS_BLOCK = 22;
- int DISPENSER = 23;
- int SANDSTONE = 24;
- int NOTEBLOCK = 25;
- int BED_BLOCK = 26;
- int POWERED_RAIL = 27;
- int DETECTOR_RAIL = 28;
- int STICKY_PISTON = 29;
- int COBWEB = 30;
- int TALL_GRASS = 31;
- int BUSH = 32;
- int DEAD_BUSH = 32;
- int PISTON = 33;
- int PISTON_HEAD = 34;
- int WOOL = 35;
- int DANDELION = 37;
- int POPPY = 38;
- int ROSE = 38;
- int FLOWER = 38;
- int RED_FLOWER = 38;
- int BROWN_MUSHROOM = 39;
- int RED_MUSHROOM = 40;
- int GOLD_BLOCK = 41;
- int IRON_BLOCK = 42;
- int DOUBLE_SLAB = 43;
- int DOUBLE_STONE_SLAB = 43;
- int DOUBLE_SLABS = 43;
- int SLAB = 44;
- int STONE_SLAB = 44;
- int SLABS = 44;
- int BRICKS = 45;
- int BRICKS_BLOCK = 45;
- int TNT = 46;
- int BOOKSHELF = 47;
- int MOSS_STONE = 48;
- int MOSSY_STONE = 48;
- int OBSIDIAN = 49;
- int TORCH = 50;
- int FIRE = 51;
- int MONSTER_SPAWNER = 52;
- int WOOD_STAIRS = 53;
- int WOODEN_STAIRS = 53;
- int OAK_WOOD_STAIRS = 53;
- int OAK_WOODEN_STAIRS = 53;
- int CHEST = 54;
- int REDSTONE_WIRE = 55;
- int DIAMOND_ORE = 56;
- int DIAMOND_BLOCK = 57;
- int CRAFTING_TABLE = 58;
- int WORKBENCH = 58;
- int WHEAT_BLOCK = 59;
- int FARMLAND = 60;
- int FURNACE = 61;
- int BURNING_FURNACE = 62;
- int LIT_FURNACE = 62;
- int SIGN_POST = 63;
- int DOOR_BLOCK = 64;
- int WOODEN_DOOR_BLOCK = 64;
- int WOOD_DOOR_BLOCK = 64;
- int LADDER = 65;
- int RAIL = 66;
- int COBBLE_STAIRS = 67;
- int COBBLESTONE_STAIRS = 67;
- int WALL_SIGN = 68;
- int LEVER = 69;
- int STONE_PRESSURE_PLATE = 70;
- int IRON_DOOR_BLOCK = 71;
- int WOODEN_PRESSURE_PLATE = 72;
- int REDSTONE_ORE = 73;
- int GLOWING_REDSTONE_ORE = 74;
- int LIT_REDSTONE_ORE = 74;
- int UNLIT_REDSTONE_TORCH = 75;
- int REDSTONE_TORCH = 76;
- int STONE_BUTTON = 77;
- int SNOW = 78;
- int SNOW_LAYER = 78;
- int ICE = 79;
- int SNOW_BLOCK = 80;
- int CACTUS = 81;
- int CLAY_BLOCK = 82;
- int REEDS = 83;
- int SUGARCANE_BLOCK = 83;
- int JUKEBOX = 84;
- int FENCE = 85;
- int PUMPKIN = 86;
- int NETHERRACK = 87;
- int SOUL_SAND = 88;
- int GLOWSTONE = 89;
- int GLOWSTONE_BLOCK = 89;
- int NETHER_PORTAL = 90;
- int LIT_PUMPKIN = 91;
- int JACK_O_LANTERN = 91;
- int CAKE_BLOCK = 92;
- int UNPOWERED_REPEATER = 93;
- int POWERED_REPEATER = 94;
- int INVISIBLE_BEDROCK = 95;
- int TRAPDOOR = 96;
- int MONSTER_EGG = 97;
- int STONE_BRICKS = 98;
- int STONE_BRICK = 98;
- int BROWN_MUSHROOM_BLOCK = 99;
- int RED_MUSHROOM_BLOCK = 100;
- int IRON_BAR = 101;
- int IRON_BARS = 101;
- int GLASS_PANE = 102;
- int GLASS_PANEL = 102;
- int MELON_BLOCK = 103;
- int PUMPKIN_STEM = 104;
- int MELON_STEM = 105;
- int VINE = 106;
- int VINES = 106;
- int FENCE_GATE = 107;
- int FENCE_GATE_OAK = 107;
- int BRICK_STAIRS = 108;
- int STONE_BRICK_STAIRS = 109;
- int MYCELIUM = 110;
- int WATER_LILY = 111;
- int LILY_PAD = 111;
- int NETHER_BRICKS = 112;
- int NETHER_BRICK_BLOCK = 112;
- int NETHER_BRICK_FENCE = 113;
- int NETHER_BRICKS_STAIRS = 114;
- int NETHER_WART_BLOCK = 115;
- int ENCHANTING_TABLE = 116;
- int ENCHANT_TABLE = 116;
- int ENCHANTMENT_TABLE = 116;
- int BREWING_STAND_BLOCK = 117;
- int BREWING_BLOCK = 117;
- int CAULDRON_BLOCK = 118;
- int END_PORTAL = 119;
- int END_PORTAL_FRAME = 120;
- int END_STONE = 121;
- int DRAGON_EGG = 122;
- int REDSTONE_LAMP = 123;
- int LIT_REDSTONE_LAMP = 124;
- int DROPPER = 125;
- int ACTIVATOR_RAIL = 126;
- int COCOA = 127;
- int COCOA_BLOCK = 127;
- int SANDSTONE_STAIRS = 128;
- int EMERALD_ORE = 129;
- int ENDER_CHEST = 130;
- int TRIPWIRE_HOOK = 131;
- int TRIPWIRE = 132;
- int EMERALD_BLOCK = 133;
- int SPRUCE_WOOD_STAIRS = 134;
- int SPRUCE_WOODEN_STAIRS = 134;
- int BIRCH_WOOD_STAIRS = 135;
- int BIRCH_WOODEN_STAIRS = 135;
- int JUNGLE_WOOD_STAIRS = 136;
- int JUNGLE_WOODEN_STAIRS = 136;
- int COMMAND_BLOCK = 137;
- int BEACON = 138;
- int COBBLE_WALL = 139;
- int STONE_WALL = 139;
- int COBBLESTONE_WALL = 139;
- int FLOWER_POT_BLOCK = 140;
- int CARROT_BLOCK = 141;
- int POTATO_BLOCK = 142;
- int WOODEN_BUTTON = 143;
- int SKULL_BLOCK = 144;
- int ANVIL = 145;
- int TRAPPED_CHEST = 146;
- int LIGHT_WEIGHTED_PRESSURE_PLATE = 147;
- int HEAVY_WEIGHTED_PRESSURE_PLATE = 148;
- int UNPOWERED_COMPARATOR = 149;
- int POWERED_COMPARATOR = 150;
- int DAYLIGHT_DETECTOR = 151;
- int REDSTONE_BLOCK = 152;
- int QUARTZ_ORE = 153;
- int HOPPER_BLOCK = 154;
- int QUARTZ_BLOCK = 155;
- int QUARTZ_STAIRS = 156;
- int DOUBLE_WOOD_SLAB = 157;
- int DOUBLE_WOODEN_SLAB = 157;
- int DOUBLE_WOOD_SLABS = 157;
- int DOUBLE_WOODEN_SLABS = 157;
- int WOOD_SLAB = 158;
- int WOODEN_SLAB = 158;
- int WOOD_SLABS = 158;
- int WOODEN_SLABS = 158;
- int STAINED_TERRACOTTA = 159;
- int STAINED_HARDENED_CLAY = 159;
- int STAINED_GLASS_PANE = 160;
- int LEAVES2 = 161;
- int LEAVE2 = 161;
- int WOOD2 = 162;
- int TRUNK2 = 162;
- int LOG2 = 162;
- int ACACIA_WOOD_STAIRS = 163;
- int ACACIA_WOODEN_STAIRS = 163;
- int DARK_OAK_WOOD_STAIRS = 164;
- int DARK_OAK_WOODEN_STAIRS = 164;
- int SLIME_BLOCK = 165;
- int GLOW_STICK = 166;
- int IRON_TRAPDOOR = 167;
- int PRISMARINE = 168;
- int SEA_LANTERN = 169;
- int HAY_BALE = 170;
- int HAY_BLOCK = 170;
- int CARPET = 171;
- int TERRACOTTA = 172;
- int COAL_BLOCK = 173;
- int PACKED_ICE = 174;
- int DOUBLE_PLANT = 175;
- int STANDING_BANNER = 176;
- int WALL_BANNER = 177;
- int DAYLIGHT_DETECTOR_INVERTED = 178;
- int RED_SANDSTONE = 179;
- int RED_SANDSTONE_STAIRS = 180;
- int DOUBLE_RED_SANDSTONE_SLAB = 181;
- int RED_SANDSTONE_SLAB = 182;
- int FENCE_GATE_SPRUCE = 183;
- int FENCE_GATE_BIRCH = 184;
- int FENCE_GATE_JUNGLE = 185;
- int FENCE_GATE_DARK_OAK = 186;
- int FENCE_GATE_ACACIA = 187;
- int REPEATING_COMMAND_BLOCK = 188;
- int CHAIN_COMMAND_BLOCK = 189;
- int HARD_GLASS_PANE = 190;
- int HARD_STAINED_GLASS_PANE = 191;
- int CHEMICAL_HEAT = 192;
- int SPRUCE_DOOR_BLOCK = 193;
- int BIRCH_DOOR_BLOCK = 194;
- int JUNGLE_DOOR_BLOCK = 195;
- int ACACIA_DOOR_BLOCK = 196;
- int DARK_OAK_DOOR_BLOCK = 197;
- int GRASS_PATH = 198;
- int ITEM_FRAME_BLOCK = 199;
- int CHORUS_FLOWER = 200;
- int PURPUR_BLOCK = 201;
- int COLORED_TORCH_RG = 202;
- int PURPUR_STAIRS = 203;
- int COLORED_TORCH_BP = 204;
- int UNDYED_SHULKER_BOX = 205;
- int END_BRICKS = 206;
- int FROSTED_ICE = 207;
- int ICE_FROSTED = 207;
- int END_ROD = 208;
- int END_GATEWAY = 209;
- // 210 Allow in Education Edition
- // 211 Deny in Education Edition
- // 212 Border in Education Edition
- int MAGMA = 213;
- int MAGMA_BLOCK = 213;
- int BLOCK_NETHER_WART_BLOCK = 214;
- int RED_NETHER_BRICK = 215;
- int BONE_BLOCK = 216;
- // 217 not yet in Minecraft
- int SHULKER_BOX = 218;
- int PURPLE_GLAZED_TERRACOTTA = 219;
- int WHITE_GLAZED_TERRACOTTA = 220;
- int ORANGE_GLAZED_TERRACOTTA = 221;
- int MAGENTA_GLAZED_TERRACOTTA = 222;
- int LIGHT_BLUE_GLAZED_TERRACOTTA = 223;
- int YELLOW_GLAZED_TERRACOTTA = 224;
- int LIME_GLAZED_TERRACOTTA = 225;
- int PINK_GLAZED_TERRACOTTA = 226;
- int GRAY_GLAZED_TERRACOTTA = 227;
- int SILVER_GLAZED_TERRACOTTA = 228;
- int CYAN_GLAZED_TERRACOTTA = 229;
- // 230 Chalkboard in Education Edition
- int BLUE_GLAZED_TERRACOTTA = 231;
- int BROWN_GLAZED_TERRACOTTA = 232;
- int GREEN_GLAZED_TERRACOTTA = 233;
- int RED_GLAZED_TERRACOTTA = 234;
- int BLACK_GLAZED_TERRACOTTA = 235;
- int CONCRETE = 236;
- int CONCRETE_POWDER = 237;
- int CHEMISTRY_TABLE = 238;
- int UNDERWATER_TORCH = 239;
- int CHORUS_PLANT = 240;
- int STAINED_GLASS = 241;
- int CAMERA_BLOCK = 242;
- int PODZOL = 243;
- int BEETROOT_BLOCK = 244;
- int STONECUTTER = 245;
- int GLOWING_OBSIDIAN = 246;
- int NETHER_REACTOR = 247;
- int INFO_UPDATE = 248;
- int INFO_UPDATE2 = 249;
- int PISTON_EXTENSION = 250;
- int MOVING_BLOCK = 250;
- int OBSERVER = 251;
- int STRUCTURE_BLOCK = 252;
- int HARD_GLASS = 253;
- int HARD_STAINED_GLASS = 254;
- int RESERVED6 = 255;
-}
diff --git a/src/main/java/cn/nukkit/block/BlockIce.java b/src/main/java/cn/nukkit/block/BlockIce.java
deleted file mode 100644
index 3bf6a2672..000000000
--- a/src/main/java/cn/nukkit/block/BlockIce.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.event.block.BlockFadeEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.level.Level;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockIce extends BlockTransparent {
-
- @Override
- public int getId() {
- return ICE;
- }
-
- @Override
- public String getName() {
- return "Ice";
- }
-
- @Override
- public double getResistance() {
- return 0.5;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getFrictionFactor() {
- return 0.98;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public boolean onBreak(Item item) {
- if (this.getLevel().getDimension() == Level.DIMENSION_NETHER || item.hasEnchantment(Enchantment.ID_SILK_TOUCH) || down().getId() == BlockID.AIR) {
- return super.onBreak(item);
- }
- return this.getLevel().setBlock(this, Block.get(BlockID.WATER), true);
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_RANDOM) {
- if (level.getBlockLightAt((int) this.x, (int) this.y, (int) this.z) >= 12) {
- BlockFadeEvent event = new BlockFadeEvent(this, level.getDimension() == Level.DIMENSION_NETHER ? get(AIR) : get(WATER));
- level.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- level.setBlock(this, event.getNewState(), true);
- }
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- return 0;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return new Item[0];
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.ICE_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockIceFrosted.java b/src/main/java/cn/nukkit/block/BlockIceFrosted.java
deleted file mode 100644
index 413839e43..000000000
--- a/src/main/java/cn/nukkit/block/BlockIceFrosted.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created by PetteriM1
- */
-public class BlockIceFrosted extends BlockTransparentMeta {
-
- public BlockIceFrosted() {
- this(0);
- }
-
- public BlockIceFrosted(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return ICE_FROSTED;
- }
-
- @Override
- public String getName() {
- return "Frosted Ice";
- }
-
- @Override
- public double getResistance() {
- return 0.5;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getFrictionFactor() {
- return 0.98;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- boolean success = super.place(item, block, target, face, fx, fy, fz, player);
- if (success) {
- level.scheduleUpdate(this, Utils.random.nextInt(20, 40));
- }
- return success;
- }
-
- @Override
- public boolean onBreak(Item item) {
- level.setBlock(this, get(WATER), true);
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- if ((this.getLevel().getBlockLightAt((int) this.x, (int) this.y, (int) this.z) >= 12 || (level.getTime() % Level.TIME_FULL < 13184 || level.getTime() % Level.TIME_FULL > 22800)) && (Utils.random.nextInt(3) == 0 || countNeighbors() < 4)) {
- slightlyMelt(true);
- } else {
- level.scheduleUpdate(this, Utils.random.nextInt(20, 40));
- }
- } else if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (countNeighbors() < 2) {
- level.setBlock(this, get(WATER), true);
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- if ((this.getLevel().getBlockLightAt((int) this.x, (int) this.y, (int) this.z) >= 12 || (level.getTime() % Level.TIME_FULL < 13184 || level.getTime() % Level.TIME_FULL > 22800)) && (Utils.random.nextInt(3) == 0 || countNeighbors() < 4)) {
- slightlyMelt(true);
- }
- }
- return super.onUpdate(type);
- }
-
- @Override
- public Item toItem() {
- return Item.get(AIR);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.ICE_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- protected void slightlyMelt(boolean isSource) {
- int age = getDamage();
- if (age < 3) {
- setDamage(age + 1);
- level.setBlock(this, this, true);
- level.scheduleUpdate(level.getBlock(this), Utils.random.nextInt(20, 40));
- } else {
- level.setBlock(this, get(WATER), true);
- if (isSource) {
- for (BlockFace face : BlockFace.values()) {
- Block block = getSide(face);
- if (block instanceof BlockIceFrosted) {
- ((BlockIceFrosted) block).slightlyMelt(false);
- }
- }
- }
- }
- }
-
- private int countNeighbors() {
- int neighbors = 0;
- for (BlockFace face : BlockFace.values()) {
- if (getSide(face).getId() == ICE_FROSTED && ++neighbors >= 4) {
- return neighbors;
- }
- }
- return neighbors;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockIcePacked.java b/src/main/java/cn/nukkit/block/BlockIcePacked.java
deleted file mode 100644
index 224bd8119..000000000
--- a/src/main/java/cn/nukkit/block/BlockIcePacked.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.enchantment.Enchantment;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockIcePacked extends BlockIce {
-
- @Override
- public int getId() {
- return PACKED_ICE;
- }
-
- @Override
- public String getName() {
- return "Packed Ice";
- }
-
- @Override
- public boolean onBreak(Item item) {
- return this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{
- this.toItem()
- };
- }
- return new Item[0];
- }
-
- @Override
- public int onUpdate(int type) {
- return 0;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public int getLightLevel() {
- return 4;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockInfoUpdate.java b/src/main/java/cn/nukkit/block/BlockInfoUpdate.java
deleted file mode 100644
index 3ab469dad..000000000
--- a/src/main/java/cn/nukkit/block/BlockInfoUpdate.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * Created by PetteriM1
- */
-public class BlockInfoUpdate extends BlockSolid {
-
- @Override
- public int getId() {
- return INFO_UPDATE;
- }
-
- @Override
- public String getName() {
- return "Update Game Block";
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockInfoUpdate2.java b/src/main/java/cn/nukkit/block/BlockInfoUpdate2.java
deleted file mode 100644
index 0665cc055..000000000
--- a/src/main/java/cn/nukkit/block/BlockInfoUpdate2.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * Created by PetteriM1
- */
-public class BlockInfoUpdate2 extends BlockSolid {
-
- @Override
- public int getId() {
- return INFO_UPDATE2;
- }
-
- @Override
- public String getName() {
- return "Update Game Block";
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockIron.java b/src/main/java/cn/nukkit/block/BlockIron.java
deleted file mode 100644
index e59d64f4c..000000000
--- a/src/main/java/cn/nukkit/block/BlockIron.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockIron extends BlockSolid {
-
- @Override
- public int getId() {
- return IRON_BLOCK;
- }
-
- @Override
- public String getName() {
- return "Block of Iron";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.IRON_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockIronBars.java b/src/main/java/cn/nukkit/block/BlockIronBars.java
deleted file mode 100644
index 947a0a36c..000000000
--- a/src/main/java/cn/nukkit/block/BlockIronBars.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/6 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockIronBars extends BlockThin {
-
- @Override
- public String getName() {
- return "Iron Bars";
- }
-
- @Override
- public int getId() {
- return IRON_BARS;
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- this.toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.IRON_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockItemFrame.java b/src/main/java/cn/nukkit/block/BlockItemFrame.java
deleted file mode 100644
index 3916616f5..000000000
--- a/src/main/java/cn/nukkit/block/BlockItemFrame.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityItemFrame;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemItemFrame;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.sound.ItemFrameItemAddedSound;
-import cn.nukkit.level.sound.ItemFrameItemRotated;
-import cn.nukkit.level.sound.ItemFramePlacedSound;
-import cn.nukkit.level.sound.ItemFrameRemovedSound;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.Tag;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * Created by Pub4Game on 03.07.2016.
- */
-public class BlockItemFrame extends BlockTransparentMeta {
-
- private final static int[] FACING = new int[]{4, 5, 3, 2, 1, 0}; // TODO when 1.13 support arrives, add UP/DOWN facings
-
- private final static int FACING_BITMASK = 0b0111;
- //private final static int MAP_BIT = 0b1000;
-
- public BlockItemFrame() {
- this(0);
- }
-
- public BlockItemFrame(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return ITEM_FRAME_BLOCK;
- }
-
- @Override
- public String getName() {
- return "Item Frame";
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (!this.getSide(getFacing()).isSolid()) {
- this.level.useBreakOn(this);
- return type;
- }
- }
-
- return 0;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- BlockEntity blockEntity = this.getLevel().getBlockEntity(this);
- BlockEntityItemFrame itemFrame = (BlockEntityItemFrame) blockEntity;
- if (itemFrame.getItem().getId() == Item.AIR) {
- Item itemToFrame = item.clone();
- if (player != null && player.isSurvival()) {
- item.setCount(item.getCount() - 1);
- player.getInventory().setItemInHand(item);
- }
- itemToFrame.setCount(1);
- itemFrame.setItem(itemToFrame);
- this.getLevel().addSound(new ItemFrameItemAddedSound(this));
- } else {
- itemFrame.setItemRotation((itemFrame.getItemRotation() + 1) % 8);
- this.getLevel().addSound(new ItemFrameItemRotated(this));
- }
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (face.getIndex() > 1 && target.isSolid() && (!block.isSolid() || block.canBeReplaced())) {
- this.setDamage(FACING[face.getIndex()]);
- this.getLevel().setBlock(block, this, true, true);
- CompoundTag nbt = new CompoundTag()
- .putString("id", BlockEntity.ITEM_FRAME)
- .putInt("x", (int) block.x)
- .putInt("y", (int) block.y)
- .putInt("z", (int) block.z)
- .putByte("ItemRotation", 0)
- .putFloat("ItemDropChance", 1.0f);
- if (item.hasCustomBlockData()) {
- for (Tag aTag : item.getCustomBlockData().getAllTags()) {
- nbt.put(aTag.getName(), aTag);
- }
- }
- BlockEntity.createBlockEntity(BlockEntity.ITEM_FRAME, this.getChunk(), nbt);
- this.getLevel().addSound(new ItemFramePlacedSound(this));
- return true;
- }
- return false;
- }
-
- @Override
- public boolean onBreak(Item item) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
- this.getLevel().addSound(new ItemFrameRemovedSound(this));
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- BlockEntity blockEntity = this.getLevel().getBlockEntity(this);
- BlockEntityItemFrame itemFrame = (BlockEntityItemFrame) blockEntity;
- if (itemFrame != null && ThreadLocalRandom.current().nextFloat() <= itemFrame.getItemDropChance()) {
- return new Item[]{
- toItem(), itemFrame.getItem().clone()
- };
- } else {
- return new Item[]{
- toItem()
- };
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemItemFrame();
- }
-
- @Override
- public boolean canPassThrough() {
- return true;
- }
-
- @Override
- public boolean hasComparatorInputOverride() {
- return true;
- }
-
- @Override
- public int getComparatorInputOverride() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityItemFrame) {
- return ((BlockEntityItemFrame) blockEntity).getAnalogOutput();
- }
-
- return super.getComparatorInputOverride();
- }
-
- public BlockFace getFacing() {
- switch (this.getDamage() & FACING_BITMASK) {
- case 0:
- return BlockFace.WEST;
- case 1:
- return BlockFace.EAST;
- case 2:
- return BlockFace.NORTH;
- case 3:
- return BlockFace.SOUTH;
- }
-
- return null;
- }
-
- @Override
- public double getHardness() {
- return 0.25;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockJukebox.java b/src/main/java/cn/nukkit/block/BlockJukebox.java
deleted file mode 100644
index 322348900..000000000
--- a/src/main/java/cn/nukkit/block/BlockJukebox.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityJukebox;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemRecord;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by CreeperFace on 7.8.2017.
- */
-public class BlockJukebox extends BlockSolid {
-
- @Override
- public String getName() {
- return "Jukebox";
- }
-
- @Override
- public int getId() {
- return JUKEBOX;
- }
-
- @Override
- public double getHardness() {
- return 0.8;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- BlockEntity blockEntity = this.getLevel().getBlockEntity(this);
- if (!(blockEntity instanceof BlockEntityJukebox)) {
- blockEntity = this.createBlockEntity();
- }
-
- BlockEntityJukebox jukebox = (BlockEntityJukebox) blockEntity;
- if (jukebox.getRecordItem().getId() != 0) {
- jukebox.dropItem();
- } else if (item instanceof ItemRecord) {
- jukebox.setRecordItem(item);
- jukebox.play();
- player.getInventory().decreaseCount(player.getInventory().getHeldItemIndex());
- }
-
- return false;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (super.place(item, block, target, face, fx, fy, fz, player)) {
- createBlockEntity();
- return true;
- }
-
- return false;
- }
-
- /*@Override // Replaced with BlockEntityJukebox#onBreak
- public boolean onBreak(Item item) {
- if (super.onBreak(item)) {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityJukebox) {
- ((BlockEntityJukebox) blockEntity).dropItem();
- }
- return true;
- }
-
- return false;
- }*/
-
- private BlockEntity createBlockEntity() {
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.JUKEBOX)
- .putInt("x", getFloorX())
- .putInt("y", getFloorY())
- .putInt("z", getFloorZ());
-
- return BlockEntity.createBlockEntity(BlockEntity.JUKEBOX, this.level.getChunk(getFloorX() >> 4, getFloorZ() >> 4), nbt);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.DIRT_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockLadder.java b/src/main/java/cn/nukkit/block/BlockLadder.java
deleted file mode 100644
index d7fc2a8f1..000000000
--- a/src/main/java/cn/nukkit/block/BlockLadder.java
+++ /dev/null
@@ -1,165 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemLadder;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created on 2015/12/8 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockLadder extends BlockTransparentMeta implements Faceable {
-
- private static final int[] faces = {
- 0, //never use
- 1, //never use
- 3,
- 2,
- 5,
- 4
- };
-
- public BlockLadder() {
- this(0);
- }
-
- public BlockLadder(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Ladder";
- }
-
- @Override
- public int getId() {
- return LADDER;
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public boolean canBeClimbed() {
- return true;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- @Override
- public double getHardness() {
- return 0.4;
- }
-
- @Override
- public double getResistance() {
- return 2;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
-
- double f = 0.1875;
-
- if (this.getDamage() == 2) {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z + 1 - f,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- } else if (this.getDamage() == 3) {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + f
- );
- } else if (this.getDamage() == 4) {
- return new AxisAlignedBB(
- this.x + 1 - f,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- } else if (this.getDamage() == 5) {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + f,
- this.y + 1,
- this.z + 1
- );
- }
- return null;
- }
-
- @Override
- protected AxisAlignedBB recalculateCollisionBoundingBox() {
- return super.recalculateBoundingBox();
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (!target.isTransparent()) {
- if (face.getIndex() >= 2 && face.getIndex() <= 5) {
- this.setDamage(face.getIndex());
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (!this.getSide(BlockFace.fromIndex(faces[this.getDamage()])).isSolid()) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- new ItemLadder(0, 1)
- };
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockLapis.java b/src/main/java/cn/nukkit/block/BlockLapis.java
deleted file mode 100644
index a7d24808f..000000000
--- a/src/main/java/cn/nukkit/block/BlockLapis.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockLapis extends BlockSolid {
-
- @Override
- public int getId() {
- return LAPIS_BLOCK;
- }
-
- @Override
- public String getName() {
- return "Lapis Lazuli Block";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 5;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.LAPIS_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockLava.java b/src/main/java/cn/nukkit/block/BlockLava.java
deleted file mode 100644
index 2336a0165..000000000
--- a/src/main/java/cn/nukkit/block/BlockLava.java
+++ /dev/null
@@ -1,249 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.item.EntityPrimedTNT;
-import cn.nukkit.event.block.BlockIgniteEvent;
-import cn.nukkit.event.entity.EntityCombustByBlockEvent;
-import cn.nukkit.event.entity.EntityDamageByBlockEvent;
-import cn.nukkit.event.entity.EntityDamageEvent.DamageCause;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.GameRule;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.potion.Effect;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockLava extends BlockLiquid {
-
- public BlockLava() {
- this(0);
- }
-
- public BlockLava(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return LAVA;
- }
-
- @Override
- public int getLightLevel() {
- return 15;
- }
-
- @Override
- public String getName() {
- return "Lava";
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- entity.highestPosition -= (entity.highestPosition - entity.y) * 0.5;
-
- // Always setting the duration to 15 seconds? TODO
- EntityCombustByBlockEvent ev = new EntityCombustByBlockEvent(this, entity, 15);
- Server.getInstance().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()
- // Making sure the entity is actually alive and not invulnerable
- && entity.isAlive()
- && entity.noDamageTicks == 0) {
- entity.setOnFire(ev.getDuration());
- }
-
- if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
- entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.LAVA, 4));
- }
-
- super.onEntityCollide(entity);
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- boolean ret = this.getLevel().setBlock(this, this, true, false);
- this.getLevel().scheduleUpdate(this, this.tickRate());
-
- return ret;
- }
-
- @Override
- public int onUpdate(int type) {
- int result = super.onUpdate(type);
-
- if (type == Level.BLOCK_UPDATE_RANDOM && this.level.gameRules.getBoolean(GameRule.DO_FIRE_TICK)) {
- int i = Utils.random.nextInt(3);
-
- if (i > 0) {
- for (int k = 0; k < i; ++k) {
- Vector3 v = this.add(Utils.random.nextInt(3) - 1, 1, Utils.random.nextInt(3) - 1);
- Block block = this.getLevel().getBlock(v);
-
- if (block.getId() == AIR) {
- if (this.isSurroundingBlockFlammable(block)) {
- BlockIgniteEvent e = new BlockIgniteEvent(block, this, null, BlockIgniteEvent.BlockIgniteCause.LAVA);
- this.level.getServer().getPluginManager().callEvent(e);
-
- if (!e.isCancelled()) {
- Block fire = Block.get(BlockID.FIRE);
- this.getLevel().setBlock(v, fire, true);
- this.getLevel().scheduleUpdate(fire, fire.tickRate());
- return Level.BLOCK_UPDATE_RANDOM;
- }
-
- return 0;
- }
- } else if (block.isSolid()) {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- } else {
- for (int k = 0; k < 3; ++k) {
- Vector3 v = this.add(Utils.random.nextInt(3) - 1, 0, Utils.random.nextInt(3) - 1);
- Block block = this.getLevel().getBlock(v);
-
- if (block.up().getId() == AIR && block.getBurnChance() > 0) {
- BlockIgniteEvent e = new BlockIgniteEvent(block, this, null, BlockIgniteEvent.BlockIgniteCause.LAVA);
- this.level.getServer().getPluginManager().callEvent(e);
-
- if (!e.isCancelled()) {
- Block fire = Block.get(BlockID.FIRE);
- this.getLevel().setBlock(v, fire, true);
- this.getLevel().scheduleUpdate(fire, fire.tickRate());
- }
- }
- }
- }
- }
-
- return result;
- }
-
- protected boolean isSurroundingBlockFlammable(Block block) {
- for (BlockFace face : BlockFace.values()) {
- if (block.getSide(face).getBurnChance() > 0) {
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.LAVA_BLOCK_COLOR;
- }
-
- @Override
- public BlockLiquid getBlock(int meta) {
- return (BlockLiquid) Block.get(LAVA, meta);
- }
-
- @Override
- public int tickRate() {
- if (this.level.getDimension() == Level.DIMENSION_NETHER) {
- return 10;
- }
- return 30;
- }
-
- @Override
- public int getFlowDecayPerBlock() {
- if (this.level.getDimension() == Level.DIMENSION_NETHER) {
- return 1;
- }
- return 2;
- }
-
- @Override
- protected void checkForHarden() {
- Block colliding = null;
- for (int side = 1; side < 6; ++side) { //don't check downwards side
- Block blockSide = this.getSide(BlockFace.fromIndex(side));
- if (blockSide instanceof BlockWater) {
- colliding = blockSide;
- break;
- }
- }
- if (colliding != null) {
- if (this.getDamage() == 0) {
- this.liquidCollide(colliding, Block.get(OBSIDIAN));
- } else if (this.getDamage() <= 4) {
- this.liquidCollide(colliding, Block.get(COBBLESTONE));
- }
- }
- }
-
- @Override
- protected void flowIntoBlock(Block block, int newFlowDecay) {
- if (block instanceof BlockWater) {
- ((BlockLiquid) block).liquidCollide(this, Block.get(STONE));
- } else {
- super.flowIntoBlock(block, newFlowDecay);
- }
- }
-
- @Override
- public void addVelocityToEntity(Entity entity, Vector3 vector) {
- if (!(entity instanceof EntityPrimedTNT)) {
- super.addVelocityToEntity(entity, vector);
- }
- }
-
- @Override
- protected boolean[] getOptimalFlowDirections() {
- int[] flowCost = new int[]{
- 1000,
- 1000,
- 1000,
- 1000
- };
- int maxCost = 4 / this.getFlowDecayPerBlock();
- for (int j = 0; j < 4; ++j) {
- int x = (int) this.x;
- int y = (int) this.y;
- int z = (int) this.z;
- if (j == 0) {
- --x;
- } else if (j == 1) {
- ++x;
- } else if (j == 2) {
- --z;
- } else {
- ++z;
- }
- Block block = this.level.getBlock(x, y, z);
- if (!this.canFlowInto(block)) {
- this.flowCostVisited.put(Level.blockHash(x, y, z), BLOCKED);
- } else if (this.level.getBlock(x, y - 1, z).canBeFlowedInto()) {
- this.flowCostVisited.put(Level.blockHash(x, y, z), CAN_FLOW_DOWN);
- flowCost[j] = maxCost = 0;
- } else if (maxCost > 0) {
- this.flowCostVisited.put(Level.blockHash(x, y, z), CAN_FLOW);
- flowCost[j] = this.calculateFlowCost(x, y, z, 1, maxCost, j ^ 0x01, j ^ 0x01);
- maxCost = Math.min(maxCost, flowCost[j]);
- }
- }
- this.flowCostVisited.clear();
- double minCost = Double.MAX_VALUE;
- for (int i = 0; i < 4; i++) {
- double d = flowCost[i];
- if (d < minCost) {
- minCost = d;
- }
- }
- boolean[] isOptimalFlowDirection = new boolean[4];
- for (int i = 0; i < 4; ++i) {
- isOptimalFlowDirection[i] = (flowCost[i] == minCost);
- }
- return isOptimalFlowDirection;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockLavaStill.java b/src/main/java/cn/nukkit/block/BlockLavaStill.java
deleted file mode 100644
index 355db4c76..000000000
--- a/src/main/java/cn/nukkit/block/BlockLavaStill.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.level.Level;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockLavaStill extends BlockLava {
-
- public BlockLavaStill() {
- super(0);
- }
-
- public BlockLavaStill(int meta) {
- super(0);
- }
-
- @Override
- public int getId() {
- return STILL_LAVA;
- }
-
- @Override
- public String getName() {
- return "Still Lava";
- }
-
- @Override
- public BlockLiquid getBlock(int meta) {
- return (BlockLiquid) Block.get(STILL_LAVA, meta);
- }
-
- @Override
- public int onUpdate(int type) {
- if (type != Level.BLOCK_UPDATE_SCHEDULED) {
- return super.onUpdate(type);
- }
- return 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockLeaves.java b/src/main/java/cn/nukkit/block/BlockLeaves.java
deleted file mode 100644
index fa72afa3a..000000000
--- a/src/main/java/cn/nukkit/block/BlockLeaves.java
+++ /dev/null
@@ -1,237 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.event.block.LeavesDecayEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Hash;
-import cn.nukkit.utils.Utils;
-import it.unimi.dsi.fastutil.longs.LongArraySet;
-import it.unimi.dsi.fastutil.longs.LongSet;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockLeaves extends BlockTransparentMeta {
-
- public static final int OAK = 0;
- public static final int SPRUCE = 1;
- public static final int BIRCH = 2;
- public static final int JUNGLE = 3;
-
- public BlockLeaves() {
- this(0);
- }
-
- public BlockLeaves(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return LEAVES;
- }
-
- @Override
- public double getHardness() {
- return 0.2;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_HOE;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Oak Leaves",
- "Spruce Leaves",
- "Birch Leaves",
- "Jungle Leaves"
- };
- return names[this.getDamage() & 0x03];
- }
-
- @Override
- public int getBurnChance() {
- return 30;
- }
-
- @Override
- public int getBurnAbility() {
- return 60;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- setPersistent(true);
- this.getLevel().setBlock(this, this, true);
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, this.getDamage() & 0x3, 1);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isShears()) {
- return new Item[]{
- toItem()
- };
- } else {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- if (this.canDropApple() && Utils.random.nextInt(200) == 0) {
- return new Item[]{
- Item.get(Item.APPLE)
- };
- }
- if (Utils.random.nextInt(20) == 0) {
- if (Utils.random.nextBoolean()) {
- return new Item[]{
- Item.get(Item.STICK, 0, Utils.random.nextInt(1, 2))
- };
- } else if ((this.getDamage() & 0x03) != JUNGLE || Utils.random.nextInt(20) == 0) {
- return new Item[]{
- this.getSapling()
- };
- }
- }
- }
- return new Item[0];
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_RANDOM && !isPersistent() && !isCheckDecay()) {
- setCheckDecay(true);
- getLevel().setBlock(this, this, false, false);
- } else if (type == Level.BLOCK_UPDATE_RANDOM && isCheckDecay() && !isPersistent()) {
- setDamage(getDamage() & 0x03);
-
- LeavesDecayEvent ev = new LeavesDecayEvent(this);
-
- Server.getInstance().getPluginManager().callEvent(ev);
- if (ev.isCancelled() || findLog(this, new LongArraySet(), 0, 0)) {
- getLevel().setBlock(this, this, false, false);
- } else {
- getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-
- private Boolean findLog(Block pos, LongSet visited, Integer distance, Integer check) {
- return findLog(pos, visited, distance, check, null);
- }
-
- private Boolean findLog(Block pos, LongSet visited, Integer distance, Integer check, BlockFace fromSide) {
- ++check;
- long index = Hash.hashBlock((int) pos.x, (int) pos.y, (int) pos.z);
- if (visited.contains(index)) return false;
- if (pos.getId() == WOOD || pos.getId() == WOOD2) return true;
- if ((pos.getId() == LEAVES || pos.getId() == LEAVES2) && distance < 6) {
- visited.add(index);
- int down = pos.down().getId();
- if (down == WOOD || down == WOOD2) {
- return true;
- }
- if (fromSide == null) {
- //North, East, South, West
- for (int side = 2; side <= 5; ++side) {
- if (this.findLog(pos.getSide(BlockFace.fromIndex(side)), visited, distance + 1, check, BlockFace.fromIndex(side)))
- return true;
- }
- } else { //No more loops
- switch (fromSide) {
- case NORTH:
- if (this.findLog(pos.getSide(BlockFace.NORTH), visited, distance + 1, check, fromSide))
- return true;
- if (this.findLog(pos.getSide(BlockFace.WEST), visited, distance + 1, check, fromSide))
- return true;
- if (this.findLog(pos.getSide(BlockFace.EAST), visited, distance + 1, check, fromSide))
- return true;
- break;
- case SOUTH:
- if (this.findLog(pos.getSide(BlockFace.SOUTH), visited, distance + 1, check, fromSide))
- return true;
- if (this.findLog(pos.getSide(BlockFace.WEST), visited, distance + 1, check, fromSide))
- return true;
- if (this.findLog(pos.getSide(BlockFace.EAST), visited, distance + 1, check, fromSide))
- return true;
- break;
- case WEST:
- if (this.findLog(pos.getSide(BlockFace.NORTH), visited, distance + 1, check, fromSide))
- return true;
- if (this.findLog(pos.getSide(BlockFace.SOUTH), visited, distance + 1, check, fromSide))
- return true;
- if (this.findLog(pos.getSide(BlockFace.WEST), visited, distance + 1, check, fromSide))
- return true;
- case EAST:
- if (this.findLog(pos.getSide(BlockFace.NORTH), visited, distance + 1, check, fromSide))
- return true;
- if (this.findLog(pos.getSide(BlockFace.SOUTH), visited, distance + 1, check, fromSide))
- return true;
- if (this.findLog(pos.getSide(BlockFace.EAST), visited, distance + 1, check, fromSide))
- return true;
- break;
- }
- }
- }
- return false;
- }
-
- public boolean isCheckDecay() {
- return (this.getDamage() & 0x08) != 0;
- }
-
- public void setCheckDecay(boolean checkDecay) {
- if (checkDecay) {
- this.setDamage(this.getDamage() | 0x08);
- } else {
- this.setDamage(this.getDamage() & -9);
- }
- }
-
- public boolean isPersistent() {
- return (this.getDamage() & 0x04) != 0;
- }
-
- public void setPersistent(boolean persistent) {
- if (persistent) {
- this.setDamage(this.getDamage() | 0x04);
- } else {
- this.setDamage(this.getDamage() & -5);
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- protected boolean canDropApple() {
- return (this.getDamage() & 0x03) == OAK;
- }
-
- protected Item getSapling() {
- return Item.get(BlockID.SAPLING, this.getDamage() & 0x03);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockLeaves2.java b/src/main/java/cn/nukkit/block/BlockLeaves2.java
deleted file mode 100644
index bbea1c26e..000000000
--- a/src/main/java/cn/nukkit/block/BlockLeaves2.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-/**
- * Created on 2015/12/1 by xtypr.
- * Package cn.nukkit.block in project Nukkit.
- */
-public class BlockLeaves2 extends BlockLeaves {
-
- public static final int ACACIA = 0;
- public static final int DARK_OAK = 1;
-
- private static final String[] names = new String[]{
- "Acacia Leaves",
- "Dark Oak Leaves"
- };
-
- public BlockLeaves2() {
- this(0);
- }
-
- public BlockLeaves2(int meta) {
- super(meta);
- }
-
- public String getName() {
- return names[this.getDamage() & 0x01];
- }
-
- @Override
- public int getId() {
- return LEAVES2;
- }
-
- @Override
- protected boolean canDropApple() {
- return (this.getDamage() & 0x01) == DARK_OAK;
- }
-
- @Override
- protected Item getSapling() {
- return Item.get(BlockID.SAPLING, (this.getDamage() & 0x01) + 4);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockLever.java b/src/main/java/cn/nukkit/block/BlockLever.java
deleted file mode 100644
index 8a19c76a8..000000000
--- a/src/main/java/cn/nukkit/block/BlockLever.java
+++ /dev/null
@@ -1,235 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.block.BlockRedstoneEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.sound.LeverSound;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockLever extends BlockFlowable implements Faceable {
-
- public BlockLever() {
- this(0);
- }
-
- public BlockLever(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Lever";
- }
-
- @Override
- public int getId() {
- return LEVER;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public double getHardness() {
- return 0.5d;
- }
-
- @Override
- public double getResistance() {
- return 2.5d;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{toItem()};
- }
-
- public boolean isPowerOn() {
- return (this.getDamage() & 0x08) > 0;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, isPowerOn() ? 15 : 0, isPowerOn() ? 0 : 15));
- this.setDamage(this.getDamage() ^ 0x08);
-
- this.getLevel().setBlock(this, this, false, true);
- this.getLevel().addSound(new LeverSound(this, this.isPowerOn()));
-
- LeverOrientation orientation = LeverOrientation.byMetadata(this.isPowerOn() ? this.getDamage() ^ 0x08 : this.getDamage());
- BlockFace face = orientation.getFacing();
- level.updateAroundRedstone(this.getLocation(), null);
- this.level.updateAroundRedstone(this.getLocation().getSide(face.getOpposite()), isPowerOn() ? face : null);
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- int face = this.isPowerOn() ? this.getDamage() ^ 0x08 : this.getDamage();
- BlockFace faces = LeverOrientation.byMetadata(face).getFacing().getOpposite();
- if (!this.getSide(faces).isSolid()) {
- this.level.useBreakOn(this);
- }
- }
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (target.isNormalBlock()) {
- this.setDamage(LeverOrientation.forFacings(face, player.getHorizontalFacing()).getMetadata());
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean onBreak(Item item) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
-
- if (isPowerOn()) {
- BlockFace face = LeverOrientation.byMetadata(this.getDamage() ^ 0x08).getFacing();
- this.level.updateAround(this.getLocation().getSide(face.getOpposite()));
- }
- return true;
- }
-
- @Override
- public int getWeakPower(BlockFace side) {
- return isPowerOn() ? 15 : 0;
- }
-
- public int getStrongPower(BlockFace side) {
- if (!isPowerOn()) {
- return 0;
- } else {
- return LeverOrientation.byMetadata(this.getDamage() ^ 0x08).getFacing() == side ? 15 : 0;
- }
- }
-
- @Override
- public boolean isPowerSource() {
- return true;
- }
-
- public enum LeverOrientation {
- DOWN_X(0, "down_x", BlockFace.DOWN),
- EAST(1, "east", BlockFace.EAST),
- WEST(2, "west", BlockFace.WEST),
- SOUTH(3, "south", BlockFace.SOUTH),
- NORTH(4, "north", BlockFace.NORTH),
- UP_Z(5, "up_z", BlockFace.UP),
- UP_X(6, "up_x", BlockFace.UP),
- DOWN_Z(7, "down_z", BlockFace.DOWN);
-
- private static final LeverOrientation[] META_LOOKUP = new LeverOrientation[values().length];
- private final int meta;
- private final String name;
- private final BlockFace facing;
-
- LeverOrientation(int meta, String name, BlockFace face) {
- this.meta = meta;
- this.name = name;
- this.facing = face;
- }
-
- public int getMetadata() {
- return this.meta;
- }
-
- public BlockFace getFacing() {
- return this.facing;
- }
-
- public String toString() {
- return this.name;
- }
-
- public static LeverOrientation byMetadata(int meta) {
- if (meta < 0 || meta >= META_LOOKUP.length) {
- meta = 0;
- }
-
- return META_LOOKUP[meta];
- }
-
- public static LeverOrientation forFacings(BlockFace clickedSide, BlockFace playerDirection) {
- switch (clickedSide) {
- case DOWN:
- switch (playerDirection.getAxis()) {
- case X:
- return DOWN_X;
-
- case Z:
- return DOWN_Z;
-
- default:
- throw new IllegalArgumentException("Invalid entityFacing " + playerDirection + " for facing " + clickedSide);
- }
-
- case UP:
- switch (playerDirection.getAxis()) {
- case X:
- return UP_X;
-
- case Z:
- return UP_Z;
-
- default:
- throw new IllegalArgumentException("Invalid entityFacing " + playerDirection + " for facing " + clickedSide);
- }
-
- case NORTH:
- return NORTH;
-
- case SOUTH:
- return SOUTH;
-
- case WEST:
- return WEST;
-
- case EAST:
- return EAST;
-
- default:
- throw new IllegalArgumentException("Invalid facing: " + clickedSide);
- }
- }
-
- public String getName() {
- return this.name;
- }
-
- static {
- for (LeverOrientation face : values()) {
- META_LOOKUP[face.meta] = face;
- }
- }
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockLiquid.java b/src/main/java/cn/nukkit/block/BlockLiquid.java
deleted file mode 100644
index 8114db83f..000000000
--- a/src/main/java/cn/nukkit/block/BlockLiquid.java
+++ /dev/null
@@ -1,441 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.entity.Entity;
-import cn.nukkit.event.block.BlockFromToEvent;
-import cn.nukkit.event.block.LiquidFlowEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.particle.SmokeParticle;
-import cn.nukkit.level.sound.FizzSound;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.network.protocol.LevelSoundEventPacket;
-import it.unimi.dsi.fastutil.longs.Long2ByteMap;
-import it.unimi.dsi.fastutil.longs.Long2ByteOpenHashMap;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockLiquid extends BlockTransparentMeta {
-
- protected static final byte CAN_FLOW_DOWN = 1;
- protected static final byte CAN_FLOW = 0;
- protected static final byte BLOCKED = -1;
- public int adjacentSources = 0;
- protected Vector3 flowVector = null;
- protected Long2ByteMap flowCostVisited = new Long2ByteOpenHashMap();
-
- protected BlockLiquid(int meta) {
- super(meta);
- }
-
- @Override
- public boolean canBeFlowedInto() {
- return true;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return null;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public boolean canBeReplaced() {
- return true;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public AxisAlignedBB getBoundingBox() {
- return null;
- }
-
- @Override
- protected AxisAlignedBB recalculateCollisionBoundingBox() {
- return new AxisAlignedBB(this.x, this.y, this.z, this.x + 1, this.y + 0.9, this.z + 1);
- }
-
- public float getFluidHeightPercent() {
- float d = (float) this.getDamage();
- if (d >= 8) {
- d = 0;
- }
-
- return (d + 1) / 9f;
- }
-
- protected int getFlowDecay(Block block) {
- if (block.getId() != this.getId()) {
- return -1;
- }
- return block.getDamage();
- }
-
- protected int getEffectiveFlowDecay(Block block) {
- if (block.getId() != this.getId()) {
- return -1;
- }
- int decay = block.getDamage();
- if (decay >= 8) {
- decay = 0;
- }
- return decay;
- }
-
- public void clearCaches() {
- this.flowVector = null;
- this.flowCostVisited.clear();
- }
-
- public Vector3 getFlowVector() {
- if (this.flowVector != null) {
- return this.flowVector;
- }
- Vector3 vector = new Vector3(0, 0, 0);
- int decay = this.getEffectiveFlowDecay(this);
- for (int j = 0; j < 4; ++j) {
- int x = (int) this.x;
- int y = (int) this.y;
- int z = (int) this.z;
- switch (j) {
- case 0:
- --x;
- break;
- case 1:
- x++;
- break;
- case 2:
- z--;
- break;
- default:
- z++;
- }
- Block sideBlock = this.level.getBlock(x, y, z);
- int blockDecay = this.getEffectiveFlowDecay(sideBlock);
- if (blockDecay < 0) {
- if (!sideBlock.canBeFlowedInto()) {
- continue;
- }
- blockDecay = this.getEffectiveFlowDecay(this.level.getBlock(x, y - 1, z));
- if (blockDecay >= 0) {
- int realDecay = blockDecay - (decay - 8);
- vector.x += (sideBlock.x - this.x) * realDecay;
- vector.y += (sideBlock.y - this.y) * realDecay;
- vector.z += (sideBlock.z - this.z) * realDecay;
- }
- } else {
- int realDecay = blockDecay - decay;
- vector.x += (sideBlock.x - this.x) * realDecay;
- vector.y += (sideBlock.y - this.y) * realDecay;
- vector.z += (sideBlock.z - this.z) * realDecay;
- }
- }
- if (this.getDamage() >= 8) {
- if (!this.canFlowInto(this.level.getBlock((int) this.x, (int) this.y, (int) this.z - 1)) ||
- !this.canFlowInto(this.level.getBlock((int) this.x, (int) this.y, (int) this.z + 1)) ||
- !this.canFlowInto(this.level.getBlock((int) this.x - 1, (int) this.y, (int) this.z)) ||
- !this.canFlowInto(this.level.getBlock((int) this.x + 1, (int) this.y, (int) this.z)) ||
- !this.canFlowInto(this.level.getBlock((int) this.x, (int) this.y + 1, (int) this.z - 1)) ||
- !this.canFlowInto(this.level.getBlock((int) this.x, (int) this.y + 1, (int) this.z + 1)) ||
- !this.canFlowInto(this.level.getBlock((int) this.x - 1, (int) this.y + 1, (int) this.z)) ||
- !this.canFlowInto(this.level.getBlock((int) this.x + 1, (int) this.y + 1, (int) this.z))) {
- vector = vector.normalize().add(0, -6, 0);
- }
- }
- return this.flowVector = vector.normalize();
- }
-
- @Override
- public void addVelocityToEntity(Entity entity, Vector3 vector) {
- if (entity.canBeMovedByCurrents()) {
- Vector3 flow = this.getFlowVector();
- vector.x += flow.x;
- vector.y += flow.y;
- vector.z += flow.z;
- }
- }
-
- public int getFlowDecayPerBlock() {
- return 1;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- this.checkForHarden();
- this.level.scheduleUpdate(this, this.tickRate());
- return 0;
- } else if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- int decay = this.getFlowDecay(this);
- int multiplier = this.getFlowDecayPerBlock();
- if (decay > 0) {
- int smallestFlowDecay = -100;
- this.adjacentSources = 0;
- smallestFlowDecay = this.getSmallestFlowDecay(this.level.getBlock((int) this.x, (int) this.y, (int) this.z - 1), smallestFlowDecay);
- smallestFlowDecay = this.getSmallestFlowDecay(this.level.getBlock((int) this.x, (int) this.y, (int) this.z + 1), smallestFlowDecay);
- smallestFlowDecay = this.getSmallestFlowDecay(this.level.getBlock((int) this.x - 1, (int) this.y, (int) this.z), smallestFlowDecay);
- smallestFlowDecay = this.getSmallestFlowDecay(this.level.getBlock((int) this.x + 1, (int) this.y, (int) this.z), smallestFlowDecay);
- int newDecay = smallestFlowDecay + multiplier;
- if (newDecay >= 8 || smallestFlowDecay < 0) {
- newDecay = -1;
- }
- int topFlowDecay = this.getFlowDecay(this.level.getBlock((int) this.x, (int) this.y + 1, (int) this.z));
- if (topFlowDecay >= 0) {
- newDecay = topFlowDecay | 0x08;
- }
- if (this.adjacentSources >= 2 && this instanceof BlockWater) {
- Block bottomBlock = this.level.getBlock((int) this.x, (int) this.y - 1, (int) this.z);
- if (bottomBlock.isSolid()) {
- newDecay = 0;
- } else if (bottomBlock instanceof BlockWater && bottomBlock.getDamage() == 0) {
- newDecay = 0;
- }
- }
- if (newDecay != decay) {
- decay = newDecay;
- boolean decayed = decay < 0;
- Block to;
- if (decayed) {
- to = Block.get(BlockID.AIR);
- } else {
- to = getBlock(decay);
- }
- BlockFromToEvent event = new BlockFromToEvent(this, to);
- level.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- this.level.setBlock(this, event.getTo(), true, true);
- if (!decayed) {
- this.level.scheduleUpdate(this, this.tickRate());
- }
- }
- }
- }
- if (decay >= 0) {
- Block bottomBlock = this.level.getBlock((int) this.x, (int) this.y - 1, (int) this.z);
- this.flowIntoBlock(bottomBlock, decay | 0x08);
- if (decay == 0 || !bottomBlock.canBeFlowedInto()) {
- int adjacentDecay;
- if (decay >= 8) {
- adjacentDecay = 1;
- } else {
- adjacentDecay = decay + multiplier;
- }
- if (adjacentDecay < 8) {
- boolean[] flags = this.getOptimalFlowDirections();
- if (flags[0]) {
- this.flowIntoBlock(this.level.getBlock((int) this.x - 1, (int) this.y, (int) this.z), adjacentDecay);
- }
- if (flags[1]) {
- this.flowIntoBlock(this.level.getBlock((int) this.x + 1, (int) this.y, (int) this.z), adjacentDecay);
- }
- if (flags[2]) {
- this.flowIntoBlock(this.level.getBlock((int) this.x, (int) this.y, (int) this.z - 1), adjacentDecay);
- }
- if (flags[3]) {
- this.flowIntoBlock(this.level.getBlock((int) this.x, (int) this.y, (int) this.z + 1), adjacentDecay);
- }
- }
- }
- this.checkForHarden();
- }
- }
- return 0;
- }
-
- protected void flowIntoBlock(Block block, int newFlowDecay) {
- if (this.canFlowInto(block) && !(block instanceof BlockLiquid)) {
- LiquidFlowEvent event = new LiquidFlowEvent(block, this, newFlowDecay);
- level.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- if (block.getId() > 0) {
- this.level.useBreakOn(block, block.getId() == COBWEB ? Item.get(Item.WOODEN_SWORD) : null);
- }
- this.level.setBlock(block, getBlock(newFlowDecay), true, true);
- this.level.scheduleUpdate(block, this.tickRate());
- }
- }
- }
-
- protected int calculateFlowCost(int blockX, int blockY, int blockZ, int accumulatedCost, int maxCost, int originOpposite, int lastOpposite) {
- int cost = 1000;
- for (int j = 0; j < 4; ++j) {
- if (j == originOpposite || j == lastOpposite) {
- continue;
- }
- int x = blockX;
- int z = blockZ;
- if (j == 0) {
- --x;
- } else if (j == 1) {
- ++x;
- } else if (j == 2) {
- --z;
- } else {
- ++z;
- }
- long hash = Level.blockHash(x, blockY, z);
- if (!this.flowCostVisited.containsKey(hash)) {
- Block blockSide = this.level.getBlock(x, blockY, z);
- if (!this.canFlowInto(blockSide)) {
- this.flowCostVisited.put(hash, BLOCKED);
- } else if (this.level.getBlock(x, blockY - 1, z).canBeFlowedInto()) {
- this.flowCostVisited.put(hash, CAN_FLOW_DOWN);
- } else {
- this.flowCostVisited.put(hash, CAN_FLOW);
- }
- }
- byte status = this.flowCostVisited.get(hash);
- if (status == BLOCKED) {
- continue;
- } else if (status == CAN_FLOW_DOWN) {
- return accumulatedCost;
- }
- if (accumulatedCost >= maxCost) {
- continue;
- }
- int realCost = this.calculateFlowCost(x, blockY, z, accumulatedCost + 1, maxCost, originOpposite, j ^ 0x01);
- if (realCost < cost) {
- cost = realCost;
- }
- }
- return cost;
- }
-
- @Override
- public double getHardness() {
- return 100d;
- }
-
- @Override
- public double getResistance() {
- return 500;
- }
-
- protected boolean[] getOptimalFlowDirections() {
- int[] flowCost = new int[]{
- 1000,
- 1000,
- 1000,
- 1000
- };
- int maxCost = 4;
- for (int j = 0; j < 4; ++j) {
- int x = (int) this.x;
- int y = (int) this.y;
- int z = (int) this.z;
- if (j == 0) {
- --x;
- } else if (j == 1) {
- ++x;
- } else if (j == 2) {
- --z;
- } else {
- ++z;
- }
- Block block = this.level.getBlock(x, y, z);
- if (!this.canFlowInto(block)) {
- this.flowCostVisited.put(Level.blockHash(x, y, z), BLOCKED);
- } else if (this.level.getBlock(x, y - 1, z).canBeFlowedInto()) {
- this.flowCostVisited.put(Level.blockHash(x, y, z), CAN_FLOW_DOWN);
- flowCost[j] = maxCost = 0;
- } else if (maxCost > 0) {
- this.flowCostVisited.put(Level.blockHash(x, y, z), CAN_FLOW);
- flowCost[j] = this.calculateFlowCost(x, y, z, 1, maxCost, j ^ 0x01, j ^ 0x01);
- maxCost = Math.min(maxCost, flowCost[j]);
- }
- }
- this.flowCostVisited.clear();
- double minCost = Double.MAX_VALUE;
- for (int i = 0; i < 4; i++) {
- double d = flowCost[i];
- if (d < minCost) {
- minCost = d;
- }
- }
- boolean[] isOptimalFlowDirection = new boolean[4];
- for (int i = 0; i < 4; ++i) {
- isOptimalFlowDirection[i] = (flowCost[i] == minCost);
- }
- return isOptimalFlowDirection;
- }
-
- private int getSmallestFlowDecay(Block block, int decay) {
- int blockDecay = this.getFlowDecay(block);
- if (blockDecay < 0) {
- return decay;
- } else if (blockDecay == 0) {
- ++this.adjacentSources;
- } else if (blockDecay >= 8) {
- blockDecay = 0;
- }
- return (decay >= 0 && blockDecay >= decay) ? decay : blockDecay;
- }
-
- protected void checkForHarden() {
- }
-
- protected void triggerLavaMixEffects(Vector3 pos) {
- this.getLevel().addSound(new FizzSound(pos.add(0.5, 0.5, 0.5), 2.6F + (ThreadLocalRandom.current().nextFloat() - ThreadLocalRandom.current().nextFloat()) * 0.8F));
- this.getLevel().addParticle(new SmokeParticle(pos.add(Math.random(), 1.2, Math.random())), null, 8);
- }
-
- public abstract BlockLiquid getBlock(int meta);
-
- @Override
- public boolean canPassThrough() {
- return true;
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- entity.resetFallDistance();
- }
-
- protected boolean liquidCollide(Block cause, Block result) {
- BlockFromToEvent event = new BlockFromToEvent(this, result);
- this.level.getServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- return false;
- }
- this.level.setBlock(this, event.getTo(), true, true);
- this.getLevel().addLevelSoundEvent(this.add(0.5, 0.5, 0.5), LevelSoundEventPacket.SOUND_FIZZ);
- return true;
- }
-
- protected boolean canFlowInto(Block block) {
- return block.canBeFlowedInto() && !(block instanceof BlockLiquid && block.getDamage() == 0);
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(BlockID.AIR));
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockMagma.java b/src/main/java/cn/nukkit/block/BlockMagma.java
deleted file mode 100644
index ef5f143bd..000000000
--- a/src/main/java/cn/nukkit/block/BlockMagma.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.event.entity.EntityDamageByBlockEvent;
-import cn.nukkit.event.entity.EntityDamageEvent;
-import cn.nukkit.inventory.PlayerInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.potion.Effect;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockMagma extends BlockSolid {
-
- @Override
- public int getId() {
- return MAGMA;
- }
-
- @Override
- public String getName() {
- return "Magma Block";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getLightLevel() {
- return 3;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
- if (entity instanceof Player) {
- Player p = (Player) entity;
- PlayerInventory inv = p.getInventory();
- if (inv == null || inv.getBootsFast().hasEnchantment(Enchantment.ID_FROST_WALKER)) {
- return;
- }
- if (!p.isCreative() && !p.isSpectator() && !p.isSneaking()) {
- entity.attack(new EntityDamageByBlockEvent(this, entity, EntityDamageEvent.DamageCause.MAGMA, 1));
- }
- } else {
- entity.attack(new EntityDamageByBlockEvent(this, entity, EntityDamageEvent.DamageCause.MAGMA, 1));
- }
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockMelon.java b/src/main/java/cn/nukkit/block/BlockMelon.java
deleted file mode 100644
index a5cb65f6d..000000000
--- a/src/main/java/cn/nukkit/block/BlockMelon.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemMelon;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created on 2015/12/11 by Pub4Game.
- * Package cn.nukkit.block in project Nukkit .
- */
-
-public class BlockMelon extends BlockSolid {
-
- @Override
- public int getId() {
- return MELON_BLOCK;
- }
-
- public String getName() {
- return "Melon Block";
- }
-
- public double getHardness() {
- return 1;
- }
-
- @Override
- public double getResistance() {
- return 5;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
-
- int count = 3 + Utils.random.nextInt(5);
-
- Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
- if (fortune != null && fortune.getLevel() >= 1) {
- count += Utils.random.nextInt(fortune.getLevel() + 1);
- }
-
- return new Item[]{
- new ItemMelon(0, Math.min(9, count))
- };
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.LIME_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- @Override
- public boolean breakWhenPushed() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockMeta.java b/src/main/java/cn/nukkit/block/BlockMeta.java
deleted file mode 100644
index 3f6e1529e..000000000
--- a/src/main/java/cn/nukkit/block/BlockMeta.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package cn.nukkit.block;
-
-public abstract class BlockMeta extends Block {
-
- private int meta;
-
- protected BlockMeta(int meta) {
- this.meta = meta;
- }
-
- @Override
- public int getFullId() {
- return (getId() << 4) + meta;
- }
-
- @Override
- public final int getDamage() {
- return this.meta;
- }
-
- @Override
- public void setDamage(int meta) {
- this.meta = meta;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockMobSpawner.java b/src/main/java/cn/nukkit/block/BlockMobSpawner.java
deleted file mode 100644
index d8ab09c16..000000000
--- a/src/main/java/cn/nukkit/block/BlockMobSpawner.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created by Pub4Game on 27.12.2015.
- */
-public class BlockMobSpawner extends BlockSolid {
-
- @Override
- public String getName() {
- return "Monster Spawner";
- }
-
- @Override
- public int getId() {
- return MONSTER_SPAWNER;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 25;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (!super.place(item, block, target, face, fx, fy, fz, player)) return false;
- BlockEntity.createBlockEntity(BlockEntity.MOB_SPAWNER, this.getChunk(), BlockEntity.getDefaultCompound(this, BlockEntity.MOB_SPAWNER));
- return true;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public int getLightLevel() {
- return 3;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockMonsterEgg.java b/src/main/java/cn/nukkit/block/BlockMonsterEgg.java
deleted file mode 100644
index 20f5d842c..000000000
--- a/src/main/java/cn/nukkit/block/BlockMonsterEgg.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Server;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.mob.EntitySilverfish;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.network.protocol.EntityEventPacket;
-import cn.nukkit.utils.Utils;
-
-public class BlockMonsterEgg extends BlockSolidMeta {
-
- public static final int STONE = 0;
- public static final int COBBLESTONE = 1;
- public static final int STONE_BRICK = 2;
- public static final int MOSSY_BRICK = 3;
- public static final int CRACKED_BRICK = 4;
- public static final int CHISELED_BRICK = 5;
-
- private static final String[] NAMES = new String[]{
- "Stone",
- "Cobblestone",
- "Stone Brick",
- "Mossy Stone Brick",
- "Cracked Stone Brick",
- "Chiseled Stone Brick"
- };
-
- public BlockMonsterEgg() {
- this(0);
- }
-
- public BlockMonsterEgg(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return MONSTER_EGG;
- }
-
- @Override
- public double getHardness() {
- return 0.75;
- }
-
- @Override
- public double getResistance() {
- return 3.75;
- }
-
- @Override
- public String getName() {
- return NAMES[this.getDamage() > 5 ? 0 : this.getDamage()] + " Monster Egg";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public boolean onBreak(Item item) {
- if (Server.getInstance().mobsFromBlocks) {
- if (Utils.rand(1, 5) == 1 && !item.hasEnchantment(Enchantment.ID_SILK_TOUCH) && this.getLevel().getBlockLightAt((int) this.x, (int) this.y, (int) this.z) < 12) {
- EntitySilverfish entity = (EntitySilverfish) Entity.createEntity("Silverfish", this.add(0.5, 0, 0.5));
- entity.spawnToAll();
- EntityEventPacket pk = new EntityEventPacket();
- pk.eid = entity.getId();
- pk.event = EntityEventPacket.SILVERFISH_SPAWN_ANIMATION;
- entity.getLevel().addChunkPacket(entity.getChunkX() >> 2, entity.getChunkZ() >> 2, pk);
- }
- }
- return this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockMossStone.java b/src/main/java/cn/nukkit/block/BlockMossStone.java
deleted file mode 100644
index 9ba866930..000000000
--- a/src/main/java/cn/nukkit/block/BlockMossStone.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockMossStone extends BlockSolid {
-
- @Override
- public String getName() {
- return "Moss Stone";
- }
-
- @Override
- public int getId() {
- return MOSS_STONE;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockMushroom.java b/src/main/java/cn/nukkit/block/BlockMushroom.java
deleted file mode 100644
index 820fd7be5..000000000
--- a/src/main/java/cn/nukkit/block/BlockMushroom.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.generator.object.mushroom.BigMushroom;
-import cn.nukkit.level.particle.BoneMealParticle;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.NukkitRandom;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-public abstract class BlockMushroom extends BlockFlowable {
-
- public BlockMushroom() {
- this(0);
- }
-
- public BlockMushroom(int meta) {
- super(0);
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (!canStay()) {
- getLevel().useBreakOn(this);
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (canStay()) {
- getLevel().setBlock(block, this, true, true);
- return true;
- }
- return false;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.getId() == Item.DYE && item.getDamage() == DyeColor.WHITE.getDyeData()) {
- if (player != null && !player.isCreative()) {
- item.count--;
- }
-
- if (ThreadLocalRandom.current().nextFloat() < 0.4) {
- this.grow();
- }
-
- this.level.addParticle(new BoneMealParticle(this));
- return true;
- }
- return false;
- }
-
- public boolean grow() {
- this.level.setBlock(this, Block.get(BlockID.AIR), true, false);
-
- BigMushroom generator = new BigMushroom(getType());
-
- if (generator.generate(this.level, new NukkitRandom(), this)) {
- return true;
- } else {
- this.level.setBlock(this, this, true, false);
- return false;
- }
- }
-
- public boolean canStay() {
- Block block = this.down();
- return block.getId() == MYCELIUM || block.getId() == PODZOL || (!block.isTransparent() && this.level.getFullLight(this) < 13);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- protected abstract int getType();
-}
diff --git a/src/main/java/cn/nukkit/block/BlockMushroomBrown.java b/src/main/java/cn/nukkit/block/BlockMushroomBrown.java
deleted file mode 100644
index 8ce4f00e3..000000000
--- a/src/main/java/cn/nukkit/block/BlockMushroomBrown.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockMushroomBrown extends BlockMushroom {
-
- public BlockMushroomBrown() {
- super();
- }
-
- public BlockMushroomBrown(int meta) {
- super(0);
- }
-
- @Override
- public String getName() {
- return "Brown Mushroom";
- }
-
- @Override
- public int getId() {
- return BROWN_MUSHROOM;
- }
-
- @Override
- public int getLightLevel() {
- return 1;
- }
-
- @Override
- protected int getType() {
- return 0;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockMushroomRed.java b/src/main/java/cn/nukkit/block/BlockMushroomRed.java
deleted file mode 100644
index 9f27cc06c..000000000
--- a/src/main/java/cn/nukkit/block/BlockMushroomRed.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * Created by Pub4Game on 03.01.2015.
- */
-public class BlockMushroomRed extends BlockMushroom {
-
- public BlockMushroomRed() {
- super();
- }
-
- public BlockMushroomRed(int meta) {
- super(0);
- }
-
- @Override
- public String getName() {
- return "Red Mushroom";
- }
-
- @Override
- public int getId() {
- return RED_MUSHROOM;
- }
-
- @Override
- protected int getType() {
- return 1;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockMycelium.java b/src/main/java/cn/nukkit/block/BlockMycelium.java
deleted file mode 100644
index f29b8fe18..000000000
--- a/src/main/java/cn/nukkit/block/BlockMycelium.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.event.block.BlockSpreadEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.Sound;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created by Pub4Game on 03.01.2016.
- */
-public class BlockMycelium extends BlockSolid {
-
- @Override
- public String getName() {
- return "Mycelium";
- }
-
- @Override
- public int getId() {
- return MYCELIUM;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- public double getHardness() {
- return 0.6;
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- new ItemBlock(Block.get(BlockID.DIRT))
- };
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_RANDOM) {
- x = Utils.rand((int) x - 1, (int) x + 1);
- y = Utils.rand((int) y - 1, (int) y + 1);
- z = Utils.rand((int) z - 1, (int) z + 1);
- Block block = this.getLevel().getBlock(new Vector3(x, y, z));
- if (block.getId() == Block.DIRT && block.getDamage() == 0) {
- if (block.up() instanceof BlockAir) {
- BlockSpreadEvent ev = new BlockSpreadEvent(block, this, Block.get(MYCELIUM));
- Server.getInstance().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(block, ev.getNewState());
- }
- }
- }
- }
- return 0;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.PURPLE_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.isShovel()) {
- Block up = this.up();
- if (up instanceof BlockAir || up instanceof BlockFlowable) {
- item.useOn(this);
- this.getLevel().setBlock(this, Block.get(GRASS_PATH));
- if (player != null) {
- player.getLevel().addSoundToViewers(player, Sound.STEP_GRASS);
- }
- return true;
- }
- }
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockNetherBrick.java b/src/main/java/cn/nukkit/block/BlockNetherBrick.java
deleted file mode 100644
index 06e3bb942..000000000
--- a/src/main/java/cn/nukkit/block/BlockNetherBrick.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/7 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockNetherBrick extends BlockSolid {
-
- @Override
- public String getName() {
- return "Nether Bricks";
- }
-
- @Override
- public int getId() {
- return NETHER_BRICKS;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockNetherPortal.java b/src/main/java/cn/nukkit/block/BlockNetherPortal.java
deleted file mode 100644
index 25e5d1fa1..000000000
--- a/src/main/java/cn/nukkit/block/BlockNetherPortal.java
+++ /dev/null
@@ -1,372 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.Position;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.BlockFace.Axis;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created on 2016/1/5 by xtypr.
- * Package cn.nukkit.block in project nukkit .
- * The name NetherPortalBlock comes from minecraft wiki.
- */
-public class BlockNetherPortal extends BlockFlowable implements Faceable {
-
- public BlockNetherPortal() {
- this(0);
- }
-
- public BlockNetherPortal(int meta) {
- super(0);
- }
-
- @Override
- public String getName() {
- return "Nether Portal Block";
- }
-
- @Override
- public int getId() {
- return NETHER_PORTAL;
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public int getLightLevel() {
- return 11;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(BlockID.AIR));
- }
-
- @Override
- public boolean canBeFlowedInto() {
- return false;
- }
-
- @Override
- public boolean onBreak(Item item) {
- boolean result = super.onBreak(item);
- for (BlockFace face : BlockFace.values()) {
- Block b = this.getSide(face);
- if (b != null) {
- if (b instanceof BlockNetherPortal) {
- result &= b.onBreak(item);
- }
- }
- }
- return result;
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- }
-
- public static boolean trySpawnPortal(Level level, Vector3 pos) {
- return trySpawnPortal(level, pos, false);
- }
-
- public static boolean trySpawnPortal(Level level, Vector3 pos, boolean force) {
- PortalBuilder builder = new PortalBuilder(level, pos, Axis.X, force);
-
- if (builder.isValid() && builder.portalBlockCount == 0) {
- builder.placePortalBlocks();
- return true;
- } else {
- builder = new PortalBuilder(level, pos, Axis.Z, force);
-
- if (builder.isValid() && builder.portalBlockCount == 0) {
- builder.placePortalBlocks();
- return true;
- } else {
- return false;
- }
- }
- }
-
- public static class PortalBuilder {
-
- private final Level level;
- private final Axis axis;
- private final BlockFace rightDir;
- private final BlockFace leftDir;
- private int portalBlockCount;
- private Vector3 bottomLeft;
- private int height;
- private int width;
-
- private boolean force;
-
- public PortalBuilder(Level level, Vector3 pos, Axis axis, boolean force) {
- this.level = level;
- this.axis = axis;
- this.force = force;
-
- if (axis == Axis.X) {
- this.leftDir = BlockFace.EAST;
- this.rightDir = BlockFace.WEST;
- } else {
- this.leftDir = BlockFace.NORTH;
- this.rightDir = BlockFace.SOUTH;
- }
-
-
- for (Vector3 blockpos = pos; pos.getY() > blockpos.getY() - 21 && pos.getY() > 0 && this.isEmptyBlock(getBlockId(pos.down())); pos = pos.down()) {
- }
-
- int i = this.getDistanceUntilEdge(pos, this.leftDir) - 1;
-
- if (i >= 0) {
- this.bottomLeft = pos.getSide(this.leftDir, i);
- this.width = this.getDistanceUntilEdge(this.bottomLeft, this.rightDir);
-
- if (this.width < 2 || this.width > 21) {
- this.bottomLeft = null;
- this.width = 0;
- }
- }
-
- if (this.bottomLeft != null) {
- this.height = this.calculatePortalHeight();
- }
- }
-
- protected int getDistanceUntilEdge(Vector3 pos, BlockFace dir) {
- int i;
-
- for (i = 0; i < 22; ++i) {
- Vector3 v = pos.getSide(dir, i);
-
- if (!this.isEmptyBlock(getBlockId(v)) || getBlockId(v.down()) != OBSIDIAN) {
- break;
- }
- }
-
- return getBlockId(pos.getSide(dir, i)) == OBSIDIAN ? i : 0;
- }
-
- public int getHeight() {
- return this.height;
- }
-
- public int getWidth() {
- return this.width;
- }
-
- protected int calculatePortalHeight() {
-
- loop:
- for (this.height = 0; this.height < 21; ++this.height) {
- for (int i = 0; i < this.width; ++i) {
- Vector3 blockpos = this.bottomLeft.getSide(this.rightDir, i).up(this.height);
- int block = getBlockId(blockpos);
-
- if (!this.isEmptyBlock(block)) {
- break loop;
- }
-
- if (block == NETHER_PORTAL) {
- ++this.portalBlockCount;
- }
-
- if (i == 0) {
- block = getBlockId(blockpos.getSide(this.leftDir));
-
- if (block != OBSIDIAN) {
- break loop;
- }
- } else if (i == this.width - 1) {
- block = getBlockId(blockpos.getSide(this.rightDir));
-
- if (block != OBSIDIAN) {
- break loop;
- }
- }
- }
- }
-
- for (int i = 0; i < this.width; ++i) {
- if (getBlockId(this.bottomLeft.getSide(this.rightDir, i).up(this.height)) != OBSIDIAN) {
- this.height = 0;
- break;
- }
- }
-
- if (this.height <= 21 && this.height >= 3) {
- return this.height;
- } else {
- this.bottomLeft = null;
- this.width = 0;
- this.height = 0;
- return 0;
- }
- }
-
- private int getBlockId(Vector3 pos) {
- return this.level.getBlockIdAt(pos.getFloorX(), pos.getFloorY(), pos.getFloorZ());
- }
-
- protected boolean isEmptyBlock(int id) {
- return force || id == AIR || id == FIRE || id == NETHER_PORTAL;
- }
-
- public boolean isValid() {
- return this.bottomLeft != null && this.width >= 2 && this.width <= 21 && this.height >= 3 && this.height <= 21;
- }
-
- public void placePortalBlocks() {
- for (int i = 0; i < this.width; ++i) {
- Vector3 blockpos = this.bottomLeft.getSide(this.rightDir, i);
-
- for (int j = 0; j < this.height; ++j) {
- this.level.setBlock(blockpos.up(j), Block.get(NETHER_PORTAL, this.axis == Axis.X ? 1 : this.axis == Axis.Z ? 2 : 0));
- }
- }
- }
- }
-
- public static Position getSafePortal(Position portal) {
- Level level = portal.getLevel();
- Vector3 down = portal.down();
- while (level.getBlockIdAt(down.getFloorX(), down.getFloorY(), down.getFloorZ()) == NETHER_PORTAL) {
- down = down.down();
- }
-
- return Position.fromObject(down.up(), portal.getLevel());
- }
-
- public static Position findNearestPortal(Position pos) {
- Level level = pos.getLevel();
- Position found = null;
-
- for (int xx = -16; xx <= 16; xx++) {
- for (int zz = -16; zz <= 16; zz++) {
- for (int y = 0; y < 255; y++) {
- int x = pos.getFloorX() + xx, z = pos.getFloorZ() + zz;
- if (level.getBlockIdAt(x, y, z) == NETHER_PORTAL) {
- found = new Position(x, y, z, level);
- break;
- }
- }
- }
- }
-
- if (found == null) {
- return null;
- }
- Vector3 up = found.up();
- int x = up.getFloorX(), y = up.getFloorY(), z = up.getFloorZ();
- int id = level.getBlockIdAt(x, y, z);
- if (id != AIR && id != OBSIDIAN && id != NETHER_PORTAL) {
- for (int xx = -1; xx < 4; xx++) {
- for (int yy = 1; yy < 4; yy++) {
- for (int zz = -1; zz < 3; zz++) {
- level.setBlockAt(x + xx, y + yy, z + zz, AIR);
- }
- }
- }
- }
- return found;
- }
-
- public static void spawnPortal(Position pos) {
- Level lvl = pos.level;
- int x = pos.getFloorX(), y = pos.getFloorY(), z = pos.getFloorZ();
-
- for (int xx = -1; xx < 4; xx++) {
- for (int yy = 1; yy < 4; yy++) {
- for (int zz = -1; zz < 3; zz++) {
- lvl.setBlockAt(x + xx, y + yy, z + zz, AIR);
- }
- }
- }
-
- lvl.setBlockAt(x + 1, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 2, y, z, OBSIDIAN);
-
- z += 1;
- lvl.setBlockAt(x, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 1, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 2, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 3, y, z, OBSIDIAN);
-
- z += 1;
- lvl.setBlockAt(x + 1, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 2, y, z, OBSIDIAN);
-
- z -= 1;
- y += 1;
- lvl.setBlockAt(x, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 1, y, z, NETHER_PORTAL);
- lvl.setBlockAt(x + 2, y, z, NETHER_PORTAL);
- lvl.setBlockAt(x + 3, y, z, OBSIDIAN);
-
- y += 1;
- lvl.setBlockAt(x, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 1, y, z, NETHER_PORTAL);
- lvl.setBlockAt(x + 2, y, z, NETHER_PORTAL);
- lvl.setBlockAt(x + 3, y, z, OBSIDIAN);
-
- y += 1;
- lvl.setBlockAt(x, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 1, y, z, NETHER_PORTAL);
- lvl.setBlockAt(x + 2, y, z, NETHER_PORTAL);
- lvl.setBlockAt(x + 3, y, z, OBSIDIAN);
-
- y += 1;
- lvl.setBlockAt(x, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 1, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 2, y, z, OBSIDIAN);
- lvl.setBlockAt(x + 3, y, z, OBSIDIAN);
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockNetherReactor.java b/src/main/java/cn/nukkit/block/BlockNetherReactor.java
deleted file mode 100644
index 541ae9763..000000000
--- a/src/main/java/cn/nukkit/block/BlockNetherReactor.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDiamond;
-import cn.nukkit.item.ItemIngotIron;
-import cn.nukkit.item.ItemTool;
-
-public class BlockNetherReactor extends BlockSolid {
-
- @Override
- public int getId() {
- return NETHER_REACTOR;
- }
-
- @Override
- public String getName() {
- return "Nether Reactor Core";
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) {
- return new Item[]{new ItemDiamond(0, 3), new ItemIngotIron(0, 6)};
- } else return new Item[0];
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockNetherWart.java b/src/main/java/cn/nukkit/block/BlockNetherWart.java
deleted file mode 100644
index 5386eddc7..000000000
--- a/src/main/java/cn/nukkit/block/BlockNetherWart.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.event.block.BlockGrowEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemNetherWart;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created by Leonidius20 on 22.03.17.
- */
-public class BlockNetherWart extends BlockFlowable {
-
- public BlockNetherWart() {
- this(0);
- }
-
- public BlockNetherWart(int meta) {
- super(meta);
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = this.down();
- if (down.getId() == SOUL_SAND) {
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().getId() != SOUL_SAND) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- if (Utils.random.nextInt(10) == 1) {
- if (this.getDamage() < 0x03) {
- BlockNetherWart block = (BlockNetherWart) this.clone();
- block.setDamage(block.getDamage() + 1);
- BlockGrowEvent ev = new BlockGrowEvent(this, block);
- Server.getInstance().getPluginManager().callEvent(ev);
-
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(this, ev.getNewState(), true, true);
- } else {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- } else {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
-
- return 0;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-
- @Override
- public String getName() {
- return "Nether Wart Block";
- }
-
- @Override
- public int getId() {
- return NETHER_WART_BLOCK;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (this.getDamage() == 0x03) {
- return new Item[]{
- new ItemNetherWart(0, 2 + (int) (Math.random() * (3)))
- };
- } else {
- return new Item[]{
- new ItemNetherWart()
- };
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemNetherWart();
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockNetherWartBlock.java b/src/main/java/cn/nukkit/block/BlockNetherWartBlock.java
deleted file mode 100644
index d20ed238e..000000000
--- a/src/main/java/cn/nukkit/block/BlockNetherWartBlock.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockNetherWartBlock extends BlockSolid {
-
- @Override
- public String getName() {
- return "Nether Wart Block";
- }
-
- @Override
- public int getId() {
- return BLOCK_NETHER_WART_BLOCK;
- }
-
- @Override
- public double getResistance() {
- return 1;
- }
-
- @Override
- public double getHardness() {
- return 1;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- toItem()
- };
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.RED_BLOCK_COLOR;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_HOE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockNetherrack.java b/src/main/java/cn/nukkit/block/BlockNetherrack.java
deleted file mode 100644
index 2043e7dd3..000000000
--- a/src/main/java/cn/nukkit/block/BlockNetherrack.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/26 by Pub4Game.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockNetherrack extends BlockSolid {
-
- @Override
- public int getId() {
- return NETHERRACK;
- }
-
- @Override
- public double getResistance() {
- return 2;
- }
-
- @Override
- public double getHardness() {
- return 0.4;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Netherrack";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockNoteblock.java b/src/main/java/cn/nukkit/block/BlockNoteblock.java
deleted file mode 100644
index 2dafb6c78..000000000
--- a/src/main/java/cn/nukkit/block/BlockNoteblock.java
+++ /dev/null
@@ -1,296 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityMusic;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.Sound;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.network.protocol.BlockEventPacket;
-import cn.nukkit.network.protocol.LevelSoundEventPacket;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by Snake1999 on 2016/1/17.
- * Package cn.nukkit.block in project nukkit.
- */
-public class BlockNoteblock extends BlockSolid {
-
- @Override
- public String getName() {
- return "Note Block";
- }
-
- @Override
- public int getId() {
- return NOTEBLOCK;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public double getHardness() {
- return 0.8D;
- }
-
- @Override
- public double getResistance() {
- return 4D;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.getLevel().setBlock(block, this, true);
- this.createBlockEntity();
- return true;
- }
-
- public int getStrength() {
- BlockEntityMusic blockEntity = this.getBlockEntity();
- return blockEntity != null ? blockEntity.getPitch() : 0;
- }
-
- public void increaseStrength() {
- BlockEntityMusic blockEntity = this.getBlockEntity();
- if (blockEntity != null) {
- blockEntity.changePitch();
- }
- }
-
- public Instrument getInstrument() {
- switch (this.down().getId()) {
- case GOLD_BLOCK:
- return Instrument.GLOCKENSPIEL;
- case CLAY_BLOCK:
- return Instrument.FLUTE;
- case PACKED_ICE:
- return Instrument.CHIME;
- case WOOL:
- return Instrument.GUITAR;
- case BONE_BLOCK:
- return Instrument.XYLOPHONE;
- case IRON_BLOCK:
- return Instrument.VIBRAPHONE;
- case SOUL_SAND:
- return Instrument.COW_BELL;
- case PUMPKIN:
- return Instrument.DIDGERIDOO;
- case EMERALD_BLOCK:
- return Instrument.SQUARE_WAVE;
- case HAY_BALE:
- return Instrument.BANJO;
- case GLOWSTONE_BLOCK:
- return Instrument.ELECTRIC_PIANO;
- case LOG:
- case LOG2:
- case PLANKS:
- case DOUBLE_WOODEN_SLAB:
- case WOODEN_SLAB:
- case WOOD_STAIRS:
- case SPRUCE_WOOD_STAIRS:
- case BIRCH_WOOD_STAIRS:
- case JUNGLE_WOOD_STAIRS:
- case ACACIA_WOOD_STAIRS:
- case DARK_OAK_WOOD_STAIRS:
- case FENCE:
- case FENCE_GATE:
- case FENCE_GATE_SPRUCE:
- case FENCE_GATE_BIRCH:
- case FENCE_GATE_JUNGLE:
- case FENCE_GATE_DARK_OAK:
- case FENCE_GATE_ACACIA:
- case DOOR_BLOCK:
- case SPRUCE_DOOR_BLOCK:
- case BIRCH_DOOR_BLOCK:
- case JUNGLE_DOOR_BLOCK:
- case ACACIA_DOOR_BLOCK:
- case DARK_OAK_DOOR_BLOCK:
- case WOODEN_PRESSURE_PLATE:
- case TRAPDOOR:
- case SIGN_POST:
- case WALL_SIGN:
- case NOTEBLOCK:
- case BOOKSHELF:
- case CHEST:
- case TRAPPED_CHEST:
- case CRAFTING_TABLE:
- case JUKEBOX:
- case BROWN_MUSHROOM_BLOCK:
- case RED_MUSHROOM_BLOCK:
- case DAYLIGHT_DETECTOR:
- case DAYLIGHT_DETECTOR_INVERTED:
- case STANDING_BANNER:
- case WALL_BANNER:
- return Instrument.BASS;
- case SAND:
- case GRAVEL:
- case CONCRETE_POWDER:
- return Instrument.DRUM;
- case GLASS:
- case GLASS_PANEL:
- case STAINED_GLASS_PANE:
- case STAINED_GLASS:
- case BEACON:
- case SEA_LANTERN:
- return Instrument.STICKS;
- case STONE:
- case SANDSTONE:
- case RED_SANDSTONE:
- case COBBLESTONE:
- case MOSSY_STONE:
- case BRICKS:
- case STONE_BRICKS:
- case NETHER_BRICK_BLOCK:
- case RED_NETHER_BRICK:
- case QUARTZ_BLOCK:
- case DOUBLE_SLAB:
- case SLAB:
- case DOUBLE_RED_SANDSTONE_SLAB:
- case RED_SANDSTONE_SLAB:
- case COBBLE_STAIRS:
- case BRICK_STAIRS:
- case STONE_BRICK_STAIRS:
- case NETHER_BRICKS_STAIRS:
- case SANDSTONE_STAIRS:
- case QUARTZ_STAIRS:
- case RED_SANDSTONE_STAIRS:
- case PURPUR_STAIRS:
- case COBBLE_WALL:
- case NETHER_BRICK_FENCE:
- case BEDROCK:
- case GOLD_ORE:
- case IRON_ORE:
- case COAL_ORE:
- case LAPIS_ORE:
- case DIAMOND_ORE:
- case REDSTONE_ORE:
- case GLOWING_REDSTONE_ORE:
- case EMERALD_ORE:
- case DROPPER:
- case DISPENSER:
- case FURNACE:
- case BURNING_FURNACE:
- case OBSIDIAN:
- case GLOWING_OBSIDIAN:
- case MONSTER_SPAWNER:
- case STONE_PRESSURE_PLATE:
- case NETHERRACK:
- case QUARTZ_ORE:
- case ENCHANTING_TABLE:
- case END_PORTAL_FRAME:
- case END_STONE:
- case END_BRICKS:
- case ENDER_CHEST:
- case STAINED_TERRACOTTA:
- case TERRACOTTA:
- case PRISMARINE:
- case COAL_BLOCK:
- case PURPUR_BLOCK:
- case MAGMA:
- case CONCRETE:
- case STONECUTTER:
- case OBSERVER:
- return Instrument.BASS_DRUM;
- default:
- return Instrument.PIANO;
- }
- }
-
- public void emitSound() {
- if (this.up().getId() != AIR) return;
-
- Instrument instrument = this.getInstrument();
-
- this.level.addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_NOTE, instrument.ordinal() << 8 | this.getStrength());
-
- BlockEventPacket pk = new BlockEventPacket();
- pk.x = this.getFloorX();
- pk.y = this.getFloorY();
- pk.z = this.getFloorZ();
- pk.case1 = instrument.ordinal();
- pk.case2 = this.getStrength();
- this.getLevel().addChunkPacket(this.getFloorX() >> 4, this.getFloorZ() >> 4, pk);
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player.isSneaking()) return false;
- this.increaseStrength();
- this.emitSound();
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_REDSTONE) {
- BlockEntityMusic blockEntity = this.getBlockEntity();
- if (blockEntity != null) {
- if (this.getLevel().isBlockPowered(this)) {
- if (!blockEntity.isPowered()) {
- this.emitSound();
- }
- blockEntity.setPowered(true);
- } else {
- blockEntity.setPowered(false);
- }
- }
- }
- return super.onUpdate(type);
- }
-
- private BlockEntityMusic getBlockEntity() {
- BlockEntity blockEntity = this.getLevel().getBlockEntity(this);
- if (blockEntity instanceof BlockEntityMusic) {
- return (BlockEntityMusic) blockEntity;
- }
- return null;
- }
-
- private BlockEntityMusic createBlockEntity() {
- return (BlockEntityMusic) BlockEntity.createBlockEntity(BlockEntity.MUSIC, this.getChunk(), BlockEntity.getDefaultCompound(this, BlockEntity.MUSIC));
- }
-
- public enum Instrument {
- PIANO(Sound.NOTE_HARP),
- BASS_DRUM(Sound.NOTE_BD),
- DRUM(Sound.NOTE_SNARE),
- STICKS(Sound.NOTE_HAT),
- BASS(Sound.NOTE_BASS),
- GLOCKENSPIEL(Sound.NOTE_BELL),
- FLUTE(Sound.NOTE_FLUTE),
- CHIME(Sound.NOTE_CHIME),
- GUITAR(Sound.NOTE_GUITAR),
- XYLOPHONE(Sound.NOTE_XYLOPHONE),
- VIBRAPHONE(Sound.NOTE_IRON_XYLOPHONE),
- COW_BELL(Sound.NOTE_COW_BELL),
- DIDGERIDOO(Sound.NOTE_DIDGERIDOO),
- SQUARE_WAVE(Sound.NOTE_BIT),
- BANJO(Sound.NOTE_BANJO),
- ELECTRIC_PIANO(Sound.NOTE_PLING);
-
- private final Sound sound;
-
- Instrument(Sound sound) {
- this.sound = sound;
- }
-
- public Sound getSound() {
- return sound;
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockObserver.java b/src/main/java/cn/nukkit/block/BlockObserver.java
deleted file mode 100644
index 5537b7b6a..000000000
--- a/src/main/java/cn/nukkit/block/BlockObserver.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.Faceable;
-
-public class BlockObserver extends BlockSolid implements Faceable {
-
- @Override
- public int getId() {
- return OBSERVER;
- }
-
- @Override
- public String getName() {
- return "Observer";
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getResistance() {
- return 17.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- Item.get(Item.OBSERVER, 0, 1)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (player != null) {
- if (Math.abs(player.x - this.x) < 2 && Math.abs(player.z - this.z) < 2) {
- double y = player.y + player.getEyeHeight();
- if (y - this.y > 2) {
- this.setDamage(BlockFace.DOWN.getIndex());
- } else if (this.y - y > 0) {
- this.setDamage(BlockFace.UP.getIndex());
- } else {
- this.setDamage(player.getHorizontalFacing().getIndex());
- }
- } else {
- this.setDamage(player.getHorizontalFacing().getIndex());
- }
- } else {
- this.setDamage(0);
- }
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockObsidian.java b/src/main/java/cn/nukkit/block/BlockObsidian.java
deleted file mode 100644
index 1ec785a6c..000000000
--- a/src/main/java/cn/nukkit/block/BlockObsidian.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockObsidian extends BlockSolid {
-
- @Override
- public String getName() {
- return "Obsidian";
- }
-
- @Override
- public int getId() {
- return OBSIDIAN;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 35;
- }
-
- @Override
- public double getResistance() {
- return 6000;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_DIAMOND) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean onBreak(Item item) {
- //destroy the nether portal
- Block[] nearby = new Block[]{
- this.up(), this.down(),
- this.north(), south(),
- this.west(), this.east(),
- };
- for (Block aNearby : nearby) {
- if (aNearby != null) if (aNearby.getId() == NETHER_PORTAL) {
- aNearby.onBreak(item);
- }
- }
- return super.onBreak(item);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.OBSIDIAN_BLOCK_COLOR;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockObsidianGlowing.java b/src/main/java/cn/nukkit/block/BlockObsidianGlowing.java
deleted file mode 100644
index b04804742..000000000
--- a/src/main/java/cn/nukkit/block/BlockObsidianGlowing.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-
-/**
- * Created on 2015/11/22 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockObsidianGlowing extends BlockObsidian {
-
- @Override
- public int getId() {
- return GLOWING_OBSIDIAN;
- }
-
- @Override
- public String getName() {
- return "Glowing Obsidian";
- }
-
- @Override
- public int getLightLevel() {
- return 12;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(GLOWING_OBSIDIAN));
- }
-
- @Override
- public boolean onBreak(Item item) {
- return this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockOreCoal.java b/src/main/java/cn/nukkit/block/BlockOreCoal.java
deleted file mode 100644
index 979b2afa6..000000000
--- a/src/main/java/cn/nukkit/block/BlockOreCoal.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemCoal;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockOreCoal extends BlockSolid {
-
- @Override
- public int getId() {
- return COAL_ORE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Coal Ore";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
-
- int count = 1;
- Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
- if (fortune != null && fortune.getLevel() >= 1) {
- int i = Utils.random.nextInt(fortune.getLevel() + 2) - 1;
-
- if (i < 0) {
- i = 0;
- }
-
- count = i + 1;
- }
-
- return new Item[]{
- new ItemCoal(0, count)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public int getDropExp() {
- return Utils.rand(0, 2);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockOreDiamond.java b/src/main/java/cn/nukkit/block/BlockOreDiamond.java
deleted file mode 100644
index 903e320b0..000000000
--- a/src/main/java/cn/nukkit/block/BlockOreDiamond.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDiamond;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockOreDiamond extends BlockSolid {
-
- @Override
- public int getId() {
- return DIAMOND_ORE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Diamond Ore";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
-
- int count = 1;
- Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
- if (fortune != null && fortune.getLevel() >= 1) {
- int i = Utils.random.nextInt(fortune.getLevel() + 2) - 1;
-
- if (i < 0) {
- i = 0;
- }
-
- count = i + 1;
- }
-
- return new Item[]{
- new ItemDiamond(0, count)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public int getDropExp() {
- return Utils.rand(3, 7);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockOreEmerald.java b/src/main/java/cn/nukkit/block/BlockOreEmerald.java
deleted file mode 100644
index 39aed84dd..000000000
--- a/src/main/java/cn/nukkit/block/BlockOreEmerald.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemEmerald;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created on 2015/12/1 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockOreEmerald extends BlockSolid {
-
- @Override
- public String getName() {
- return "Emerald Ore";
- }
-
- @Override
- public int getId() {
- return EMERALD_ORE;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
-
- int count = 1;
- Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
- if (fortune != null && fortune.getLevel() >= 1) {
- int i = Utils.random.nextInt(fortune.getLevel() + 2) - 1;
-
- if (i < 0) {
- i = 0;
- }
-
- count = i + 1;
- }
-
- return new Item[]{
- new ItemEmerald(0, count)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public int getDropExp() {
- return Utils.rand(3, 7);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockOreGold.java b/src/main/java/cn/nukkit/block/BlockOreGold.java
deleted file mode 100644
index 802fbb50a..000000000
--- a/src/main/java/cn/nukkit/block/BlockOreGold.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockOreGold extends BlockSolid {
-
- @Override
- public int getId() {
- return GOLD_ORE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Gold Ore";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
- return new Item[]{
- Item.get(GOLD_ORE)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockOreIron.java b/src/main/java/cn/nukkit/block/BlockOreIron.java
deleted file mode 100644
index 0c03d9548..000000000
--- a/src/main/java/cn/nukkit/block/BlockOreIron.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockOreIron extends BlockSolid {
-
- @Override
- public int getId() {
- return IRON_ORE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Iron Ore";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) {
- return new Item[]{
- Item.get(IRON_ORE)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockOreLapis.java b/src/main/java/cn/nukkit/block/BlockOreLapis.java
deleted file mode 100644
index 54f6b263a..000000000
--- a/src/main/java/cn/nukkit/block/BlockOreLapis.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemDye;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockOreLapis extends BlockSolid {
-
- @Override
- public int getId() {
- return LAPIS_ORE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Lapis Lazuli Ore";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_STONE) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
-
- int count = 4 + Utils.random.nextInt(5);
- Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
- if (fortune != null && fortune.getLevel() >= 1) {
- int i = Utils.random.nextInt(fortune.getLevel() + 2) - 1;
-
- if (i < 0) {
- i = 0;
- }
-
- count = count + i;
- }
-
- return new Item[]{
- new ItemDye(4, count)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public int getDropExp() {
- return Utils.rand(2, 5);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockOreQuartz.java b/src/main/java/cn/nukkit/block/BlockOreQuartz.java
deleted file mode 100644
index 6043fb38a..000000000
--- a/src/main/java/cn/nukkit/block/BlockOreQuartz.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemQuartz;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created on 2015/12/26 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockOreQuartz extends BlockSolid {
-
- @Override
- public String getName() {
- return "Quartz Ore";
- }
-
- @Override
- public int getId() {
- return QUARTZ_ORE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
-
- int count = 1;
- Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
- if (fortune != null && fortune.getLevel() >= 1) {
- int i = Utils.random.nextInt(fortune.getLevel() + 2) - 1;
-
- if (i < 0) {
- i = 0;
- }
-
- count = i + 1;
- }
-
- return new Item[]{
- new ItemQuartz(0, count)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public int getDropExp() {
- return Utils.rand(1, 5);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockOreRedstone.java b/src/main/java/cn/nukkit/block/BlockOreRedstone.java
deleted file mode 100644
index 66a8bad29..000000000
--- a/src/main/java/cn/nukkit/block/BlockOreRedstone.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemRedstone;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.level.Level;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockOreRedstone extends BlockSolid {
-
- @Override
- public int getId() {
- return REDSTONE_ORE;
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Redstone Ore";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_IRON) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
-
- int count = Utils.random.nextInt(2) + 4;
-
- Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
- if (fortune != null && fortune.getLevel() >= 1) {
- count += Utils.random.nextInt(fortune.getLevel() + 1);
- }
-
- return new Item[]{
- new ItemRedstone(0, count)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_TOUCH) {
- this.getLevel().setBlock(this, Block.get(GLOWING_REDSTONE_ORE), false, false);
- this.getLevel().scheduleUpdate(this, 600);
-
- return Level.BLOCK_UPDATE_WEAK;
- }
-
- return 0;
- }
-
- @Override
- public int getDropExp() {
- return Utils.rand(1, 5);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockOreRedstoneGlowing.java b/src/main/java/cn/nukkit/block/BlockOreRedstoneGlowing.java
deleted file mode 100644
index d737a298b..000000000
--- a/src/main/java/cn/nukkit/block/BlockOreRedstoneGlowing.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.event.block.BlockFadeEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-
-/**
- * Created on 2015/12/6 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockOreRedstoneGlowing extends BlockOreRedstone {
-
- @Override
- public String getName() {
- return "Glowing Redstone Ore";
- }
-
- @Override
- public int getId() {
- return GLOWING_REDSTONE_ORE;
- }
-
- @Override
- public int getLightLevel() {
- return 9;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(REDSTONE_ORE));
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_SCHEDULED || type == Level.BLOCK_UPDATE_RANDOM) {
- BlockFadeEvent event = new BlockFadeEvent(this, get(REDSTONE_ORE));
- level.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- level.setBlock(this, event.getNewState(), false, false);
- }
-
- return Level.BLOCK_UPDATE_WEAK;
- }
-
- return 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPiston.java b/src/main/java/cn/nukkit/block/BlockPiston.java
deleted file mode 100644
index 6bf3cff2f..000000000
--- a/src/main/java/cn/nukkit/block/BlockPiston.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * @author CreeperFace
- */
-public class BlockPiston extends BlockPistonBase {
-
- public BlockPiston() {
- this(0);
- }
-
- public BlockPiston(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return PISTON;
- }
-
- @Override
- public String getName() {
- return "Piston";
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPistonBase.java b/src/main/java/cn/nukkit/block/BlockPistonBase.java
deleted file mode 100644
index b621e4a67..000000000
--- a/src/main/java/cn/nukkit/block/BlockPistonBase.java
+++ /dev/null
@@ -1,417 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityPistonArm;
-import cn.nukkit.event.block.BlockPistonChangeEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.network.protocol.LevelSoundEventPacket;
-import cn.nukkit.utils.Faceable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author CreeperFace
- */
-public abstract class BlockPistonBase extends BlockSolidMeta implements Faceable {
-
- public boolean sticky;
-
- public BlockPistonBase() {
- this(0);
- }
-
- public BlockPistonBase(int meta) {
- super(meta);
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (Math.abs(player.x - this.x) < 2 && Math.abs(player.z - this.z) < 2) {
- double y = player.y + player.getEyeHeight();
-
- if (y - this.y > 2) {
- this.setDamage(BlockFace.DOWN.getIndex()); // These needed to be swapped for some reason
- } else if (this.y - y > 0) {
- this.setDamage(BlockFace.UP.getIndex());
- } else {
- this.setDamage(player.getHorizontalFacing().getIndex());
- }
- } else {
- this.setDamage(player.getHorizontalFacing().getIndex());
- }
- this.level.setBlock(block, this, true, false);
-
- CompoundTag nbt = new CompoundTag("")
- .putString("id", BlockEntity.PISTON_ARM)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putBoolean("Sticky", this.sticky);
-
- BlockEntityPistonArm be = (BlockEntityPistonArm) BlockEntity.createBlockEntity(BlockEntity.PISTON_ARM, this.getChunk(), nbt);
- be.sticky = this.sticky;
- be.spawnToAll();
-
- this.checkState();
- return true;
- }
-
- @Override
- public boolean onBreak(Item item) {
- this.level.setBlock(this, Block.get(BlockID.AIR), true, true);
-
- Block block = this.getSide(getFacing());
-
- if (block instanceof BlockPistonHead && ((BlockPistonHead) block).getFacing() == this.getFacing()) {
- block.onBreak(item);
- }
- return true;
- }
-
- public boolean isExtended() {
- BlockFace face = getFacing();
- Block block = getSide(face);
- return block instanceof BlockPistonHead && ((BlockPistonHead) block).getFacing() == face;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type != 6 && type != 1) {
- return 0;
- } else {
- this.checkState();
-
- return type;
- }
- }
-
- private void checkState() {
- BlockFace facing = getFacing();
- boolean isPowered = this.isPowered();
-
- if (isPowered && !isExtended()) {
- BlocksCalculator calculator = new BlocksCalculator(this, facing, true);
- if (calculator.canMove()) {
- if (!this.doMove(true, calculator)) {
- return;
- }
-
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_PISTON_OUT);
- }
- } else if (!isPowered && isExtended()) {
- //this.level.setBlock() TODO: Set piston extension?
-
- if (this.sticky) {
- Vector3 pos = this.add(facing.getXOffset() << 1, facing.getYOffset() << 1, facing.getZOffset() << 1);
- Block block = this.level.getBlock(pos);
-
- if (block.getId() == AIR) {
- this.level.setBlock(this.getLocation().getSide(facing), Block.get(BlockID.AIR), true, true);
- }
- if (canPush(block, facing.getOpposite(), false) && (!(block instanceof BlockFlowable) || block.getId() == PISTON || block.getId() == STICKY_PISTON)) {
- this.doMove(false, null);
- }
- } else {
- this.level.setBlock(getLocation().getSide(facing), Block.get(BlockID.AIR), true, false);
- }
-
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_PISTON_IN);
- }
- }
-
- public BlockFace getFacing() {
- return BlockFace.fromIndex(this.getDamage()).getOpposite();
- }
-
- private boolean isPowered() {
- BlockFace face = getFacing();
-
- for (BlockFace side : BlockFace.values()) {
- if (side != face && this.level.isSidePowered(this.getLocation().getSide(side), side)) {
- return true;
- }
- }
-
- if (this.level.isSidePowered(this, BlockFace.DOWN)) {
- return true;
- } else {
- Vector3 pos = this.getLocation().up();
-
- for (BlockFace side : BlockFace.values()) {
- if (side != BlockFace.DOWN && this.level.isSidePowered(pos.getSide(side), side)) {
- return true;
- }
- }
-
- return false;
- }
- }
-
- private boolean doMove(boolean extending, BlocksCalculator calculator) {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
- if (blockEntity instanceof BlockEntityPistonArm) {
- BlockEntityPistonArm arm = (BlockEntityPistonArm) blockEntity;
- if (arm.powered != extending) {
- this.level.getServer().getPluginManager().callEvent(new BlockPistonChangeEvent(this, extending ? 0 : 15, extending ? 15 : 0));
- arm.powered = !arm.powered;
- if (arm.chunk != null) {
- arm.chunk.setChanged();
- }
- }
- }
-
- Vector3 pos = this.getLocation();
- BlockFace direction = getFacing();
-
- if (!extending) {
- this.level.setBlock(pos.getSide(direction), Block.get(BlockID.AIR), true, false);
- }
- if (calculator == null) {
- calculator = new BlocksCalculator(this, direction, extending);
- }
-
- if (calculator.canMove()) {
- List blocks = calculator.getBlocksToMove();
- if (!extending && blocks.isEmpty()) {
- this.level.setBlock(pos.getSide(direction), Block.get(BlockID.AIR), false, true);
- return true;
- }
- List newBlocks = new ArrayList<>(blocks);
- List destroyBlocks = calculator.getBlocksToDestroy();
- BlockFace side = extending ? direction : direction.getOpposite();
-
- for (int i = destroyBlocks.size() - 1; i >= 0; --i) {
- Block block = destroyBlocks.get(i);
- this.level.useBreakOn(block);
- }
-
- for (int i = blocks.size() - 1; i >= 0; --i) {
- Block block = blocks.get(i);
- this.level.setBlock(block, Block.get(BlockID.AIR), true, false);
- Vector3 newPos = block.getLocation().getSide(side);
-
- // TODO: Change this to block entity
- this.level.setBlock(newPos, newBlocks.get(i), true, false);
- }
-
- if (extending) {
- this.setDamage(this.getDamage() | 0x8);
- } else {
- this.setDamage(this.getDamage() & 0x7);
- }
-
- if (extending) {
- // Extension block entity
- Vector3 pistonHead = pos.getSide(direction);
- this.level.setBlockFullIdAt(pistonHead.getFloorX(), pistonHead.getFloorY(), pistonHead.getFloorZ(), (544) | (this.getDamage() & 0x7));
- //this.level.setBlock(pistonHead, Block.get(PISTON_HEAD, this.getDamage()));
- }
- return true;
- } else {
- return false;
- }
- }
-
- public static boolean canPush(Block block, BlockFace face, boolean destroyBlocks) {
- if (block.canBePushed() && block.getY() >= 0 && (face != BlockFace.DOWN || block.getY() != 0) && block.getY() <= 255 && (face != BlockFace.UP || block.getY() != 255)) {
- if (!(block instanceof BlockPistonBase)) {
- if (block instanceof BlockFlowable) {
- return destroyBlocks;
- }
- } else return !((BlockPistonBase) block).isExtended();
- return true;
- }
- return false;
- }
-
- public static class BlocksCalculator {
- private final Vector3 pistonPos;
- private final Block blockToMove;
- private final BlockFace moveDirection;
-
- private final List toMove = new ArrayList<>();
- private final List toDestroy = new ArrayList<>();
-
- protected Boolean canMove;
-
- public BlocksCalculator(Block pos, BlockFace facing, boolean extending) {
- this.pistonPos = pos.getLocation();
-
- if (extending) {
- this.moveDirection = facing;
- this.blockToMove = pos.getSide(facing);
- } else {
- this.moveDirection = facing.getOpposite();
- this.blockToMove = pos.getSide(facing, 2);
- }
- }
-
- public boolean canMove() {
- return this.canMove == null ? this.canMove = this.eval() : this.canMove;
- }
-
- private boolean eval() {
- this.toMove.clear();
- this.toDestroy.clear();
- Block block = this.blockToMove;
-
- if (!canPush(block, this.moveDirection, false)) {
- if (block instanceof BlockFlowable || block.breakWhenPushed()) {
- this.toDestroy.add(this.blockToMove);
- return true;
- } else {
- return false;
- }
- } else if (!this.addBlockLine(this.blockToMove)) {
- return false;
- } else {
- /*if (false) { //todo?
- for (Block b : this.toMove) {
- if (b.getId() == SLIME_BLOCK && !this.addBranchingBlocks(b)) {
- return false;
- }
- }
- }*/
-
- return true;
- }
- }
-
- private boolean addBlockLine(Block origin) {
- Block block = origin.clone();
-
- if (block.getId() == AIR) {
- return true;
- } else if (!canPush(origin, this.moveDirection, false)) {
- return true;
- } else if (origin.equals(this.pistonPos)) {
- return true;
- } else if (this.toMove.contains(origin)) {
- return true;
- } else {
- int count = 1;
-
- if (count + this.toMove.size() > 12) {
- return false;
- } else {
- while (false && block.getId() == SLIME_BLOCK) {
- block = origin.getSide(this.moveDirection.getOpposite(), count);
-
- if (block.getId() == AIR || !canPush(block, this.moveDirection, false) || block.equals(this.pistonPos)) {
- break;
- }
-
- ++count;
-
- if (count + this.toMove.size() > 12) {
- return false;
- }
- }
-
- int blockCount = 0;
-
- for (int step = count - 1; step >= 0; --step) {
- this.toMove.add(block.getSide(this.moveDirection.getOpposite(), step));
- ++blockCount;
- }
-
- int steps = 1;
-
- while (true) {
- Block nextBlock = block.getSide(this.moveDirection, steps);
- int index = this.toMove.indexOf(nextBlock);
-
- if (index > -1) {
- this.reorderListAtCollision(blockCount, index);
-
- for (int l = 0; l <= index + blockCount; ++l) {
- Block b = this.toMove.get(l);
-
- if (false && b.getId() == SLIME_BLOCK && !this.addBranchingBlocks(b)) {
- return false;
- }
- }
-
- return true;
- }
-
- if (nextBlock.getId() == AIR) {
- return true;
- }
-
- if (!canPush(nextBlock, this.moveDirection, true) || nextBlock.equals(this.pistonPos)) {
- return false;
- }
-
- if (nextBlock instanceof BlockFlowable || block.breakWhenPushed()) {
- this.toDestroy.add(nextBlock);
- return true;
- }
-
- if (this.toMove.size() >= 12) {
- return false;
- }
-
- this.toMove.add(nextBlock);
- ++blockCount;
- ++steps;
- }
- }
- }
- }
-
- private void reorderListAtCollision(int count, int index) {
- List list = new ArrayList<>(this.toMove.subList(0, index));
- List list1 = new ArrayList<>(this.toMove.subList(this.toMove.size() - count, this.toMove.size()));
- List list2 = new ArrayList<>(this.toMove.subList(index, this.toMove.size() - count));
- this.toMove.clear();
- this.toMove.addAll(list);
- this.toMove.addAll(list1);
- this.toMove.addAll(list2);
- }
-
- private boolean addBranchingBlocks(Block block) {
- for (BlockFace face : BlockFace.values()) {
- if (face.getAxis() != this.moveDirection.getAxis() && !this.addBlockLine(block.getSide(face))) {
- return false;
- }
- }
-
- return true;
- }
-
- public List getBlocksToMove() {
- return this.toMove;
- }
-
- public List getBlocksToDestroy() {
- return this.toDestroy;
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x07);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockPistonExtension.java b/src/main/java/cn/nukkit/block/BlockPistonExtension.java
deleted file mode 100644
index 92df04df9..000000000
--- a/src/main/java/cn/nukkit/block/BlockPistonExtension.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-public class BlockPistonExtension extends BlockTransparent {
-
- @Override
- public int getId() {
- return PISTON_EXTENSION;
- }
-
- @Override
- public String getName() {
- return "Piston Extension";
- }
-
- @Override
- public double getHardness() {
- return 0.1;
- }
-
- @Override
- public double getResistance() {
- return 0.1;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPistonHead.java b/src/main/java/cn/nukkit/block/BlockPistonHead.java
deleted file mode 100644
index fb99b4233..000000000
--- a/src/main/java/cn/nukkit/block/BlockPistonHead.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.math.BlockFace;
-
-/**
- * @author CreeperFace
- */
-public class BlockPistonHead extends BlockTransparentMeta {
-
- public BlockPistonHead() {
- this(0);
- }
-
- public BlockPistonHead(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return PISTON_HEAD;
- }
-
- @Override
- public String getName() {
- return "Piston Head";
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[0];
- }
-
- @Override
- public boolean onBreak(Item item) {
- this.level.setBlock(this, Block.get(BlockID.AIR), true, true);
- Block piston = getSide(getFacing().getOpposite());
-
- if (piston instanceof BlockPistonBase && ((BlockPistonBase) piston).getFacing() == this.getFacing()) {
- piston.onBreak(item);
- }
- return true;
- }
-
- public BlockFace getFacing() {
- return BlockFace.fromIndex(this.getDamage()).getOpposite();
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(BlockID.AIR));
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPistonSticky.java b/src/main/java/cn/nukkit/block/BlockPistonSticky.java
deleted file mode 100644
index 4962b5c6d..000000000
--- a/src/main/java/cn/nukkit/block/BlockPistonSticky.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * @author CreeperFace
- */
-public class BlockPistonSticky extends BlockPistonBase {
-
- public BlockPistonSticky() {
- this(0);
- }
-
- public BlockPistonSticky(int meta) {
- super(meta);
- this.sticky = true;
- }
-
- @Override
- public int getId() {
- return STICKY_PISTON;
- }
-
- @Override
- public String getName() {
- return "Sticky Piston";
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPlanks.java b/src/main/java/cn/nukkit/block/BlockPlanks.java
deleted file mode 100644
index 11f265e87..000000000
--- a/src/main/java/cn/nukkit/block/BlockPlanks.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockPlanks extends BlockSolidMeta {
-
- public static final int OAK = 0;
- public static final int SPRUCE = 1;
- public static final int BIRCH = 2;
- public static final int JUNGLE = 3;
- public static final int ACACIA = 4;
- public static final int DARK_OAK = 5;
-
- public BlockPlanks() {
- this(0);
- }
-
- public BlockPlanks(int meta) {
- super(meta % 6);
- }
-
- @Override
- public int getId() {
- return WOODEN_PLANKS;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getBurnChance() {
- return 5;
- }
-
- @Override
- public int getBurnAbility() {
- return 20;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Oak Wood Planks",
- "Spruce Wood Planks",
- "Birch Wood Planks",
- "Jungle Wood Planks",
- "Acacia Wood Planks",
- "Dark Oak Wood Planks",
- };
-
- return names[this.getDamage() & 0x07];
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public BlockColor getColor() {
- switch (getDamage() & 0x07) {
- default:
- case OAK:
- return BlockColor.WOOD_BLOCK_COLOR;
- case SPRUCE:
- return BlockColor.SPRUCE_BLOCK_COLOR;
- case BIRCH:
- return BlockColor.SAND_BLOCK_COLOR;
- case JUNGLE:
- return BlockColor.DIRT_BLOCK_COLOR;
- case ACACIA:
- return BlockColor.ORANGE_BLOCK_COLOR;
- case DARK_OAK:
- return BlockColor.BROWN_BLOCK_COLOR;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPodzol.java b/src/main/java/cn/nukkit/block/BlockPodzol.java
deleted file mode 100644
index 59c994271..000000000
--- a/src/main/java/cn/nukkit/block/BlockPodzol.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Sound;
-
-/**
- * Created on 2015/11/22 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockPodzol extends BlockDirt {
-
- public BlockPodzol() {
- this(0);
- }
-
- public BlockPodzol(int meta) {
- super(0);
- }
-
- @Override
- public int getId() {
- return PODZOL;
- }
-
- @Override
- public String getName() {
- return "Podzol";
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.isShovel()) {
- Block up = this.up();
- if (up instanceof BlockAir || up instanceof BlockFlowable) {
- item.useOn(this);
- this.getLevel().setBlock(this, Block.get(GRASS_PATH));
- if (player != null) {
- player.getLevel().addSoundToViewers(player, Sound.STEP_GRASS);
- }
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int getFullId() {
- return 3888;
- }
-
- @Override
- public void setDamage(int meta) {
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPotato.java b/src/main/java/cn/nukkit/block/BlockPotato.java
deleted file mode 100644
index 1d07daa2a..000000000
--- a/src/main/java/cn/nukkit/block/BlockPotato.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemPotato;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created by Pub4Game on 15.01.2016.
- */
-public class BlockPotato extends BlockCrops {
-
- public BlockPotato(int meta) {
- super(meta);
- }
-
- public BlockPotato() {
- this(0);
- }
-
- @Override
- public String getName() {
- return "Potato Block";
- }
-
- @Override
- public int getId() {
- return POTATO_BLOCK;
- }
-
- @Override
- public Item toItem() {
- return new ItemPotato();
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (getDamage() >= 0x07) {
- return new Item[]{
- new ItemPotato(0, Utils.random.nextInt(3) + 2)
- };
- } else {
- return new Item[]{
- new ItemPotato()
- };
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPressurePlateBase.java b/src/main/java/cn/nukkit/block/BlockPressurePlateBase.java
deleted file mode 100644
index 9e43a33bf..000000000
--- a/src/main/java/cn/nukkit/block/BlockPressurePlateBase.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.event.Event;
-import cn.nukkit.event.block.BlockRedstoneEvent;
-import cn.nukkit.event.entity.EntityInteractEvent;
-import cn.nukkit.event.player.PlayerInteractEvent;
-import cn.nukkit.event.player.PlayerInteractEvent.Action;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.sound.ClickSound;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created by Snake1999 on 2016/1/11.
- * Package cn.nukkit.block in project nukkit
- */
-public abstract class BlockPressurePlateBase extends BlockFlowable {
-
- protected float onPitch;
- protected float offPitch;
-
- protected BlockPressurePlateBase() {
- this(0);
- }
-
- protected BlockPressurePlateBase(int meta) {
- super(meta);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- if (isActivated()) {
- return new AxisAlignedBB(this.x + 0.0625, this.y, this.z + 0.0625, this.x + 0.9375, this.y + 0.03125, this.z + 0.9375);
- } else {
- return new AxisAlignedBB(this.x + 0.0625, this.y, this.z + 0.0625, this.x + 0.9375, this.y + 0.0625, this.z + 0.9375);
- }
- }
-
- @Override
- public boolean isPowerSource() {
- return true;
- }
-
- public boolean isActivated() {
- return this.getDamage() == 0;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().isTransparent()) {
- this.level.useBreakOn(this);
- }
- } else if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- int power = this.getRedstonePower();
-
- if (power > 0) {
- this.updateState(power);
- }
- }
-
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (block.down().isTransparent()) {
- return false;
- }
-
- this.level.setBlock(block, this, true, true);
- return true;
- }
-
- @Override
- protected AxisAlignedBB recalculateCollisionBoundingBox() {
- return new AxisAlignedBB(this.x + 0.125, this.y, this.z + 0.125, this.x + 0.875, this.y + 0.25, this.z + 0.875D);
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- int power = getRedstonePower();
-
- if (power == 0) {
- Event ev;
-
- if (entity instanceof Player) {
- ev = new PlayerInteractEvent((Player) entity, null, this, null, Action.PHYSICAL);
- } else {
- ev = new EntityInteractEvent(entity, this);
- }
-
- this.level.getServer().getPluginManager().callEvent(ev);
-
- if (!ev.isCancelled()) {
- updateState(power);
- }
- }
- }
-
- protected void updateState(int oldStrength) {
- int strength = this.computeRedstoneStrength();
- boolean wasPowered = oldStrength > 0;
- boolean isPowered = strength > 0;
-
- if (oldStrength != strength) {
- this.setRedstonePower(strength);
- this.level.setBlock(this, this, false, false);
-
- this.level.updateAroundRedstone(this, null);
- this.level.updateAroundRedstone(this.getLocation().down(), null);
-
- if (!isPowered && wasPowered) {
- this.playOffSound();
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0));
- } else if (isPowered && !wasPowered) {
- this.playOnSound();
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 0, 15));
- }
- }
-
- if (isPowered) {
- this.level.scheduleUpdate(this, 20);
- }
- }
-
- @Override
- public boolean onBreak(Item item) {
- this.level.setBlock(this, Block.get(BlockID.AIR), true, true);
-
- if (this.getRedstonePower() > 0) {
- this.level.updateAroundRedstone(this, null);
- this.level.updateAroundRedstone(this.getLocation().down(), null);
- }
-
- return true;
- }
-
- @Override
- public int getWeakPower(BlockFace side) {
- return getRedstonePower();
- }
-
- @Override
- public int getStrongPower(BlockFace side) {
- return side == BlockFace.UP ? this.getRedstonePower() : 0;
- }
-
- public int getRedstonePower() {
- return this.getDamage();
- }
-
- public void setRedstonePower(int power) {
- this.setDamage(power);
- }
-
- protected void playOnSound() {
- this.level.addSound(new ClickSound(this, onPitch));
- }
-
- protected void playOffSound() {
- this.level.addSound(new ClickSound(this, offPitch));
- }
-
- protected abstract int computeRedstoneStrength();
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0, 1);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPressurePlateStone.java b/src/main/java/cn/nukkit/block/BlockPressurePlateStone.java
deleted file mode 100644
index e18fa96f0..000000000
--- a/src/main/java/cn/nukkit/block/BlockPressurePlateStone.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.EntityLiving;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockPressurePlateStone extends BlockPressurePlateBase {
-
- public BlockPressurePlateStone(int meta) {
- super(meta);
- this.onPitch = 0.6f;
- this.offPitch = 0.5f;
- }
-
- public BlockPressurePlateStone() {
- this(0);
- }
-
- @Override
- public String getName() {
- return "Stone Pressure Plate";
- }
-
- @Override
- public int getId() {
- return STONE_PRESSURE_PLATE;
- }
-
- @Override
- public double getHardness() {
- return 0.5D;
- }
-
- @Override
- public double getResistance() {
- return 2.5D;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.STONE_BLOCK_COLOR;
- }
-
- @Override
- protected int computeRedstoneStrength() {
- AxisAlignedBB bb = getCollisionBoundingBox();
-
- for (Entity entity : this.level.getCollidingEntities(bb)) {
- if (entity instanceof EntityLiving && entity.doesTriggerPressurePlate()) {
- return 15;
- }
- }
-
- return 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPressurePlateWood.java b/src/main/java/cn/nukkit/block/BlockPressurePlateWood.java
deleted file mode 100644
index 7588c91f9..000000000
--- a/src/main/java/cn/nukkit/block/BlockPressurePlateWood.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.entity.Entity;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockPressurePlateWood extends BlockPressurePlateBase {
-
- public BlockPressurePlateWood(int meta) {
- super(meta);
- this.onPitch = 0.8f;
- this.offPitch = 0.7f;
- }
-
- public BlockPressurePlateWood() {
- this(0);
- }
-
- @Override
- public String getName() {
- return "Wooden Pressure Plate";
- }
-
- @Override
- public int getId() {
- return WOODEN_PRESSURE_PLATE;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public double getHardness() {
- return 0.5D;
- }
-
- @Override
- public double getResistance() {
- return 2.5D;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- toItem()
- };
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-
- @Override
- protected int computeRedstoneStrength() {
- AxisAlignedBB bb = getCollisionBoundingBox();
-
- for (Entity entity : this.level.getCollidingEntities(bb)) {
- if (entity.doesTriggerPressurePlate()) {
- return 15;
- }
- }
-
- return 0;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockPrismarine.java b/src/main/java/cn/nukkit/block/BlockPrismarine.java
deleted file mode 100644
index bb87923c5..000000000
--- a/src/main/java/cn/nukkit/block/BlockPrismarine.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-
-public class BlockPrismarine extends BlockSolidMeta {
-
- public static final int NORMAL = 0;
- public static final int DARK = 1;
- public static final int BRICKS = 2;
-
- private static final String[] NAMES = new String[]{
- "Prismarine",
- "Dark Prismarine",
- "Prismarine Bricks"
- };
-
- public BlockPrismarine() {
- this(0);
- }
-
- public BlockPrismarine(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return PRISMARINE;
- }
-
- @Override
- public double getHardness() {
- return 1.5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return NAMES[this.getDamage() > 2 ? 0 : this.getDamage()];
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- switch (getDamage() & 0x07) {
- case NORMAL:
- return BlockColor.CYAN_BLOCK_COLOR;
- case BRICKS:
- case DARK:
- return BlockColor.DIAMOND_BLOCK_COLOR;
- default:
- return BlockColor.STONE_BLOCK_COLOR;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPumpkin.java b/src/main/java/cn/nukkit/block/BlockPumpkin.java
deleted file mode 100644
index 8170c1bb3..000000000
--- a/src/main/java/cn/nukkit/block/BlockPumpkin.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created on 2015/12/8 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockPumpkin extends BlockSolidMeta implements Faceable {
-
- public BlockPumpkin() {
- this(0);
- }
-
- public BlockPumpkin(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Pumpkin";
- }
-
- @Override
- public int getId() {
- return PUMPKIN;
- }
-
- @Override
- public double getHardness() {
- return 1;
- }
-
- @Override
- public double getResistance() {
- return 5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(player != null ? player.getDirection().getOpposite().getHorizontalIndex() : 0);
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.ORANGE_BLOCK_COLOR;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public boolean breakWhenPushed() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPumpkinLit.java b/src/main/java/cn/nukkit/block/BlockPumpkinLit.java
deleted file mode 100644
index 328720d3c..000000000
--- a/src/main/java/cn/nukkit/block/BlockPumpkinLit.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * Created on 2015/12/8 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockPumpkinLit extends BlockPumpkin {
-
- public BlockPumpkinLit() {
- this(0);
- }
-
- public BlockPumpkinLit(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Jack o'Lantern";
- }
-
- @Override
- public int getId() {
- return LIT_PUMPKIN;
- }
-
- @Override
- public int getLightLevel() {
- return 15;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockPurpur.java b/src/main/java/cn/nukkit/block/BlockPurpur.java
deleted file mode 100644
index 93e30d682..000000000
--- a/src/main/java/cn/nukkit/block/BlockPurpur.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockPurpur extends BlockSolidMeta {
-
- public static final int PURPUR_NORMAL = 0;
- public static final int PURPUR_PILLAR = 2;
-
- private static final short[] faces = new short[]{
- 0,
- 0,
- 0b1000,
- 0b1000,
- 0b0100,
- 0b0100
- };
-
- public BlockPurpur() {
- this(PURPUR_NORMAL);
- }
-
- public BlockPurpur(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Purpur Block",
- "",
- "Purpur Pillar",
- ""
- };
-
- return names[this.getDamage() & 0x03];
- }
-
- @Override
- public int getId() {
- return PURPUR_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return 1.5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (this.getDamage() != PURPUR_NORMAL) {
- this.setDamage(((this.getDamage() & 0x03) | faces[face.getIndex()]));
- }
- this.getLevel().setBlock(block, this, true, true);
-
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(Block.PURPUR_BLOCK), this.getDamage() & 0x03, 1);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.MAGENTA_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockQuartz.java b/src/main/java/cn/nukkit/block/BlockQuartz.java
deleted file mode 100644
index 87e3ea596..000000000
--- a/src/main/java/cn/nukkit/block/BlockQuartz.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockQuartz extends BlockSolidMeta {
-
- public static final int QUARTZ_NORMAL = 0;
- public static final int QUARTZ_CHISELED = 1;
- public static final int QUARTZ_PILLAR = 2;
- public static final int QUARTZ_PILLAR2 = 3;
-
- private static final short[] faces = new short[]{
- 0,
- 0,
- 0b1000,
- 0b1000,
- 0b0100,
- 0b0100
- };
-
- public BlockQuartz() {
- this(0);
- }
-
- public BlockQuartz(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return QUARTZ_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return 0.8;
- }
-
- @Override
- public double getResistance() {
- return 4;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Quartz Block",
- "Chiseled Quartz Block",
- "Quartz Pillar",
- "Quartz Pillar"
- };
-
- return names[this.getDamage() & 0x03];
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (this.getDamage() != QUARTZ_NORMAL) {
- this.setDamage(((this.getDamage() & 0x03) | faces[face.getIndex()]));
- }
- this.getLevel().setBlock(block, this, true, true);
-
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(QUARTZ_BLOCK), this.getDamage() & 0x03, 1);
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.QUARTZ_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRail.java b/src/main/java/cn/nukkit/block/BlockRail.java
deleted file mode 100644
index 5b7072460..000000000
--- a/src/main/java/cn/nukkit/block/BlockRail.java
+++ /dev/null
@@ -1,278 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemRail;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-import cn.nukkit.utils.Rail;
-import cn.nukkit.utils.Rail.Orientation;
-
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static cn.nukkit.math.BlockFace.*;
-import static cn.nukkit.utils.Rail.Orientation.*;
-
-/**
- * Created by Snake1999 on 2016/1/11.
- * Package cn.nukkit.block in project nukkit
- */
-public class BlockRail extends BlockFlowable implements Faceable {
-
- // 0x8: Set the block active
- // 0x7: Reset the block to normal
- // If the rail can be powered. So its a complex rail!
- protected boolean canBePowered = false;
-
- public BlockRail() {
- this(0);
- }
-
- public BlockRail(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Rail";
- }
-
- @Override
- public int getId() {
- return RAIL;
- }
-
- @Override
- public double getHardness() {
- return 0.7;
- }
-
- @Override
- public double getResistance() {
- return 3.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- Optional ascendingDirection = this.getOrientation().ascendingDirection();
- Block down = this.down();
- if ((down.isTransparent() && down.getId() != HOPPER_BLOCK) || (ascendingDirection.isPresent() && this.getSide(ascendingDirection.get()).isTransparent())) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-
- @Override
- public AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 0.125D,
- this.z + 1);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- //Information from http://minecraft.gamepedia.com/Rail
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = this.down();
- if (down == null || (down.isTransparent() && down.getId() != HOPPER_BLOCK)) {
- return false;
- }
- Map railsAround = this.checkRailsAroundAffected();
- List rails = new ArrayList<>(railsAround.keySet());
- List faces = new ArrayList<>(railsAround.values());
- if (railsAround.size() == 1) {
- BlockRail other = rails.get(0);
- this.setDamage(this.connect(other, railsAround.get(other)).metadata());
- } else if (railsAround.size() == 4) {
- if (this.isAbstract()) {
- this.setDamage(this.connect(rails.get(faces.indexOf(SOUTH)), SOUTH, rails.get(faces.indexOf(EAST)), EAST).metadata());
- } else {
- this.setDamage(this.connect(rails.get(faces.indexOf(EAST)), EAST, rails.get(faces.indexOf(WEST)), WEST).metadata());
- }
- } else if (!railsAround.isEmpty()) {
- if (this.isAbstract()) {
- if (railsAround.size() == 2) {
- BlockRail rail1 = rails.get(0);
- BlockRail rail2 = rails.get(1);
- this.setDamage(this.connect(rail1, railsAround.get(rail1), rail2, railsAround.get(rail2)).metadata());
- } else {
- List cd = Stream.of(CURVED_SOUTH_EAST, CURVED_NORTH_EAST, CURVED_SOUTH_WEST)
- .filter(o -> faces.containsAll(o.connectingDirections()))
- .findFirst().get().connectingDirections();
- BlockFace f1 = cd.get(0);
- BlockFace f2 = cd.get(1);
- this.setDamage(this.connect(rails.get(faces.indexOf(f1)), f1, rails.get(faces.indexOf(f2)), f2).metadata());
- }
- } else {
- BlockFace f = faces.stream().min((f1, f2) -> (f1.getIndex() < f2.getIndex()) ? 1 : ((x == y) ? 0 : -1)).get();
- BlockFace fo = f.getOpposite();
- if (faces.contains(fo)) { //Opposite connectable
- this.setDamage(this.connect(rails.get(faces.indexOf(f)), f, rails.get(faces.indexOf(fo)), fo).metadata());
- } else {
- this.setDamage(this.connect(rails.get(faces.indexOf(f)), f).metadata());
- }
- }
- }
- this.level.setBlock(this, this, true, true);
- if (!isAbstract()) {
- level.scheduleUpdate(this, this, 0);
- }
- return true;
- }
-
- private Orientation connect(BlockRail rail1, BlockFace face1, BlockRail rail2, BlockFace face2) {
- this.connect(rail1, face1);
- this.connect(rail2, face2);
-
- if (face1.getOpposite() == face2) {
- int delta1 = (int) (this.y - rail1.y);
- int delta2 = (int) (this.y - rail2.y);
-
- if (delta1 == -1) {
- return Orientation.ascending(face1);
- } else if (delta2 == -1) {
- return Orientation.ascending(face2);
- }
- }
- return straightOrCurved(face1, face2);
- }
-
- private Orientation connect(BlockRail other, BlockFace face) {
- int delta = (int) (this.y - other.y);
- Map rails = other.checkRailsConnected();
- if (rails.isEmpty()) { //Only one
- other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
- return delta == -1 ? ascending(face) : straight(face);
- } else if (rails.size() == 1) { //Already connected
- BlockFace faceConnected = rails.values().iterator().next();
-
- if (other.isAbstract() && faceConnected != face) { //Curve!
- other.setOrientation(curved(face.getOpposite(), faceConnected));
- return delta == -1 ? ascending(face) : straight(face);
- } else if (faceConnected == face) { //Turn!
- if (!other.getOrientation().isAscending()) {
- other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
- }
- return delta == -1 ? ascending(face) : straight(face);
- } else if (other.getOrientation().hasConnectingDirections(NORTH, SOUTH)) { //North-south
- other.setOrientation(delta == 1 ? ascending(face.getOpposite()) : straight(face));
- return delta == -1 ? ascending(face) : straight(face);
- }
- }
- return STRAIGHT_NORTH_SOUTH;
- }
-
- private Map checkRailsAroundAffected() {
- Map railsAround = this.checkRailsAround(Arrays.asList(SOUTH, EAST, WEST, NORTH));
- return railsAround.keySet().stream()
- .filter(r -> r.checkRailsConnected().size() != 2)
- .collect(Collectors.toMap(r -> r, railsAround::get));
- }
-
- private Map checkRailsAround(Collection faces) {
- Map result = new HashMap<>();
- faces.forEach(f -> {
- Block b = this.getSide(f);
- Stream.of(b, b.up(), b.down())
- .filter(Rail::isRailBlock)
- .forEach(block -> result.put((BlockRail) block, f));
- });
- return result;
- }
-
- protected Map checkRailsConnected() {
- Map railsAround = this.checkRailsAround(this.getOrientation().connectingDirections());
- return railsAround.keySet().stream()
- .filter(r -> r.getOrientation().hasConnectingDirections(railsAround.get(r).getOpposite()))
- .collect(Collectors.toMap(r -> r, railsAround::get));
- }
-
- public boolean isAbstract() {
- return this.getId() == RAIL;
- }
-
- public boolean canPowered() {
- return this.canBePowered;
- }
-
- public Orientation getOrientation() {
- return byMetadata(this.getRealMeta());
- }
-
- public void setOrientation(Orientation o) {
- if (o.metadata() != this.getRealMeta()) {
- this.setDamage(o.metadata());
- this.level.setBlock(this, this, false, true);
- }
- }
-
- public int getRealMeta() {
- // Check if this can be powered
- // Avoid modifying the value from meta (The rail orientation may be false)
- // Reason: When the rail is curved, the meta will return STRAIGHT_NORTH_SOUTH.
- // OR Null Pointer Exception
- if (!isAbstract()) {
- return getDamage() & 0x7;
- }
- // Return the default: This meta
- return getDamage();
- }
-
- public boolean isActive() {
- return (getDamage() & 0x8) != 0;
- }
-
- public void setActive(boolean active) {
- if (active) {
- setDamage(getDamage() | 0x8);
- } else {
- setDamage(getDamage() & 0x7);
- }
- level.setBlock(this, this, true, true);
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- new ItemRail(0, 1)
- };
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public boolean canBeFlowedInto() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRailActivator.java b/src/main/java/cn/nukkit/block/BlockRailActivator.java
deleted file mode 100644
index 2ca3d83a3..000000000
--- a/src/main/java/cn/nukkit/block/BlockRailActivator.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.Rail;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockRailActivator extends BlockRail {
-
- public BlockRailActivator(int meta) {
- super(meta);
- }
-
- public BlockRailActivator() {
- this(0);
- canBePowered = true;
- }
-
- @Override
- public String getName() {
- return "Activator Rail";
- }
-
- @Override
- public int getId() {
- return ACTIVATOR_RAIL;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE || type == Level.BLOCK_UPDATE_SCHEDULED) {
- if (super.onUpdate(type) == Level.BLOCK_UPDATE_NORMAL) {
- return 0; // Already broken
- }
-
- boolean isPowered = level.isBlockPowered(this.getLocation())
- || checkSurrounding(this, true, 0)
- || checkSurrounding(this, false, 0);
-
- if (isActive() != isPowered) {
- setActive(isPowered);
- level.updateAround(down());
- if (getOrientation().isAscending()) {
- level.updateAround(up());
- }
- }
- return type;
- }
- return 0;
- }
-
- /**
- * Check the surrounding of the rail
- *
- * @param pos The rail position
- * @param relative The relative of the rail that will be checked
- * @param power The count of the rail that had been counted
- * @return Boolean of the surrounding area. Where the powered rail on!
- */
- protected boolean checkSurrounding(Vector3 pos, boolean relative, int power) {
- if (power >= 8) {
- return false;
- }
- int dx = pos.getFloorX();
- int dy = pos.getFloorY();
- int dz = pos.getFloorZ();
-
- BlockRail block;
- Block block2 = level.getBlock(new Vector3(dx, dy, dz));
-
- if (Rail.isRailBlock(block2)) {
- block = (BlockRail) block2;
- } else {
- return false;
- }
-
- Rail.Orientation base = null;
- boolean onStraight = true;
-
- switch (block.getOrientation()) {
- case STRAIGHT_NORTH_SOUTH:
- if (relative) {
- dz++;
- } else {
- dz--;
- }
- break;
- case STRAIGHT_EAST_WEST:
- if (relative) {
- dx--;
- } else {
- dx++;
- }
- break;
- case ASCENDING_EAST:
- if (relative) {
- dx--;
- } else {
- dx++;
- dy++;
- onStraight = false;
- }
- base = Rail.Orientation.STRAIGHT_EAST_WEST;
- break;
- case ASCENDING_WEST:
- if (relative) {
- dx--;
- dy++;
- onStraight = false;
- } else {
- dx++;
- }
- base = Rail.Orientation.STRAIGHT_EAST_WEST;
- break;
- case ASCENDING_NORTH:
- if (relative) {
- dz++;
- } else {
- dz--;
- dy++;
- onStraight = false;
- }
- base = Rail.Orientation.STRAIGHT_NORTH_SOUTH;
- break;
- case ASCENDING_SOUTH:
- if (relative) {
- dz++;
- dy++;
- onStraight = false;
- } else {
- dz--;
- }
- base = Rail.Orientation.STRAIGHT_NORTH_SOUTH;
- break;
- default:
- return false;
- }
-
- return canPowered(new Vector3(dx, dy, dz), base, power, relative)
- || onStraight && canPowered(new Vector3(dx, dy - 1, dz), base, power, relative);
- }
-
- protected boolean canPowered(Vector3 pos, Rail.Orientation state, int power, boolean relative) {
- Block block = level.getBlock(pos);
-
- if (!(block instanceof BlockRailActivator)) {
- return false;
- }
-
- Rail.Orientation base = ((BlockRailActivator) block).getOrientation();
-
- return (state != Rail.Orientation.STRAIGHT_EAST_WEST
- || base != Rail.Orientation.STRAIGHT_NORTH_SOUTH
- && base != Rail.Orientation.ASCENDING_NORTH
- && base != Rail.Orientation.ASCENDING_SOUTH)
- && (state != Rail.Orientation.STRAIGHT_NORTH_SOUTH
- || base != Rail.Orientation.STRAIGHT_EAST_WEST
- && base != Rail.Orientation.ASCENDING_EAST
- && base != Rail.Orientation.ASCENDING_WEST)
- && (level.isBlockPowered(pos) || checkSurrounding(pos, relative, power + 1));
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- Item.get(Item.ACTIVATOR_RAIL, 0, 1)
- };
- }
-
- @Override
- public double getHardness() {
- return 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRailDetector.java b/src/main/java/cn/nukkit/block/BlockRailDetector.java
deleted file mode 100644
index 15847cbb1..000000000
--- a/src/main/java/cn/nukkit/block/BlockRailDetector.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.item.EntityMinecartAbstract;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created on 2015/11/22 by CreeperFace.
- * Contributed by: larryTheCoder on 2017/7/8.
- *
- * Nukkit Project,
- * Minecart and Riding Project,
- * Package cn.nukkit.block in project Nukkit.
- */
-public class BlockRailDetector extends BlockRail {
-
- public BlockRailDetector() {
- this(0);
- canBePowered = true;
- }
-
- public BlockRailDetector(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return DETECTOR_RAIL;
- }
-
- @Override
- public String getName() {
- return "Detector Rail";
- }
-
- @Override
- public boolean isPowerSource() {
- return true;
- }
-
- @Override
- public int getWeakPower(BlockFace side) {
- return isActive() ? 15 : 0;
- }
-
- @Override
- public int getStrongPower(BlockFace side) {
- return isActive() ? 0 : (side == BlockFace.UP ? 15 : 0);
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- updateState();
- return type;
- }
- return super.onUpdate(type);
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- updateState();
- }
-
- protected void updateState() {
- boolean wasPowered = isActive();
- boolean isPowered = false;
- boolean changed = false;
-
- for (Entity entity : level.getCollidingEntities(new AxisAlignedBB(
- getFloorX() + 0.125D,
- getFloorY(),
- getFloorZ() + 0.125D,
- getFloorX() + 0.875D,
- getFloorY() + 0.750D,
- getFloorZ() + 0.875D))) {
- if (entity instanceof EntityMinecartAbstract) {
- isPowered = true;
- break;
- }
- }
-
- if (isPowered && !wasPowered) {
- setActive(true);
- level.scheduleUpdate(this, this, 0);
- level.scheduleUpdate(this, this.down(), 0);
- changed = true;
- }
-
- if (!isPowered && wasPowered) {
- setActive(false);
- level.scheduleUpdate(this, this, 0);
- level.scheduleUpdate(this, this.down(), 0);
- changed = true;
- }
-
- if (changed) {
- level.updateComparatorOutputLevel(this);
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- Item.get(Item.DETECTOR_RAIL, 0, 1)
- };
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRailPowered.java b/src/main/java/cn/nukkit/block/BlockRailPowered.java
deleted file mode 100644
index 20de69538..000000000
--- a/src/main/java/cn/nukkit/block/BlockRailPowered.java
+++ /dev/null
@@ -1,192 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.Rail;
-
-/**
- * Created by Snake1999 on 2016/1/11.
- * Contributed by: larryTheCoder on 2017/7/18.
- *
- * Nukkit Project,
- * Minecart and Riding Project,
- * Package cn.nukkit.block in project Nukkit.
- */
-public class BlockRailPowered extends BlockRail {
-
- public BlockRailPowered() {
- this(0);
- canBePowered = true;
- }
-
- public BlockRailPowered(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return POWERED_RAIL;
- }
-
- @Override
- public String getName() {
- return "Powered Rail";
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE || type == Level.BLOCK_UPDATE_SCHEDULED) {
- if (super.onUpdate(type) == Level.BLOCK_UPDATE_NORMAL) {
- return 0; // Already broken
- }
-
- boolean isPowered = level.isBlockPowered(this.getLocation())
- || checkSurrounding(this, true, 0)
- || checkSurrounding(this, false, 0);
-
- if (isActive() != isPowered) {
- setActive(isPowered);
- level.updateAround(down());
- if (getOrientation().isAscending()) {
- level.updateAround(up());
- }
- }
- return type;
- }
- return 0;
- }
-
- /**
- * Check the surrounding of the rail
- *
- * @param pos The rail position
- * @param relative The relative of the rail that will be checked
- * @param power The count of the rail that had been counted
- * @return Boolean of the surrounding area. Where the powered rail on!
- */
- protected boolean checkSurrounding(Vector3 pos, boolean relative, int power) {
- // The powered rail can power up to 8 blocks only
- if (power >= 8) {
- return false;
- }
- // The position of the floor numbers
- int dx = pos.getFloorX();
- int dy = pos.getFloorY();
- int dz = pos.getFloorZ();
- // First: get the base block
- BlockRail block;
- Block block2 = level.getBlock(new Vector3(dx, dy, dz));
-
- // Second: check if the rail is Powered rail
- if (Rail.isRailBlock(block2)) {
- block = (BlockRail) block2;
- } else {
- return false;
- }
-
- // Used to check if the next ascending rail should be what
- Rail.Orientation base = null;
- boolean onStraight = true;
- // Third: Recalculate the base position
- switch (block.getOrientation()) {
- case STRAIGHT_NORTH_SOUTH:
- if (relative) {
- dz++;
- } else {
- dz--;
- }
- break;
- case STRAIGHT_EAST_WEST:
- if (relative) {
- dx--;
- } else {
- dx++;
- }
- break;
- case ASCENDING_EAST:
- if (relative) {
- dx--;
- } else {
- dx++;
- dy++;
- onStraight = false;
- }
- base = Rail.Orientation.STRAIGHT_EAST_WEST;
- break;
- case ASCENDING_WEST:
- if (relative) {
- dx--;
- dy++;
- onStraight = false;
- } else {
- dx++;
- }
- base = Rail.Orientation.STRAIGHT_EAST_WEST;
- break;
- case ASCENDING_NORTH:
- if (relative) {
- dz++;
- } else {
- dz--;
- dy++;
- onStraight = false;
- }
- base = Rail.Orientation.STRAIGHT_NORTH_SOUTH;
- break;
- case ASCENDING_SOUTH:
- if (relative) {
- dz++;
- dy++;
- onStraight = false;
- } else {
- dz--;
- }
- base = Rail.Orientation.STRAIGHT_NORTH_SOUTH;
- break;
- default:
- // Unable to determinate the rail orientation
- // Wrong rail?
- return false;
- }
- // Next check the if rail is on power state
- return canPowered(new Vector3(dx, dy, dz), base, power, relative)
- || onStraight && canPowered(new Vector3(dx, dy - 1, dz), base, power, relative);
- }
-
- protected boolean canPowered(Vector3 pos, Rail.Orientation state, int power, boolean relative) {
- Block block = level.getBlock(pos);
- // What! My block is air??!! Impossible! XD
- if (!(block instanceof BlockRailPowered)) {
- return false;
- }
-
- // Sometimes the rails are diffrent orientation
- Rail.Orientation base = ((BlockRailPowered) block).getOrientation();
-
- // Possible way how to know when the rail is activated is rail were directly powered
- // OR recheck the surrounding... Which will returns here =w=
- return (state != Rail.Orientation.STRAIGHT_EAST_WEST
- || base != Rail.Orientation.STRAIGHT_NORTH_SOUTH
- && base != Rail.Orientation.ASCENDING_NORTH
- && base != Rail.Orientation.ASCENDING_SOUTH)
- && (state != Rail.Orientation.STRAIGHT_NORTH_SOUTH
- || base != Rail.Orientation.STRAIGHT_EAST_WEST
- && base != Rail.Orientation.ASCENDING_EAST
- && base != Rail.Orientation.ASCENDING_WEST)
- && (level.isBlockPowered(pos) || checkSurrounding(pos, relative, power + 1));
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- Item.get(Item.POWERED_RAIL, 0, 1)
- };
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedSandstone.java b/src/main/java/cn/nukkit/block/BlockRedSandstone.java
deleted file mode 100644
index 1c8fd32ba..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedSandstone.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by CreeperFace on 26. 11. 2016.
- */
-public class BlockRedSandstone extends BlockSandstone {
-
- public BlockRedSandstone() {
- this(0);
- }
-
- public BlockRedSandstone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return RED_SANDSTONE;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Red Sandstone",
- "Chiseled Red Sandstone",
- "Smooth Red Sandstone",
- ""
- };
-
- return names[this.getDamage() & 0x03];
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, this.getDamage() & 0x03);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.ORANGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedstone.java b/src/main/java/cn/nukkit/block/BlockRedstone.java
deleted file mode 100644
index 84e9a3538..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstone.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-/*
- * Created on 2015/12/11 by Pub4Game.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockRedstone extends BlockSolid {
-
- @Override
- public int getId() {
- return REDSTONE_BLOCK;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Block of Redstone";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.REDSTONE_BLOCK_COLOR;
- }
-
- @Override
- public boolean isPowerSource() {
- return true;
- }
-
- @Override
- public int getWeakPower(BlockFace face) {
- return 15;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canBePushed() {
- return false; // anti crash machine
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneComparator.java b/src/main/java/cn/nukkit/block/BlockRedstoneComparator.java
deleted file mode 100644
index dcf881a5f..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneComparator.java
+++ /dev/null
@@ -1,204 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityComparator;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemRedstoneComparator;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.sound.ClickSound;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author CreeperFace
- */
-public abstract class BlockRedstoneComparator extends BlockRedstoneDiode {
-
- public BlockRedstoneComparator() {
- this(0);
- }
-
- public BlockRedstoneComparator(int meta) {
- super(meta);
- }
-
- @Override
- protected int getDelay() {
- return 2;
- }
-
- @Override
- public BlockFace getFacing() {
- return BlockFace.fromHorizontalIndex(this.getDamage());
- }
-
- public Mode getMode() {
- return (getDamage() & 4) > 0 ? Mode.SUBTRACT : Mode.COMPARE;
- }
-
- @Override
- protected BlockRedstoneComparator getUnpowered() {
- return (BlockRedstoneComparator) Block.get(UNPOWERED_COMPARATOR, this.getDamage());
- }
-
- @Override
- protected BlockRedstoneComparator getPowered() {
- return (BlockRedstoneComparator) Block.get(POWERED_COMPARATOR, this.getDamage());
- }
-
- @Override
- protected int getRedstoneSignal() {
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- return blockEntity instanceof BlockEntityComparator ? ((BlockEntityComparator) blockEntity).getOutputSignal() : 0;
- }
-
- @Override
- public void updateState() {
- if (!this.level.isBlockTickPending(this, this)) {
- int output = this.calculateOutput();
- BlockEntity blockEntity = this.level.getBlockEntity(this);
- int power = blockEntity instanceof BlockEntityComparator ? ((BlockEntityComparator) blockEntity).getOutputSignal() : 0;
-
- if (output != power || this.isPowered() != this.shouldBePowered()) {
- /*if (isFacingTowardsRepeater()) {
- this.level.scheduleUpdate(this, this, 2, -1);
- } else {
- this.level.scheduleUpdate(this, this, 2, 0);
- }*/
-
- this.level.scheduleUpdate(this, this, 2);
- }
- }
- }
-
- protected int calculateInputStrength() {
- int power = super.calculateInputStrength();
- BlockFace face = getFacing();
- Block block = this.getSide(face);
-
- if (block.hasComparatorInputOverride()) {
- power = block.getComparatorInputOverride();
- } else if (power < 15 && block.isNormalBlock()) {
- block = block.getSide(face);
-
- if (block.hasComparatorInputOverride()) {
- power = block.getComparatorInputOverride();
- }
- }
-
- return power;
- }
-
- protected boolean shouldBePowered() {
- int input = this.calculateInputStrength();
-
- if (input >= 15) {
- return true;
- } else if (input == 0) {
- return false;
- } else {
- int sidePower = this.getPowerOnSides();
- return sidePower == 0 || input >= sidePower;
- }
- }
-
- private int calculateOutput() {
- return getMode() == Mode.SUBTRACT ? Math.max(this.calculateInputStrength() - this.getPowerOnSides(), 0) : this.calculateInputStrength();
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (getMode() == Mode.SUBTRACT) {
- this.setDamage(this.getDamage() - 4);
- } else {
- this.setDamage(this.getDamage() + 4);
- }
-
- this.level.addSound(new ClickSound(this, getMode() == Mode.SUBTRACT ? 0.55F : 0.5F));
- this.level.setBlock(this, this, true, false);
- //bug?
-
- this.onChange();
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- this.onChange();
- return type;
- }
-
- return super.onUpdate(type);
- }
-
- private void onChange() {
- int output = this.calculateOutput();
- BlockEntity blockEntity = this.level.getBlockEntity(this);
- int currentOutput = 0;
-
- if (blockEntity instanceof BlockEntityComparator) {
- BlockEntityComparator blockEntityComparator = (BlockEntityComparator) blockEntity;
- currentOutput = blockEntityComparator.getOutputSignal();
- blockEntityComparator.setOutputSignal(output);
- }
-
- if (currentOutput != output || getMode() == Mode.COMPARE) {
- boolean shouldBePowered = this.shouldBePowered();
- boolean isPowered = this.isPowered();
-
- if (isPowered && !shouldBePowered) {
- this.level.setBlock(this, getUnpowered(), true, false);
- } else if (!isPowered && shouldBePowered) {
- this.level.setBlock(this, getPowered(), true, false);
- }
-
- this.level.updateAroundRedstone(this, null); //TODO: remove
- //Block side = this.getSide(getFacing().getOpposite());
- //side.onUpdate(Level.BLOCK_UPDATE_REDSTONE);
- //this.level.updateAroundRedstone(side, null);
- }
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (super.place(item, block, target, face, fx, fy, fz, player)) {
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.COMPARATOR)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- BlockEntity.createBlockEntity(BlockEntity.COMPARATOR, this.getChunk(), nbt);
-
- onUpdate(Level.BLOCK_UPDATE_REDSTONE);
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean isPowered() {
- return this.isPowered || (this.getDamage() & 8) > 0;
- }
-
- @Override
- public Item toItem() {
- return new ItemRedstoneComparator();
- }
-
- public enum Mode {
- COMPARE,
- SUBTRACT
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneComparatorPowered.java b/src/main/java/cn/nukkit/block/BlockRedstoneComparatorPowered.java
deleted file mode 100644
index ef84ea848..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneComparatorPowered.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * @author CreeperFace
- */
-public class BlockRedstoneComparatorPowered extends BlockRedstoneComparator {
-
- public BlockRedstoneComparatorPowered() {
- this(0);
- }
-
- public BlockRedstoneComparatorPowered(int meta) {
- super(meta);
- this.isPowered = true;
- }
-
- @Override
- public int getId() {
- return POWERED_COMPARATOR;
- }
-
- @Override
- public String getName() {
- return "Comparator Block Powered";
- }
-
- @Override
- protected BlockRedstoneComparator getPowered() {
- return this;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneComparatorUnpowered.java b/src/main/java/cn/nukkit/block/BlockRedstoneComparatorUnpowered.java
deleted file mode 100644
index 0ecb8c6b7..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneComparatorUnpowered.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * @author CreeperFace
- */
-public class BlockRedstoneComparatorUnpowered extends BlockRedstoneComparator {
-
- public BlockRedstoneComparatorUnpowered() {
- this(0);
- }
-
- public BlockRedstoneComparatorUnpowered(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return UNPOWERED_COMPARATOR;
- }
-
- @Override
- public String getName() {
- return "Comparator Block Unpowered";
- }
-
- @Override
- protected BlockRedstoneComparator getUnpowered() {
- return this;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneDiode.java b/src/main/java/cn/nukkit/block/BlockRedstoneDiode.java
deleted file mode 100644
index 9966ade57..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneDiode.java
+++ /dev/null
@@ -1,213 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.redstone.RedstoneUpdateEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * @author CreeperFace
- */
-public abstract class BlockRedstoneDiode extends BlockFlowable implements Faceable {
-
- protected boolean isPowered = false;
-
- public BlockRedstoneDiode() {
- this(0);
- }
-
- public BlockRedstoneDiode(int meta) {
- super(meta);
- }
-
- @Override
- public boolean onBreak(Item item) {
- Vector3 pos = getLocation();
- this.level.setBlock(this, Block.get(BlockID.AIR), true, true);
-
- for (BlockFace face : BlockFace.values()) {
- this.level.updateAroundRedstone(pos.getSide(face), null);
- }
-
- return true;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (block.getSide(BlockFace.DOWN).isTransparent() && !(this.down() instanceof BlockSlab)) {
- return false;
- }
-
- this.setDamage(player != null ? player.getDirection().getOpposite().getHorizontalIndex() : 0);
- this.level.setBlock(block, this, true, true);
-
- if (shouldBePowered()) {
- this.level.scheduleUpdate(this, 1);
- }
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- if (!this.isLocked()) {
- Vector3 pos = getLocation();
- boolean shouldBePowered = this.shouldBePowered();
-
- if (this.isPowered && !shouldBePowered) {
- this.level.setBlock(pos, this.getUnpowered(), true, true);
-
- this.level.updateAroundRedstone(this.getLocation().getSide(getFacing().getOpposite()), null);
- } else if (!this.isPowered) {
- this.level.setBlock(pos, this.getPowered(), true, true);
- this.level.updateAroundRedstone(this.getLocation().getSide(getFacing().getOpposite()), null);
-
- if (!shouldBePowered) {
- level.scheduleUpdate(getPowered(), this, this.getDelay());
- }
- }
- }
- } else if (type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE) {
- // Redstone event
- RedstoneUpdateEvent ev = new RedstoneUpdateEvent(this);
- getLevel().getServer().getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return 0;
- }
- if (type == Level.BLOCK_UPDATE_NORMAL && this.getSide(BlockFace.DOWN).isTransparent() && !(this.down() instanceof BlockSlab)) {
- this.level.useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- } else {
- this.updateState();
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-
- public void updateState() {
- if (!this.isLocked()) {
- boolean shouldPowered = this.shouldBePowered();
-
- if ((this.isPowered && !shouldPowered || !this.isPowered && shouldPowered) && !this.level.isBlockTickPending(this, this)) {
- /*int priority = -1;
-
- if (this.isFacingTowardsRepeater()) {
- priority = -3;
- } else if (this.isPowered) {
- priority = -2;
- }*/
-
- this.level.scheduleUpdate(this, this, this.getDelay());
- }
- }
- }
-
- public boolean isLocked() {
- return false;
- }
-
- protected int calculateInputStrength() {
- BlockFace face = getFacing();
- Vector3 pos = this.getLocation().getSide(face);
- int power = this.level.getRedstonePower(pos, face);
-
- if (power >= 15) {
- return power;
- } else {
- Block block = this.level.getBlock(pos);
- return Math.max(power, block.getId() == Block.REDSTONE_WIRE ? block.getDamage() : 0);
- }
- }
-
- protected int getPowerOnSides() {
- Vector3 pos = getLocation();
-
- BlockFace face = getFacing();
- BlockFace face1 = face.rotateY();
- BlockFace face2 = face.rotateYCCW();
- return Math.max(this.getPowerOnSide(pos.getSide(face1), face1), this.getPowerOnSide(pos.getSide(face2), face2));
- }
-
- protected int getPowerOnSide(Vector3 pos, BlockFace side) {
- Block block = this.level.getBlock(pos);
- return isAlternateInput(block) ? (block.getId() == Block.REDSTONE_BLOCK ? 15 : (block.getId() == Block.REDSTONE_WIRE ? block.getDamage() : this.level.getStrongPower(pos, side))) : 0;
- }
-
- @Override
- public boolean isPowerSource() {
- return true;
- }
-
- protected boolean shouldBePowered() {
- return this.calculateInputStrength() > 0;
- }
-
- public abstract BlockFace getFacing();
-
- protected abstract int getDelay();
-
- protected abstract Block getUnpowered();
-
- protected abstract Block getPowered();
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(this.x, this.y, this.z, this.x + 1, this.y + 0.125, this.z + 1);
- }
-
- @Override
- public boolean canPassThrough() {
- return false;
- }
-
- protected boolean isAlternateInput(Block block) {
- return block.isPowerSource();
- }
-
- public static boolean isDiode(Block block) {
- return block instanceof BlockRedstoneDiode;
- }
-
- protected int getRedstoneSignal() {
- return 15;
- }
-
- public int getStrongPower(BlockFace side) {
- return getWeakPower(side);
- }
-
- public int getWeakPower(BlockFace side) {
- return !this.isPowered() ? 0 : (getFacing() == side ? this.getRedstoneSignal() : 0);
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- public boolean isPowered() {
- return isPowered;
- }
-
- public boolean isFacingTowardsRepeater() {
- BlockFace side = getFacing().getOpposite();
- Block block = this.getSide(side);
- return block instanceof BlockRedstoneDiode && ((BlockRedstoneDiode) block).getFacing() != side;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneLamp.java b/src/main/java/cn/nukkit/block/BlockRedstoneLamp.java
deleted file mode 100644
index 9ee6dd0e1..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneLamp.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.redstone.RedstoneUpdateEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockRedstoneLamp extends BlockSolid {
-
- @Override
- public String getName() {
- return "Redstone Lamp";
- }
-
- @Override
- public int getId() {
- return REDSTONE_LAMP;
- }
-
- @Override
- public double getHardness() {
- return 0.3D;
- }
-
- @Override
- public double getResistance() {
- return 1.5D;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (this.level.isBlockPowered(this.getLocation())) {
- this.level.setBlock(this, Block.get(LIT_REDSTONE_LAMP), false, true);
- } else {
- this.level.setBlock(this, this, false, true);
- }
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE) {
- // Redstone event
- RedstoneUpdateEvent ev = new RedstoneUpdateEvent(this);
- getLevel().getServer().getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return 0;
- }
- if (this.level.isBlockPowered(this.getLocation())) {
- this.level.setBlock(this, Block.get(LIT_REDSTONE_LAMP), false, false);
- return 1;
- }
- }
-
- return 0;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- new ItemBlock(Block.get(REDSTONE_LAMP))
- };
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneLampLit.java b/src/main/java/cn/nukkit/block/BlockRedstoneLampLit.java
deleted file mode 100644
index b79948f0f..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneLampLit.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.event.redstone.RedstoneUpdateEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-
-/**
- * @author Pub4Game
- */
-public class BlockRedstoneLampLit extends BlockRedstoneLamp {
-
- @Override
- public String getName() {
- return "Lit Redstone Lamp";
- }
-
- @Override
- public int getId() {
- return LIT_REDSTONE_LAMP;
- }
-
- @Override
- public int getLightLevel() {
- return 15;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(REDSTONE_LAMP));
- }
-
- @Override
- public int onUpdate(int type) {
- if ((type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE) && !this.level.isBlockPowered(this.getLocation())) {
- RedstoneUpdateEvent ev = new RedstoneUpdateEvent(this);
- getLevel().getServer().getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return 0;
- }
- this.level.scheduleUpdate(this, 4);
- return 1;
- }
-
- if (type == Level.BLOCK_UPDATE_SCHEDULED && !this.level.isBlockPowered(this.getLocation())) {
- this.level.setBlock(this, Block.get(REDSTONE_LAMP), false, false);
- }
- return 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneRepeaterPowered.java b/src/main/java/cn/nukkit/block/BlockRedstoneRepeaterPowered.java
deleted file mode 100644
index 7d4701ca0..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneRepeaterPowered.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemRedstoneRepeater;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created by CreeperFace on 10.4.2017.
- */
-public class BlockRedstoneRepeaterPowered extends BlockRedstoneDiode {
-
- public BlockRedstoneRepeaterPowered() {
- this(0);
- }
-
- public BlockRedstoneRepeaterPowered(int meta) {
- super(meta);
- this.isPowered = true;
- }
-
- @Override
- public int getId() {
- return POWERED_REPEATER;
- }
-
- @Override
- public String getName() {
- return "Powered Repeater";
- }
-
- @Override
- public BlockFace getFacing() {
- return BlockFace.fromHorizontalIndex(getDamage());
- }
-
- @Override
- protected boolean isAlternateInput(Block block) {
- return isDiode(block);
- }
-
- @Override
- public Item toItem() {
- return new ItemRedstoneRepeater();
- }
-
- @Override
- protected int getDelay() {
- return (1 + (getDamage() >> 2)) << 1;
- }
-
- @Override
- protected Block getPowered() {
- return this;
- }
-
- @Override
- protected Block getUnpowered() {
- return Block.get(UNPOWERED_REPEATER, this.getDamage());
- }
-
- @Override
- public int getLightLevel() {
- return 7;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- this.setDamage(this.getDamage() + 4);
- if (this.getDamage() > 15) this.setDamage(this.getDamage() % 4);
-
- this.level.setBlock(this, this, true, false);
- return true;
- }
-
- @Override
- public boolean isLocked() {
- return this.getPowerOnSides() > 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneRepeaterUnpowered.java b/src/main/java/cn/nukkit/block/BlockRedstoneRepeaterUnpowered.java
deleted file mode 100644
index d90190e52..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneRepeaterUnpowered.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemRedstoneRepeater;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created by CreeperFace on 10.4.2017.
- */
-public class BlockRedstoneRepeaterUnpowered extends BlockRedstoneDiode {
-
- public BlockRedstoneRepeaterUnpowered() {
- this(0);
- }
-
- public BlockRedstoneRepeaterUnpowered(int meta) {
- super(meta);
- this.isPowered = false;
- }
-
- @Override
- public int getId() {
- return UNPOWERED_REPEATER;
- }
-
- @Override
- public String getName() {
- return "Unpowered Repeater";
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- this.setDamage(this.getDamage() + 4);
- if (this.getDamage() > 15) this.setDamage(this.getDamage() % 4);
-
- this.level.setBlock(this, this, true, false);
- return true;
- }
-
- @Override
- public BlockFace getFacing() {
- return BlockFace.fromHorizontalIndex(getDamage());
- }
-
- @Override
- protected boolean isAlternateInput(Block block) {
- return isDiode(block);
- }
-
- @Override
- public Item toItem() {
- return new ItemRedstoneRepeater();
- }
-
- @Override
- protected int getDelay() {
- return (1 + (getDamage() >> 2)) << 1;
- }
-
- @Override
- protected Block getPowered() {
- return Block.get(POWERED_REPEATER, this.getDamage());
- }
-
- @Override
- protected Block getUnpowered() {
- return this;
- }
-
- @Override
- public boolean isLocked() {
- return this.getPowerOnSides() > 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneTorch.java b/src/main/java/cn/nukkit/block/BlockRedstoneTorch.java
deleted file mode 100644
index 5b1239349..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneTorch.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.redstone.RedstoneUpdateEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockRedstoneTorch extends BlockTorch implements Faceable {
-
- public BlockRedstoneTorch() {
- this(0);
- }
-
- public BlockRedstoneTorch(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Redstone Torch";
- }
-
- @Override
- public int getId() {
- return REDSTONE_TORCH;
- }
-
- @Override
- public int getLightLevel() {
- return 7;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (!super.place(item, block, target, face, fx, fy, fz, player)) {
- return false;
- }
-
- checkState();
-
- return true;
- }
-
- @Override
- public int getWeakPower(BlockFace side) {
- return getBlockFace() != side ? 15 : 0;
- }
-
- @Override
- public int getStrongPower(BlockFace side) {
- return side == BlockFace.DOWN ? this.getWeakPower(side) : 0;
- }
-
- @Override
- public boolean onBreak(Item item) {
- super.onBreak(item);
-
- Vector3 pos = getLocation();
-
- BlockFace face = getBlockFace().getOpposite();
-
- for (BlockFace side : BlockFace.values()) {
- if (side == face) {
- continue;
- }
-
- this.level.updateAroundRedstone(pos.getSide(side), null);
- }
- return true;
- }
-
- @Override
- public int onUpdate(int type) {
- if (super.onUpdate(type) == 0) {
- if (type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE) {
- this.level.scheduleUpdate(this, tickRate());
- } else if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- RedstoneUpdateEvent ev = new RedstoneUpdateEvent(this);
- getLevel().getServer().getPluginManager().callEvent(ev);
-
- if (ev.isCancelled()) {
- return 0;
- }
-
- if (checkState()) {
- return 1;
- }
- }
- }
-
- return 0;
- }
-
- protected boolean checkState() {
- if (isPoweredFromSide()) {
- BlockFace face = getBlockFace().getOpposite();
- Vector3 pos = getLocation();
-
- this.level.setBlock(pos, Block.get(UNLIT_REDSTONE_TORCH, getDamage()), false, true);
-
- for (BlockFace side : BlockFace.values()) {
- if (side == face) {
- continue;
- }
-
- this.level.updateAroundRedstone(pos.getSide(side), null);
- }
-
- return true;
- }
-
- return false;
- }
-
- protected boolean isPoweredFromSide() {
- BlockFace face = getBlockFace().getOpposite();
- return this.level.isSidePowered(this.getLocation().getSide(face), face);
- }
- @Override
- public int tickRate() {
- return 2;
- }
-
- @Override
- public boolean isPowerSource() {
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneTorchUnlit.java b/src/main/java/cn/nukkit/block/BlockRedstoneTorchUnlit.java
deleted file mode 100644
index 33bd74173..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneTorchUnlit.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.event.redstone.RedstoneUpdateEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-
-/**
- * Created by CreeperFace on 10.4.2017.
- */
-public class BlockRedstoneTorchUnlit extends BlockTorch {
-
- public BlockRedstoneTorchUnlit() {
- this(0);
- }
-
- public BlockRedstoneTorchUnlit(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Unlit Redstone Torch";
- }
-
- @Override
- public int getId() {
- return UNLIT_REDSTONE_TORCH;
- }
-
- @Override
- public int getLightLevel() {
- return 0;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(Block.get(REDSTONE_TORCH));
- }
-
- @Override
- public int onUpdate(int type) {
- if (super.onUpdate(type) == 0) {
- if (type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE) {
- this.level.scheduleUpdate(this, tickRate());
- } else if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- RedstoneUpdateEvent ev = new RedstoneUpdateEvent(this);
- getLevel().getServer().getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return 0;
- }
-
- if (checkState()) {
- return 1;
- }
- }
- }
-
- return 0;
- }
-
- protected boolean checkState() {
- BlockFace face = getBlockFace().getOpposite();
- Vector3 pos = getLocation();
-
- if (!this.level.isSidePowered(pos.getSide(face), face)) {
- this.level.setBlock(pos, Block.get(REDSTONE_TORCH, getDamage()), false, true);
-
- for (BlockFace side : BlockFace.values()) {
- if (side == face) {
- continue;
- }
-
- this.level.updateAroundRedstone(pos.getSide(side), null);
- }
- return true;
- }
-
- return false;
- }
-
- @Override
- public int tickRate() {
- return 2;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockRedstoneWire.java b/src/main/java/cn/nukkit/block/BlockRedstoneWire.java
deleted file mode 100644
index 5773fa217..000000000
--- a/src/main/java/cn/nukkit/block/BlockRedstoneWire.java
+++ /dev/null
@@ -1,325 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.block.BlockRedstoneEvent;
-import cn.nukkit.event.redstone.RedstoneUpdateEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemRedstone;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.BlockFace.Plane;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-
-import java.util.EnumSet;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockRedstoneWire extends BlockFlowable {
-
- private boolean canProvidePower = true;
-
- public BlockRedstoneWire() {
- this(0);
- }
-
- public BlockRedstoneWire(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Redstone Wire";
- }
-
- @Override
- public int getId() {
- return REDSTONE_WIRE;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (face != BlockFace.UP || !canBePlacedOn(target)) {
- return false;
- }
-
- this.getLevel().setBlock(block, this, true, false);
- this.calculateCurrentChanges(true, true);
- Vector3 pos = getLocation();
-
- for (BlockFace blockFace : Plane.VERTICAL) {
- this.level.updateAroundRedstone(pos.getSide(blockFace), blockFace.getOpposite());
- }
-
- for (BlockFace blockFace : Plane.VERTICAL) {
- this.updateAround(pos.getSide(blockFace), blockFace.getOpposite());
- }
-
- for (BlockFace blockFace : Plane.HORIZONTAL) {
- Vector3 v = pos.getSide(blockFace);
-
- if (this.level.getBlock(v).isNormalBlock()) {
- this.updateAround(v.up(), BlockFace.DOWN);
- } else {
- this.updateAround(v.down(), BlockFace.UP);
- }
- }
- return true;
- }
-
- private void updateAround(Vector3 pos, BlockFace face) {
- if (this.level.getBlock(pos).getId() == Block.REDSTONE_WIRE) {
- this.level.updateAroundRedstone(pos, face);
-
- for (BlockFace side : BlockFace.values()) {
- this.level.updateAroundRedstone(pos.getSide(side), side.getOpposite());
- }
- }
- }
-
- private void calculateCurrentChanges(boolean force, boolean stillExists) {
- Vector3 pos = this.getLocation();
-
- int meta = this.getDamage();
- int maxStrength = meta;
- this.canProvidePower = false;
- int power = this.getIndirectPower();
-
- this.canProvidePower = true;
-
- if (power > 0 && power > maxStrength - 1) {
- maxStrength = power;
- }
-
- int strength = 0;
-
- for (BlockFace face : Plane.HORIZONTAL) {
- Vector3 v = pos.getSide(face);
-
- if (v.getX() == this.getX() && v.getZ() == this.getZ()) {
- continue;
- }
-
-
- strength = this.getMaxCurrentStrength(v, strength);
-
- boolean vNormal = this.level.getBlock(v).isNormalBlock();
-
- if (vNormal && !this.level.getBlock(pos.up()).isNormalBlock()) {
- strength = this.getMaxCurrentStrength(v.up(), strength);
- } else if (!vNormal) {
- strength = this.getMaxCurrentStrength(v.down(), strength);
- }
- }
-
- if (strength > maxStrength) {
- maxStrength = strength - 1;
- } else if (maxStrength > 0) {
- --maxStrength;
- } else {
- maxStrength = 0;
- }
-
- if (power > maxStrength - 1) {
- maxStrength = power;
- } else if (power < maxStrength && strength <= maxStrength) {
- maxStrength = Math.max(power, strength - 1);
- }
-
- if (meta != maxStrength) {
- if (stillExists) {
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, meta, maxStrength));
-
- this.setDamage(maxStrength);
- this.level.setBlock(this, this, false, false);
- }
-
- this.level.updateAroundRedstone(this, null);
- for (BlockFace face : BlockFace.values()) {
- this.level.updateAroundRedstone(pos.getSide(face), face.getOpposite());
- }
- } else if (force) {
- for (BlockFace face : BlockFace.values()) {
- this.level.updateAroundRedstone(pos.getSide(face), face.getOpposite());
- }
- }
- }
-
- private int getMaxCurrentStrength(Vector3 pos, int maxStrength) {
- if (this.level.getBlockIdAt(pos.getFloorX(), pos.getFloorY(), pos.getFloorZ()) != REDSTONE_WIRE) {
- return maxStrength;
- } else {
- int strength = this.level.getBlockDataAt(pos.getFloorX(), pos.getFloorY(), pos.getFloorZ());
- return Math.max(strength, maxStrength);
- }
- }
-
- @Override
- public boolean onBreak(Item item) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
-
- Vector3 pos = getLocation();
-
- this.calculateCurrentChanges(false, false);
-
- for (BlockFace blockFace : BlockFace.values()) {
- this.level.updateAroundRedstone(pos.getSide(blockFace), null);
- }
-
- for (BlockFace blockFace : Plane.HORIZONTAL) {
- Vector3 v = pos.getSide(blockFace);
-
- if (this.level.getBlock(v).isNormalBlock()) {
- this.updateAround(v.up(), BlockFace.DOWN);
- } else {
- this.updateAround(v.down(), BlockFace.UP);
- }
- }
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemRedstone();
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type != Level.BLOCK_UPDATE_NORMAL && type != Level.BLOCK_UPDATE_REDSTONE) {
- return 0;
- }
-
- if (type == Level.BLOCK_UPDATE_NORMAL && !this.canBePlacedOn(this.getLocation().down())) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
-
- // Redstone event
- RedstoneUpdateEvent ev = new RedstoneUpdateEvent(this);
- getLevel().getServer().getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return 0;
- }
-
- this.calculateCurrentChanges(false, true);
-
- return Level.BLOCK_UPDATE_REDSTONE;
- }
-
- public boolean canBePlacedOn(Vector3 v) {
- Block b = this.level.getBlock(v);
-
- return (b.isSolid() && !b.isTransparent() && b.getId() != GLOWSTONE) || b.getId() == HOPPER_BLOCK;
- }
-
- public int getStrongPower(BlockFace side) {
- return !this.canProvidePower ? 0 : getWeakPower(side);
- }
-
- public int getWeakPower(BlockFace side) {
- if (!this.canProvidePower) {
- return 0;
- } else {
- int power = this.getDamage();
-
- if (power == 0) {
- return 0;
- } else if (side == BlockFace.UP) {
- return power;
- } else {
- EnumSet enumset = EnumSet.noneOf(BlockFace.class);
-
- for (BlockFace face : Plane.HORIZONTAL) {
- if (this.isPowerSourceAt(face)) {
- enumset.add(face);
- }
- }
-
- if (side.getAxis().isHorizontal() && enumset.isEmpty()) {
- return power;
- } else if (enumset.contains(side) && !enumset.contains(side.rotateYCCW()) && !enumset.contains(side.rotateY())) {
- return power;
- } else {
- return 0;
- }
- }
- }
- }
-
- private boolean isPowerSourceAt(BlockFace side) {
- Vector3 pos = getLocation();
- Vector3 v = pos.getSide(side);
- Block block = this.level.getBlock(v);
- boolean flag = block.isNormalBlock();
- boolean flag1 = this.level.getBlock(pos.up()).isNormalBlock();
- return !flag1 && flag && canConnectUpwardsTo(this.level, v.up()) || (canConnectTo(block, side) || !flag && canConnectUpwardsTo(this.level, block.down()));
- }
-
- protected static boolean canConnectUpwardsTo(Level level, Vector3 pos) {
- return canConnectUpwardsTo(level.getBlock(pos));
- }
-
- protected static boolean canConnectUpwardsTo(Block block) {
- return canConnectTo(block, null);
- }
-
- protected static boolean canConnectTo(Block block, BlockFace side) {
- if (block.getId() == Block.REDSTONE_WIRE) {
- return true;
- } else if (BlockRedstoneDiode.isDiode(block)) {
- BlockFace face = ((BlockRedstoneDiode) block).getFacing();
- return face == side || face.getOpposite() == side;
- } else {
- return block.isPowerSource() && side != null;
- }
- }
-
- @Override
- public boolean isPowerSource() {
- return this.canProvidePower;
- }
-
- private int getIndirectPower() {
- int power = 0;
- Vector3 pos = getLocation();
-
- for (BlockFace face : BlockFace.values()) {
- int blockPower = this.getIndirectPower(pos.getSide(face), face);
-
- if (blockPower >= 15) {
- return 15;
- }
-
- if (blockPower > power) {
- power = blockPower;
- }
- }
-
- return power;
- }
-
- private int getIndirectPower(Vector3 pos, BlockFace face) {
- Block block = this.level.getBlock(pos);
- if (block.getId() == Block.REDSTONE_WIRE) {
- return 0;
- }
- return block.isNormalBlock() ? getStrongPower(pos.getSide(face), face) : block.getWeakPower(face);
- }
-
- private int getStrongPower(Vector3 pos, BlockFace direction) {
- Block block = this.level.getBlock(pos);
-
- if (block.getId() == Block.REDSTONE_WIRE) {
- return 0;
- }
-
- return block.getStrongPower(direction);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockReserved6.java b/src/main/java/cn/nukkit/block/BlockReserved6.java
deleted file mode 100644
index 3eee7cc08..000000000
--- a/src/main/java/cn/nukkit/block/BlockReserved6.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * Created by PetteriM1
- */
-public class BlockReserved6 extends BlockSolid {
-
- @Override
- public int getId() {
- return RESERVED6;
- }
-
- @Override
- public String getName() {
- return "reserved6";
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSand.java b/src/main/java/cn/nukkit/block/BlockSand.java
deleted file mode 100644
index 9188a17f3..000000000
--- a/src/main/java/cn/nukkit/block/BlockSand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockSand extends BlockFallableMeta {
-
- public static final int DEFAULT = 0;
- public static final int RED = 1;
-
- public BlockSand() {
- this(0);
- }
-
- public BlockSand(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return SAND;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- public String getName() {
- if (this.getDamage() == 0x01) {
- return "Red Sand";
- }
-
- return "Sand";
- }
-
- @Override
- public BlockColor getColor() {
- if (this.getDamage() == 0x01) {
- return BlockColor.ORANGE_BLOCK_COLOR;
- }
-
- return BlockColor.SAND_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSandstone.java b/src/main/java/cn/nukkit/block/BlockSandstone.java
deleted file mode 100644
index 13a535d73..000000000
--- a/src/main/java/cn/nukkit/block/BlockSandstone.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockSandstone extends BlockSolidMeta {
-
- public static final int NORMAL = 0;
- public static final int CHISELED = 1;
- public static final int SMOOTH = 2;
-
- public BlockSandstone() {
- this(0);
- }
-
- public BlockSandstone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return SANDSTONE;
- }
-
- @Override
- public double getHardness() {
- return 0.8;
- }
-
- @Override
- public double getResistance() {
- return 4;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Sandstone",
- "Chiseled Sandstone",
- "Smooth Sandstone",
- ""
- };
-
- return names[this.getDamage() & 0x03];
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, this.getDamage() & 0x03);
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SAND_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSapling.java b/src/main/java/cn/nukkit/block/BlockSapling.java
deleted file mode 100644
index 513128153..000000000
--- a/src/main/java/cn/nukkit/block/BlockSapling.java
+++ /dev/null
@@ -1,232 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.generator.object.BasicGenerator;
-import cn.nukkit.level.generator.object.tree.*;
-import cn.nukkit.level.particle.BoneMealParticle;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.NukkitRandom;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockSapling extends BlockFlowable {
-
- public static final int OAK = 0;
- public static final int SPRUCE = 1;
- public static final int BIRCH = 2;
- public static final int JUNGLE = 3;
- public static final int ACACIA = 4;
- public static final int DARK_OAK = 5;
- public static final int BIRCH_TALL = 10;
-
- public BlockSapling() {
- this(0);
- }
-
- public BlockSapling(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return SAPLING;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Oak Sapling",
- "Spruce Sapling",
- "Birch Sapling",
- "Jungle Sapling",
- "Acacia Sapling",
- "Dark Oak Sapling",
- "",
- ""
- };
- return names[this.getDamage() & 0x07];
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = this.down();
- if (down.getId() == Block.GRASS || down.getId() == Block.DIRT || down.getId() == Block.FARMLAND || down.getId() == Block.PODZOL) {
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
-
- return false;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- public boolean onActivate(Item item, Player player) {
- if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { // Bone meal
- if (player != null && !player.isCreative()) {
- item.count--;
- }
-
- this.level.addParticle(new BoneMealParticle(this));
- if (ThreadLocalRandom.current().nextFloat() >= 0.45) {
- return true;
- }
-
- BasicGenerator generator = null;
- boolean bigTree = false;
-
- int x = 0;
- int z = 0;
-
- switch (this.getDamage()) {
- case JUNGLE:
- loop:
- for (x = 0; x >= -1; --x) {
- for (z = 0; z >= -1; --z) {
- if (this.findSaplings(x, z, JUNGLE)) {
- generator = new ObjectJungleBigTree(10, 20, Block.get(WOOD, BlockWood.JUNGLE), Block.get(LEAVES, BlockLeaves.JUNGLE));
- bigTree = true;
- break loop;
- }
- }
- }
-
- if (!bigTree) {
- generator = new NewJungleTree(4, 7);
- }
- break;
- case ACACIA:
- generator = new ObjectSavannaTree();
- break;
- case DARK_OAK:
- bigTree = false;
-
- loop:
- for (x = 0; x >= -1; --x) {
- for (z = 0; z >= -1; --z) {
- if (this.findSaplings(x, z, DARK_OAK)) {
- generator = new ObjectDarkOakTree();
- bigTree = true;
- break loop;
- }
- }
- }
-
- if (!bigTree) {
- return false;
- }
- break;
- case SPRUCE:
- bigTree = false;
-
- loop:
- for (x = 0; x >= -1; --x) {
- for (z = 0; z >= -1; --z) {
- if (this.findSaplings(x, z, SPRUCE)) {
- new ObjectBigSpruceTree(0.5f, 5, true).placeObject(this.level, (int) this.x, (int) this.y, (int) this.z, new NukkitRandom());
- bigTree = true;
- break loop;
- }
- }
- }
-
- if (!bigTree) {
- ObjectTree.growTree(this.getLevel(), (int) this.x, (int) this.y, (int) this.z, new NukkitRandom(), this.getDamage() & 0x07);
- } else {
- Block air = Block.get(BlockID.AIR);
- this.level.setBlock(this.add(this.x, 0, this.z), air, true, false);
- this.level.setBlock(this.add(this.x + 1, 0, this.z), air, true, false);
- this.level.setBlock(this.add(this.x, 0, this.z + 1), air, true, false);
- this.level.setBlock(this.add(this.x + 1, 0, this.z + 1), air, true, false);
- }
-
- return true;
- default:
- ObjectTree.growTree(this.getLevel(), (int) this.x, (int) this.y, (int) this.z, new NukkitRandom(), this.getDamage() & 0x07);
- return true;
- }
-
- Block air = Block.get(BlockID.AIR);
-
- if (bigTree) {
- this.level.setBlock(this.add(x, 0, z), air, true, false);
- this.level.setBlock(this.add(x + 1, 0, z), air, true, false);
- this.level.setBlock(this.add(x, 0, z + 1), air, true, false);
- this.level.setBlock(this.add(x + 1, 0, z + 1), air, true, false);
- } else {
- this.level.setBlock(this, air, true, false);
- }
-
- if (!generator.generate(this.level, new NukkitRandom(), this.add(x, 0, z))) {
- if (bigTree) {
- this.level.setBlock(this.add(x, 0, z), this, true, false);
- this.level.setBlock(this.add(x + 1, 0, z), this, true, false);
- this.level.setBlock(this.add(x, 0, z + 1), this, true, false);
- this.level.setBlock(this.add(x + 1, 0, z + 1), this, true, false);
- } else {
- this.level.setBlock(this, this, true, false);
- }
- }
- return true;
- }
- this.getLevel().loadChunk((int) this.x >> 4, (int) this.z >> 4);
- return false;
- }
-
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().isTransparent()) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) { //Growth
- if (Utils.rand(1, 7) == 1) {
- if ((this.getDamage() & 0x08) == 0x08) {
- if ((this.getDamage() & 0x07) == ACACIA) {
- this.level.setBlock(this, Block.get(BlockID.AIR), true, false);
- new ObjectSavannaTree().generate(level, new NukkitRandom(), this);
- } else {
- ObjectTree.growTree(this.getLevel(), (int) this.x, (int) this.y, (int) this.z, new NukkitRandom(), this.getDamage() & 0x07);
- }
- } else {
- this.setDamage(this.getDamage() | 0x08);
- this.getLevel().setBlock(this, this, true);
- return Level.BLOCK_UPDATE_RANDOM;
- }
- } else {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- return 1;
- }
-
- private boolean findSaplings(int x, int z, int type) {
- return this.isSameType(this.add(x, 0, z), type) && this.isSameType(this.add(x + 1, 0, z), type) && this.isSameType(this.add(x, 0, z + 1), type) && this.isSameType(this.add(x + 1, 0, z + 1), type);
- }
-
- public boolean isSameType(Vector3 pos, int type) {
- Block block = this.level.getBlock(pos);
- return block.getId() == SAPLING && block.getDamage() == type;
- }
-
- @Override
- public Item toItem() {
- return Item.get(BlockID.SAPLING, this.getDamage() & 0x7);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSeaLantern.java b/src/main/java/cn/nukkit/block/BlockSeaLantern.java
deleted file mode 100644
index 57b73c9db..000000000
--- a/src/main/java/cn/nukkit/block/BlockSeaLantern.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemPrismarineCrystals;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-public class BlockSeaLantern extends BlockTransparent {
-
- @Override
- public String getName() {
- return "Sea Lantern";
- }
-
- @Override
- public int getId() {
- return SEA_LANTERN;
- }
-
- @Override
- public double getResistance() {
- return 1.5;
- }
-
- @Override
- public double getHardness() {
- return 0.3;
- }
-
- @Override
- public int getLightLevel() {
- return 15;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return new Item[]{
- new ItemPrismarineCrystals(0, Utils.random.nextInt(2, 4))
- };
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.QUARTZ_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockShulkerBox.java b/src/main/java/cn/nukkit/block/BlockShulkerBox.java
deleted file mode 100644
index 2d0710cf2..000000000
--- a/src/main/java/cn/nukkit/block/BlockShulkerBox.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityShulkerBox;
-import cn.nukkit.inventory.ShulkerBoxInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by PetteriM1
- */
-public class BlockShulkerBox extends BlockTransparentMeta {
-
- public BlockShulkerBox() {
- this(0);
- }
-
- public BlockShulkerBox(int meta) {
- super(meta);
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public int getId() {
- return SHULKER_BOX;
- }
-
- @Override
- public String getName() {
- return this.getDyeColor().getName() + " Shulker Box";
- }
-
- @Override
- public double getHardness() {
- return 2.5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item toItem() {
- ItemBlock item = new ItemBlock(this, this.getDamage(), 1);
-
- BlockEntityShulkerBox t = (BlockEntityShulkerBox) this.getLevel().getBlockEntity(this);
-
- if (t != null) {
- ShulkerBoxInventory i = t.getRealInventory();
-
- if (!i.isEmpty()) {
-
- CompoundTag nbt = item.getNamedTag();
- if (nbt == null)
- nbt = new CompoundTag("");
-
- ListTag items = new ListTag<>();
-
- for (int it = 0; it < i.getSize(); it++) {
- if (i.getItem(it).getId() != Item.AIR) {
- CompoundTag d = NBTIO.putItemHelper(i.getItem(it), it);
- items.add(d);
- }
- }
-
- nbt.put("Items", items);
-
- item.setCompoundTag(nbt);
- }
-
- if (t.hasName()) {
- item.setCustomName(t.getName());
- }
- }
-
- return item;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.getLevel().setBlock(block, this, true, true);
- CompoundTag nbt = BlockEntity.getDefaultCompound(this, BlockEntity.SHULKER_BOX)
- .putByte("facing", face.getIndex());
-
- if (item.hasCustomName()) {
- nbt.putString("CustomName", item.getCustomName());
- }
-
- CompoundTag t = item.getNamedTag();
-
- if (t != null) {
- if (t.contains("Items")) {
- nbt.putList(t.getList("Items"));
- }
- }
-
- BlockEntity.createBlockEntity(BlockEntity.SHULKER_BOX, this.getChunk(), nbt);
- return true;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (player != null) {
- BlockEntity t = this.getLevel().getBlockEntity(this);
- BlockEntityShulkerBox box;
- if (t instanceof BlockEntityShulkerBox) {
- box = (BlockEntityShulkerBox) t;
- } else {
- CompoundTag nbt = BlockEntity.getDefaultCompound(this, BlockEntity.SHULKER_BOX);
- box = (BlockEntityShulkerBox) BlockEntity.createBlockEntity(BlockEntity.SHULKER_BOX, this.getChunk(), nbt);
- }
-
- Block block = this.getSide(BlockFace.fromIndex(box.namedTag.getByte("facing")));
- if (!(block instanceof BlockAir) && !(block instanceof BlockLiquid) && !(block instanceof BlockFlowable)) {
- return true;
- }
-
- player.addWindow(box.getInventory());
- }
-
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return this.getDyeColor().getColor();
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(this.getDamage());
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockSignPost.java b/src/main/java/cn/nukkit/block/BlockSignPost.java
deleted file mode 100644
index 174ea1ba4..000000000
--- a/src/main/java/cn/nukkit/block/BlockSignPost.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSign;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.Tag;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * @author Nukkit Project Team
- */
-public class BlockSignPost extends BlockTransparentMeta implements Faceable {
-
- public BlockSignPost() {
- this(0);
- }
-
- public BlockSignPost(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return SIGN_POST;
- }
-
- @Override
- public double getHardness() {
- return 1;
- }
-
- @Override
- public double getResistance() {
- return 5;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- @Override
- public String getName() {
- return "Sign Post";
- }
-
- @Override
- public AxisAlignedBB getBoundingBox() {
- return null;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (face != BlockFace.DOWN) {
- CompoundTag nbt = new CompoundTag()
- .putString("id", BlockEntity.SIGN)
- .putInt("x", (int) block.x)
- .putInt("y", (int) block.y)
- .putInt("z", (int) block.z)
- .putString("Text1", "")
- .putString("Text2", "")
- .putString("Text3", "")
- .putString("Text4", "");
-
- if (face == BlockFace.UP) {
- setDamage((int) Math.floor(((player.yaw + 180) * 16 / 360) + 0.5) & 0x0f);
- getLevel().setBlock(block, Block.get(SIGN_POST, getDamage()), true);
- } else {
- setDamage(face.getIndex());
- getLevel().setBlock(block, Block.get(WALL_SIGN, getDamage()), true);
- }
-
- if (player != null) {
- nbt.putString("Creator", player.getUniqueId().toString());
- }
-
- if (item.hasCustomBlockData()) {
- for (Tag aTag : item.getCustomBlockData().getAllTags()) {
- nbt.put(aTag.getName(), aTag);
- }
- }
-
- BlockEntity.createBlockEntity(BlockEntity.SIGN, this.level.getChunk(block.getChunkX(), block.getChunkZ()), nbt);
- return true;
- }
-
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (down().getId() == Block.AIR) {
- getLevel().useBreakOn(this);
-
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
-
- return 0;
- }
-
- @Override
- public Item toItem() {
- return new ItemSign();
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromIndex(this.getDamage() & 0x07);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSkull.java b/src/main/java/cn/nukkit/block/BlockSkull.java
deleted file mode 100644
index 7db8c5a98..000000000
--- a/src/main/java/cn/nukkit/block/BlockSkull.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSkull;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.Tag;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author Justin
- */
-public class BlockSkull extends BlockTransparentMeta {
-
- public BlockSkull() {
- this(0);
- }
-
- public BlockSkull(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return SKULL_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return 1;
- }
-
- @Override
- public double getResistance() {
- return 5;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- @Override
- public String getName() {
- int itemMeta = 0;
-
- if (this.level != null) {
- BlockEntity blockEntity = getLevel().getBlockEntity(this);
- if (blockEntity != null) itemMeta = blockEntity.namedTag.getByte("SkullType");
- }
-
- return ItemSkull.getItemSkullName(itemMeta);
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- switch (face) {
- case NORTH:
- case SOUTH:
- case EAST:
- case WEST:
- case UP:
- this.setDamage(face.getIndex());
- break;
- case DOWN:
- default:
- return false;
- }
- this.getLevel().setBlock(block, this, true, true);
-
- CompoundTag nbt = new CompoundTag()
- .putString("id", BlockEntity.SKULL)
- .putByte("SkullType", item.getDamage())
- .putInt("x", block.getFloorX())
- .putInt("y", block.getFloorY())
- .putInt("z", block.getFloorZ())
- .putByte("Rot", (int) Math.floor((player.yaw * 16 / 360) + 0.5) & 0x0f);
- if (item.hasCustomBlockData()) {
- for (Tag aTag : item.getCustomBlockData().getAllTags()) {
- nbt.put(aTag.getName(), aTag);
- }
- }
-
- // HACK
- Server.getInstance().getScheduler().scheduleDelayedTask(() -> {
- BlockEntity.createBlockEntity(BlockEntity.SKULL, this.getLevel().getChunk(block.getChunkX(), block.getChunkZ()), nbt);
- }, 2);
-
- // TODO: 2016/2/3 SPAWN WITHER
-
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- BlockEntity blockEntity = getLevel().getBlockEntity(this);
- int dropMeta = 0;
- if (blockEntity != null) dropMeta = blockEntity.namedTag.getByte("SkullType");
- return new Item[]{
- new ItemSkull(dropMeta)
- };
- }
-
- @Override
- public Item toItem() {
- BlockEntity blockEntity = getLevel().getBlockEntity(this);
- int itemMeta = 0;
- if (blockEntity != null) itemMeta = blockEntity.namedTag.getByte("SkullType");
- return new ItemSkull(itemMeta);
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSlab.java b/src/main/java/cn/nukkit/block/BlockSlab.java
deleted file mode 100644
index 340e3a9fb..000000000
--- a/src/main/java/cn/nukkit/block/BlockSlab.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockSlab extends BlockTransparentMeta {
-
- protected final int doubleSlab;
-
- public BlockSlab(int meta, int doubleSlab) {
- super(meta);
- this.doubleSlab = doubleSlab;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- if ((this.getDamage() & 0x08) > 0) {
- return new AxisAlignedBB(
- this.x,
- this.y + 0.5,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- } else {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 0.5,
- this.z + 1
- );
- }
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return getToolType() < ItemTool.TYPE_AXE ? 30 : 15;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(this.getDamage() & 0x07);
- if (face == BlockFace.DOWN) {
- if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0x08 && (target.getDamage() & 0x07) == (this.getDamage() & 0x07)) {
- this.getLevel().setBlock(target, Block.get(doubleSlab, this.getDamage()), true);
-
- return true;
- } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.getDamage() & 0x07)) {
- this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true);
-
- return true;
- } else {
- this.setDamage(this.getDamage() | 0x08);
- }
- } else if (face == BlockFace.UP) {
- if (target instanceof BlockSlab && (target.getDamage() & 0x08) == 0 && (target.getDamage() & 0x07) == (this.getDamage() & 0x07)) {
- this.getLevel().setBlock(target, Block.get(doubleSlab, this.getDamage()), true);
-
- return true;
- } else if (block instanceof BlockSlab && (block.getDamage() & 0x07) == (this.getDamage() & 0x07)) {
- this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true);
-
- return true;
- }
- //TODO: check for collision
- } else {
- if (block instanceof BlockSlab) {
- if ((block.getDamage() & 0x07) == (this.getDamage() & 0x07)) {
- this.getLevel().setBlock(block, Block.get(doubleSlab, this.getDamage()), true);
-
- return true;
- }
-
- return false;
- } else {
- if (fy > 0.5) {
- this.setDamage(this.getDamage() | 0x08);
- }
- }
- }
-
- if (block instanceof BlockSlab && (target.getDamage() & 0x07) != (this.getDamage() & 0x07)) {
- return false;
- }
- this.getLevel().setBlock(block, this, true, true);
-
- return true;
- }
-
- @Override
- public boolean isTransparent() {
- //HACK: Fix unable to place many blocks on slabs
- return (this.getDamage() & 0x08) <= 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSlabRedSandstone.java b/src/main/java/cn/nukkit/block/BlockSlabRedSandstone.java
deleted file mode 100644
index 768b5a35f..000000000
--- a/src/main/java/cn/nukkit/block/BlockSlabRedSandstone.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by CreeperFace on 26. 11. 2016.
- */
-public class BlockSlabRedSandstone extends BlockSlab {
-
- public static final int RED_SANDSTONE = 0;
- public static final int PURPUR = 1;
-
- public BlockSlabRedSandstone() {
- this(RED_SANDSTONE);
- }
-
- public BlockSlabRedSandstone(int meta) {
- super(meta, DOUBLE_RED_SANDSTONE_SLAB);
- }
-
- @Override
- public int getId() {
- return RED_SANDSTONE_SLAB;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Red Sandstone",
- "Purpur",
- "",
- "",
- "",
- "",
- "",
- ""
- };
-
- return ((this.getDamage() & 0x08) > 0 ? "Upper " : "") + names[this.getDamage() & 0x07] + " Slab";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, this.getDamage() & 0x07);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.ORANGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSlabStone.java b/src/main/java/cn/nukkit/block/BlockSlabStone.java
deleted file mode 100644
index c66a98506..000000000
--- a/src/main/java/cn/nukkit/block/BlockSlabStone.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by CreeperFace on 26. 11. 2016.
- */
-public class BlockSlabStone extends BlockSlab {
-
- public static final int STONE = 0;
- public static final int SANDSTONE = 1;
- public static final int WOODEN = 2;
- public static final int COBBLESTONE = 3;
- public static final int BRICK = 4;
- public static final int STONE_BRICK = 5;
- public static final int QUARTZ = 6;
- public static final int NETHER_BRICK = 7;
-
- public BlockSlabStone() {
- this(0);
- }
-
- public BlockSlabStone(int meta) {
- super(meta, DOUBLE_STONE_SLAB);
- }
-
- @Override
- public int getId() {
- return STONE_SLAB;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Stone",
- "Sandstone",
- "Wooden",
- "Cobblestone",
- "Brick",
- "Stone Brick",
- "Quartz",
- "Nether Brick"
- };
-
- return ((this.getDamage() & 0x08) > 0 ? "Upper " : "") + names[this.getDamage() & 0x07] + " Slab";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, this.getDamage() & 0x07);
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public BlockColor getColor() {
- switch (this.getDamage() & 0x07) {
- case NETHER_BRICK:
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- default:
- case STONE:
- case COBBLESTONE:
- case BRICK:
- case STONE_BRICK:
- return BlockColor.STONE_BLOCK_COLOR;
- case SANDSTONE:
- return BlockColor.SAND_BLOCK_COLOR;
- case WOODEN:
- return BlockColor.WOOD_BLOCK_COLOR;
- case QUARTZ:
- return BlockColor.QUARTZ_BLOCK_COLOR;
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSlabWood.java b/src/main/java/cn/nukkit/block/BlockSlabWood.java
deleted file mode 100644
index b0fc413c8..000000000
--- a/src/main/java/cn/nukkit/block/BlockSlabWood.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockSlabWood extends BlockSlab {
-
- public BlockSlabWood() {
- this(0);
- }
-
- public BlockSlabWood(int meta) {
- super(meta, DOUBLE_WOODEN_SLAB);
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Oak",
- "Spruce",
- "Birch",
- "Jungle",
- "Acacia",
- "Dark Oak",
- "",
- ""
- };
- return (((this.getDamage() & 0x08) == 0x08) ? "Upper " : "") + names[this.getDamage() & 0x07] + " Wooden Slab";
- }
-
- @Override
- public int getId() {
- return WOOD_SLAB;
- }
-
- @Override
- public int getBurnChance() {
- return 5;
- }
-
- @Override
- public int getBurnAbility() {
- return 20;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- toItem()
- };
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, this.getDamage() & 0x07);
- }
-
- @Override
- public BlockColor getColor() {
- switch (getDamage() & 0x07) {
- default:
- case 0: //OAK
- return BlockColor.WOOD_BLOCK_COLOR;
- case 1: //SPRUCE
- return BlockColor.SPRUCE_BLOCK_COLOR;
- case 2: //BIRCH
- return BlockColor.SAND_BLOCK_COLOR;
- case 3: //JUNGLE
- return BlockColor.DIRT_BLOCK_COLOR;
- case 4: //ACACIA
- return BlockColor.ORANGE_BLOCK_COLOR;
- case 5: //DARK OAK
- return BlockColor.BROWN_BLOCK_COLOR;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSlime.java b/src/main/java/cn/nukkit/block/BlockSlime.java
deleted file mode 100644
index 19ea18499..000000000
--- a/src/main/java/cn/nukkit/block/BlockSlime.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by Pub4Game on 21.02.2016.
- */
-public class BlockSlime extends BlockSolid {
-
- @Override
- public double getHardness() {
- return 0;
- }
-
- @Override
- public String getName() {
- return "Slime Block";
- }
-
- @Override
- public int getId() {
- return SLIME_BLOCK;
- }
-
- @Override
- public double getResistance() {
- return 0;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.GREEN_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSnow.java b/src/main/java/cn/nukkit/block/BlockSnow.java
deleted file mode 100644
index 17250132a..000000000
--- a/src/main/java/cn/nukkit/block/BlockSnow.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSnowball;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockSnow extends BlockSolid {
-
- @Override
- public String getName() {
- return "Snow";
- }
-
- @Override
- public int getId() {
- return SNOW_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return 0.2;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isShovel() && item.getTier() >= ItemTool.TIER_WOODEN) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return new Item[]{
- new ItemSnowball(0, 4)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SNOW_BLOCK_COLOR;
- }
-
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.isShovel() && !Server.getInstance().suomiCraftPEMode()) {
- item.useOn(this);
- this.level.useBreakOn(this, item.clone().clearNamedTag(), null, true);
- return true;
- }
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSnowLayer.java b/src/main/java/cn/nukkit/block/BlockSnowLayer.java
deleted file mode 100644
index bbe0152a9..000000000
--- a/src/main/java/cn/nukkit/block/BlockSnowLayer.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.block.BlockFadeEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSnowball;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.GameRule;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/6 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockSnowLayer extends BlockFallableMeta {
-
- public BlockSnowLayer() {
- this(0);
- }
-
- public BlockSnowLayer(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Top Snow";
- }
-
- @Override
- public int getId() {
- return SNOW_LAYER;
- }
-
- @Override
- public double getHardness() {
- return 0.1;
- }
-
- @Override
- public double getResistance() {
- return 0.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- public boolean canBeReplaced() {
- return (this.getDamage() & 0x7) != 0x7;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (this.canSurvive()) {
- this.getLevel().setBlock(block, this, true);
-
- return true;
- }
- return false;
- }
-
- private boolean canSurvive() {
- Block below = this.down();
- return below.getId() != ICE && below.getId() != PACKED_ICE && below.getId() != ICE_FROSTED && (below.isSolid() || (this.getDamage() & 0x7) == 0x7);
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if ((this.getDamage() & 0x7) != 0x7 || this.up().getId() != SNOW_LAYER) {
- super.onUpdate(type);
- }
-
- if (this.level.getBlockIdAt(this.getFloorX(), this.getFloorY(), this.getFloorZ()) == SNOW_LAYER && !this.canSurvive()) {
- this.level.useBreakOn(this, null, null, true);
- if (this.level.getGameRules().getBoolean(GameRule.DO_TILE_DROPS)) {
- this.level.dropItem(this, this.toItem());
- }
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- if (this.getLevel().getBlockLightAt((int) this.x, (int) this.y, (int) this.z) >= 10) {
- BlockFadeEvent event = new BlockFadeEvent(this, (this.getDamage() & 0x7) > 0 ? get(SNOW_LAYER, this.getDamage() - 1) : get(AIR));
- level.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- level.setBlock(this, event.getNewState(), true);
- }
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-
- @Override
- public Item toItem() {
- return new ItemSnowball();
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isShovel() && item.getTier() >= ItemTool.TIER_WOODEN) {
- Item drop = this.toItem();
- int height = this.getDamage() & 0x7;
- drop.setCount(height < 3 ? 1 : height < 5 ? 2 : height == 7 ? 4 : 3);
- return new Item[]{drop};
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SNOW_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean isTransparent() {
- return (this.getDamage() & 0x7) != 0x7;
- }
-
- @Override
- public boolean canBeFlowedInto() {
- return true;
- }
-
- @Override
- public boolean isSolid() {
- return (this.getDamage() & 0x7) == 0x7;
- }
-
- @Override
- public double getMaxY() {
- int height = this.getDamage() & 0x7;
- return height < 3 ? this.y : height == 7 ? this.y + 1 : this.y + 0.5;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.isShovel()) {
- item.useOn(this);
- this.level.useBreakOn(this, item.clone().clearNamedTag(), null, true);
- return true;
- } else if (item.getId() == SNOW_LAYER) {
- if ((this.getDamage() & 0x7) != 0x7) {
- this.setDamage(this.getDamage() + 1);
- this.level.setBlock(this ,this, true);
-
- if (player != null && (player.gamemode & 0x1) == 0) {
- item.count--;
- }
- return true;
- } else {
- this.level.setBlock(this ,this, true);
- }
- }
- return false;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- getMaxY(),
- this.z + 1
- );
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSolid.java b/src/main/java/cn/nukkit/block/BlockSolid.java
deleted file mode 100644
index 889be6f58..000000000
--- a/src/main/java/cn/nukkit/block/BlockSolid.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockSolid extends Block {
-
- protected BlockSolid() {
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.STONE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSolidMeta.java b/src/main/java/cn/nukkit/block/BlockSolidMeta.java
deleted file mode 100644
index f650f403b..000000000
--- a/src/main/java/cn/nukkit/block/BlockSolidMeta.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-public abstract class BlockSolidMeta extends BlockMeta {
-
- protected BlockSolidMeta(int meta) {
- super(meta);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.STONE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSoulSand.java b/src/main/java/cn/nukkit/block/BlockSoulSand.java
deleted file mode 100644
index 80ca0ca66..000000000
--- a/src/main/java/cn/nukkit/block/BlockSoulSand.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.entity.Entity;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by Pub4Game on 27.12.2015.
- */
-public class BlockSoulSand extends BlockSolid {
-
- @Override
- public String getName() {
- return "Soul Sand";
- }
-
- @Override
- public int getId() {
- return SOUL_SAND;
- }
-
- @Override
- public double getHardness() {
- return 0.5;
- }
-
- @Override
- public double getResistance() {
- return 2.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHOVEL;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 0.875,
- this.z + 1
- );
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- entity.motionX *= 0.4d;
- entity.motionZ *= 0.4d;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.BROWN_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSponge.java b/src/main/java/cn/nukkit/block/BlockSponge.java
deleted file mode 100644
index 53ea8b81a..000000000
--- a/src/main/java/cn/nukkit/block/BlockSponge.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.GlobalBlockPalette;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.Sound;
-import cn.nukkit.level.particle.ExplodeParticle;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.network.protocol.LevelEventPacket;
-import cn.nukkit.network.protocol.ProtocolInfo;
-import cn.nukkit.utils.BlockColor;
-
-import java.util.ArrayDeque;
-import java.util.Queue;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockSponge extends BlockSolidMeta {
-
- public static final int DRY = 0;
- public static final int WET = 1;
-
- private static final String[] NAMES = new String[]{
- "Sponge",
- "Wet sponge"
- };
-
- public BlockSponge() {
- this(0);
- }
-
- public BlockSponge(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return SPONGE;
- }
-
- @Override
- public double getHardness() {
- return 0.6;
- }
-
- @Override
- public double getResistance() {
- return 3;
- }
-
- @Override
- public String getName() {
- return NAMES[this.getDamage() & 0b1];
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.CLOTH_BLOCK_COLOR;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_HOE;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (this.getDamage() == WET && level.getDimension() == Level.DIMENSION_NETHER) {
- level.setBlock(block, Block.get(BlockID.SPONGE, DRY), true, true);
- level.addSoundToViewers(block.getLocation(), Sound.RANDOM_FIZZ);
- level.addParticle(new ExplodeParticle(block.add(0.5, 1, 0.5)));
- return true;
- } else if (this.getDamage() == DRY && block instanceof BlockWater && performWaterAbsorb(block)) {
- level.setBlock(block, Block.get(BlockID.SPONGE, WET), true, true);
-
- for (int i = 0; i < 4; i++) {
- LevelEventPacket packet = new LevelEventPacket();
- packet.evid = LevelEventPacket.EVENT_PARTICLE_DESTROY;
- packet.x = (float) block.getX() + 0.5f;
- packet.y = (float) block.getY() + 1f;
- packet.z = (float) block.getZ() + 0.5f;
- packet.data = GlobalBlockPalette.getOrCreateRuntimeId(ProtocolInfo.CURRENT_PROTOCOL, BlockID.WATER, 0);
- level.addChunkPacket(getChunkX(), getChunkZ(), packet);
- }
-
- return true;
- }
-
- return super.place(item, block, target, face, fx, fy, fz, player);
- }
-
- private boolean performWaterAbsorb(Block block) {
- Queue entries = new ArrayDeque<>();
-
- entries.add(new Entry(block, 0));
-
- Entry entry;
- int waterRemoved = 0;
- while (waterRemoved < 64 && (entry = entries.poll()) != null) {
- for (BlockFace face : BlockFace.values()) {
-
- Block faceBlock = entry.block.getSide(face);
- if (faceBlock.getId() == BlockID.WATER || faceBlock.getId() == BlockID.STILL_WATER) {
- this.level.setBlock(faceBlock, Block.get(BlockID.AIR));
- ++waterRemoved;
- if (entry.distance < 6) {
- entries.add(new Entry(faceBlock, entry.distance + 1));
- }
- } else if (faceBlock.getId() == BlockID.AIR) {
- if (entry.distance < 6) {
- entries.add(new Entry(faceBlock, entry.distance + 1));
- }
- }
- }
- }
- return waterRemoved > 0;
- }
-
- private static class Entry {
- private final Block block;
- private final int distance;
-
- public Entry(Block block, int distance) {
- this.block = block;
- this.distance = distance;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairs.java b/src/main/java/cn/nukkit/block/BlockStairs.java
deleted file mode 100644
index 5f623e0c5..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairs.java
+++ /dev/null
@@ -1,145 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.Faceable;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockStairs extends BlockSolidMeta implements Faceable {
-
- private static final short[] faces = new short[]{2, 1, 3, 0};
-
- protected BlockStairs(int meta) {
- super(meta);
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- if ((this.getDamage() & 0x04) > 0) {
- return new AxisAlignedBB(
- this.x,
- this.y + 0.5,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- } else {
- return new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 0.5,
- this.z + 1
- );
- }
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);
- if ((fy > 0.5 && face != BlockFace.UP) || face == BlockFace.DOWN) {
- this.setDamage(this.getDamage() | 0x04); //Upside-down stairs
- }
- this.getLevel().setBlock(block, this, true, true);
-
- return true;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- Item item = super.toItem();
- item.setDamage(0);
- return item;
- }
-
- @Override
- public boolean collidesWithBB(AxisAlignedBB bb) {
- int damage = this.getDamage();
- int side = damage & 0x03;
- double f = 0;
- double f1 = 0.5;
- double f2 = 0.5;
- double f3 = 1;
- if ((damage & 0x04) > 0) {
- f = 0.5;
- f1 = 1;
- f2 = 0;
- f3 = 0.5;
- }
-
- if (bb.intersectsWith(new AxisAlignedBB(
- this.x,
- this.y + f,
- this.z,
- this.x + 1,
- this.y + f1,
- this.z + 1
- ))) {
- return true;
- }
-
-
- if (side == 0) {
- return bb.intersectsWith(new AxisAlignedBB(
- this.x + 0.5,
- this.y + f2,
- this.z,
- this.x + 1,
- this.y + f3,
- this.z + 1
- ));
- } else if (side == 1) {
- return bb.intersectsWith(new AxisAlignedBB(
- this.x,
- this.y + f2,
- this.z,
- this.x + 0.5,
- this.y + f3,
- this.z + 1
- ));
- } else if (side == 2) {
- return bb.intersectsWith(new AxisAlignedBB(
- this.x,
- this.y + f2,
- this.z + 0.5,
- this.x + 1,
- this.y + f3,
- this.z + 1
- ));
- } else if (side == 3) {
- return bb.intersectsWith(new AxisAlignedBB(
- this.x,
- this.y + f2,
- this.z,
- this.x + 1,
- this.y + f3,
- this.z + 0.5
- ));
- }
-
- return false;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsAcacia.java b/src/main/java/cn/nukkit/block/BlockStairsAcacia.java
deleted file mode 100644
index 78f31ba5c..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsAcacia.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockStairsAcacia extends BlockStairsWood {
-
- public BlockStairsAcacia() {
- this(0);
- }
-
- public BlockStairsAcacia(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return ACACIA_WOOD_STAIRS;
- }
-
- @Override
- public String getName() {
- return "Acacia Wood Stairs";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.ORANGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsBirch.java b/src/main/java/cn/nukkit/block/BlockStairsBirch.java
deleted file mode 100644
index d24eff46b..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsBirch.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsBirch extends BlockStairsWood {
-
- public BlockStairsBirch() {
- this(0);
- }
-
- public BlockStairsBirch(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return BIRCH_WOOD_STAIRS;
- }
-
- @Override
- public String getName() {
- return "Birch Wood Stairs";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SAND_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsBrick.java b/src/main/java/cn/nukkit/block/BlockStairsBrick.java
deleted file mode 100644
index d73f6de54..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsBrick.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsBrick extends BlockStairs {
-
- public BlockStairsBrick() {
- this(0);
- }
-
- public BlockStairsBrick(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return BRICK_STAIRS;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Brick Stairs";
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.RED_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsCobblestone.java b/src/main/java/cn/nukkit/block/BlockStairsCobblestone.java
deleted file mode 100644
index 1497c3e46..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsCobblestone.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsCobblestone extends BlockStairs {
-
- public BlockStairsCobblestone() {
- this(0);
- }
-
- public BlockStairsCobblestone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return COBBLESTONE_STAIRS;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Cobblestone Stairs";
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsDarkOak.java b/src/main/java/cn/nukkit/block/BlockStairsDarkOak.java
deleted file mode 100644
index 19d5b74ed..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsDarkOak.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsDarkOak extends BlockStairsWood {
-
- public BlockStairsDarkOak() {
- this(0);
- }
-
- public BlockStairsDarkOak(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return DARK_OAK_WOOD_STAIRS;
- }
-
- @Override
- public String getName() {
- return "Dark Oak Wood Stairs";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.BROWN_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsJungle.java b/src/main/java/cn/nukkit/block/BlockStairsJungle.java
deleted file mode 100644
index 390f7915a..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsJungle.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsJungle extends BlockStairsWood {
-
- public BlockStairsJungle() {
- this(0);
- }
-
- public BlockStairsJungle(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return JUNGLE_WOOD_STAIRS;
- }
-
- @Override
- public String getName() {
- return "Jungle Wood Stairs";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.DIRT_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsNetherBrick.java b/src/main/java/cn/nukkit/block/BlockStairsNetherBrick.java
deleted file mode 100644
index f64eae90c..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsNetherBrick.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsNetherBrick extends BlockStairs {
-
- public BlockStairsNetherBrick() {
- this(0);
- }
-
- public BlockStairsNetherBrick(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return NETHER_BRICKS_STAIRS;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Nether Bricks Stairs";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.NETHERRACK_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsPurpur.java b/src/main/java/cn/nukkit/block/BlockStairsPurpur.java
deleted file mode 100644
index 46d4dd535..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsPurpur.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-public class BlockStairsPurpur extends BlockStairs {
-
- public BlockStairsPurpur() {
- this(0);
- }
-
- public BlockStairsPurpur(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return PURPUR_STAIRS;
- }
-
- @Override
- public double getHardness() {
- return 1.5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Purpur Stairs";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.MAGENTA_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsQuartz.java b/src/main/java/cn/nukkit/block/BlockStairsQuartz.java
deleted file mode 100644
index a204d5e2f..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsQuartz.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsQuartz extends BlockStairs {
-
- public BlockStairsQuartz() {
- this(0);
- }
-
- public BlockStairsQuartz(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return QUARTZ_STAIRS;
- }
-
- @Override
- public double getHardness() {
- return 0.8;
- }
-
- @Override
- public double getResistance() {
- return 4;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Quartz Stairs";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.QUARTZ_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsRedSandstone.java b/src/main/java/cn/nukkit/block/BlockStairsRedSandstone.java
deleted file mode 100644
index 0de03be8c..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsRedSandstone.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by CreeperFace on 26. 11. 2016.
- */
-public class BlockStairsRedSandstone extends BlockStairs {
-
- public BlockStairsRedSandstone() {
- this(0);
- }
-
- public BlockStairsRedSandstone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return RED_SANDSTONE_STAIRS;
- }
-
- @Override
- public double getHardness() {
- return 0.8;
- }
-
- @Override
- public double getResistance() {
- return 4;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Red Sandstone Stairs";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, this.getDamage() & 0x07);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.ORANGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsSandstone.java b/src/main/java/cn/nukkit/block/BlockStairsSandstone.java
deleted file mode 100644
index a3597e02d..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsSandstone.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsSandstone extends BlockStairs {
-
- public BlockStairsSandstone() {
- this(0);
- }
-
- public BlockStairsSandstone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return SANDSTONE_STAIRS;
- }
-
- @Override
- public double getHardness() {
- return 0.8;
- }
-
- @Override
- public double getResistance() {
- return 4;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Sandstone Stairs";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SAND_BLOCK_COLOR;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsSpruce.java b/src/main/java/cn/nukkit/block/BlockStairsSpruce.java
deleted file mode 100644
index cb9b3cfb7..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsSpruce.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsSpruce extends BlockStairsWood {
-
- public BlockStairsSpruce() {
- this(0);
- }
-
- public BlockStairsSpruce(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return SPRUCE_WOOD_STAIRS;
- }
-
- @Override
- public String getName() {
- return "Spruce Wood Stairs";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.SPRUCE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsStoneBrick.java b/src/main/java/cn/nukkit/block/BlockStairsStoneBrick.java
deleted file mode 100644
index a7145c21d..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsStoneBrick.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsStoneBrick extends BlockStairs {
-
- public BlockStairsStoneBrick() {
- this(0);
- }
-
- public BlockStairsStoneBrick(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return STONE_BRICK_STAIRS;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 1.5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public String getName() {
- return "Stone Brick Stairs";
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStairsWood.java b/src/main/java/cn/nukkit/block/BlockStairsWood.java
deleted file mode 100644
index edd63e22e..000000000
--- a/src/main/java/cn/nukkit/block/BlockStairsWood.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/11/25 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockStairsWood extends BlockStairs {
-
- public BlockStairsWood() {
- this(0);
- }
-
- public BlockStairsWood(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return WOOD_STAIRS;
- }
-
- @Override
- public String getName() {
- return "Wood Stairs";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public int getBurnChance() {
- return 5;
- }
-
- @Override
- public int getBurnAbility() {
- return 20;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return new Item[]{
- toItem()
- };
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStemMelon.java b/src/main/java/cn/nukkit/block/BlockStemMelon.java
deleted file mode 100644
index 173c6f87d..000000000
--- a/src/main/java/cn/nukkit/block/BlockStemMelon.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Server;
-import cn.nukkit.event.block.BlockGrowEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSeedsMelon;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.BlockFace.Plane;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created by Pub4Game on 15.01.2016.
- */
-public class BlockStemMelon extends BlockCrops {
-
- public BlockStemMelon() {
- this(0);
- }
-
- public BlockStemMelon(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return MELON_STEM;
- }
-
- @Override
- public String getName() {
- return "Melon Stem";
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().getId() != FARMLAND) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- if (Utils.rand(1, 2) == 1) {
- if (this.getDamage() < 0x07) {
- Block block = this.clone();
- block.setDamage(block.getDamage() + 1);
- BlockGrowEvent ev = new BlockGrowEvent(this, block);
- Server.getInstance().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(this, ev.getNewState(), true);
- }
- return Level.BLOCK_UPDATE_RANDOM;
- } else {
- for (BlockFace face : Plane.HORIZONTAL) {
- Block b = this.getSide(face);
- if (b.getId() == MELON_BLOCK) {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- Block side = this.getSide(Plane.HORIZONTAL.random(Utils.nukkitRandom));
- Block d = side.down();
- if (side.getId() == AIR && (d.getId() == FARMLAND || d.getId() == GRASS || d.getId() == DIRT)) {
- BlockGrowEvent ev = new BlockGrowEvent(side, Block.get(MELON_BLOCK));
- Server.getInstance().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(side, ev.getNewState(), true);
- }
- }
- }
- }
- return Level.BLOCK_UPDATE_RANDOM;
- }
- return 0;
- }
-
- @Override
- public Item toItem() {
- return new ItemSeedsMelon();
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (this.getDamage() < 4) return new Item[0];
- return new Item[]{
- new ItemSeedsMelon(0, Utils.rand(0, 48) >> 4)
- };
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStemPumpkin.java b/src/main/java/cn/nukkit/block/BlockStemPumpkin.java
deleted file mode 100644
index a725f92c4..000000000
--- a/src/main/java/cn/nukkit/block/BlockStemPumpkin.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Server;
-import cn.nukkit.event.block.BlockGrowEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSeedsPumpkin;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.BlockFace.Plane;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created by Pub4Game on 15.01.2016.
- */
-public class BlockStemPumpkin extends BlockCrops {
-
- public BlockStemPumpkin() {
- this(0);
- }
-
- public BlockStemPumpkin(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return PUMPKIN_STEM;
- }
-
- @Override
- public String getName() {
- return "Pumpkin Stem";
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().getId() != FARMLAND) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- if (Utils.rand(1, 2) == 1) {
- if (this.getDamage() < 0x07) {
- Block block = this.clone();
- block.setDamage(block.getDamage() + 1);
- BlockGrowEvent ev = new BlockGrowEvent(this, block);
- Server.getInstance().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(this, ev.getNewState(), true);
- }
- return Level.BLOCK_UPDATE_RANDOM;
- } else {
- for (BlockFace face : Plane.HORIZONTAL) {
- Block b = this.getSide(face);
- if (b.getId() == PUMPKIN) {
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- Block side = this.getSide(Plane.HORIZONTAL.random(Utils.nukkitRandom));
- Block d = side.down();
- if (side.getId() == AIR && (d.getId() == FARMLAND || d.getId() == GRASS || d.getId() == DIRT)) {
- BlockGrowEvent ev = new BlockGrowEvent(side, Block.get(PUMPKIN));
- Server.getInstance().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(side, ev.getNewState(), true);
- }
- }
- }
- }
- return Level.BLOCK_UPDATE_RANDOM;
- }
- return 0;
- }
-
- @Override
- public Item toItem() {
- return new ItemSeedsPumpkin();
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (this.getDamage() < 4) return new Item[0];
- return new Item[]{
- new ItemSeedsPumpkin(0, Utils.rand(0, 48) >> 4)
- };
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStone.java b/src/main/java/cn/nukkit/block/BlockStone.java
deleted file mode 100644
index a4572aef2..000000000
--- a/src/main/java/cn/nukkit/block/BlockStone.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockStone extends BlockSolidMeta {
-
- public static final int NORMAL = 0;
- public static final int GRANITE = 1;
- public static final int POLISHED_GRANITE = 2;
- public static final int DIORITE = 3;
- public static final int POLISHED_DIORITE = 4;
- public static final int ANDESITE = 5;
- public static final int POLISHED_ANDESITE = 6;
-
- public BlockStone() {
- this(0);
- }
-
- public BlockStone(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return STONE;
- }
-
- @Override
- public double getHardness() {
- return 1.5;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Stone",
- "Granite",
- "Polished Granite",
- "Diorite",
- "Polished Diorite",
- "Andesite",
- "Polished Andesite",
- "Unknown Stone"
- };
- return names[this.getDamage() & 0x07];
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- if (item.hasEnchantment(Enchantment.ID_SILK_TOUCH)) {
- return new Item[]{this.toItem()};
- }
- return new Item[]{
- Item.get(this.getDamage() == 0 ? Item.COBBLESTONE : Item.STONE, this.getDamage(), 1)
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStonecutter.java b/src/main/java/cn/nukkit/block/BlockStonecutter.java
deleted file mode 100644
index 079f98933..000000000
--- a/src/main/java/cn/nukkit/block/BlockStonecutter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-
-public class BlockStonecutter extends BlockSolid {
-
- @Override
- public int getId() {
- return STONECUTTER;
- }
-
- @Override
- public double getHardness() {
- return 3.5;
- }
-
- @Override
- public double getResistance() {
- return 17.5;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public String getName() {
- return "Stonecutter";
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockStructureBlock.java b/src/main/java/cn/nukkit/block/BlockStructureBlock.java
deleted file mode 100644
index c12f79999..000000000
--- a/src/main/java/cn/nukkit/block/BlockStructureBlock.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-
-/**
- * Created by PetteriM1
- */
-public class BlockStructureBlock extends BlockSolid {
-
- @Override
- public int getId() {
- return STRUCTURE_BLOCK;
- }
-
- @Override
- public double getHardness() {
- return -1;
- }
-
- @Override
- public double getResistance() {
- return 18000000;
- }
-
- @Override
- public String getName() {
- return "Structure Block";
- }
-
- @Override
- public boolean isBreakable(Item item) {
- return false;
- }
-
- @Override
- public boolean canBePushed() {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockSugarcane.java b/src/main/java/cn/nukkit/block/BlockSugarcane.java
deleted file mode 100644
index 008d44f01..000000000
--- a/src/main/java/cn/nukkit/block/BlockSugarcane.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.event.block.BlockGrowEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSugarcane;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.particle.BoneMealParticle;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by Pub4Game on 09.01.2016.
- */
-public class BlockSugarcane extends BlockFlowable {
-
- public BlockSugarcane() {
- this(0);
- }
-
- public BlockSugarcane(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Sugar Cane";
- }
-
- @Override
- public int getId() {
- return SUGARCANE_BLOCK;
- }
-
- @Override
- public Item toItem() {
- return new ItemSugarcane();
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { // Bone meal
- int count = 1;
-
- for (int i = 1; i <= 2; i++) {
- int id = this.level.getBlockIdAt(this.getFloorX(), this.getFloorY() - i, this.getFloorZ());
-
- if (id == SUGARCANE_BLOCK) {
- count++;
- }
- }
-
- if (count < 3) {
- boolean success = false;
- int toGrow = 3 - count;
-
- for (int i = 1; i <= toGrow; i++) {
- Block block = this.up(i);
- if (block.getId() == 0) {
- BlockGrowEvent ev = new BlockGrowEvent(block, Block.get(SUGARCANE_BLOCK));
- Server.getInstance().getPluginManager().callEvent(ev);
-
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(block, ev.getNewState(), true);
- success = true;
- }
- } else if (block.getId() != SUGARCANE_BLOCK) {
- break;
- }
- }
-
- if (success) {
- if (player != null && !player.isCreative()) {
- item.count--;
- }
-
- this.level.addParticle(new BoneMealParticle(this));
- }
- }
- return true;
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- Block down = this.down();
- if (down.isTransparent() && down.getId() != SUGARCANE_BLOCK) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- if (this.down().getId() != SUGARCANE_BLOCK) {
- if (this.getDamage() == 0x0F) {
- for (int y = 1; y < 3; ++y) {
- Block b = this.getLevel().getBlock(new Vector3(this.x, this.y + y, this.z));
- if (b.getId() == AIR) {
- BlockGrowEvent ev = new BlockGrowEvent(b, Block.get(BlockID.SUGARCANE_BLOCK));
- Server.getInstance().getPluginManager().callEvent(ev);
-
- if (!ev.isCancelled()) {
- this.getLevel().setBlock(b, ev.getNewState(), false);
- }
- break;
- }
- }
- this.setDamage(0);
- this.getLevel().setBlock(this, this, false);
- } else {
- this.setDamage(this.getDamage() + 1);
- this.getLevel().setBlock(this, this, false);
- }
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (block.getId() != AIR) {
- return false;
- }
- Block down = this.down();
- if (down.getId() == SUGARCANE_BLOCK) {
- this.getLevel().setBlock(block, Block.get(SUGARCANE_BLOCK), true);
- return true;
- } else if (down.getId() == GRASS || down.getId() == DIRT || down.getId() == SAND || down.getId() == PODZOL) {
- Block block0 = down.north();
- Block block1 = down.south();
- Block block2 = down.west();
- Block block3 = down.east();
- if (block0 instanceof BlockWater || block1 instanceof BlockWater || block2 instanceof BlockWater || block3 instanceof BlockWater || block0 instanceof BlockIceFrosted || block1 instanceof BlockIceFrosted || block2 instanceof BlockIceFrosted || block3 instanceof BlockIceFrosted) {
- this.getLevel().setBlock(block, Block.get(SUGARCANE_BLOCK), true);
- return true;
- }
- }
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTNT.java b/src/main/java/cn/nukkit/block/BlockTNT.java
deleted file mode 100644
index 71db67968..000000000
--- a/src/main/java/cn/nukkit/block/BlockTNT.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.item.EntityPrimedTNT;
-import cn.nukkit.entity.projectile.EntityArrow;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.Sound;
-import cn.nukkit.level.sound.TNTPrimeSound;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.DoubleTag;
-import cn.nukkit.nbt.tag.FloatTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created on 2015/12/8 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockTNT extends BlockSolid {
-
- @Override
- public String getName() {
- return "TNT";
- }
-
- @Override
- public int getId() {
- return TNT;
- }
-
- @Override
- public double getHardness() {
- return 0;
- }
-
- @Override
- public double getResistance() {
- return 0;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public int getBurnChance() {
- return 15;
- }
-
- @Override
- public int getBurnAbility() {
- return 100;
- }
-
- public void prime() {
- this.prime(80);
- }
-
- public void prime(int fuse) {
- prime(fuse, null);
- }
-
- public void prime(int fuse, Entity source) {
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true);
- double mot = Utils.nukkitRandom.nextSignedFloat() * 6.283185307179586;
- CompoundTag nbt = new CompoundTag()
- .putList(new ListTag("Pos")
- .add(new DoubleTag("", this.x + 0.5))
- .add(new DoubleTag("", this.y))
- .add(new DoubleTag("", this.z + 0.5)))
- .putList(new ListTag("Motion")
- .add(new DoubleTag("", -Math.sin(mot) * 0.02))
- .add(new DoubleTag("", 0.2))
- .add(new DoubleTag("", -Math.cos(mot) * 0.02)))
- .putList(new ListTag("Rotation")
- .add(new FloatTag("", 0))
- .add(new FloatTag("", 0)))
- .putShort("Fuse", fuse);
- Entity tnt = new EntityPrimedTNT(
- this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4),
- nbt, source
- );
- tnt.spawnToAll();
- this.level.addSound(new TNTPrimeSound(this));
- }
-
- @Override
- public int onUpdate(int type) {
- if ((type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_REDSTONE) && this.level.isBlockPowered(this.getLocation())) {
- this.prime();
- }
-
- return 0;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.getId() == Item.FLINT_STEEL) {
- item.useOn(this);
- this.prime(80, player);
- return true;
- } else if (item.getId() == Item.FIRE_CHARGE) {
- if (!player.isCreative()) item.count--;
- this.level.addSoundToViewers(this, Sound.MOB_GHAST_FIREBALL);
- this.prime(80, player);
- return true;
- } else if (item instanceof ItemTool && item.hasEnchantment(Enchantment.ID_FIRE_ASPECT)) {
- item.useOn(this);
- this.prime(80, player);
- return true;
- }
-
- return false;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.TNT_BLOCK_COLOR;
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- if (entity instanceof EntityArrow && entity.isOnFire()) {
- entity.close();
- this.prime();
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTallGrass.java b/src/main/java/cn/nukkit/block/BlockTallGrass.java
deleted file mode 100644
index d2de06ed0..000000000
--- a/src/main/java/cn/nukkit/block/BlockTallGrass.java
+++ /dev/null
@@ -1,158 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSeedsWheat;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.particle.BoneMealParticle;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockTallGrass extends BlockFlowable {
-
- public BlockTallGrass() {
- this(1);
- }
-
- public BlockTallGrass(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return TALL_GRASS;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Grass",
- "Grass",
- "Fern",
- "Fern"
- };
- return names[this.getDamage() & 0x03];
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public boolean canBeReplaced() {
- return true;
- }
-
- @Override
- public int getBurnChance() {
- return 60;
- }
-
- @Override
- public int getBurnAbility() {
- return 100;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- Block down = this.down();
- if (down.getId() == Block.GRASS || down.getId() == Block.DIRT || down.getId() == Block.PODZOL) {
- this.getLevel().setBlock(block, this, true);
- return true;
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.down().isTransparent()) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (item.getId() == Item.DYE && item.getDamage() == 0x0f) {
- Block up = this.up();
-
- if (up.getId() == AIR) {
- int meta;
-
- switch (this.getDamage()) {
- case 0:
- case 1:
- meta = BlockDoublePlant.TALL_GRASS;
- break;
- case 2:
- case 3:
- meta = BlockDoublePlant.LARGE_FERN;
- break;
- default:
- meta = -1;
- }
-
- if (meta != -1) {
- if (player != null && !player.isCreative()) {
- item.count--;
- }
-
- this.level.addParticle(new BoneMealParticle(this));
- this.level.setBlock(this, get(DOUBLE_PLANT, meta), true, false);
- this.level.setBlock(up, get(DOUBLE_PLANT, meta ^ BlockDoublePlant.TOP_HALF_BITMASK), true);
- }
- }
-
- return true;
- }
-
- return false;
- }
-
-
- @Override
- public Item[] getDrops(Item item) {
- boolean dropSeeds = Utils.random.nextInt(10) == 0;
- if (item.isShears()) {
- //todo enchantment
- if (dropSeeds) {
- return new Item[]{
- new ItemSeedsWheat(),
- Item.get(Item.TALL_GRASS, this.getDamage(), 1)
- };
- } else {
- return new Item[]{
- Item.get(Item.TALL_GRASS, this.getDamage(), 1)
- };
- }
- }
-
- if (dropSeeds) {
- return new Item[]{
- new ItemSeedsWheat()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHEARS;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracotta.java b/src/main/java/cn/nukkit/block/BlockTerracotta.java
deleted file mode 100644
index d7aa08519..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracotta.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-import cn.nukkit.utils.TerracottaColor;
-
-/**
- * Created on 2015/11/24 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockTerracotta extends BlockSolidMeta {
-
- public BlockTerracotta() {
- this(0);
- }
-
- public BlockTerracotta(int meta) {
- super(0);
- }
-
- public BlockTerracotta(DyeColor dyeColor) {
- this(dyeColor.getWoolData());
- }
-
- public BlockTerracotta(TerracottaColor dyeColor) {
- this(dyeColor.getTerracottaData());
- }
-
- @Override
- public int getId() {
- return TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Terracotta";
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public double getHardness() {
- return 1.25;
- }
-
- @Override
- public double getResistance() {
- return 7;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return TerracottaColor.getByTerracottaData(getDamage()).getColor();
- }
-
- public TerracottaColor getDyeColor() {
- return TerracottaColor.getByTerracottaData(getDamage());
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazed.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazed.java
deleted file mode 100644
index 732233c5c..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazed.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public abstract class BlockTerracottaGlazed extends BlockSolidMeta {
-
- private static final int[] faces = {2, 5, 3, 4};
-
- public BlockTerracottaGlazed() {
- this(0);
- }
-
- public BlockTerracottaGlazed(int meta) {
- super(meta);
- }
-
- @Override
- public double getResistance() {
- return 7;
- }
-
- @Override
- public double getHardness() {
- return 1.4;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- return item.getTier() >= ItemTool.TIER_WOODEN ? new Item[]{this.toItem()} : new Item[0];
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);
- return this.getLevel().setBlock(block, this, true, true);
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBlack.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBlack.java
deleted file mode 100644
index 7dd57d617..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBlack.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedBlack extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedBlack() {
- this(0);
- }
-
- public BlockTerracottaGlazedBlack(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return BLACK_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Black Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.BLACK;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBlue.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBlue.java
deleted file mode 100644
index 9bb8bd023..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBlue.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedBlue extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedBlue() {
- this(0);
- }
-
- public BlockTerracottaGlazedBlue(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return BLUE_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Blue Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.BLUE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBrown.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBrown.java
deleted file mode 100644
index ac83855a8..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedBrown.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedBrown extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedBrown() {
- this(0);
- }
-
- public BlockTerracottaGlazedBrown(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return BROWN_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Brown Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.BROWN;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedCyan.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedCyan.java
deleted file mode 100644
index 28760195b..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedCyan.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedCyan extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedCyan() {
- this(0);
- }
-
- public BlockTerracottaGlazedCyan(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return CYAN_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Cyan Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.CYAN;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedGray.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedGray.java
deleted file mode 100644
index 350adb3d3..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedGray.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedGray extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedGray() {
- this(0);
- }
-
- public BlockTerracottaGlazedGray(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return GRAY_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Gray Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.GRAY;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedGreen.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedGreen.java
deleted file mode 100644
index 20d50be66..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedGreen.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedGreen extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedGreen() {
- this(0);
- }
-
- public BlockTerracottaGlazedGreen(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return GREEN_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Green Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.GREEN;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedLightBlue.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedLightBlue.java
deleted file mode 100644
index 837de5564..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedLightBlue.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedLightBlue extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedLightBlue() {
- this(0);
- }
-
- public BlockTerracottaGlazedLightBlue(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return LIGHT_BLUE_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Light Blue Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.LIGHT_BLUE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedLime.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedLime.java
deleted file mode 100644
index 2c7f72b0b..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedLime.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedLime extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedLime() {
- this(0);
- }
-
- public BlockTerracottaGlazedLime(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return LIME_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Lime Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.LIME;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedMagenta.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedMagenta.java
deleted file mode 100644
index e04103636..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedMagenta.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedMagenta extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedMagenta() {
- this(0);
- }
-
- public BlockTerracottaGlazedMagenta(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return MAGENTA_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Magenta Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.MAGENTA;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedOrange.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedOrange.java
deleted file mode 100644
index 58a851c6f..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedOrange.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedOrange extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedOrange() {
- this(0);
- }
-
- public BlockTerracottaGlazedOrange(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return ORANGE_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Orange Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.ORANGE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedPink.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedPink.java
deleted file mode 100644
index 34b06e4c7..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedPink.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedPink extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedPink() {
- this(0);
- }
-
- public BlockTerracottaGlazedPink(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return PINK_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Pink Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.PINK;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedPurple.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedPurple.java
deleted file mode 100644
index 06b4b2db8..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedPurple.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedPurple extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedPurple() {
- this(0);
- }
-
- public BlockTerracottaGlazedPurple(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return PURPLE_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Purple Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.PURPLE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedRed.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedRed.java
deleted file mode 100644
index 5bc9a00b0..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedRed.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedRed extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedRed() {
- this(0);
- }
-
- public BlockTerracottaGlazedRed(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return RED_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Red Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.RED;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedSilver.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedSilver.java
deleted file mode 100644
index 62d9953fd..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedSilver.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedSilver extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedSilver() {
- this(0);
- }
-
- public BlockTerracottaGlazedSilver(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return SILVER_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Light Gray Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.LIGHT_GRAY;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedWhite.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedWhite.java
deleted file mode 100644
index 3e478b564..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedWhite.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedWhite extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedWhite() {
- this(0);
- }
-
- public BlockTerracottaGlazedWhite(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return WHITE_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "White Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.WHITE;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedYellow.java b/src/main/java/cn/nukkit/block/BlockTerracottaGlazedYellow.java
deleted file mode 100644
index 438713153..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaGlazedYellow.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockTerracottaGlazedYellow extends BlockTerracottaGlazed {
-
- public BlockTerracottaGlazedYellow() {
- this(0);
- }
-
- public BlockTerracottaGlazedYellow(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return YELLOW_GLAZED_TERRACOTTA;
- }
-
- @Override
- public String getName() {
- return "Yellow Glazed Terracotta";
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.YELLOW;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTerracottaStained.java b/src/main/java/cn/nukkit/block/BlockTerracottaStained.java
deleted file mode 100644
index 7d0fd18e2..000000000
--- a/src/main/java/cn/nukkit/block/BlockTerracottaStained.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockTerracottaStained extends BlockSolidMeta {
-
- public BlockTerracottaStained() {
- this(0);
- }
-
- public BlockTerracottaStained(int meta) {
- super(meta);
- }
-
- public BlockTerracottaStained(DyeColor dyeColor) {
- this(dyeColor.getWoolData());
- }
-
- @Override
- public String getName() {
- return getDyeColor().getName() + " Terracotta";
- }
-
- @Override
- public int getId() {
- return STAINED_TERRACOTTA;
- }
-
- @Override
- public double getHardness() {
- return 1.25;
- }
-
- @Override
- public double getResistance() {
- return 0.75;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{toItem()};
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public BlockColor getColor() {
- return DyeColor.getByWoolData(getDamage()).getColor();
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(getDamage());
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockThin.java b/src/main/java/cn/nukkit/block/BlockThin.java
deleted file mode 100644
index 7a11ac5a9..000000000
--- a/src/main/java/cn/nukkit/block/BlockThin.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.utils.LevelException;
-
-/**
- * Created on 2015/12/6 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public abstract class BlockThin extends BlockTransparent {
-
- protected BlockThin() {
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- protected AxisAlignedBB recalculateBoundingBox() {
- double f = 0.4375;
- double f1 = 0.5625;
- double f2 = 0.4375;
- double f3 = 0.5625;
- try {
- boolean flag = this.canConnect(this.north());
- boolean flag1 = this.canConnect(this.south());
- boolean flag2 = this.canConnect(this.west());
- boolean flag3 = this.canConnect(this.east());
- if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) {
- if (flag2) {
- f = 0;
- } else if (flag3) {
- f1 = 1;
- }
- } else {
- f = 0;
- f1 = 1;
- }
- if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1)) {
- if (flag) {
- f2 = 0;
- } else if (flag1) {
- f3 = 1;
- }
- } else {
- f2 = 0;
- f3 = 1;
- }
- } catch (LevelException ignore) {}
- return new AxisAlignedBB(
- this.x + f,
- this.y,
- this.z + f2,
- this.x + f1,
- this.y + 1,
- this.z + f3
- );
- }
-
- public boolean canConnect(Block block) {
- return block.isSolid() || block.getId() == this.getId() || block.getId() == GLASS_PANE || block.getId() == GLASS;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTorch.java b/src/main/java/cn/nukkit/block/BlockTorch.java
deleted file mode 100644
index 7811177d9..000000000
--- a/src/main/java/cn/nukkit/block/BlockTorch.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockTorch extends BlockFlowable implements Faceable {
-
- private static final short[] faces = new short[]{
- 0, //0, never used
- 5, //1
- 4, //2
- 3, //3
- 2, //4
- 1, //5
- };
-
- private static final short[] faces2 = new short[]{
- 0, //0
- 4, //1
- 5, //2
- 2, //3
- 3, //4
- 0, //5
- 0 //6
- };
-
- public BlockTorch() {
- this(0);
- }
-
- public BlockTorch(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Torch";
- }
-
- @Override
- public int getId() {
- return TORCH;
- }
-
- @Override
- public int getLightLevel() {
- return 14;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- Block below = this.down();
- int side = this.getDamage();
- Block block = this.getSide(BlockFace.fromIndex(faces2[side]));
- int id = block.getId();
-
- if ((block.isTransparent() && !(side == 0 && (below instanceof BlockFence || below.getId() == COBBLE_WALL))) && id != GLASS && id != STAINED_GLASS && id != HARD_STAINED_GLASS) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
-
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- int side = faces[face.getIndex()];
- int bid = this.getSide(BlockFace.fromIndex(faces2[side])).getId();
- if ((!target.isTransparent() || bid == GLASS || bid == STAINED_GLASS || bid == HARD_STAINED_GLASS) && face != BlockFace.DOWN) {
- this.setDamage(side);
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
-
- Block below = this.down();
- if (!below.isTransparent() || below instanceof BlockFence || below.getId() == COBBLE_WALL || below.getId() == GLASS || below.getId() == STAINED_GLASS || below.getId() == HARD_STAINED_GLASS) {
- this.setDamage(0);
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
- return false;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.AIR_BLOCK_COLOR;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return getBlockFace(this.getDamage() & 0x07);
- }
-
- public BlockFace getBlockFace(int meta) {
- switch (meta) {
- case 1:
- return BlockFace.EAST;
- case 2:
- return BlockFace.WEST;
- case 3:
- return BlockFace.SOUTH;
- case 4:
- return BlockFace.NORTH;
- default:
- return BlockFace.UP;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTransparent.java b/src/main/java/cn/nukkit/block/BlockTransparent.java
deleted file mode 100644
index 0499a6496..000000000
--- a/src/main/java/cn/nukkit/block/BlockTransparent.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockTransparent extends Block {
-
- @Override
- public boolean isTransparent() {
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.TRANSPARENT_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTransparentMeta.java b/src/main/java/cn/nukkit/block/BlockTransparentMeta.java
deleted file mode 100644
index bc96d517f..000000000
--- a/src/main/java/cn/nukkit/block/BlockTransparentMeta.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockTransparentMeta extends BlockMeta {
-
- protected BlockTransparentMeta() {
- this(0);
- }
-
- protected BlockTransparentMeta(int meta) {
- super(meta);
- }
-
- @Override
- public boolean isTransparent() {
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.TRANSPARENT_BLOCK_COLOR;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTrapdoor.java b/src/main/java/cn/nukkit/block/BlockTrapdoor.java
deleted file mode 100644
index 80ef97852..000000000
--- a/src/main/java/cn/nukkit/block/BlockTrapdoor.java
+++ /dev/null
@@ -1,219 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.block.BlockRedstoneEvent;
-import cn.nukkit.event.block.DoorToggleEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.sound.DoorSound;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Faceable;
-
-/**
- * Created by Pub4Game on 26.12.2015.
- */
-public class BlockTrapdoor extends BlockTransparentMeta implements Faceable {
-
- public static int TRAPDOOR_OPEN_BIT = 0x08;
- public static int TRAPDOOR_TOP_BIT = 0x04;
-
- private static final int[] faces = {2, 1, 3, 0};
-
- public BlockTrapdoor() {
- this(0);
- }
-
- public BlockTrapdoor(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return TRAPDOOR;
- }
-
- @Override
- public String getName() {
- return "Wooden Trapdoor";
- }
-
- @Override
- public double getHardness() {
- return 3;
- }
-
- @Override
- public double getResistance() {
- return 15;
- }
-
- @Override
- public boolean canBeActivated() {
- return true;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- int damage = this.getDamage();
- AxisAlignedBB bb;
- double f = 0.1875;
- if ((damage & TRAPDOOR_TOP_BIT) > 0) {
- bb = new AxisAlignedBB(
- this.x,
- this.y + 1 - f,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- } else {
- bb = new AxisAlignedBB(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + f,
- this.z + 1
- );
- }
- if ((damage & TRAPDOOR_OPEN_BIT) > 0) {
- if ((damage & 0x03) == 0) {
- bb.setBounds(
- this.x,
- this.y,
- this.z + 1 - f,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- } else if ((damage & 0x03) == 1) {
- bb.setBounds(
- this.x,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + f
- );
- }
- if ((damage & 0x03) == 2) {
- bb.setBounds(
- this.x + 1 - f,
- this.y,
- this.z,
- this.x + 1,
- this.y + 1,
- this.z + 1
- );
- }
- if ((damage & 0x03) == 3) {
- bb.setBounds(
- this.x,
- this.y,
- this.z,
- this.x + f,
- this.y + 1,
- this.z + 1
- );
- }
- }
- return bb;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_REDSTONE) {
- if ((!isOpen() && this.level.isBlockPowered(this.getLocation())) || (isOpen() && !this.level.isBlockPowered(this.getLocation()))) {
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, isOpen() ? 15 : 0, isOpen() ? 0 : 15));
- this.setDamage(this.getDamage() ^ TRAPDOOR_OPEN_BIT);
- this.level.setBlock(this, this, true);
- this.level.addSound(new DoorSound(this));
- return type;
- }
- }
-
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- BlockFace facing;
- boolean top;
- int meta = 0;
-
- if (face.getAxis().isHorizontal() || player == null) {
- facing = face;
- top = fy > 0.5;
- } else {
- facing = player.getDirection().getOpposite();
- top = face != BlockFace.UP;
- }
-
- if (top) {
- meta |= TRAPDOOR_TOP_BIT;
- } else {
- meta |= faces[facing.getHorizontalIndex()];
- }
-
- this.setDamage(meta);
- this.level.setBlock(block, this, true, true);
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- if (toggle(player)) {
- this.level.addSound(new DoorSound(this));
- return true;
- }
- return false;
- }
-
- public boolean toggle(Player player) {
- DoorToggleEvent ev = new DoorToggleEvent(this, player);
- level.getServer().getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return false;
- }
- this.setDamage(this.getDamage() ^ TRAPDOOR_OPEN_BIT);
- level.setBlock(this, this, true, true);
- return true;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WOOD_BLOCK_COLOR;
- }
-
- public boolean isOpen() {
- return (this.getDamage() & TRAPDOOR_OPEN_BIT) != 0;
- }
-
- public boolean isTop() {
- return (this.getDamage() & TRAPDOOR_TOP_BIT) != 0;
- }
-
- @Override
- public BlockFace getBlockFace() {
- return BlockFace.fromHorizontalIndex(this.getDamage() & 0x7);
- }
-
- @Override
- public boolean canPassThrough() {
- return this.isOpen();
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTrapdoorIron.java b/src/main/java/cn/nukkit/block/BlockTrapdoorIron.java
deleted file mode 100644
index ad441a4c3..000000000
--- a/src/main/java/cn/nukkit/block/BlockTrapdoorIron.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created by Pub4Game on 26.12.2015.
- */
-public class BlockTrapdoorIron extends BlockTrapdoor {
-
- public BlockTrapdoorIron() {
- this(0);
- }
-
- public BlockTrapdoorIron(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return IRON_TRAPDOOR;
- }
-
- @Override
- public String getName() {
- return "Iron Trapdoor";
- }
-
- @Override
- public double getHardness() {
- return 5;
- }
-
- @Override
- public double getResistance() {
- return 25;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.IRON_BLOCK_COLOR;
- }
-
- @Override
- public boolean onActivate(Item item, Player player) {
- return false;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTrappedChest.java b/src/main/java/cn/nukkit/block/BlockTrappedChest.java
deleted file mode 100644
index adcd91af4..000000000
--- a/src/main/java/cn/nukkit/block/BlockTrappedChest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.blockentity.BlockEntityChest;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.BlockFace.Plane;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.nbt.tag.Tag;
-
-import java.util.Map;
-
-public class BlockTrappedChest extends BlockChest {
-
- private static final int[] faces = {2, 5, 3, 4};
-
- public BlockTrappedChest() {
- this(0);
- }
-
- public BlockTrappedChest(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return TRAPPED_CHEST;
- }
-
- @Override
- public String getName() {
- return "Trapped Chest";
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- BlockEntityChest chest = null;
- this.setDamage(faces[player != null ? player.getDirection().getHorizontalIndex() : 0]);
-
- for (BlockFace side : Plane.HORIZONTAL) {
- if ((this.getDamage() == 4 || this.getDamage() == 5) && (side == BlockFace.WEST || side == BlockFace.EAST)) {
- continue;
- } else if ((this.getDamage() == 3 || this.getDamage() == 2) && (side == BlockFace.NORTH || side == BlockFace.SOUTH)) {
- continue;
- }
- Block c = this.getSide(side);
- if (c instanceof BlockTrappedChest && c.getDamage() == this.getDamage()) {
- BlockEntity blockEntity = this.getLevel().getBlockEntity(c);
- if (blockEntity instanceof BlockEntityChest && !((BlockEntityChest) blockEntity).isPaired()) {
- chest = (BlockEntityChest) blockEntity;
- break;
- }
- }
- }
-
- this.getLevel().setBlock(block, this, true, true);
- CompoundTag nbt = new CompoundTag("")
- .putList(new ListTag<>("Items"))
- .putString("id", BlockEntity.CHEST)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (item.hasCustomName()) {
- nbt.putString("CustomName", item.getCustomName());
- }
-
- if (item.hasCustomBlockData()) {
- Map customData = item.getCustomBlockData().getTags();
- for (Map.Entry tag : customData.entrySet()) {
- nbt.put(tag.getKey(), tag.getValue());
- }
- }
-
- BlockEntityChest blockEntity = (BlockEntityChest) BlockEntity.createBlockEntity(BlockEntity.CHEST, this.getChunk(), nbt);
-
- if (chest != null) {
- chest.pairWith(blockEntity);
- blockEntity.pairWith(chest);
- }
-
- return true;
- }
-
- @Override
- public int getWeakPower(BlockFace face) {
- int playerCount = 0;
-
- BlockEntity blockEntity = this.level.getBlockEntity(this);
-
- if (blockEntity instanceof BlockEntityChest) {
- playerCount = ((BlockEntityChest) blockEntity).getInventory().getViewers().size();
- }
-
- return Math.min(playerCount, 15);
- }
-
- @Override
- public int getStrongPower(BlockFace side) {
- return side == BlockFace.UP ? this.getWeakPower(side) : 0;
- }
-
- @Override
- public boolean isPowerSource() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTripWire.java b/src/main/java/cn/nukkit/block/BlockTripWire.java
deleted file mode 100644
index 1f8822187..000000000
--- a/src/main/java/cn/nukkit/block/BlockTripWire.java
+++ /dev/null
@@ -1,174 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemString;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-
-/**
- * @author CreeperFace
- */
-public class BlockTripWire extends BlockFlowable {
-
- public BlockTripWire(int meta) {
- super(meta);
- }
-
- public BlockTripWire() {
- this(0);
- }
-
- @Override
- public int getId() {
- return TRIPWIRE;
- }
-
- @Override
- public String getName() {
- return "Tripwire";
- }
-
- @Override
- public AxisAlignedBB getBoundingBox() {
- return null;
- }
-
- @Override
- public Item toItem() {
- return new ItemString();
- }
-
- public boolean isPowered() {
- return (this.getDamage() & 1) > 0;
- }
-
- public boolean isAttached() {
- return (this.getDamage() & 4) > 0;
- }
-
- public boolean isDisarmed() {
- return (this.getDamage() & 8) > 0;
- }
-
- public void setPowered(boolean value) {
- if (value ^ this.isPowered()) {
- this.setDamage(this.getDamage() ^ 0x01);
- }
- }
-
- public void setAttached(boolean value) {
- if (value ^ this.isAttached()) {
- this.setDamage(this.getDamage() ^ 0x04);
- }
- }
-
- public void setDisarmed(boolean value) {
- if (value ^ this.isDisarmed()) {
- this.setDamage(this.getDamage() ^ 0x08);
- }
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- if (!entity.doesTriggerPressurePlate()) {
- return;
- }
-
- boolean powered = this.isPowered();
-
- if (!powered) {
- this.setPowered(true);
- this.level.setBlock(this, this, true, false);
- this.updateHook(false);
-
- this.level.scheduleUpdate(this, 10);
- }
- }
-
- public void updateHook(boolean scheduleUpdate) {
- for (BlockFace side : new BlockFace[]{BlockFace.SOUTH, BlockFace.WEST}) {
- for (int i = 1; i < 42; ++i) {
- Block block = this.getSide(side, i);
-
- if (block instanceof BlockTripWireHook) {
- BlockTripWireHook hook = (BlockTripWireHook) block;
-
- if (hook.getFacing() == side.getOpposite()) {
- hook.calculateState(false, true, i, this);
- }
-
- /*if (scheduleUpdate) {
- this.level.scheduleUpdate(hook, 10);
- }*/
- break;
- }
-
- if (block.getId() != Block.TRIPWIRE) {
- break;
- }
- }
- }
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- if (!isPowered()) {
- return type;
- }
-
- boolean found = false;
- Entity[] e = this.level.getCollidingEntities(this.getCollisionBoundingBox());
- for (Entity entity : e) {
- if (!entity.doesTriggerPressurePlate()) {
- continue;
- }
-
- found = true;
- }
-
- if (found) {
- this.level.scheduleUpdate(this, 10);
- } else {
- this.setPowered(false);
- this.level.setBlock(this, this, true, false);
- this.updateHook(false);
- }
- return type;
- }
-
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.getLevel().setBlock(this, this, true, true);
- this.updateHook(false);
-
- return true;
- }
-
- @Override
- public boolean onBreak(Item item) {
- if (item.getId() == Item.SHEARS) {
- this.setDisarmed(true);
- this.level.setBlock(this, this, true, false);
- this.updateHook(false);
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
- } else {
- this.setPowered(true);
- this.getLevel().setBlock(this, Block.get(BlockID.AIR), true, true);
- this.updateHook(true);
- }
-
- return true;
- }
-
- @Override
- protected AxisAlignedBB recalculateCollisionBoundingBox() {
- return new AxisAlignedBB(this.x, this.y, this.z, this.x + 1, this.y + 0.5, this.z + 1);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockTripWireHook.java b/src/main/java/cn/nukkit/block/BlockTripWireHook.java
deleted file mode 100644
index dad75d5aa..000000000
--- a/src/main/java/cn/nukkit/block/BlockTripWireHook.java
+++ /dev/null
@@ -1,237 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.event.block.BlockRedstoneEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.network.protocol.LevelSoundEventPacket;
-
-/**
- * @author CreeperFace
- */
-public class BlockTripWireHook extends BlockFlowable {
-
- public BlockTripWireHook() {
- this(0);
- }
-
- public BlockTripWireHook(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Tripwire Hook";
- }
-
- @Override
- public int getId() {
- return TRIPWIRE_HOOK;
- }
-
- public BlockFace getFacing() {
- return BlockFace.fromHorizontalIndex(getDamage() & 0b11);
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (!this.getSide(this.getFacing().getOpposite()).isNormalBlock()) {
- this.level.useBreakOn(this);
- }
-
- return type;
- } else if (type == Level.BLOCK_UPDATE_SCHEDULED) {
- this.calculateState(false, true, -1, null);
- return type;
- }
-
- return 0;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (!this.getSide(face.getOpposite()).isNormalBlock() || face == BlockFace.DOWN || face == BlockFace.UP) {
- return false;
- }
-
- if (face.getAxis().isHorizontal()) {
- this.setFace(face);
- }
-
- this.level.setBlock(this, this);
-
- if (player != null) {
- this.calculateState(false, false, -1, null);
- }
- return true;
- }
-
- @Override
- public boolean onBreak(Item item) {
- super.onBreak(item);
- boolean attached = isAttached();
- boolean powered = isPowered();
-
- if (attached || powered) {
- this.calculateState(true, false, -1, null);
- }
-
- if (powered) {
- this.level.updateAroundRedstone(this, null);
- this.level.updateAroundRedstone(this.getLocation().getSide(getFacing().getOpposite()), null);
- }
-
- return true;
- }
-
- public void calculateState(boolean onBreak, boolean updateAround, int pos, Block block) {
- BlockFace facing = getFacing();
- Vector3 v = this.getLocation();
- boolean attached = isAttached();
- boolean powered = isPowered();
- boolean canConnect = !onBreak;
- boolean nextPowered = false;
- int distance = 0;
- Block[] blocks = new Block[42];
-
- for (int i = 1; i < 42; ++i) {
- Vector3 vector = v.getSide(facing, i);
- Block b = this.level.getBlock(vector);
-
- if (b instanceof BlockTripWireHook) {
- if (((BlockTripWireHook) b).getFacing() == facing.getOpposite()) {
- distance = i;
- }
- break;
- }
-
- if (b.getId() != Block.TRIPWIRE && i != pos) {
- blocks[i] = null;
- canConnect = false;
- } else {
- if (i == pos) {
- b = block != null ? block : b;
- }
-
- if (b instanceof BlockTripWire) {
- boolean disarmed = !((BlockTripWire) b).isDisarmed();
- boolean wirePowered = ((BlockTripWire) b).isPowered();
- nextPowered |= disarmed && wirePowered;
-
- if (i == pos) {
- this.level.scheduleUpdate(this, 10);
- canConnect &= disarmed;
- }
- }
- blocks[i] = b;
- }
- }
-
- canConnect = canConnect & distance > 1;
- nextPowered = nextPowered & canConnect;
- BlockTripWireHook hook = (BlockTripWireHook) Block.get(TRIPWIRE_HOOK);
- hook.setAttached(canConnect);
- hook.setPowered(nextPowered);
-
-
- if (distance > 0) {
- Vector3 vec = v.getSide(facing, distance);
- BlockFace face = facing.getOpposite();
- hook.setFace(face);
- this.level.setBlock(vec, hook, true, false);
- this.level.updateAroundRedstone(vec, null);
- this.level.updateAroundRedstone(vec.getSide(face.getOpposite()), null);
- this.addSound(vec, canConnect, nextPowered, attached, powered);
- }
-
- this.addSound(v, canConnect, nextPowered, attached, powered);
-
- if (!onBreak) {
- hook.setFace(facing);
- this.level.setBlock(v, hook, true, false);
-
- if (updateAround) {
- this.level.updateAroundRedstone(v, null);
- this.level.updateAroundRedstone(v.getSide(facing.getOpposite()), null);
- }
- }
-
- if (attached != canConnect) {
- for (int i = 1; i < distance; i++) {
- Vector3 vc = v.getSide(facing, i);
- block = blocks[i];
-
- if (block != null && this.level.getBlockIdAt(vc.getFloorX(), vc.getFloorY(), vc.getFloorZ()) != Block.AIR) {
- if (canConnect ^ ((block.getDamage() & 0x04) > 0)) {
- block.setDamage(block.getDamage() ^ 0x04);
- }
-
- this.level.setBlock(vc, block, true, false);
- }
- }
- }
- }
-
- private void addSound(Vector3 pos, boolean canConnect, boolean nextPowered, boolean attached, boolean powered) {
- if (nextPowered && !powered) {
- this.level.addLevelSoundEvent(pos, LevelSoundEventPacket.SOUND_POWER_ON);
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 0, 15));
- } else if (!nextPowered && powered) {
- this.level.addLevelSoundEvent(pos, LevelSoundEventPacket.SOUND_POWER_OFF);
- this.level.getServer().getPluginManager().callEvent(new BlockRedstoneEvent(this, 15, 0));
- } else if (canConnect && !attached) {
- this.level.addLevelSoundEvent(pos, LevelSoundEventPacket.SOUND_ATTACH);
- } else if (!canConnect && attached) {
- this.level.addLevelSoundEvent(pos, LevelSoundEventPacket.SOUND_DETACH);
- }
- }
-
- public boolean isAttached() {
- return (getDamage() & 0x04) > 0;
- }
-
- public boolean isPowered() {
- return (this.getDamage() & 0x08) > 0;
- }
-
- public void setPowered(boolean value) {
- if (value ^ this.isPowered()) {
- this.setDamage(this.getDamage() ^ 0x08);
- }
- }
-
- public void setAttached(boolean value) {
- if (value ^ this.isAttached()) {
- this.setDamage(this.getDamage() ^ 0x04);
- }
- }
-
- public void setFace(BlockFace face) {
- this.setDamage(this.getDamage() - this.getDamage() % 4);
- this.setDamage(this.getDamage() | face.getHorizontalIndex());
- }
-
- @Override
- public boolean isPowerSource() {
- return true;
- }
-
- @Override
- public int getWeakPower(BlockFace face) {
- return isPowered() ? 15 : 0;
- }
-
- @Override
- public int getStrongPower(BlockFace side) {
- return !isPowered() ? 0 : getFacing() == side ? 15 : 0;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockUnderwaterTorch.java b/src/main/java/cn/nukkit/block/BlockUnderwaterTorch.java
deleted file mode 100644
index 16da38be3..000000000
--- a/src/main/java/cn/nukkit/block/BlockUnderwaterTorch.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * Created by PetteriM1
- */
-public class BlockUnderwaterTorch extends BlockTorch {
-
- public BlockUnderwaterTorch() {
- this(0);
- }
-
- public BlockUnderwaterTorch(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Underwater Torch";
- }
-
- @Override
- public int getId() {
- return UNDERWATER_TORCH;
- }
-
- @Override
- public int onUpdate(int type) {
- return 0;
- }
-
- @Override
- public boolean canBeFlowedInto() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockUndyedShulkerBox.java b/src/main/java/cn/nukkit/block/BlockUndyedShulkerBox.java
deleted file mode 100644
index 510cefa29..000000000
--- a/src/main/java/cn/nukkit/block/BlockUndyedShulkerBox.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.inventory.ContainerInventory;
-import cn.nukkit.inventory.InventoryHolder;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-public class BlockUndyedShulkerBox extends BlockShulkerBox {
-
- public BlockUndyedShulkerBox() {
- super(0);
- }
-
- @Override
- public int getId() {
- return UNDYED_SHULKER_BOX;
- }
-
- @Override
- public String getName() {
- return "Shulker Box";
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.PURPLE_BLOCK_COLOR;
- }
-
- @Override
- public DyeColor getDyeColor() {
- return null;
- }
-
- @Override
- public void setDamage(int meta) {
- }
-
- @Override
- public boolean hasComparatorInputOverride() {
- return true;
- }
-
- @Override
- public int getComparatorInputOverride() {
- BlockEntity be = this.getLevel().getBlockEntity(this);
-
- if (!(be instanceof InventoryHolder)) {
- return 0;
- }
-
- return ContainerInventory.calculateRedstone(((InventoryHolder) be).getInventory());
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockUnknown.java b/src/main/java/cn/nukkit/block/BlockUnknown.java
deleted file mode 100644
index aa866cd1a..000000000
--- a/src/main/java/cn/nukkit/block/BlockUnknown.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockUnknown extends BlockMeta {
-
- private final int id;
-
- public BlockUnknown(int id) {
- this(id, 0);
- }
-
- public BlockUnknown(int id, Integer meta) {
- super(meta);
- this.id = id;
- }
-
- @Override
- public int getId() {
- return id;
- }
-
- @Override
- public String getName() {
- return "Unknown";
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockVine.java b/src/main/java/cn/nukkit/block/BlockVine.java
deleted file mode 100644
index 60afdfa0c..000000000
--- a/src/main/java/cn/nukkit/block/BlockVine.java
+++ /dev/null
@@ -1,321 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.event.block.BlockGrowEvent;
-import cn.nukkit.event.block.BlockSpreadEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-import java.util.Random;
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * Created by Pub4Game on 15.01.2016.
- */
-public class BlockVine extends BlockTransparentMeta {
-
- public BlockVine(int meta) {
- super(meta);
- }
-
- public BlockVine() {
- this(0);
- }
-
- @Override
- public String getName() {
- return "Vines";
- }
-
- @Override
- public int getId() {
- return VINE;
- }
-
- @Override
- public double getHardness() {
- return 0.2;
- }
-
- @Override
- public double getResistance() {
- return 1;
- }
-
- @Override
- public boolean canPassThrough() {
- return true;
- }
-
- @Override
- public boolean hasEntityCollision() {
- return true;
- }
-
- @Override
- public boolean canBeReplaced() {
- return true;
- }
-
- @Override
- public boolean canBeClimbed() {
- return true;
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- entity.resetFallDistance();
- entity.onGround = true;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- double f1 = 1;
- double f2 = 1;
- double f3 = 1;
- double f4 = 0;
- double f5 = 0;
- double f6 = 0;
- boolean flag = this.getDamage() > 0;
- if ((this.getDamage() & 0x02) > 0) {
- f4 = Math.max(f4, 0.0625);
- f1 = 0;
- f2 = 0;
- f5 = 1;
- f3 = 0;
- f6 = 1;
- flag = true;
- }
- if ((this.getDamage() & 0x08) > 0) {
- f1 = Math.min(f1, 0.9375);
- f4 = 1;
- f2 = 0;
- f5 = 1;
- f3 = 0;
- f6 = 1;
- flag = true;
- }
- if ((this.getDamage() & 0x01) > 0) {
- f3 = Math.min(f3, 0.9375);
- f6 = 1;
- f1 = 0;
- f4 = 1;
- f2 = 0;
- f5 = 1;
- flag = true;
- }
- if (!flag && this.up().isSolid()) {
- f2 = Math.min(f2, 0.9375);
- f5 = 1;
- f1 = 0;
- f4 = 1;
- f3 = 0;
- f6 = 1;
- }
- return new AxisAlignedBB(
- this.x + f1,
- this.y + f2,
- this.z + f3,
- this.x + f4,
- this.y + f5,
- this.z + f6
- );
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (block.getId() != VINE && target.isSolid() && face.getHorizontalIndex() != -1) {
- this.setDamage(getMetaFromFace(face.getOpposite()));
- this.getLevel().setBlock(block, this, true, true);
- return true;
- }
-
- return false;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isShears()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- int meta = this.getDamage();
- Block up = this.up();
- for (BlockFace face : BlockFace.Plane.HORIZONTAL) {
- int faceMeta = getMetaFromFace(face);
- if (!this.getSide(face).isSolid() && (up.getId() != VINE || (up.getDamage() & faceMeta) != faceMeta)) {
- meta &= ~faceMeta;
- }
- }
- if (meta == 0 && !up.isSolid()) {
- this.getLevel().useBreakOn(this, null, null, true);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- if (meta != this.getDamage()) {
- this.level.setBlock(this, Block.get(VINE, meta), true);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- } else if (type == Level.BLOCK_UPDATE_RANDOM) {
- Random random = ThreadLocalRandom.current();
- if (random.nextInt(4) == 0) {
- BlockFace face = BlockFace.random(random);
- Block block = this.getSide(face);
- int faceMeta = getMetaFromFace(face);
- int meta = this.getDamage();
-
- if (this.y < 255 && face == BlockFace.UP && block.getId() == AIR) {
- if (this.canSpread()) {
- for (BlockFace horizontalFace : BlockFace.Plane.HORIZONTAL) {
- if (random.nextBoolean() || !this.getSide(horizontalFace).getSide(face).isSolid()) {
- meta &= ~getMetaFromFace(horizontalFace);
- }
- }
- putVineOnHorizontalFace(block, meta, this);
- }
- } else if (face.getHorizontalIndex() != -1 && (meta & faceMeta) != faceMeta) {
- if (this.canSpread()) {
- if (block.getId() == AIR) {
- BlockFace cwFace = face.rotateY();
- BlockFace ccwFace = face.rotateYCCW();
- Block cwBlock = block.getSide(cwFace);
- Block ccwBlock = block.getSide(ccwFace);
- int cwMeta = getMetaFromFace(cwFace);
- int ccwMeta = getMetaFromFace(ccwFace);
- boolean onCw = (meta & cwMeta) == cwMeta;
- boolean onCcw = (meta & ccwMeta) == ccwMeta;
-
- if (onCw && cwBlock.isSolid()) {
- putVine(block, getMetaFromFace(cwFace), this);
- } else if (onCcw && ccwBlock.isSolid()) {
- putVine(block, getMetaFromFace(ccwFace), this);
- } else if (onCw && cwBlock.getId() == AIR && this.getSide(cwFace).isSolid()) {
- putVine(cwBlock, getMetaFromFace(face.getOpposite()), this);
- } else if (onCcw && ccwBlock.getId() == AIR && this.getSide(ccwFace).isSolid()) {
- putVine(ccwBlock, getMetaFromFace(face.getOpposite()), this);
- } else if (block.up().isSolid()) {
- putVine(block, 0, this);
- }
- } else if (!block.isTransparent()) {
- meta |= getMetaFromFace(face);
- putVine(this, meta, null);
- }
- }
- } else if (this.y > 0) {
- Block below = this.down();
- int id = below.getId();
- if (id == AIR || id == VINE) {
- for (BlockFace horizontalFace : BlockFace.Plane.HORIZONTAL) {
- if (random.nextBoolean()) {
- meta &= ~getMetaFromFace(horizontalFace);
- }
- }
- putVineOnHorizontalFace(below, below.getDamage() | meta, id == AIR ? this : null);
- }
- }
- return Level.BLOCK_UPDATE_RANDOM;
- }
- }
- return 0;
- }
-
- private boolean canSpread() {
- int blockX = this.getFloorX();
- int blockY = this.getFloorY();
- int blockZ = this.getFloorZ();
-
- int count = 0;
- for (int x = blockX - 4; x <= blockX + 4; x++) {
- for (int z = blockZ - 4; z <= blockZ + 4; z++) {
- for (int y = blockY - 1; y <= blockY + 1; y++) {
- if (this.level.getBlockIdAt(x, y, z) == VINE) {
- if (++count >= 5) return false;
- }
- }
- }
- }
- return true;
- }
-
- private void putVine(Block block, int meta, Block source) {
- if (block.getId() == VINE && block.getDamage() == meta) return;
- Block vine = get(VINE, meta);
- BlockGrowEvent event;
- if (source != null) {
- event = new BlockSpreadEvent(block, source, vine);
- } else {
- event = new BlockGrowEvent(block, vine);
- }
- this.level.getServer().getPluginManager().callEvent(event);
- if (!event.isCancelled()) {
- this.level.setBlock(block, vine, true);
- }
- }
-
- private void putVineOnHorizontalFace(Block block, int meta, Block source) {
- if (block.getId() == VINE && block.getDamage() == meta) return;
- boolean isOnHorizontalFace = false;
- for (BlockFace face : BlockFace.Plane.HORIZONTAL) {
- int faceMeta = getMetaFromFace(face);
- if ((meta & faceMeta) == faceMeta) {
- isOnHorizontalFace = true;
- break;
- }
- }
- if (isOnHorizontalFace) {
- putVine(block, meta, source);
- }
- }
-
- private static int getMetaFromFace(BlockFace face) {
- switch (face) {
- case SOUTH:
- default:
- return 0x01;
- case WEST:
- return 0x02;
- case NORTH:
- return 0x04;
- case EAST:
- return 0x08;
- }
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-
- @Override
- public boolean canSilkTouch() {
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWall.java b/src/main/java/cn/nukkit/block/BlockWall.java
deleted file mode 100644
index 23b0d8e80..000000000
--- a/src/main/java/cn/nukkit/block/BlockWall.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockWall extends BlockTransparentMeta {
-
- public static final int NONE_MOSSY_WALL = 0;
- public static final int MOSSY_WALL = 1;
-
- public BlockWall() {
- this(0);
- }
-
- public BlockWall(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return STONE_WALL;
- }
-
- @Override
- public boolean isSolid() {
- return false;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 30;
- }
-
- @Override
- public String getName() {
- if (this.getDamage() == 0x01) {
- return "Mossy Cobblestone Wall";
- }
-
- return "Cobblestone Wall";
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
-
- boolean north = this.canConnect(this.getSide(BlockFace.NORTH));
- boolean south = this.canConnect(this.getSide(BlockFace.SOUTH));
- boolean west = this.canConnect(this.getSide(BlockFace.WEST));
- boolean east = this.canConnect(this.getSide(BlockFace.EAST));
-
- double n = north ? 0 : 0.25;
- double s = south ? 1 : 0.75;
- double w = west ? 0 : 0.25;
- double e = east ? 1 : 0.75;
-
- if (north && south && !west && !east) {
- w = 0.3125;
- e = 0.6875;
- } else if (!north && !south && west && east) {
- n = 0.3125;
- s = 0.6875;
- }
-
- return new AxisAlignedBB(
- this.x + w,
- this.y,
- this.z + n,
- this.x + e,
- this.y + 1.5,
- this.z + s
- );
- }
-
- public boolean canConnect(Block block) {
- return (!(block.getId() != COBBLE_WALL && block.getId() != FENCE_GATE)) || block.isSolid() && !block.isTransparent();
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public boolean canHarvestWithHand() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWallBanner.java b/src/main/java/cn/nukkit/block/BlockWallBanner.java
deleted file mode 100644
index 4a1468bc4..000000000
--- a/src/main/java/cn/nukkit/block/BlockWallBanner.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created by PetteriM1
- */
-public class BlockWallBanner extends BlockBanner {
-
- public BlockWallBanner() {
- this(0);
- }
-
- public BlockWallBanner(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return WALL_BANNER;
- }
-
- @Override
- public String getName() {
- return "Wall Banner";
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.getDamage() >= BlockFace.NORTH.getIndex() && this.getDamage() <= BlockFace.EAST.getIndex()) {
- if (this.getSide(BlockFace.fromIndex(this.getDamage()).getOpposite()).getId() == AIR) {
- this.getLevel().useBreakOn(this);
- }
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWallSign.java b/src/main/java/cn/nukkit/block/BlockWallSign.java
deleted file mode 100644
index 695352b0b..000000000
--- a/src/main/java/cn/nukkit/block/BlockWallSign.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-
-/**
- * Created by Pub4Game on 26.12.2015.
- */
-public class BlockWallSign extends BlockSignPost {
-
- private static final int[] faces = {
- 3,
- 2,
- 5,
- 4,
- };
-
- public BlockWallSign() {
- this(0);
- }
-
- public BlockWallSign(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return WALL_SIGN;
- }
-
- @Override
- public String getName() {
- return "Wall Sign";
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (this.getDamage() >= 2 && this.getDamage() <= 5) {
- if (this.getSide(BlockFace.fromIndex(faces[this.getDamage() - 2])).getId() == Item.AIR) {
- this.getLevel().useBreakOn(this);
- }
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWater.java b/src/main/java/cn/nukkit/block/BlockWater.java
deleted file mode 100644
index 7a49315e2..000000000
--- a/src/main/java/cn/nukkit/block/BlockWater.java
+++ /dev/null
@@ -1,95 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.event.block.WaterFrostEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.Utils;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockWater extends BlockLiquid {
-
- /**
- * Used to cache biome check for freezing
- * 1 = can't freeze, 2 = can freeze
- */
- private byte freezing;
-
- public BlockWater() {
- this(0);
- }
-
- public BlockWater(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return WATER;
- }
-
- @Override
- public String getName() {
- return "Water";
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- boolean ret = this.getLevel().setBlock(this, this, true, false);
- this.getLevel().scheduleUpdate(this, this.tickRate());
-
- return ret;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.WATER_BLOCK_COLOR;
- }
-
- @Override
- public BlockLiquid getBlock(int meta) {
- return (BlockLiquid) Block.get(WATER, meta);
- }
-
- @Override
- public void onEntityCollide(Entity entity) {
- super.onEntityCollide(entity);
-
- if (entity.fireTicks > 0) {
- entity.extinguish();
- }
- }
-
- @Override
- public int tickRate() {
- return 5;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_RANDOM && this.getDamage() == 0) {
- if (freezing < 1) {
- freezing = Utils.freezingBiomes.contains(level.getBiomeId((int) this.x, (int) this.z)) ? (byte) 2 : (byte) 1;
- }
- if (freezing == 2) {
- if (ThreadLocalRandom.current().nextInt(10) == 0 && level.getBlockLightAt((int) this.x, (int) this.y, (int) this.z) < 12 && level.canBlockSeeSky(this)) {
- WaterFrostEvent ev = new WaterFrostEvent(this);
- level.getServer().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- level.setBlock(this, Block.get(Block.ICE), true, true);
- }
- }
- }
- return Level.BLOCK_UPDATE_RANDOM;
- }
- return super.onUpdate(type);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWaterLily.java b/src/main/java/cn/nukkit/block/BlockWaterLily.java
deleted file mode 100644
index e2e475d6e..000000000
--- a/src/main/java/cn/nukkit/block/BlockWaterLily.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * Created on 2015/12/1 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockWaterLily extends BlockFlowable {
-
- public BlockWaterLily() {
- this(0);
- }
-
- public BlockWaterLily(int meta) {
- super(0);
- }
-
- @Override
- public String getName() {
- return "Lily Pad";
- }
-
- @Override
- public int getId() {
- return WATER_LILY;
- }
-
- @Override
- protected AxisAlignedBB recalculateBoundingBox() {
- return new AxisAlignedBB(
- this.x + 0.0625,
- this.y,
- this.z + 0.0625,
- this.x + 0.9375,
- this.y + 0.015625,
- this.z + 0.9375
- );
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- if (target instanceof BlockWater) {
- Block up = target.up();
- if (up.getId() == Block.AIR) {
- this.getLevel().setBlock(up, this, true, true);
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int onUpdate(int type) {
- if (type == Level.BLOCK_UPDATE_NORMAL) {
- if (!(this.down() instanceof BlockWater)) {
- this.getLevel().useBreakOn(this);
- return Level.BLOCK_UPDATE_NORMAL;
- }
- }
- return 0;
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.FOLIAGE_BLOCK_COLOR;
- }
-
- @Override
- public boolean canPassThrough() {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWaterStill.java b/src/main/java/cn/nukkit/block/BlockWaterStill.java
deleted file mode 100644
index 40822a32f..000000000
--- a/src/main/java/cn/nukkit/block/BlockWaterStill.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.block;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class BlockWaterStill extends BlockWater {
-
- public BlockWaterStill() {
- super(0);
- }
-
- public BlockWaterStill(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return STILL_WATER;
- }
-
- @Override
- public String getName() {
- return "Still Water";
- }
-
- @Override
- public BlockLiquid getBlock(int meta) {
- return (BlockLiquid) Block.get(STILL_WATER, meta);
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWeightedPressurePlateHeavy.java b/src/main/java/cn/nukkit/block/BlockWeightedPressurePlateHeavy.java
deleted file mode 100644
index d52ae08ae..000000000
--- a/src/main/java/cn/nukkit/block/BlockWeightedPressurePlateHeavy.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.NukkitMath;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author CreeperFace
- */
-public class BlockWeightedPressurePlateHeavy extends BlockPressurePlateBase {
-
- public BlockWeightedPressurePlateHeavy() {
- this(0);
- }
-
- public BlockWeightedPressurePlateHeavy(int meta) {
- super(meta);
- this.onPitch = 0.90000004f;
- this.offPitch = 0.75f;
- }
-
- @Override
- public int getId() {
- return HEAVY_WEIGHTED_PRESSURE_PLATE;
- }
-
- @Override
- public String getName() {
- return "Weighted Pressure Plate (Heavy)";
- }
-
- @Override
- public double getHardness() {
- return 0.5D;
- }
-
- @Override
- public double getResistance() {
- return 2.5D;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.IRON_BLOCK_COLOR;
- }
-
- @Override
- protected int computeRedstoneStrength() {
- int count = Math.min(this.level.getCollidingEntities(getCollisionBoundingBox()).length, this.getMaxWeight());
-
- if (count > 0) {
- float f = (float) Math.min(this.getMaxWeight(), count) / (float) this.getMaxWeight();
- return Math.max(1, NukkitMath.ceilFloat(f * 15.0F));
- } else {
- return 0;
- }
- }
-
- public int getMaxWeight() {
- return 150;
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWeightedPressurePlateLight.java b/src/main/java/cn/nukkit/block/BlockWeightedPressurePlateLight.java
deleted file mode 100644
index 9859e303e..000000000
--- a/src/main/java/cn/nukkit/block/BlockWeightedPressurePlateLight.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.NukkitMath;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author CreeperFace
- */
-public class BlockWeightedPressurePlateLight extends BlockPressurePlateBase {
-
- public BlockWeightedPressurePlateLight() {
- this(0);
- }
-
- public BlockWeightedPressurePlateLight(int meta) {
- super(meta);
- this.onPitch = 0.90000004f;
- this.offPitch = 0.75f;
- }
-
- @Override
- public int getId() {
- return LIGHT_WEIGHTED_PRESSURE_PLATE;
- }
-
- @Override
- public String getName() {
- return "Weighted Pressure Plate (Light)";
- }
-
- @Override
- public double getHardness() {
- return 0.5D;
- }
-
- @Override
- public double getResistance() {
- return 2.5D;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_PICKAXE;
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (item.isPickaxe()) {
- return new Item[]{
- toItem()
- };
- } else {
- return new Item[0];
- }
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, 0);
- }
-
- @Override
- public BlockColor getColor() {
- return BlockColor.GOLD_BLOCK_COLOR;
- }
-
- @Override
- protected int computeRedstoneStrength() {
- int count = Math.min(this.level.getCollidingEntities(getCollisionBoundingBox()).length, this.getMaxWeight());
-
- if (count > 0) {
- float f = (float) Math.min(this.getMaxWeight(), count) / (float) this.getMaxWeight();
- return NukkitMath.ceilFloat(f * 15.0F);
- } else {
- return 0;
- }
- }
-
- public int getMaxWeight() {
- return 15;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/block/BlockWheat.java b/src/main/java/cn/nukkit/block/BlockWheat.java
deleted file mode 100644
index f025c07be..000000000
--- a/src/main/java/cn/nukkit/block/BlockWheat.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSeedsWheat;
-import cn.nukkit.item.ItemWheat;
-import cn.nukkit.utils.Utils;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockWheat extends BlockCrops {
-
- public BlockWheat() {
- this(0);
- }
-
- public BlockWheat(int meta) {
- super(meta);
- }
-
- @Override
- public String getName() {
- return "Wheat Block";
- }
-
- @Override
- public int getId() {
- return WHEAT_BLOCK;
- }
-
- @Override
- public Item toItem() {
- return new ItemSeedsWheat();
- }
-
- @Override
- public Item[] getDrops(Item item) {
- if (this.getDamage() >= 0x07) {
- return new Item[]{
- new ItemWheat(),
- new ItemSeedsWheat(0, Utils.random.nextInt(1, 3))
- };
- } else {
- return new Item[]{
- new ItemSeedsWheat()
- };
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWood.java b/src/main/java/cn/nukkit/block/BlockWood.java
deleted file mode 100644
index 5dda5346d..000000000
--- a/src/main/java/cn/nukkit/block/BlockWood.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.Player;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockWood extends BlockSolidMeta {
-
- public static final int OAK = 0;
- public static final int SPRUCE = 1;
- public static final int BIRCH = 2;
- public static final int JUNGLE = 3;
-
- private static final short[] faces = new short[]{
- 0,
- 0,
- 0b1000,
- 0b1000,
- 0b0100,
- 0b0100
- };
-
- public BlockWood() {
- this(0);
- }
-
- public BlockWood(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return WOOD;
- }
-
- @Override
- public double getHardness() {
- return 2;
- }
-
- @Override
- public double getResistance() {
- return 10;
- }
-
- @Override
- public String getName() {
- String[] names = new String[]{
- "Oak Wood",
- "Spruce Wood",
- "Birch Wood",
- "Jungle Wood"
- };
-
- return names[this.getDamage() & 0x03];
- }
-
- @Override
- public int getBurnChance() {
- return 5;
- }
-
- @Override
- public int getBurnAbility() {
- return 10;
- }
-
- @Override
- public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
- this.setDamage(((this.getDamage() & 0x03) | faces[face.getIndex()]));
- this.getLevel().setBlock(block, this, true, true);
-
- return true;
- }
-
- @Override
- public Item toItem() {
- return new ItemBlock(this, this.getDamage() & 0x03);
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_AXE;
- }
-
- @Override
- public BlockColor getColor() {
- switch (getDamage() & 0x07) {
- default:
- case OAK:
- return BlockColor.WOOD_BLOCK_COLOR;
- case SPRUCE:
- return BlockColor.SPRUCE_BLOCK_COLOR;
- case BIRCH:
- return BlockColor.SAND_BLOCK_COLOR;
- case JUNGLE:
- return BlockColor.DIRT_BLOCK_COLOR;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWood2.java b/src/main/java/cn/nukkit/block/BlockWood2.java
deleted file mode 100644
index 540ae2a4a..000000000
--- a/src/main/java/cn/nukkit/block/BlockWood2.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockWood2 extends BlockWood {
-
- public static final int ACACIA = 0;
- public static final int DARK_OAK = 1;
-
- private static final String[] NAMES = new String[]{
- "Acacia Wood",
- "Dark Oak Wood",
- ""
- };
-
- public BlockWood2() {
- this(0);
- }
-
- public BlockWood2(int meta) {
- super(meta);
- }
-
- @Override
- public int getId() {
- return WOOD2;
- }
-
- @Override
- public String getName() {
- return NAMES[this.getDamage() > 2 ? 0 : this.getDamage()];
- }
-
- @Override
- public BlockColor getColor() {
- switch (getDamage() & 0x07) {
- case ACACIA:
- return BlockColor.ORANGE_BLOCK_COLOR;
- case DARK_OAK:
- return BlockColor.BROWN_BLOCK_COLOR;
- default:
- return BlockColor.WOOD_BLOCK_COLOR;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/block/BlockWool.java b/src/main/java/cn/nukkit/block/BlockWool.java
deleted file mode 100644
index ede90427b..000000000
--- a/src/main/java/cn/nukkit/block/BlockWool.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package cn.nukkit.block;
-
-import cn.nukkit.item.ItemTool;
-import cn.nukkit.utils.BlockColor;
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created on 2015/12/2 by xtypr.
- * Package cn.nukkit.block in project Nukkit .
- */
-public class BlockWool extends BlockSolidMeta {
-
- public BlockWool() {
- this(0);
- }
-
- public BlockWool(int meta) {
- super(meta);
- }
-
- public BlockWool(DyeColor dyeColor) {
- this(dyeColor.getWoolData());
- }
-
- @Override
- public String getName() {
- return getDyeColor().getName() + " Wool";
- }
-
- @Override
- public int getId() {
- return WOOL;
- }
-
- @Override
- public int getToolType() {
- return ItemTool.TYPE_SHEARS;
- }
-
- @Override
- public double getHardness() {
- return 0.8;
- }
-
- @Override
- public double getResistance() {
- return 4;
- }
-
- @Override
- public int getBurnChance() {
- return 30;
- }
-
- @Override
- public int getBurnAbility() {
- return 60;
- }
-
- @Override
- public BlockColor getColor() {
- return DyeColor.getByWoolData(getDamage()).getColor();
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(getDamage());
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntity.java b/src/main/java/cn/nukkit/blockentity/BlockEntity.java
deleted file mode 100644
index c685ed738..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntity.java
+++ /dev/null
@@ -1,212 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Server;
-import cn.nukkit.block.Block;
-import cn.nukkit.level.Position;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.utils.ChunkException;
-import co.aikar.timings.Timing;
-import co.aikar.timings.Timings;
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-
-import java.lang.reflect.Constructor;
-
-/**
- * @author MagicDroidX
- */
-public abstract class BlockEntity extends Position {
-
- //WARNING: DO NOT CHANGE ANY NAME HERE, OR THE CLIENT WILL CRASH
- public static final String CHEST = "Chest";
- public static final String ENDER_CHEST = "EnderChest";
- public static final String FURNACE = "Furnace";
- public static final String SIGN = "Sign";
- public static final String MOB_SPAWNER = "MobSpawner";
- public static final String ENCHANT_TABLE = "EnchantTable";
- public static final String SKULL = "Skull";
- public static final String FLOWER_POT = "FlowerPot";
- public static final String BREWING_STAND = "BrewingStand";
- public static final String DAYLIGHT_DETECTOR = "DaylightDetector";
- public static final String MUSIC = "Music";
- public static final String ITEM_FRAME = "ItemFrame";
- public static final String CAULDRON = "Cauldron";
- public static final String BEACON = "Beacon";
- public static final String PISTON_ARM = "PistonArm";
- public static final String MOVING_BLOCK = "MovingBlock";
- public static final String COMPARATOR = "Comparator";
- public static final String HOPPER = "Hopper";
- public static final String BED = "Bed";
- public static final String JUKEBOX = "Jukebox";
- public static final String SHULKER_BOX = "ShulkerBox";
- public static final String BANNER = "Banner";
- public static final String DROPPER = "Dropper";
- public static final String DISPENSER = "Dispenser";
-
- public static long count = 1;
-
- private static final BiMap> knownBlockEntities = HashBiMap.create(24);
-
- public FullChunk chunk;
- public String name;
- public long id;
-
- public boolean movable;
-
- public boolean closed = false;
- public CompoundTag namedTag;
- protected Server server;
- protected Timing timing;
-
- public BlockEntity(FullChunk chunk, CompoundTag nbt) {
- if (chunk == null || chunk.getProvider() == null) {
- throw new ChunkException("Invalid garbage chunk given to BlockEntity");
- }
-
- this.timing = Timings.getBlockEntityTiming(this);
- this.server = chunk.getProvider().getLevel().getServer();
- this.chunk = chunk;
- this.setLevel(chunk.getProvider().getLevel());
- this.namedTag = nbt;
- this.name = "";
- this.id = BlockEntity.count++;
- this.x = this.namedTag.getInt("x");
- this.y = this.namedTag.getInt("y");
- this.z = this.namedTag.getInt("z");
- this.movable = this.namedTag.getBoolean("isMovable", true);
-
- this.initBlockEntity();
-
- this.chunk.addBlockEntity(this);
- this.getLevel().addBlockEntity(this);
- }
-
- protected void initBlockEntity() {}
-
- public static BlockEntity createBlockEntity(String type, FullChunk chunk, CompoundTag nbt, Object... args) {
- BlockEntity blockEntity = null;
-
- if (knownBlockEntities.containsKey(type)) {
- Class extends BlockEntity> clazz = knownBlockEntities.get(type);
-
- if (clazz == null) {
- return null;
- }
-
- for (Constructor> constructor : clazz.getConstructors()) {
- if (blockEntity != null) {
- break;
- }
-
- if (constructor.getParameterCount() != (args == null ? 2 : args.length + 2)) {
- continue;
- }
-
- try {
- if (args == null || args.length == 0) {
- blockEntity = (BlockEntity) constructor.newInstance(chunk, nbt);
- } else {
- Object[] objects = new Object[args.length + 2];
-
- objects[0] = chunk;
- objects[1] = nbt;
- System.arraycopy(args, 0, objects, 2, args.length);
- blockEntity = (BlockEntity) constructor.newInstance(objects);
-
- }
- } catch (Exception ignored) {}
- }
- } else {
- Server.getInstance().getLogger().warning("Tried to create block entity that doesn't exists: " + type);
- }
-
- return blockEntity;
- }
-
- public static boolean registerBlockEntity(String name, Class extends BlockEntity> c) {
- if (c == null) {
- return false;
- }
-
- knownBlockEntities.put(name, c);
- return true;
- }
-
- public final String getSaveId() {
- return knownBlockEntities.inverse().get(getClass());
- }
-
- public long getId() {
- return id;
- }
-
- public void saveNBT() {
- this.namedTag.putString("id", this.getSaveId());
- this.namedTag.putInt("x", (int) this.getX());
- this.namedTag.putInt("y", (int) this.getY());
- this.namedTag.putInt("z", (int) this.getZ());
- this.namedTag.putBoolean("isMovable", this.movable);
- }
-
- public CompoundTag getCleanedNBT() {
- this.saveNBT();
- CompoundTag tag = this.namedTag.clone();
- tag.remove("x").remove("y").remove("z").remove("id");
- if (!tag.getTags().isEmpty()) {
- return tag;
- } else {
- return null;
- }
- }
-
- public Block getBlock() {
- return this.getLevelBlock();
- }
-
- public abstract boolean isBlockEntityValid();
-
- public boolean onUpdate() {
- return false;
- }
-
- public final void scheduleUpdate() {
- this.level.scheduleBlockEntityUpdate(this);
- }
-
- public void close() {
- if (!this.closed) {
- this.closed = true;
- if (this.chunk != null) {
- this.chunk.removeBlockEntity(this);
- }
- if (this.level != null) {
- this.level.removeBlockEntity(this);
- }
- this.level = null;
- }
- }
-
- public void onBreak() {}
-
- public void setDirty() {
- chunk.setChanged();
- }
-
- public String getName() {
- return name;
- }
-
- public boolean isMovable() {
- return movable;
- }
-
- public static CompoundTag getDefaultCompound(Vector3 pos, String id) {
- return new CompoundTag()
- .putString("id", id)
- .putInt("x", pos.getFloorX())
- .putInt("y", pos.getFloorY())
- .putInt("z", pos.getFloorZ());
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityBanner.java b/src/main/java/cn/nukkit/blockentity/BlockEntityBanner.java
deleted file mode 100644
index ece50cf03..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityBanner.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.utils.BannerPattern;
-import cn.nukkit.utils.DyeColor;
-
-public class BlockEntityBanner extends BlockEntitySpawnable {
-
- public int color;
-
- public BlockEntityBanner(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (!this.namedTag.contains("color")) {
- this.namedTag.putByte("color", 0);
- }
-
- this.color = this.namedTag.getByte("color");
-
- super.initBlockEntity();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.getBlock().getId() == Block.WALL_BANNER || this.getBlock().getId() == Block.STANDING_BANNER;
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
- this.namedTag.putByte("color", this.color);
- }
-
- @Override
- public String getName() {
- return "Banner";
- }
-
- public int getBaseColor() {
- return this.namedTag.getInt("Base");
- }
-
- public void setBaseColor(DyeColor color) {
- this.namedTag.putInt("Base", color.getDyeData() & 0x0f);
- }
-
- public int getType() {
- return this.namedTag.getInt("Type");
- }
-
- public void setType(int type) {
- this.namedTag.putInt("Type", type);
- }
-
- public void addPattern(BannerPattern pattern) {
- ListTag patterns = this.namedTag.getList("Patterns", CompoundTag.class);
- patterns.add(new CompoundTag("").
- putInt("Color", pattern.getColor().getDyeData() & 0x0f).
- putString("Pattern", pattern.getType().getName()));
- this.namedTag.putList(patterns);
- }
-
- public BannerPattern getPattern(int index) {
- return BannerPattern.fromCompoundTag(this.namedTag.getList("Patterns").size() > index && index >= 0 ? this.namedTag.getList("Patterns", CompoundTag.class).get(index) : new CompoundTag());
- }
-
- public void removePattern(int index) {
- ListTag patterns = this.namedTag.getList("Patterns", CompoundTag.class);
- if (patterns.size() > index && index >= 0) {
- patterns.remove(index);
- }
- }
-
- public int getPatternsSize() {
- return this.namedTag.getList("Patterns").size();
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- return getDefaultCompound(this, BANNER)
- .putInt("Base", getBaseColor())
- .putList(this.namedTag.getList("Patterns"))
- .putInt("Type", getType())
- .putByte("color", this.color);
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(color);
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityBeacon.java b/src/main/java/cn/nukkit/blockentity/BlockEntityBeacon.java
deleted file mode 100644
index 2838c3262..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityBeacon.java
+++ /dev/null
@@ -1,250 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.block.Block;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.network.protocol.LevelSoundEventPacket;
-import cn.nukkit.potion.Effect;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Rover656
- */
-public class BlockEntityBeacon extends BlockEntitySpawnable {
-
- public BlockEntityBeacon(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (!namedTag.contains("Lock")) {
- namedTag.putString("Lock", "");
- }
-
- if (!namedTag.contains("Levels")) {
- namedTag.putInt("Levels", 0);
- }
-
- if (!namedTag.contains("Primary")) {
- namedTag.putInt("Primary", 0);
- }
-
- if (!namedTag.contains("Secondary")) {
- namedTag.putInt("Secondary", 0);
- }
-
- this.scheduleUpdate();
-
- super.initBlockEntity();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- int blockID = getBlock().getId();
- return blockID == Block.BEACON;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- return new CompoundTag()
- .putString("id", BlockEntity.BEACON)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putString("Lock", this.namedTag.getString("Lock"))
- .putInt("Levels", this.namedTag.getInt("Levels"))
- .putInt("Primary", this.namedTag.getInt("Primary"))
- .putInt("Secondary", this.namedTag.getInt("Secondary"));
- }
-
- private long currentTick = 0;
-
- @Override
- public boolean onUpdate() {
- //Only apply effects every 4 secs
- if (currentTick++ % 80 != 0) {
- return true;
- }
-
- int oldPowerLevel = this.getPowerLevel();
- //Get the power level based on the pyramid
- setPowerLevel(calculatePowerLevel());
-
- //Skip beacons that do not have a pyramid or sky access
- if (this.getPowerLevel() < 1 || !hasSkyAccess()) {
- if (oldPowerLevel > 0) {
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_BEACON_DEACTIVATE);
- }
- return true;
- } else if (oldPowerLevel < 1) {
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_BEACON_ACTIVATE);
- } else {
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_BEACON_AMBIENT);
- }
-
- int duration = 9 + (getPowerLevel() << 1);
-
- for (Map.Entry entry : this.level.getPlayers().entrySet()) {
- Player p = entry.getValue();
-
- //If the player is in range
- if (p.distance(this) < 10 + getPowerLevel() * 10) {
- Effect e;
-
- if (getPrimaryPower() != 0) {
- //Apply the primary power
- e = Effect.getEffect(getPrimaryPower());
-
- //Set duration
- e.setDuration(duration * 20);
-
- //If secondary is selected as the primary too, apply 2 amplification
- if (getSecondaryPower() == getPrimaryPower()) {
- e.setAmplifier(1);
- } else {
- e.setAmplifier(0);
- }
-
- //Hide particles
- e.setVisible(false);
-
- //Add the effect
- p.addEffect(e);
- }
-
- //If we have a secondary power as regen, apply it
- if (getSecondaryPower() == Effect.REGENERATION) {
- //Get the regen effect
- e = Effect.getEffect(Effect.REGENERATION);
-
- //Set duration
- e.setDuration(duration * 20);
-
- //Regen I
- e.setAmplifier(0);
-
- //Hide particles
- e.setVisible(false);
-
- //Add effect
- p.addEffect(e);
- }
- }
- }
-
- return true;
- }
-
- private static final int POWER_LEVEL_MAX = 4;
-
- private boolean hasSkyAccess() {
- //Check every block from our y coord to the top of the world
- for (int y = getFloorY() + 1; y <= 255; y++) {
- int testBlockId = level.getBlockIdAt(chunk, getFloorX(), y, getFloorZ());
- if (!Block.transparent[testBlockId]) {
- //There is no sky access
- return false;
- }
- }
-
- return true;
- }
-
- private int calculatePowerLevel() {
- //The power level that we're testing for
- for (int powerLevel = 1; powerLevel <= POWER_LEVEL_MAX; powerLevel++) {
- int queryY = getFloorY() - powerLevel; //Layer below the beacon block
-
- for (int queryX = getFloorX() - powerLevel; queryX <= getFloorX() + powerLevel; queryX++) {
- for (int queryZ = getFloorZ() - powerLevel; queryZ <= getFloorZ() + powerLevel; queryZ++) {
-
- int testBlockId = level.getBlockIdAt(queryX, queryY, queryZ);
- if (
- testBlockId != Block.IRON_BLOCK &&
- testBlockId != Block.GOLD_BLOCK &&
- testBlockId != Block.EMERALD_BLOCK &&
- testBlockId != Block.DIAMOND_BLOCK
- ) {
- return powerLevel - 1;
- }
- }
- }
- }
-
- return POWER_LEVEL_MAX;
- }
-
- public int getPowerLevel() {
- return namedTag.getInt("Level");
- }
-
- public void setPowerLevel(int level) {
- int currentLevel = getPowerLevel();
- if (level != currentLevel) {
- namedTag.putInt("Level", level);
- setDirty();
- this.spawnToAll();
- }
- }
-
- public int getPrimaryPower() {
- return namedTag.getInt("Primary");
- }
-
- public void setPrimaryPower(int power) {
- int currentPower = getPrimaryPower();
- if (power != currentPower) {
- namedTag.putInt("Primary", power);
- setDirty();
- this.spawnToAll();
- }
- }
-
- public int getSecondaryPower() {
- return namedTag.getInt("Secondary");
- }
-
- public void setSecondaryPower(int power) {
- int currentPower = getSecondaryPower();
- if (power != currentPower) {
- namedTag.putInt("Secondary", power);
- setDirty();
- this.spawnToAll();
- }
- }
-
- private static final List allowedEffects = Arrays.asList(Effect.SPEED, Effect.HASTE, Effect.DAMAGE_RESISTANCE, Effect.JUMP, Effect.STRENGTH, Effect.REGENERATION);
-
- @Override
- public boolean updateCompoundTag(CompoundTag nbt, Player player) {
- if (!nbt.getString("id").equals(BlockEntity.BEACON)) {
- return false;
- }
-
- int primary = nbt.getInt("primary");
- if (allowedEffects.contains(primary)) {
- this.setPrimaryPower(primary);
- } else {
- Server.getInstance().getLogger().debug(player.getName() + " tried to set an invalid primary effect to a beacon: " + primary);
- }
-
- int secondary = nbt.getInt("secondary");
- if (allowedEffects.contains(secondary)) {
- this.setSecondaryPower(secondary);
- } else {
- Server.getInstance().getLogger().debug(player.getName() + " tried to set an invalid secondary effect to a beacon: " + secondary);
- }
-
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_BEACON_POWER);
-
- player.getWindowById(Player.BEACON_WINDOW_ID).setItem(0, Item.get(Item.AIR));
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityBed.java b/src/main/java/cn/nukkit/blockentity/BlockEntityBed.java
deleted file mode 100644
index 74a17852c..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityBed.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.item.Item;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.utils.DyeColor;
-
-/**
- * Created by CreeperFace on 2.6.2017.
- */
-public class BlockEntityBed extends BlockEntitySpawnable {
-
- public int color;
-
- public BlockEntityBed(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (!this.namedTag.contains("color")) {
- this.namedTag.putByte("color", 0);
- }
-
- this.color = this.namedTag.getByte("color");
-
- super.initBlockEntity();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.level.getBlockIdAt(chunk, this.getFloorX(), this.getFloorY(), this.getFloorZ()) == Item.BED_BLOCK;
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
- this.namedTag.putByte("color", this.color);
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- return new CompoundTag()
- .putString("id", BlockEntity.BED)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putByte("color", this.color);
- }
-
- public DyeColor getDyeColor() {
- return DyeColor.getByWoolData(color);
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityBrewingStand.java b/src/main/java/cn/nukkit/blockentity/BlockEntityBrewingStand.java
deleted file mode 100644
index 393d4fccc..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityBrewingStand.java
+++ /dev/null
@@ -1,391 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockBrewingStand;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.event.inventory.BrewEvent;
-import cn.nukkit.event.inventory.StartBrewEvent;
-import cn.nukkit.inventory.*;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.item.ItemID;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.network.protocol.ContainerSetDataPacket;
-import cn.nukkit.network.protocol.LevelSoundEventPacket;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-
-public class BlockEntityBrewingStand extends BlockEntitySpawnable implements InventoryHolder, BlockEntityContainer, BlockEntityNameable {
-
- protected BrewingInventory inventory;
-
- public static final int MAX_BREW_TIME = 400;
-
- public int brewTime;
- public int fuelTotal;
- public int fuelAmount;
-
- public static final List ingredients = new ArrayList<>(Arrays.asList(Item.NETHER_WART, Item.GHAST_TEAR, Item.GLOWSTONE_DUST, Item.REDSTONE_DUST, Item.GUNPOWDER, Item.MAGMA_CREAM, Item.BLAZE_POWDER, Item.GOLDEN_CARROT, Item.SPIDER_EYE, Item.FERMENTED_SPIDER_EYE, Item.GLISTERING_MELON, Item.SUGAR, Item.RABBIT_FOOT, Item.PUFFERFISH, Item.TURTLE_SHELL, Item.PHANTOM_MEMBRANE, Item.DRAGON_BREATH));
-
- public BlockEntityBrewingStand(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- inventory = new BrewingInventory(this);
-
- if (!namedTag.contains("Items") || !(namedTag.get("Items") instanceof ListTag)) {
- namedTag.putList(new ListTag("Items"));
- }
-
- for (int i = 0; i < getSize(); i++) {
- inventory.setItem(i, this.getItem(i));
- }
-
- if (!namedTag.contains("CookTime") || namedTag.getShort("CookTime") > MAX_BREW_TIME) {
- this.brewTime = MAX_BREW_TIME;
- } else {
- this.brewTime = namedTag.getShort("CookTime");
- }
-
- this.fuelAmount = namedTag.getShort("FuelAmount");
- this.fuelTotal = namedTag.getShort("FuelTotal");
-
- if (brewTime < MAX_BREW_TIME) {
- this.scheduleUpdate();
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public String getName() {
- return this.hasName() ? this.namedTag.getString("CustomName") : "Brewing Stand";
- }
-
- @Override
- public boolean hasName() {
- return namedTag.contains("CustomName");
- }
-
- @Override
- public void setName(String name) {
- if (name == null || name.isEmpty()) {
- namedTag.remove("CustomName");
- return;
- }
-
- namedTag.putString("CustomName", name);
- }
-
- @Override
- public void close() {
- if (!closed) {
- for (Player player : new HashSet<>(inventory.getViewers())) {
- player.removeWindow(inventory);
- }
- super.close();
- }
- }
-
- @Override
- public void onBreak() {
- for (Item content : inventory.getContents().values()) {
- level.dropItem(this, content);
- }
- inventory.clearAll();
- }
-
- @Override
- public void saveNBT() {
- namedTag.putList(new ListTag("Items"));
- for (int index = 0; index < getSize(); index++) {
- this.setItem(index, inventory.getItem(index));
- }
-
- namedTag.putShort("CookTime", brewTime);
- namedTag.putShort("FuelAmount", this.fuelAmount);
- namedTag.putShort("FuelTotal", this.fuelTotal);
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return getBlock().getId() == Block.BREWING_STAND_BLOCK;
- }
-
- @Override
- public int getSize() {
- return 5;
- }
-
- protected int getSlotIndex(int index) {
- ListTag list = this.namedTag.getList("Items", CompoundTag.class);
- for (int i = 0; i < list.size(); i++) {
- if (list.get(i).getByte("Slot") == index) {
- return i;
- }
- }
-
- return -1;
- }
-
- @Override
- public Item getItem(int index) {
- int i = this.getSlotIndex(index);
- if (i < 0) {
- return new ItemBlock(Block.get(BlockID.AIR), 0, 0);
- } else {
- CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i);
- return NBTIO.getItemHelper(data);
- }
- }
-
- @Override
- public void setItem(int index, Item item) {
- int i = this.getSlotIndex(index);
-
- CompoundTag d = NBTIO.putItemHelper(item, index);
-
- if (item.getId() == Item.AIR || item.getCount() <= 0) {
- if (i >= 0) {
- this.namedTag.getList("Items").getAll().remove(i);
- }
- } else if (i < 0) {
- (this.namedTag.getList("Items", CompoundTag.class)).add(d);
- } else {
- (this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
- }
- }
-
- @Override
- public BrewingInventory getInventory() {
- return inventory;
- }
-
- protected boolean checkIngredient(Item ingredient) {
- return ingredients.contains(ingredient.getId());
- }
-
- @Override
- public boolean onUpdate() {
- if (closed) {
- return false;
- }
-
- restockFuel();
-
- if (this.fuelAmount <= 0 || matchRecipes(true)[0] == null) {
- stopBrewing();
- return false;
- }
-
- if (brewTime == MAX_BREW_TIME) {
- StartBrewEvent e = new StartBrewEvent(this);
- this.server.getPluginManager().callEvent(e);
-
- if (e.isCancelled()) {
- return false;
- }
-
- this.sendBrewTime();
- }
-
- if (--brewTime > 0) {
-
- if (brewTime % 40 == 0) {
- sendBrewTime();
- }
-
- return true;
- }
-
- //20 seconds
- BrewEvent e = new BrewEvent(this);
- this.server.getPluginManager().callEvent(e);
-
- if (e.isCancelled()) {
- stopBrewing();
- return true;
- }
-
- boolean mixed = false;
- MixRecipe[] recipes = matchRecipes(false);
- for (int i = 0; i < 3; i++) {
- MixRecipe recipe = recipes[i];
- if (recipe == null) {
- continue;
- }
-
- Item previous = inventory.getItem(i + 1);
- if (!previous.isNull()) {
- Item result = recipe.getResult();
- result.setCount(previous.getCount());
- if (recipe instanceof ContainerRecipe) {
- result.setDamage(previous.getDamage());
- }
- inventory.setItem(i + 1, result);
- mixed = true;
- }
- }
-
- if (mixed) {
- Item ingredient = this.inventory.getIngredient();
- ingredient.count--;
- this.inventory.setIngredient(ingredient);
-
- this.fuelAmount--;
- this.sendFuel();
-
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_POTION_BREWED);
- }
-
- stopBrewing();
- return true;
- }
-
- private void restockFuel() {
- Item fuel = this.getInventory().getFuel();
- if (this.fuelAmount > 0 || fuel.getId() != ItemID.BLAZE_POWDER || fuel.getCount() <= 0) {
- return;
- }
-
- fuel.count--;
- this.fuelAmount = 20;
- this.fuelTotal = 20;
-
- this.inventory.setFuel(fuel);
- this.sendFuel();
- }
-
- private void stopBrewing() {
- this.brewTime = 0;
- this.sendBrewTime();
- this.brewTime = MAX_BREW_TIME;
- }
-
- private MixRecipe[] matchRecipes(boolean quickTest) {
- MixRecipe[] recipes = new MixRecipe[quickTest? 1 : 3];
- Item ingredient = inventory.getIngredient();
- CraftingManager craftingManager = getLevel().getServer().getCraftingManager();
- for (int i = 0; i < 3; i++) {
- Item potion = inventory.getItem(i + 1);
- if (potion.isNull()) {
- continue;
- }
-
- MixRecipe recipe = craftingManager.matchBrewingRecipe(ingredient, potion);
- if (recipe == null) {
- recipe = craftingManager.matchContainerRecipe(ingredient, potion);
- }
- if (recipe == null) {
- continue;
- }
-
- if (quickTest) {
- recipes[0] = recipe;
- return recipes;
- }
-
- recipes[i] = recipe;
- }
-
- return recipes;
- }
-
- protected void sendFuel() {
- ContainerSetDataPacket pk = new ContainerSetDataPacket();
-
- for (Player p : this.inventory.getViewers()) {
- int windowId = p.getWindowId(this.inventory);
- if (windowId > 0) {
- pk.windowId = windowId;
-
- pk.property = ContainerSetDataPacket.PROPERTY_BREWING_STAND_FUEL_AMOUNT;
- pk.value = this.fuelAmount;
- p.dataPacket(pk);
-
- pk.property = ContainerSetDataPacket.PROPERTY_BREWING_STAND_FUEL_TOTAL;
- pk.value = this.fuelTotal;
- p.dataPacket(pk);
- }
- }
- }
-
- protected void sendBrewTime() {
- ContainerSetDataPacket pk = new ContainerSetDataPacket();
- pk.property = ContainerSetDataPacket.PROPERTY_BREWING_STAND_BREW_TIME;
- pk.value = this.brewTime;
-
- for (Player p : this.inventory.getViewers()) {
- int windowId = p.getWindowId(this.inventory);
- if (windowId > 0) {
- pk.windowId = windowId;
-
- p.dataPacket(pk);
- }
- }
- }
-
- public void updateBlock() {
- Block block = this.getLevelBlock();
-
- if (!(block instanceof BlockBrewingStand)) {
- return;
- }
-
- int meta = 0;
-
- for (int i = 1; i <= 3; ++i) {
- Item potion = this.inventory.getItem(i);
-
- int id = potion.getId();
- if ((id == Item.POTION || id == Item.SPLASH_POTION || id == Item.LINGERING_POTION) && potion.getCount() > 0) {
- meta |= 1 << (i - 1);
- }
- }
-
- block.setDamage(meta);
- this.level.setBlock(block, block, false, false);
-
- if (brewTime != MAX_BREW_TIME && matchRecipes(true)[0] == null) {
- stopBrewing();
- }
- }
-
- public int getFuel() {
- return fuelAmount;
- }
-
- public void setFuel(int fuel) {
- this.fuelAmount = fuel;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag nbt = new CompoundTag()
- .putString("id", BlockEntity.BREWING_STAND)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putShort("FuelTotal", this.fuelTotal)
- .putShort("FuelAmount", this.fuelAmount);
-
- if (this.brewTime < MAX_BREW_TIME) {
- nbt.putShort("CookTime", this.brewTime);
- }
-
- if (this.hasName()) {
- nbt.put("CustomName", namedTag.get("CustomName"));
- }
-
- return nbt;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityCauldron.java b/src/main/java/cn/nukkit/blockentity/BlockEntityCauldron.java
deleted file mode 100644
index 429e07d8d..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityCauldron.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.level.GlobalBlockPalette;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.network.protocol.UpdateBlockPacket;
-import cn.nukkit.utils.BlockColor;
-
-/**
- * @author CreeperFace
- * Nukkit Project
- */
-public class BlockEntityCauldron extends BlockEntitySpawnable {
-
- public static final int POTION_TYPE_EMPTY = 0xFFFF;
- public static final int POTION_TYPE_NORMAL = 0;
- public static final int POTION_TYPE_SPLASH = 1;
- public static final int POTION_TYPE_LINGERING = 2;
- public static final int POTION_TYPE_LAVA = 0xF19B;
-
- public BlockEntityCauldron(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- int potionId;
- if (!namedTag.contains("PotionId")) {
- namedTag.putShort("PotionId", 0xffff);
- }
- potionId = namedTag.getShort("PotionId");
-
- int potionType = (potionId & 0xFFFF) == 0xFFFF? POTION_TYPE_EMPTY : POTION_TYPE_NORMAL;
- if (namedTag.getBoolean("SplashPotion")) {
- potionType = POTION_TYPE_SPLASH;
- namedTag.remove("SplashPotion");
- }
-
- if (!namedTag.contains("PotionType")) {
- namedTag.putShort("PotionType", potionType);
- }
-
- super.initBlockEntity();
- }
-
- public int getPotionId() {
- return namedTag.getShort("PotionId");
- }
-
- public void setPotionId(int potionId) {
- namedTag.putShort("PotionId", potionId);
- this.spawnToAll();
- }
-
- public boolean hasPotion() {
- return getPotionId() != 0xffff;
- }
-
- public void setPotionType(int potionType) {
- this.namedTag.putShort("PotionType", potionType & 0xFFFF);
- }
-
- public int getPotionType() {
- return this.namedTag.getShort("PotionType") & 0xFFFF;
- }
-
- public boolean isSplashPotion() {
- return namedTag.getShort("PotionType") == POTION_TYPE_SPLASH;
- }
-
- public void setSplashPotion(boolean value) {
- namedTag.putShort("PotionType", value ? 1 : 0);
- }
-
- public BlockColor getCustomColor() {
- if (isCustomColor()) {
- int color = namedTag.getInt("CustomColor");
-
- int red = (color >> 16) & 0xff;
- int green = (color >> 8) & 0xff;
- int blue = (color) & 0xff;
-
- return new BlockColor(red, green, blue);
- }
-
- return null;
- }
-
- public boolean isCustomColor() {
- return namedTag.contains("CustomColor");
- }
-
- public void setCustomColor(BlockColor color) {
- setCustomColor(color.getRed(), color.getGreen(), color.getBlue());
- }
-
- public void setCustomColor(int r, int g, int b) {
- int color = (r << 16 | g << 8 | b) & 0xffffff;
-
- if (color != namedTag.getInt("CustomColor")) {
- namedTag.putInt("CustomColor", color);
- Block block = getBlock();
- Player[] pl = level.getChunkPlayers(getChunkX(), getChunkZ()).values().toArray(new Player[0]);
- for (Player p : pl) {
- UpdateBlockPacket air = new UpdateBlockPacket();
- air.blockRuntimeId = GlobalBlockPalette.getOrCreateRuntimeId(p.protocol, 0);
- air.flags = UpdateBlockPacket.FLAG_ALL_PRIORITY;
- air.x = (int) x;
- air.y = (int) y;
- air.z = (int) z;
- UpdateBlockPacket self = (UpdateBlockPacket) air.clone();
- self.blockRuntimeId = GlobalBlockPalette.getOrCreateRuntimeId(p.protocol, block.getId(), block.getDamage());
- p.dataPacket(air);
- p.dataPacket(self);
- }
-
- spawnToAll();
- }
- }
-
- public void clearCustomColor() {
- namedTag.remove("CustomColor");
- spawnToAll();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return getBlock().getId() == Block.CAULDRON_BLOCK;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag compoundTag = new CompoundTag()
- .putString("id", BlockEntity.CAULDRON)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putShort("PotionId", namedTag.getShort("PotionId"))
- .putByte("PotionType", namedTag.getShort("PotionType"));
- if (namedTag.contains("CustomColor")) {
- compoundTag.putInt("CustomColor", namedTag.getInt("CustomColor"));
- }
- return compoundTag;
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityChest.java b/src/main/java/cn/nukkit/blockentity/BlockEntityChest.java
deleted file mode 100644
index 5c6f20659..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityChest.java
+++ /dev/null
@@ -1,285 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.inventory.BaseInventory;
-import cn.nukkit.inventory.ChestInventory;
-import cn.nukkit.inventory.DoubleChestInventory;
-import cn.nukkit.inventory.InventoryHolder;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-
-import java.util.HashSet;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockEntityChest extends BlockEntitySpawnable implements InventoryHolder, BlockEntityContainer, BlockEntityNameable {
-
- protected ChestInventory inventory;
-
- protected DoubleChestInventory doubleInventory = null;
-
- public BlockEntityChest(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- this.inventory = new ChestInventory(this);
-
- if (!this.namedTag.contains("Items") || !(this.namedTag.get("Items") instanceof ListTag)) {
- this.namedTag.putList(new ListTag("Items"));
- }
-
- ListTag list = (ListTag) this.namedTag.getList("Items");
- for (CompoundTag compound : list.getAll()) {
- Item item = NBTIO.getItemHelper(compound);
- this.inventory.slots.put(compound.getByte("Slot"), item);
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public void close() {
- if (!closed) {
- if (this.doubleInventory != null) {
- for (Player player : new HashSet<>(this.doubleInventory.getViewers())) {
- player.removeWindow(this.doubleInventory);
- }
- this.doubleInventory = null;
- }
-
- for (Player player : new HashSet<>(this.inventory.getViewers())) {
- player.removeWindow(this.inventory);
- }
-
- this.inventory.destroyed = true;
- super.close();
- }
- }
-
- @Override
- public void onBreak() {
- unpair();
- for (Item content : inventory.getContents().values()) {
- level.dropItem(this, content);
- }
- inventory.clearAll(); // Stop items from being moved around by another player in the inventory
- }
-
- @Override
- public void saveNBT() {
- this.namedTag.putList(new ListTag("Items"));
- for (int index = 0; index < this.getSize(); index++) {
- this.setItem(index, this.inventory.getItem(index));
- }
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return getBlock().getId() == Block.CHEST || getBlock().getId() == Block.TRAPPED_CHEST;
- }
-
- @Override
- public int getSize() {
- return 27;
- }
-
- protected int getSlotIndex(int index) {
- ListTag list = this.namedTag.getList("Items", CompoundTag.class);
- for (int i = 0; i < list.size(); i++) {
- if (list.get(i).getByte("Slot") == index) {
- return i;
- }
- }
-
- return -1;
- }
-
- @Override
- public Item getItem(int index) {
- int i = this.getSlotIndex(index);
- if (i < 0) {
- return new ItemBlock(Block.get(BlockID.AIR), 0, 0);
- } else {
- CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i);
- return NBTIO.getItemHelper(data);
- }
- }
-
- @Override
- public void setItem(int index, Item item) {
- int i = this.getSlotIndex(index);
-
- CompoundTag d = NBTIO.putItemHelper(item, index);
-
- // If item is air or count less than 0, remove the item from the "Items" list
- if (item.getId() == Item.AIR || item.getCount() <= 0) {
- if (i >= 0) {
- this.namedTag.getList("Items").remove(i);
- }
- } else if (i < 0) {
- // If it is less than i, then it is a new item, so we are going to add it at the end of the list
- (this.namedTag.getList("Items", CompoundTag.class)).add(d);
- } else {
- // If it is more than i, then it is an update on a inventorySlot, so we are going to overwrite the item in the list
- (this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
- }
- }
-
- @Override
- public BaseInventory getInventory() {
- if (this.doubleInventory == null && this.isPaired()) {
- this.checkPairing();
- }
-
- return this.doubleInventory != null ? this.doubleInventory : this.inventory;
- }
-
- public ChestInventory getRealInventory() {
- return inventory;
- }
-
- protected void checkPairing() {
- BlockEntityChest pair = this.getPair();
-
- if (pair != null) {
- if (!pair.isPaired()) {
- pair.createPair(this);
- pair.checkPairing();
- }
-
- if (pair.doubleInventory != null) {
- this.doubleInventory = pair.doubleInventory;
- } else if (this.doubleInventory == null) {
- if ((pair.x + ((int) pair.z << 15)) > (this.x + ((int) this.z << 15))) { //Order them correctly
- this.doubleInventory = new DoubleChestInventory(pair, this);
- } else {
- this.doubleInventory = new DoubleChestInventory(this, pair);
- }
- }
- } else {
- if (level.isChunkLoaded(this.namedTag.getInt("pairx") >> 4, this.namedTag.getInt("pairz") >> 4)) {
- this.doubleInventory = null;
- this.namedTag.remove("pairx");
- this.namedTag.remove("pairz");
- }
- }
- }
-
- @Override
- public String getName() {
- return this.hasName() ? this.namedTag.getString("CustomName") : "Chest";
- }
-
- @Override
- public boolean hasName() {
- return this.namedTag.contains("CustomName");
- }
-
- @Override
- public void setName(String name) {
- if (name == null || name.isEmpty()) {
- this.namedTag.remove("CustomName");
- return;
- }
-
- this.namedTag.putString("CustomName", name);
- }
-
- public boolean isPaired() {
- return this.namedTag.contains("pairx") && this.namedTag.contains("pairz");
- }
-
- public BlockEntityChest getPair() {
- if (this.isPaired()) {
- BlockEntity blockEntity = this.getLevel().getBlockEntityIfLoaded(new Vector3(this.namedTag.getInt("pairx"), this.y, this.namedTag.getInt("pairz")));
- if (blockEntity instanceof BlockEntityChest) {
- return (BlockEntityChest) blockEntity;
- }
- }
-
- return null;
- }
-
- public boolean pairWith(BlockEntityChest chest) {
- if (this.isPaired() || chest.isPaired() || this.getBlock().getId() != chest.getBlock().getId()) {
- return false;
- }
-
- this.createPair(chest);
-
- chest.spawnToAll();
- this.spawnToAll();
- this.checkPairing();
-
- return true;
- }
-
- public void createPair(BlockEntityChest chest) {
- this.namedTag.putInt("pairx", (int) chest.x);
- this.namedTag.putInt("pairz", (int) chest.z);
- chest.namedTag.putInt("pairx", (int) this.x);
- chest.namedTag.putInt("pairz", (int) this.z);
- }
-
- public boolean unpair() {
- if (!this.isPaired()) {
- return false;
- }
-
- BlockEntityChest chest = this.getPair();
-
- this.doubleInventory = null;
- this.namedTag.remove("pairx");
- this.namedTag.remove("pairz");
-
- this.spawnToAll();
-
- if (chest != null) {
- chest.namedTag.remove("pairx");
- chest.namedTag.remove("pairz");
- chest.doubleInventory = null;
- chest.checkPairing();
- chest.spawnToAll();
- }
- this.checkPairing();
-
- return true;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag c;
- if (this.isPaired()) {
- c = new CompoundTag()
- .putString("id", BlockEntity.CHEST)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putInt("pairx", this.namedTag.getInt("pairx"))
- .putInt("pairz", this.namedTag.getInt("pairz"));
- } else {
- c = new CompoundTag()
- .putString("id", BlockEntity.CHEST)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- }
-
- if (this.hasName()) {
- c.put("CustomName", this.namedTag.get("CustomName"));
- }
-
- return c;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityComparator.java b/src/main/java/cn/nukkit/blockentity/BlockEntityComparator.java
deleted file mode 100644
index 5409ec524..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityComparator.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.BlockRedstoneComparator;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-/**
- * @author CreeperFace
- */
-public class BlockEntityComparator extends BlockEntity {
-
- private int outputSignal;
-
- public BlockEntityComparator(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
-
- if (!nbt.contains("OutputSignal")) {
- nbt.putInt("OutputSignal", 0);
- }
-
- this.outputSignal = nbt.getInt("OutputSignal");
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.getLevelBlock() instanceof BlockRedstoneComparator;
- }
-
- public int getOutputSignal() {
- return outputSignal;
- }
-
- public void setOutputSignal(int outputSignal) {
- this.outputSignal = outputSignal;
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
- this.namedTag.putInt("OutputSignal", this.outputSignal);
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityContainer.java b/src/main/java/cn/nukkit/blockentity/BlockEntityContainer.java
deleted file mode 100644
index d209dbf11..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityContainer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.item.Item;
-
-/**
- * 表达一个容器的接口。
- * An interface describes a container.
- *
- * {@code BlockEntityContainer}容器必须包含物品的{@code Item}对象。
- * A {@code BlockEntityContainer} must contain items as {@code Item} objects.
- *
- * @author MagicDroidX(code) @ Nukkit Project
- * @author 粉鞋大妈(javadoc) @ Nukkit Project
- * @see BlockEntityChest
- * @see BlockEntityFurnace
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
-public interface BlockEntityContainer {
-
- /**
- * 返回一个存储在容器里的物品的{@code Item}对象。
- * Returns an item that stores in this container, as an {@code Item} object.
- *
- * @param index 这个物品的索引序号。
The index number of this item.
- * @return 这个物品的 {@code Item}对象。
An {@code Item} object for this item.
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- Item getItem(int index);
-
- /**
- * 把一个物品存储进容器。
- * Sets or stores this item into this container.
- *
- * 注意:如果这个容器相应的索引序号已经有了物品,那么新存储的物品将会替换原有的物品。
- * Notice: If there is already an item for this index number, the new item being stored will REPLACE the old one.
- *
- * @param index 这个物品的索引序号。
The index number of this item.
- * @param item 描述这个物品的 {@code Item}对象。
The {@code Item} object that describes this item.
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- void setItem(int index, Item item);
-
- /**
- * 返回这个容器最多能包含的物品数量。
- * Returns the max number of items that this container can contain.
- *
- * @return 最多能包含的物品数量。
The max number.
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- int getSize();
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityDispenser.java b/src/main/java/cn/nukkit/blockentity/BlockEntityDispenser.java
deleted file mode 100644
index 0b30d6189..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityDispenser.java
+++ /dev/null
@@ -1,146 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.inventory.DispenserInventory;
-import cn.nukkit.inventory.InventoryHolder;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-
-/**
- * Created by PetteriM1
- */
-public class BlockEntityDispenser extends BlockEntitySpawnable implements InventoryHolder, BlockEntityContainer, BlockEntityNameable {
-
- protected DispenserInventory inventory;
-
- public BlockEntityDispenser(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- this.inventory = new DispenserInventory(this);
-
- if (!this.namedTag.contains("Items") || !(this.namedTag.get("Items") instanceof ListTag)) {
- this.namedTag.putList(new ListTag("Items"));
- }
-
- for (int i = 0; i < this.getSize(); i++) {
- this.inventory.setItem(i, this.getItem(i));
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.getLevelBlock().getId() == BlockID.DISPENSER;
- }
-
- @Override
- public String getName() {
- return this.hasName() ? this.namedTag.getString("CustomName") : "Dispenser";
- }
-
- @Override
- public boolean hasName() {
- return this.namedTag.contains("CustomName");
- }
-
- @Override
- public void setName(String name) {
- if (name == null || name.isEmpty()) {
- this.namedTag.remove("CustomName");
- return;
- }
-
- this.namedTag.putString("CustomName", name);
- }
-
- @Override
- public int getSize() {
- return 9;
- }
-
- protected int getSlotIndex(int index) {
- ListTag list = this.namedTag.getList("Items", CompoundTag.class);
- for (int i = 0; i < list.size(); i++) {
- if (list.get(i).getByte("Slot") == index) {
- return i;
- }
- }
-
- return -1;
- }
-
- @Override
- public Item getItem(int index) {
- int i = this.getSlotIndex(index);
- if (i < 0) {
- return new ItemBlock(Block.get(BlockID.AIR), 0, 0);
- } else {
- CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i);
- return NBTIO.getItemHelper(data);
- }
- }
-
- @Override
- public void setItem(int index, Item item) {
- int i = this.getSlotIndex(index);
-
- CompoundTag d = NBTIO.putItemHelper(item, index);
-
- if (item.getId() == Item.AIR || item.getCount() <= 0) {
- if (i >= 0) {
- this.namedTag.getList("Items").getAll().remove(i);
- }
- } else if (i < 0) {
- (this.namedTag.getList("Items", CompoundTag.class)).add(d);
- } else {
- (this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
- }
- }
-
- @Override
- public void saveNBT() {
- this.namedTag.putList(new ListTag("Items"));
- for (int index = 0; index < this.getSize(); index++) {
- this.setItem(index, this.inventory.getItem(index));
- }
-
- super.saveNBT();
- }
-
- @Override
- public DispenserInventory getInventory() {
- return inventory;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag c = new CompoundTag()
- .putString("id", BlockEntity.DISPENSER)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (this.hasName()) {
- c.put("CustomName", this.namedTag.get("CustomName"));
- }
-
- return c;
- }
-
- @Override
- public void onBreak() {
- for (Item content : inventory.getContents().values()) {
- level.dropItem(this, content);
- }
- inventory.clearAll();
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityDropper.java b/src/main/java/cn/nukkit/blockentity/BlockEntityDropper.java
deleted file mode 100644
index e4db068ae..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityDropper.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.inventory.DropperInventory;
-import cn.nukkit.inventory.InventoryHolder;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-
-/**
- * Created by PetteriM1
- */
-public class BlockEntityDropper extends BlockEntitySpawnable implements InventoryHolder, BlockEntityContainer, BlockEntityNameable {
-
- protected final DropperInventory inventory;
-
- public BlockEntityDropper(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
-
- this.inventory = new DropperInventory(this);
-
- if (!this.namedTag.contains("Items") || !(this.namedTag.get("Items") instanceof ListTag)) {
- this.namedTag.putList(new ListTag("Items"));
- }
-
- for (int i = 0; i < this.getSize(); i++) {
- this.inventory.setItem(i, this.getItem(i));
- }
-
- this.scheduleUpdate();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.level.getBlockIdAt(chunk, this.getFloorX(), this.getFloorY(), this.getFloorZ()) == Block.DROPPER;
- }
-
- @Override
- public String getName() {
- return this.hasName() ? this.namedTag.getString("CustomName") : "Dropper";
- }
-
- @Override
- public boolean hasName() {
- return this.namedTag.contains("CustomName");
- }
-
- @Override
- public void setName(String name) {
- if (name == null || name.isEmpty()) {
- this.namedTag.remove("CustomName");
- return;
- }
-
- this.namedTag.putString("CustomName", name);
- }
-
- @Override
- public int getSize() {
- return 9;
- }
-
- protected int getSlotIndex(int index) {
- ListTag list = this.namedTag.getList("Items", CompoundTag.class);
- for (int i = 0; i < list.size(); i++) {
- if (list.get(i).getByte("Slot") == index) {
- return i;
- }
- }
-
- return -1;
- }
-
- @Override
- public Item getItem(int index) {
- int i = this.getSlotIndex(index);
- if (i < 0) {
- return new ItemBlock(Block.get(BlockID.AIR), 0, 0);
- } else {
- CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i);
- return NBTIO.getItemHelper(data);
- }
- }
-
- @Override
- public void setItem(int index, Item item) {
- int i = this.getSlotIndex(index);
-
- CompoundTag d = NBTIO.putItemHelper(item, index);
-
- if (item.getId() == Item.AIR || item.getCount() <= 0) {
- if (i >= 0) {
- this.namedTag.getList("Items").getAll().remove(i);
- }
- } else if (i < 0) {
- (this.namedTag.getList("Items", CompoundTag.class)).add(d);
- } else {
- (this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
- }
- }
-
- @Override
- public void saveNBT() {
- this.namedTag.putList(new ListTag("Items"));
- for (int index = 0; index < this.getSize(); index++) {
- this.setItem(index, this.inventory.getItem(index));
- }
- }
-
- @Override
- public DropperInventory getInventory() {
- return inventory;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag c = new CompoundTag()
- .putString("id", BlockEntity.DROPPER)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (this.hasName()) {
- c.put("CustomName", this.namedTag.get("CustomName"));
- }
-
- return c;
- }
-
- @Override
- public void onBreak() {
- for (Item content : inventory.getContents().values()) {
- level.dropItem(this, content);
- }
- inventory.clearAll();
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityEnchantTable.java b/src/main/java/cn/nukkit/blockentity/BlockEntityEnchantTable.java
deleted file mode 100644
index 7d92474f5..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityEnchantTable.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockEntityEnchantTable extends BlockEntitySpawnable implements BlockEntityNameable {
-
- public BlockEntityEnchantTable(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return getBlock().getId() == Block.ENCHANT_TABLE;
- }
-
- @Override
- public String getName() {
- return this.hasName() ? this.namedTag.getString("CustomName") : "Enchanting Table";
- }
-
- @Override
- public boolean hasName() {
- return this.namedTag.contains("CustomName");
- }
-
- @Override
- public void setName(String name) {
- if (name == null || name.isEmpty()) {
- this.namedTag.remove("CustomName");
- return;
- }
-
- this.namedTag.putString("CustomName", name);
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag c = new CompoundTag()
- .putString("id", BlockEntity.ENCHANT_TABLE)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (this.hasName()) {
- c.put("CustomName", this.namedTag.get("CustomName"));
- }
-
- return c;
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityEnderChest.java b/src/main/java/cn/nukkit/blockentity/BlockEntityEnderChest.java
deleted file mode 100644
index ef834c937..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityEnderChest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-public class BlockEntityEnderChest extends BlockEntitySpawnable {
-
- public BlockEntityEnderChest(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.getBlock().getId() == Block.ENDER_CHEST;
- }
-
- @Override
- public String getName() {
- return "EnderChest";
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- return new CompoundTag()
- .putString("id", BlockEntity.ENDER_CHEST)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityFlowerPot.java b/src/main/java/cn/nukkit/blockentity/BlockEntityFlowerPot.java
deleted file mode 100644
index 2f810d372..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityFlowerPot.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-/**
- * Created by Snake1999 on 2016/2/4.
- * Package cn.nukkit.blockentity in project Nukkit.
- */
-public class BlockEntityFlowerPot extends BlockEntitySpawnable {
- public BlockEntityFlowerPot(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (!namedTag.contains("item")) {
- namedTag.putShort("item", 0);
- }
-
- if (!namedTag.contains("data")) {
- if (namedTag.contains("mData")) {
- namedTag.putInt("data", namedTag.getInt("mData"));
- namedTag.remove("mData");
- } else {
- namedTag.putInt("data", 0);
- }
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- int blockID = getBlock().getId();
- return blockID == Block.FLOWER_POT_BLOCK;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag tag = new CompoundTag()
- .putString("id", BlockEntity.FLOWER_POT)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- int item = namedTag.getShort("item");
- if (item != Block.AIR) {
- tag.putShort("item", item)
- .putInt("mData", this.namedTag.getInt("data"));
- }
- return tag;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityFurnace.java b/src/main/java/cn/nukkit/blockentity/BlockEntityFurnace.java
deleted file mode 100644
index 20fa14b1c..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityFurnace.java
+++ /dev/null
@@ -1,355 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.event.inventory.FurnaceBurnEvent;
-import cn.nukkit.event.inventory.FurnaceSmeltEvent;
-import cn.nukkit.inventory.FurnaceInventory;
-import cn.nukkit.inventory.FurnaceRecipe;
-import cn.nukkit.inventory.InventoryHolder;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.network.protocol.ContainerSetDataPacket;
-
-import java.util.HashSet;
-
-/**
- * @author MagicDroidX
- */
-public class BlockEntityFurnace extends BlockEntitySpawnable implements InventoryHolder, BlockEntityContainer, BlockEntityNameable {
-
- protected FurnaceInventory inventory;
-
- private int burnTime;
- private int burnDuration;
- private int cookTime;
- private int maxTime;
-
- public BlockEntityFurnace(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- this.inventory = new FurnaceInventory(this);
-
- if (!this.namedTag.contains("Items") || !(this.namedTag.get("Items") instanceof ListTag)) {
- this.namedTag.putList(new ListTag("Items"));
- }
-
- for (int i = 0; i < this.getSize(); i++) {
- this.inventory.setItem(i, this.getItem(i));
- }
-
- if (!this.namedTag.contains("BurnTime") || this.namedTag.getShort("BurnTime") < 0) {
- burnTime = 0;
- } else {
- burnTime = this.namedTag.getShort("BurnTime");
- }
-
- if (!this.namedTag.contains("CookTime") || this.namedTag.getShort("CookTime") < 0 || (this.namedTag.getShort("BurnTime") == 0 && this.namedTag.getShort("CookTime") > 0)) {
- cookTime = 0;
- } else {
- cookTime = this.namedTag.getShort("CookTime");
- }
-
- if (!this.namedTag.contains("BurnDuration") || this.namedTag.getShort("BurnDuration") < 0) {
- burnDuration = 0;
- } else {
- burnDuration = this.namedTag.getShort("BurnDuration");
- }
-
- if (!this.namedTag.contains("MaxTime")) {
- maxTime = burnTime;
- burnDuration = 0;
- } else {
- maxTime = this.namedTag.getShort("MaxTime");
- }
-
- if (this.namedTag.contains("BurnTicks")) {
- burnDuration = this.namedTag.getShort("BurnTicks");
- this.namedTag.remove("BurnTicks");
- }
-
- if (burnTime > 0) {
- this.scheduleUpdate();
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public String getName() {
- return this.hasName() ? this.namedTag.getString("CustomName") : "Furnace";
- }
-
- @Override
- public boolean hasName() {
- return this.namedTag.contains("CustomName");
- }
-
- @Override
- public void setName(String name) {
- if (name == null || name.isEmpty()) {
- this.namedTag.remove("CustomName");
- return;
- }
-
- this.namedTag.putString("CustomName", name);
- }
-
- @Override
- public void close() {
- if (!closed) {
- for (Player player : new HashSet<>(this.inventory.getViewers())) {
- player.removeWindow(this.inventory);
- }
-
- super.close();
- }
- }
-
- @Override
- public void onBreak() {
- for (Item content : inventory.getContents().values()) {
- level.dropItem(this, content);
- }
- inventory.clearAll();
- }
-
- @Override
- public void saveNBT() {
- this.namedTag.putList(new ListTag("Items"));
- for (int index = 0; index < this.getSize(); index++) {
- this.setItem(index, this.inventory.getItem(index));
- }
-
- this.namedTag.putShort("CookTime", cookTime);
- this.namedTag.putShort("BurnTime", burnTime);
- this.namedTag.putShort("BurnDuration", burnDuration);
- this.namedTag.putShort("MaxTime", maxTime);
- }
-
- @Override
- public boolean isBlockEntityValid() {
- int blockID = getBlock().getId();
- return blockID == Block.FURNACE || blockID == Block.BURNING_FURNACE;
- }
-
- @Override
- public int getSize() {
- return 3;
- }
-
- protected int getSlotIndex(int index) {
- ListTag list = this.namedTag.getList("Items", CompoundTag.class);
- for (int i = 0; i < list.size(); i++) {
- if (list.get(i).getByte("Slot") == index) {
- return i;
- }
- }
-
- return -1;
- }
-
- @Override
- public Item getItem(int index) {
- int i = this.getSlotIndex(index);
- if (i < 0) {
- return new ItemBlock(Block.get(BlockID.AIR), 0, 0);
- } else {
- CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i);
- return NBTIO.getItemHelper(data);
- }
- }
-
- @Override
- public void setItem(int index, Item item) {
- int i = this.getSlotIndex(index);
-
- CompoundTag d = NBTIO.putItemHelper(item, index);
-
- if (item.getId() == Item.AIR || item.getCount() <= 0) {
- if (i >= 0) {
- this.namedTag.getList("Items").getAll().remove(i);
- }
- } else if (i < 0) {
- (this.namedTag.getList("Items", CompoundTag.class)).add(d);
- } else {
- (this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
- }
- }
-
- @Override
- public FurnaceInventory getInventory() {
- return inventory;
- }
-
- protected void checkFuel(Item fuel) {
- FurnaceBurnEvent ev = new FurnaceBurnEvent(this, fuel, fuel.getFuelTime() == null ? 0 : fuel.getFuelTime());
-
- this.server.getPluginManager().callEvent(ev);
-
- if (ev.isCancelled()) {
- return;
- }
-
- maxTime = ev.getBurnTime();
- burnTime = ev.getBurnTime();
- burnDuration = 0;
- if (this.getBlock().getId() == Item.FURNACE) {
- this.getLevel().setBlock(this, Block.get(BlockID.BURNING_FURNACE, this.getBlock().getDamage()), true);
- }
-
- if (burnTime > 0 && ev.isBurning()) {
- fuel.setCount(fuel.getCount() - 1);
- if (fuel.getCount() == 0) {
- if (fuel.getId() == Item.BUCKET && fuel.getDamage() == 10) {
- fuel.setDamage(0);
- fuel.setCount(1);
- } else {
- fuel = new ItemBlock(Block.get(BlockID.AIR), 0, 0);
- }
- }
- this.inventory.setFuel(fuel);
- }
- }
-
- @Override
- public boolean onUpdate() {
- if (this.closed) {
- return false;
- }
-
- if (this.timing != null) this.timing.startTiming();
-
- boolean ret = false;
- Item fuel = this.inventory.getFuel();
- Item raw = this.inventory.getSmelting();
- Item product = this.inventory.getResult();
- FurnaceRecipe smelt = this.server.getCraftingManager().matchFurnaceRecipe(raw);
- boolean canSmelt = (smelt != null && raw.getCount() > 0 && ((smelt.getResult().equals(product, true) && product.getCount() < product.getMaxStackSize()) || product.getId() == Item.AIR));
-
- if (burnTime <= 0 && canSmelt && fuel.getFuelTime() != null && fuel.getCount() > 0) {
- this.checkFuel(fuel);
- }
-
- if (burnTime > 0) {
- burnTime--;
- burnDuration = (int) Math.ceil((float) burnTime / maxTime * 200);
-
- if (smelt != null && canSmelt) {
- cookTime++;
- if (cookTime >= 200) {
- product = Item.get(smelt.getResult().getId(), smelt.getResult().getDamage(), product.getCount() + 1);
-
- FurnaceSmeltEvent ev = new FurnaceSmeltEvent(this, raw, product);
- this.server.getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- this.inventory.setResult(ev.getResult());
- raw.setCount(raw.getCount() - 1);
- if (raw.getCount() == 0) {
- raw = new ItemBlock(Block.get(BlockID.AIR), 0, 0);
- }
- this.inventory.setSmelting(raw);
- }
-
- cookTime -= 200;
- }
- } else if (burnTime <= 0) {
- burnTime = 0;
- cookTime = 0;
- burnDuration = 0;
- } else {
- cookTime = 0;
- }
- ret = true;
- } else {
- if (this.getBlock().getId() == Item.BURNING_FURNACE) {
- this.getLevel().setBlock(this, Block.get(BlockID.FURNACE, this.getBlock().getDamage()), true);
- }
- burnTime = 0;
- cookTime = 0;
- burnDuration = 0;
- }
-
- if (Server.getInstance().getTick() % 4 == 0) {
- for (Player player : this.inventory.getViewers()) {
- int windowId = player.getWindowId(this.inventory);
- if (windowId > 0) {
- ContainerSetDataPacket pk = new ContainerSetDataPacket();
- pk.windowId = windowId;
- pk.property = ContainerSetDataPacket.PROPERTY_FURNACE_TICK_COUNT;
- pk.value = cookTime;
- player.dataPacket(pk);
-
- pk = new ContainerSetDataPacket();
- pk.windowId = windowId;
- pk.property = ContainerSetDataPacket.PROPERTY_FURNACE_LIT_TIME;
- pk.value = burnDuration;
- player.dataPacket(pk);
- }
- }
- }
-
- if (this.timing != null) this.timing.stopTiming();
-
- return ret;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag c = new CompoundTag()
- .putString("id", BlockEntity.FURNACE)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putShort("BurnDuration", burnDuration)
- .putShort("BurnTime", burnTime)
- .putShort("CookTime", cookTime);
-
- if (this.hasName()) {
- c.put("CustomName", this.namedTag.get("CustomName"));
- }
-
- return c;
- }
-
- public int getBurnTime() {
- return burnTime;
- }
-
- public void setBurnTime(int burnTime) {
- this.burnTime = burnTime;
- }
-
- public int getBurnDuration() {
- return burnDuration;
- }
-
- public void setBurnDuration(int burnDuration) {
- this.burnDuration = burnDuration;
- }
-
- public int getCookTime() {
- return cookTime;
- }
-
- public void setCookTime(int cookTime) {
- this.cookTime = cookTime;
- }
-
- public int getMaxTime() {
- return maxTime;
- }
-
- public void setMaxTime(int maxTime) {
- this.maxTime = maxTime;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityHopper.java b/src/main/java/cn/nukkit/blockentity/BlockEntityHopper.java
deleted file mode 100644
index dc79e2001..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityHopper.java
+++ /dev/null
@@ -1,459 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.item.EntityItem;
-import cn.nukkit.event.inventory.InventoryMoveItemEvent;
-import cn.nukkit.inventory.*;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-
-import java.util.HashSet;
-
-/**
- * Created by CreeperFace on 8.5.2017.
- */
-public class BlockEntityHopper extends BlockEntitySpawnable implements InventoryHolder, BlockEntityContainer, BlockEntityNameable {
-
- protected HopperInventory inventory;
-
- public int transferCooldown;
-
- private AxisAlignedBB pickupArea;
-
- public BlockEntityHopper(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (this.namedTag.contains("TransferCooldown")) {
- this.transferCooldown = this.namedTag.getInt("TransferCooldown");
- } else {
- this.transferCooldown = 8;
- }
-
- this.inventory = new HopperInventory(this);
-
- if (!this.namedTag.contains("Items") || !(this.namedTag.get("Items") instanceof ListTag)) {
- this.namedTag.putList(new ListTag("Items"));
- }
-
- for (int i = 0; i < this.getSize(); i++) {
- this.inventory.setItem(i, this.getItem(i));
- }
-
- this.pickupArea = new AxisAlignedBB(this.x, this.y, this.z, this.x + 1, this.y + 2, this.z + 1);
-
- this.scheduleUpdate();
-
- super.initBlockEntity();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.level.getBlockIdAt(chunk, this.getFloorX(), this.getFloorY(), this.getFloorZ()) == Block.HOPPER_BLOCK;
- }
-
- @Override
- public String getName() {
- return this.hasName() ? this.namedTag.getString("CustomName") : "Hopper";
- }
-
- @Override
- public boolean hasName() {
- return this.namedTag.contains("CustomName");
- }
-
- @Override
- public void setName(String name) {
- if (name == null || name.isEmpty()) {
- this.namedTag.remove("CustomName");
- return;
- }
-
- this.namedTag.putString("CustomName", name);
- }
-
- public boolean isOnTransferCooldown() {
- return this.transferCooldown > 0;
- }
-
- public void setTransferCooldown(int transferCooldown) {
- this.transferCooldown = transferCooldown;
- }
-
- @Override
- public int getSize() {
- return 5;
- }
-
- protected int getSlotIndex(int index) {
- ListTag list = this.namedTag.getList("Items", CompoundTag.class);
- for (int i = 0; i < list.size(); i++) {
- if (list.get(i).getByte("Slot") == index) {
- return i;
- }
- }
-
- return -1;
- }
-
- @Override
- public Item getItem(int index) {
- int i = this.getSlotIndex(index);
- if (i < 0) {
- return new ItemBlock(Block.get(BlockID.AIR), 0, 0);
- } else {
- CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i);
- return NBTIO.getItemHelper(data);
- }
- }
-
- @Override
- public void setItem(int index, Item item) {
- int i = this.getSlotIndex(index);
-
- CompoundTag d = NBTIO.putItemHelper(item, index);
-
- if (item.getId() == Item.AIR || item.getCount() <= 0) {
- if (i >= 0) {
- this.namedTag.getList("Items").getAll().remove(i);
- }
- } else if (i < 0) {
- (this.namedTag.getList("Items", CompoundTag.class)).add(d);
- } else {
- (this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
- }
- }
-
- @Override
- public void saveNBT() {
- this.namedTag.putList(new ListTag("Items"));
- for (int index = 0; index < this.getSize(); index++) {
- this.setItem(index, this.inventory.getItem(index));
- }
-
- this.namedTag.putInt("TransferCooldown", this.transferCooldown);
- }
-
- @Override
- public HopperInventory getInventory() {
- return inventory;
- }
-
- @Override
- public boolean onUpdate() {
- if (this.closed) {
- return false;
- }
-
- this.transferCooldown--;
-
- if (!this.isOnTransferCooldown()) {
- if (this.level.isBlockPowered(getBlock())) {
- return true;
- }
-
- boolean changed = pushItems();
-
- if (!changed) {
- BlockEntity blockEntity = this.level.getBlockEntity(this.up());
- if (!(blockEntity instanceof BlockEntityContainer)) {
- changed = pickupItems();
- } else {
- changed = pullItems();
- }
- }
-
- if (changed) {
- this.setTransferCooldown(8);
- setDirty();
- }
- }
-
-
- return true;
- }
-
- public boolean pullItems() {
- if (this.inventory.isFull()) {
- return false;
- }
-
- BlockEntity blockEntity = this.level.getBlockEntity(this.up());
- if (blockEntity instanceof BlockEntityFurnace) {
- FurnaceInventory inv = ((BlockEntityFurnace) blockEntity).getInventory();
- Item item = inv.getResult();
-
- if (!item.isNull()) {
- Item itemToAdd = item.clone();
- itemToAdd.count = 1;
-
- if (!this.inventory.canAddItem(itemToAdd)) {
- return false;
- }
-
- InventoryMoveItemEvent ev = new InventoryMoveItemEvent(inv, this.inventory, this, itemToAdd, InventoryMoveItemEvent.Action.SLOT_CHANGE);
- this.server.getPluginManager().callEvent(ev);
-
- if (ev.isCancelled()) {
- return false;
- }
-
- Item[] items = this.inventory.addItem(itemToAdd);
-
- if (items.length <= 0) {
- item.count--;
- inv.setResult(item);
- return true;
- }
- }
- } else if (blockEntity instanceof InventoryHolder) {
- Inventory inv = ((InventoryHolder) blockEntity).getInventory();
-
- for (int i = 0; i < inv.getSize(); i++) {
- Item item = inv.getItem(i);
-
- if (!item.isNull()) {
- Item itemToAdd = item.clone();
- itemToAdd.count = 1;
-
- if (!this.inventory.canAddItem(itemToAdd)) {
- continue;
- }
-
- InventoryMoveItemEvent ev = new InventoryMoveItemEvent(inv, this.inventory, this, itemToAdd, InventoryMoveItemEvent.Action.SLOT_CHANGE);
- this.server.getPluginManager().callEvent(ev);
-
- if (ev.isCancelled()) {
- continue;
- }
-
- Item[] items = this.inventory.addItem(itemToAdd);
-
- if (items.length >= 1) {
- continue;
- }
-
- item.count--;
-
- inv.setItem(i, item);
- return true;
- }
- }
- }
- return false;
- }
-
- public boolean pickupItems() {
- if (this.inventory.isFull()) {
- return false;
- }
-
- boolean pickedUpItem = false;
-
- for (Entity entity : this.level.getCollidingEntities(this.pickupArea)) {
- if (entity.isClosed() || !(entity instanceof EntityItem)) {
- continue;
- }
-
- EntityItem itemEntity = (EntityItem) entity;
- Item item = itemEntity.getItem();
-
- if (item.isNull()) {
- continue;
- }
-
- int originalCount = item.getCount();
-
- if (!this.inventory.canAddItem(item)) {
- continue;
- }
-
- InventoryMoveItemEvent ev = new InventoryMoveItemEvent(null, this.inventory, this, item, InventoryMoveItemEvent.Action.PICKUP);
- this.server.getPluginManager().callEvent(ev);
-
- if (ev.isCancelled()) {
- continue;
- }
-
- Item[] items = this.inventory.addItem(item);
-
- if (items.length == 0) {
- entity.close();
- pickedUpItem = true;
- continue;
- }
-
- if (items[0].getCount() != originalCount) {
- pickedUpItem = true;
- item.setCount(items[0].getCount());
- }
- }
-
- return pickedUpItem;
- }
-
- @Override
- public void close() {
- if (!closed) {
- for (Player player : new HashSet<>(this.inventory.getViewers())) {
- player.removeWindow(this.inventory);
- }
- super.close();
- }
- }
-
- @Override
- public void onBreak() {
- for (Item content : inventory.getContents().values()) {
- level.dropItem(this, content);
- }
- inventory.clearAll();
- }
-
- public boolean pushItems() {
- if (this.inventory.isEmpty()) {
- return false;
- }
-
- BlockEntity be = this.level.getBlockEntity(this.getSide(BlockFace.fromIndex(this.level.getBlockDataAt(this.getFloorX(), this.getFloorY(), this.getFloorZ()))));
-
- if (be instanceof BlockEntityHopper && this.getBlock().getDamage() == 0 || !(be instanceof InventoryHolder))
- return false;
-
- InventoryMoveItemEvent event;
-
- if (be instanceof BlockEntityFurnace) {
- BlockEntityFurnace furnace = (BlockEntityFurnace) be;
- FurnaceInventory inventory = furnace.getInventory();
- if (inventory.isFull()) {
- return false;
- }
-
- boolean pushedItem = false;
-
- for (int i = 0; i < this.inventory.getSize(); i++) {
- Item item = this.inventory.getItem(i);
- if (!item.isNull()) {
- Item itemToAdd = item.clone();
- itemToAdd.setCount(1);
-
- if (this.getBlock().getDamage() == 0) {
- Item smelting = inventory.getSmelting();
- if (smelting.isNull()) {
- event = new InventoryMoveItemEvent(this.inventory, inventory, this, itemToAdd, InventoryMoveItemEvent.Action.SLOT_CHANGE);
- this.server.getPluginManager().callEvent(event);
-
- if (!event.isCancelled()) {
- inventory.setSmelting(itemToAdd);
- item.count--;
- pushedItem = true;
- }
- } else if (inventory.getSmelting().getId() == itemToAdd.getId() && inventory.getSmelting().getDamage() == itemToAdd.getDamage() && smelting.count < smelting.getMaxStackSize()) {
- event = new InventoryMoveItemEvent(this.inventory, inventory, this, itemToAdd, InventoryMoveItemEvent.Action.SLOT_CHANGE);
- this.server.getPluginManager().callEvent(event);
-
- if (!event.isCancelled()) {
- smelting.count++;
- inventory.setSmelting(smelting);
- item.count--;
- pushedItem = true;
- }
- }
- } else if (Fuel.duration.containsKey(itemToAdd.getId())) {
- Item fuel = inventory.getFuel();
- if (fuel.isNull()) {
- event = new InventoryMoveItemEvent(this.inventory, inventory, this, itemToAdd, InventoryMoveItemEvent.Action.SLOT_CHANGE);
- this.server.getPluginManager().callEvent(event);
-
- if (!event.isCancelled()) {
- inventory.setFuel(itemToAdd);
- item.count--;
- pushedItem = true;
- }
- } else if (fuel.getId() == itemToAdd.getId() && fuel.getDamage() == itemToAdd.getDamage() && fuel.count < fuel.getMaxStackSize()) {
- event = new InventoryMoveItemEvent(this.inventory, inventory, this, itemToAdd, InventoryMoveItemEvent.Action.SLOT_CHANGE);
- this.server.getPluginManager().callEvent(event);
-
- if (!event.isCancelled()) {
- fuel.count++;
- inventory.setFuel(fuel);
- item.count--;
- pushedItem = true;
- }
- }
- }
-
- if (pushedItem) {
- this.inventory.setItem(i, item);
- }
- }
- }
-
- return pushedItem;
- } else {
- Inventory inventory = ((InventoryHolder) be).getInventory();
-
- if (inventory.isFull()) {
- return false;
- }
-
- for (int i = 0; i < this.inventory.getSize(); i++) {
- Item item = this.inventory.getItem(i);
-
- if (!item.isNull()) {
- Item itemToAdd = item.clone();
- itemToAdd.setCount(1);
-
- if (!inventory.canAddItem(itemToAdd)) {
- continue;
- }
-
- InventoryMoveItemEvent ev = new InventoryMoveItemEvent(this.inventory, inventory, this, itemToAdd, InventoryMoveItemEvent.Action.SLOT_CHANGE);
- this.server.getPluginManager().callEvent(ev);
-
- if (ev.isCancelled()) {
- continue;
- }
-
- Item[] items = inventory.addItem(itemToAdd);
-
- if (items.length > 0) {
- continue;
- }
-
- item.count--;
- this.inventory.setItem(i, item);
- return true;
- }
- }
- }
-
- return false;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag c = new CompoundTag()
- .putString("id", BlockEntity.HOPPER)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (this.hasName()) {
- c.put("CustomName", this.namedTag.get("CustomName"));
- }
-
- return c;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityItemFrame.java b/src/main/java/cn/nukkit/blockentity/BlockEntityItemFrame.java
deleted file mode 100644
index 306434270..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityItemFrame.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.event.block.ItemFrameDropItemEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.network.protocol.LevelEventPacket;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * Created by Pub4Game on 03.07.2016.
- */
-public class BlockEntityItemFrame extends BlockEntitySpawnable {
-
- private Item item_;
-
- public BlockEntityItemFrame(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (!namedTag.contains("Item")) {
- namedTag.putCompound("Item", NBTIO.putItemHelper(item_ = new ItemBlock(Block.get(BlockID.AIR))));
- }
-
- if (!namedTag.contains("ItemRotation")) {
- namedTag.putByte("ItemRotation", 0);
- }
-
- if (!namedTag.contains("ItemDropChance")) {
- namedTag.putFloat("ItemDropChance", 1.0f);
- }
-
- this.level.updateComparatorOutputLevel(this);
-
- super.initBlockEntity();
- }
-
- @Override
- public String getName() {
- return "Item Frame";
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.getBlock().getId() == Block.ITEM_FRAME_BLOCK;
- }
-
- public int getItemRotation() {
- return this.namedTag.getByte("ItemRotation");
- }
-
- public void setItemRotation(int itemRotation) {
- this.namedTag.putByte("ItemRotation", itemRotation);
- this.level.updateComparatorOutputLevel(this);
- this.setDirty();
- }
-
- public Item getItem() {
- if (item_ == null) {
- CompoundTag NBTTag = this.namedTag.getCompound("Item");
- item_ = NBTIO.getItemHelper(NBTTag);
- }
- return item_;
- }
-
- public void setItem(Item item) {
- this.setItem(item, true);
- }
-
- public void setItem(Item item, boolean setChanged) {
- item_ = null;
- this.namedTag.putCompound("Item", NBTIO.putItemHelper(item));
- if (setChanged) {
- this.setDirty();
- }
-
- this.level.updateComparatorOutputLevel(this);
- }
-
- public float getItemDropChance() {
- return this.namedTag.getFloat("ItemDropChance");
- }
-
- public void setItemDropChance(float chance) {
- this.namedTag.putFloat("ItemDropChance", chance);
- }
-
- public void setDirty() {
- this.spawnToAll();
- super.setDirty();
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- if (!this.namedTag.contains("Item")) {
- this.setItem(new ItemBlock(Block.get(BlockID.AIR)), false);
- }
-
- CompoundTag item = namedTag.getCompound("Item").copy();
- item.setName("Item");
- CompoundTag tag = new CompoundTag()
- .putString("id", BlockEntity.ITEM_FRAME)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
-
- if (item.getShort("id") != Item.AIR) {
- tag.putCompound("Item", item)
- .putByte("ItemRotation", this.getItemRotation());
- }
- return tag;
- }
-
- public int getAnalogOutput() {
- return this.getItem() == null || this.getItem().getId() == 0 ? 0 : this.getItemRotation() % 8 + 1;
- }
-
- public boolean dropItem(Player player) {
- Item item = this.getItem();
- if (item != null && item.getId() != Item.AIR) {
- if (player != null) {
- ItemFrameDropItemEvent event = new ItemFrameDropItemEvent(player, this.getBlock(), this, item);
- this.level.getServer().getPluginManager().callEvent(event);
- if (event.isCancelled()) {
- this.spawnTo(player);
- return true;
- }
- }
- this.setItem(Item.get(Item.AIR));
- this.setItemRotation(0);
- if (this.getItemDropChance() > ThreadLocalRandom.current().nextFloat()) {
- this.level.dropItem(this.add(0.5, 0, 0.5), item);
- }
- this.level.addLevelEvent(this, LevelEventPacket.EVENT_SOUND_ITEM_FRAME_ITEM_REMOVED);
- return true;
- }
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityJukebox.java b/src/main/java/cn/nukkit/blockentity/BlockEntityJukebox.java
deleted file mode 100644
index 73157e8cb..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityJukebox.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemRecord;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.network.protocol.LevelSoundEventPacket;
-
-import java.util.Objects;
-
-/**
- * @author CreeperFace
- */
-public class BlockEntityJukebox extends BlockEntitySpawnable {
-
- private Item recordItem;
-
- public BlockEntityJukebox(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (namedTag.contains("RecordItem")) {
- this.recordItem = NBTIO.getItemHelper(namedTag.getCompound("RecordItem"));
- } else {
- this.recordItem = Item.get(0);
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.getLevel().getBlockIdAt(chunk, getFloorX(), getFloorY(), getFloorZ()) == Block.JUKEBOX;
- }
-
- public void setRecordItem(Item recordItem) {
- Objects.requireNonNull(recordItem, "Record item cannot be null");
- this.recordItem = recordItem;
- }
-
- public Item getRecordItem() {
- return recordItem;
- }
-
- public void play() {
- if (this.recordItem instanceof ItemRecord) {
- switch (this.recordItem.getId()) {
- case Item.RECORD_13:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_13);
- break;
- case Item.RECORD_CAT:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_CAT);
- break;
- case Item.RECORD_BLOCKS:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_BLOCKS);
- break;
- case Item.RECORD_CHIRP:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_CHIRP);
- break;
- case Item.RECORD_FAR:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_FAR);
- break;
- case Item.RECORD_MALL:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_MALL);
- break;
- case Item.RECORD_MELLOHI:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_MELLOHI);
- break;
- case Item.RECORD_STAL:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_STAL);
- break;
- case Item.RECORD_STRAD:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_STRAD);
- break;
- case Item.RECORD_WARD:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_WARD);
- break;
- case Item.RECORD_11:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_11);
- break;
- case Item.RECORD_WAIT:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_WAIT);
- break;
- case Item.RECORD_PIGSTEP:
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_RECORD_PIGSTEP);
- break;
- }
- }
- }
-
- public void stop() {
- this.getLevel().addLevelSoundEvent(this, LevelSoundEventPacket.SOUND_STOP_RECORD);
- }
-
- public void dropItem() {
- if (this.recordItem.getId() != 0) {
- stop();
- this.level.dropItem(this.up(), this.recordItem);
- this.recordItem = Item.get(0);
- }
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
- this.namedTag.putCompound("RecordItem", NBTIO.putItemHelper(this.recordItem));
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- return getDefaultCompound(this, JUKEBOX)
- .putCompound("RecordItem", NBTIO.putItemHelper(this.recordItem));
- }
-
- @Override
- public void onBreak() {
- this.dropItem();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityMovingBlock.java b/src/main/java/cn/nukkit/blockentity/BlockEntityMovingBlock.java
deleted file mode 100644
index 1d23842ac..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityMovingBlock.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.math.BlockVector3;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-/**
- * Created by CreeperFace on 11.4.2017.
- */
-public class BlockEntityMovingBlock extends BlockEntitySpawnable {
-
- public Block block;
-
- public BlockVector3 piston;
- public int progress;
-
- public BlockEntityMovingBlock(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (namedTag.contains("movingBlockData") && namedTag.contains("movingBlockId")) {
- this.block = Block.get(namedTag.getInt("movingBlockId"), namedTag.getInt("movingBlockData"));
- } else {
- this.close();
- }
-
- if (namedTag.contains("pistonPosX") && namedTag.contains("pistonPosY") && namedTag.contains("pistonPosZ")) {
- this.piston = new BlockVector3(namedTag.getInt("pistonPosX"), namedTag.getInt("pistonPosY"), namedTag.getInt("pistonPosZ"));
- } else {
- this.close();
- }
-
- super.initBlockEntity();
- }
-
- public Block getBlock() {
- return this.block;
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return true;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- return getDefaultCompound(this, MOVING_BLOCK)
- .putFloat("movingBlockId", this.block.getId())
- .putFloat("movingBlockData", this.block.getDamage())
- .putInt("pistonPosX", this.piston.x)
- .putInt("pistonPosY", this.piston.y)
- .putInt("pistonPosZ", this.piston.z);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityMusic.java b/src/main/java/cn/nukkit/blockentity/BlockEntityMusic.java
deleted file mode 100644
index 336943f0c..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityMusic.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-public class BlockEntityMusic extends BlockEntity {
-
- public BlockEntityMusic(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (!this.namedTag.contains("note")) {
- this.namedTag.putByte("note", 0);
- }
-
- if (!this.namedTag.contains("powered")) {
- this.namedTag.putBoolean("note", false);
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.getBlock().getId() == Block.NOTEBLOCK;
- }
-
- public void changePitch() {
- this.namedTag.putByte("note", (this.namedTag.getByte("note") + 1) % 25);
- }
-
- public int getPitch() {
- return this.namedTag.getByte("note");
- }
-
- public void setPowered(boolean powered) {
- this.namedTag.putBoolean("powered", powered);
- }
-
- public boolean isPowered() {
- return this.namedTag.getBoolean("powered");
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityNameable.java b/src/main/java/cn/nukkit/blockentity/BlockEntityNameable.java
deleted file mode 100644
index e7bea12b7..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityNameable.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package cn.nukkit.blockentity;
-
-/**
- * 表达一个能被命名的事物的接口。
- * An interface describes an object that can be named.
- *
- * @author MagicDroidX(code) @ Nukkit Project
- * @author 粉鞋大妈(javadoc) @ Nukkit Project
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
-public interface BlockEntityNameable {
-
- /**
- * 返回这个事物的名字。
- * Gets the name of this object.
- *
- * @return 这个事物的名字。
The name of this object.
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- String getName();
-
- /**
- * 设置或更改这个事物的名字。
- * Changes the name of this object, or names it.
- *
- * @param name 这个事物的新名字。
The new name of this object.
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- void setName(String name);
-
- /**
- * 返回这个事物是否有名字。
- * Whether this object has a name.
- *
- * @return 如果有名字,返回 {@code true}。
{@code true} for this object has a name.
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- boolean hasName();
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityPistonArm.java b/src/main/java/cn/nukkit/blockentity/BlockEntityPistonArm.java
deleted file mode 100644
index e19d0a096..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityPistonArm.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.IntTag;
-import cn.nukkit.nbt.tag.ListTag;
-
-/**
- * @author CreeperFace
- */
-public class BlockEntityPistonArm extends BlockEntitySpawnable {
-
- public float progress;
- public float lastProgress;
- public BlockFace facing;
- public boolean extending = false;
- public boolean sticky = false;
- public byte state;
- public byte newState = 1;
- public Vector3 attachedBlock = null;
- public boolean isMovable = true;
- public boolean powered = false;
-
- public BlockEntityPistonArm(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- this.isMovable = true;
-
- if (namedTag.contains("Progress")) {
- this.progress = namedTag.getFloat("Progress");
- }
-
- if (namedTag.contains("LastProgress")) {
- this.lastProgress = (float) namedTag.getInt("LastProgress");
- }
-
- if (namedTag.contains("Sticky")) {
- this.sticky = namedTag.getBoolean("Sticky");
- }
-
- if (namedTag.contains("Extending")) {
- this.extending = namedTag.getBoolean("Extending");
- }
-
- if (namedTag.contains("powered")) {
- this.powered = namedTag.getBoolean("powered");
- }
-
- if (namedTag.contains("AttachedBlocks")) {
- ListTag blocks = namedTag.getList("AttachedBlocks", IntTag.class);
- if (blocks != null && blocks.size() > 0) {
- this.attachedBlock = new Vector3((double) ((IntTag) blocks.get(0)).getData(), (double) ((IntTag) blocks.get(1)).getData(), (double) ((IntTag) blocks.get(2)).getData());
- }
- } else {
- namedTag.putList(new ListTag("AttachedBlocks"));
- }
-
- super.initBlockEntity();
- }
-
- public boolean isBlockEntityValid() {
- int blockId = getBlock().getId();
- return blockId == Block.PISTON || blockId == Block.STICKY_PISTON;
- }
-
- public void saveNBT() {
- super.saveNBT();
- this.namedTag.putBoolean("isMovable", this.isMovable);
- this.namedTag.putByte("State", this.state);
- this.namedTag.putByte("NewState", this.newState);
- this.namedTag.putFloat("Progress", this.progress);
- this.namedTag.putFloat("LastProgress", this.lastProgress);
- this.namedTag.putBoolean("powered", this.powered);
- }
-
- public CompoundTag getSpawnCompound() {
- return new CompoundTag()
- .putString("id", BlockEntity.PISTON_ARM)
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .putFloat("Progress", this.progress)
- .putFloat("LastProgress", this.lastProgress)
- .putBoolean("Sticky", this.sticky)
- .putByte("State", this.state)
- .putByte("NewState", this.newState);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntityShulkerBox.java b/src/main/java/cn/nukkit/blockentity/BlockEntityShulkerBox.java
deleted file mode 100644
index 34f49cad2..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntityShulkerBox.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.inventory.BaseInventory;
-import cn.nukkit.inventory.InventoryHolder;
-import cn.nukkit.inventory.ShulkerBoxInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBlock;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-
-import java.util.HashSet;
-
-public class BlockEntityShulkerBox extends BlockEntitySpawnable implements InventoryHolder, BlockEntityContainer, BlockEntityNameable {
-
- protected ShulkerBoxInventory inventory;
-
- public BlockEntityShulkerBox(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- this.inventory = new ShulkerBoxInventory(this);
-
- if (!this.namedTag.contains("Items") || !(this.namedTag.get("Items") instanceof ListTag)) {
- this.namedTag.putList(new ListTag("Items"));
- }
-
- ListTag list = (ListTag) this.namedTag.getList("Items");
- for (CompoundTag compound : list.getAll()) {
- Item item = NBTIO.getItemHelper(compound);
- this.inventory.slots.put(compound.getByte("Slot"), item);
- }
-
- if (!this.namedTag.contains("facing")) {
- this.namedTag.putByte("facing", 0);
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public void close() {
- if (!closed) {
- for (Player player : new HashSet<>(this.getInventory().getViewers())) {
- player.removeWindow(this.getInventory());
- }
- this.inventory.destroyed = true;
- super.close();
- }
- }
-
- @Override
- public void saveNBT() {
- this.namedTag.putList(new ListTag("Items"));
- for (int index = 0; index < this.getSize(); index++) {
- this.setItem(index, this.inventory.getItem(index));
- }
- }
-
- @Override
- public boolean isBlockEntityValid() {
- int blockID = this.getBlock().getId();
- return blockID == Block.SHULKER_BOX || blockID == Block.UNDYED_SHULKER_BOX;
- }
-
- @Override
- public int getSize() {
- return 27;
- }
-
- protected int getSlotIndex(int index) {
- ListTag list = this.namedTag.getList("Items", CompoundTag.class);
- for (int i = 0; i < list.size(); i++) {
- if (list.get(i).getByte("Slot") == index) {
- return i;
- }
- }
-
- return -1;
- }
-
- @Override
- public Item getItem(int index) {
- int i = this.getSlotIndex(index);
- if (i < 0) {
- return new ItemBlock(Block.get(BlockID.AIR), 0, 0);
- } else {
- CompoundTag data = (CompoundTag) this.namedTag.getList("Items").get(i);
- return NBTIO.getItemHelper(data);
- }
- }
-
- @Override
- public void setItem(int index, Item item) {
- int i = this.getSlotIndex(index);
-
- CompoundTag d = NBTIO.putItemHelper(item, index);
-
- if (item.getId() == Item.AIR || item.getCount() <= 0) {
- if (i >= 0) {
- this.namedTag.getList("Items").remove(i);
- }
- } else if (i < 0) {
- (this.namedTag.getList("Items", CompoundTag.class)).add(d);
- } else {
- (this.namedTag.getList("Items", CompoundTag.class)).add(i, d);
- }
- }
-
- @Override
- public BaseInventory getInventory() {
- return this.inventory;
- }
-
- public ShulkerBoxInventory getRealInventory() {
- return inventory;
- }
-
- @Override
- public String getName() {
- return this.hasName() ? this.namedTag.getString("CustomName") : "Shulker Box";
- }
-
- @Override
- public boolean hasName() {
- return this.namedTag.contains("CustomName");
- }
-
- @Override
- public void setName(String name) {
- if (name == null || name.isEmpty()) {
- this.namedTag.remove("CustomName");
- return;
- }
-
- this.namedTag.putString("CustomName", name);
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- CompoundTag c = getDefaultCompound(this, SHULKER_BOX)
- .putByte("facing", this.namedTag.getByte("facing"));
-
- if (this.hasName()) {
- c.put("CustomName", this.namedTag.get("CustomName"));
- }
-
- return c;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntitySign.java b/src/main/java/cn/nukkit/blockentity/BlockEntitySign.java
deleted file mode 100644
index f77be69b7..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntitySign.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.event.block.SignChangeEvent;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.utils.TextFormat;
-
-import java.util.Arrays;
-import java.util.Objects;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BlockEntitySign extends BlockEntitySpawnable {
-
- private String[] text;
-
- public BlockEntitySign(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- text = new String[4];
-
- if (!namedTag.contains("Text")) {
-
- for (int i = 1; i <= 4; i++) {
- String key = "Text" + i;
-
- if (namedTag.contains(key)) {
- String line = namedTag.getString(key);
-
- this.text[i - 1] = line;
-
- this.namedTag.remove(key);
- }
- }
- } else {
- String[] lines = namedTag.getString("Text").split("\n", 4);
-
- for (int i = 0; i < text.length; i++) {
- if (i < lines.length)
- text[i] = lines[i];
- else
- text[i] = "";
- }
- }
-
- // Check old text to sanitize
- if (text != null) {
- sanitizeText(text);
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
- this.namedTag.remove("Creator");
- }
-
- @Override
- public boolean isBlockEntityValid() {
- int blockID = getBlock().getId();
- return blockID == Block.SIGN_POST || blockID == Block.WALL_SIGN;
- }
-
- public boolean setText(String... lines) {
- for (int i = 0; i < 4; i++) {
- if (i < lines.length)
- text[i] = lines[i];
- else
- text[i] = "";
- }
-
- this.namedTag.putString("Text", String.join("\n", text));
- this.spawnToAll();
-
- if (this.chunk != null) {
- setDirty();
- }
-
- return true;
- }
-
- public String[] getText() {
- return text;
- }
-
- @Override
- public boolean updateCompoundTag(CompoundTag nbt, Player player) {
- if (!nbt.getString("id").equals(BlockEntity.SIGN)) {
- return false;
- }
- String[] lines = new String[4];
- Arrays.fill(lines, "");
- String[] splitLines = nbt.getString("Text").split("\n", 4);
- System.arraycopy(splitLines, 0, lines, 0, splitLines.length);
-
- sanitizeText(lines);
-
- SignChangeEvent signChangeEvent = new SignChangeEvent(this.getBlock(), player, lines);
-
- if (!this.namedTag.contains("Creator") || !Objects.equals(player.getUniqueId().toString(), this.namedTag.getString("Creator"))) {
- signChangeEvent.setCancelled();
- }
-
- if (player.getRemoveFormat()) {
- for (int i = 0; i < lines.length; i++) {
- lines[i] = TextFormat.clean(lines[i]);
- }
- }
-
- this.server.getPluginManager().callEvent(signChangeEvent);
-
- if (!signChangeEvent.isCancelled()) {
- this.setText(signChangeEvent.getLines());
- return true;
- }
-
- return false;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- return new CompoundTag()
- .putString("id", BlockEntity.SIGN)
- .putString("Text", this.namedTag.getString("Text"))
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z);
- }
-
- private static void sanitizeText(String[] lines) {
- for (int i = 0; i < lines.length; i++) {
- // Don't allow excessive text per line
- if (lines[i] != null) {
- lines[i] = lines[i].substring(0, Math.min(200, lines[i].length()));
- }
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntitySkull.java b/src/main/java/cn/nukkit/blockentity/BlockEntitySkull.java
deleted file mode 100644
index 87ad7abd0..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntitySkull.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-/**
- * Created by Snake1999 on 2016/2/3.
- * Package cn.nukkit.blockentity in project Nukkit.
- */
-public class BlockEntitySkull extends BlockEntitySpawnable {
- public BlockEntitySkull(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- if (!namedTag.contains("SkullType")) {
- namedTag.putByte("SkullType", 0);
- }
- if (!namedTag.contains("Rot")) {
- namedTag.putByte("Rot", 0);
- }
-
- super.initBlockEntity();
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
- this.namedTag.remove("Creator");
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return getBlock().getId() == Block.SKULL_BLOCK;
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- return new CompoundTag()
- .putString("id", BlockEntity.SKULL)
- .put("SkullType", this.namedTag.get("SkullType"))
- .putInt("x", (int) this.x)
- .putInt("y", (int) this.y)
- .putInt("z", (int) this.z)
- .put("Rot", this.namedTag.get("Rot"));
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntitySpawnable.java b/src/main/java/cn/nukkit/blockentity/BlockEntitySpawnable.java
deleted file mode 100644
index e771fd797..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntitySpawnable.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.network.protocol.BlockEntityDataPacket;
-
-import java.io.IOException;
-import java.nio.ByteOrder;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class BlockEntitySpawnable extends BlockEntity {
-
- public BlockEntitySpawnable(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initBlockEntity() {
- super.initBlockEntity();
-
- this.spawnToAll();
- }
-
- public abstract CompoundTag getSpawnCompound();
-
- public BlockEntityDataPacket createSpawnPacket() {
- CompoundTag tag = this.getSpawnCompound();
- BlockEntityDataPacket pk = new BlockEntityDataPacket();
- pk.x = (int) this.x;
- pk.y = (int) this.y;
- pk.z = (int) this.z;
-
- try {
- pk.namedTag = NBTIO.write(tag, ByteOrder.LITTLE_ENDIAN, true);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
-
- return pk;
- }
-
- public void spawnTo(Player player) {
- if (!this.closed) {
- player.dataPacket(this.createSpawnPacket());
- }
- }
-
- public void spawnToAll() {
- if (!this.closed) {
- this.level.addChunkPacket(this.chunk.getX(), this.chunk.getZ(), this.createSpawnPacket());
- }
- }
-
- /**
- * Called when a player updates a block entity's NBT data
- * for example when writing on a sign.
- *
- * @param nbt tag
- * @param player player
- * @return bool indication of success, will respawn the tile to the player if false.
- */
- public boolean updateCompoundTag(CompoundTag nbt, Player player) {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/blockentity/BlockEntitySpawner.java b/src/main/java/cn/nukkit/blockentity/BlockEntitySpawner.java
deleted file mode 100644
index 90a2c9ae6..000000000
--- a/src/main/java/cn/nukkit/blockentity/BlockEntitySpawner.java
+++ /dev/null
@@ -1,239 +0,0 @@
-package cn.nukkit.blockentity;
-
-import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.entity.BaseEntity;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.mob.EntityMob;
-import cn.nukkit.event.entity.CreatureSpawnEvent;
-import cn.nukkit.level.Position;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ShortTag;
-import cn.nukkit.utils.Utils;
-
-public class BlockEntitySpawner extends BlockEntitySpawnable {
-
- private int entityId;
- private int spawnRange;
- private int maxNearbyEntities;
- private int requiredPlayerRange;
- private int requiredPlayerRange2;
-
- private int delay = 0;
-
- private int minSpawnDelay;
- private int maxSpawnDelay;
-
- private int minSpawnCount;
- private int maxSpawnCount;
-
- public static final String TAG_ID = "id";
- public static final String TAG_X = "x";
- public static final String TAG_Y = "y";
- public static final String TAG_Z = "z";
- public static final String TAG_ENTITY_ID = "EntityId";
- public static final String TAG_SPAWN_RANGE = "SpawnRange";
- public static final String TAG_MIN_SPAWN_DELAY = "MinSpawnDelay";
- public static final String TAG_MAX_SPAWN_DELAY = "MaxSpawnDelay";
- public static final String TAG_MAX_NEARBY_ENTITIES = "MaxNearbyEntities";
- public static final String TAG_REQUIRED_PLAYER_RANGE = "RequiredPlayerRange";
- public static final String TAG_MINIMUM_SPAWN_COUNT = "MinimumSpawnerCount";
- public static final String TAG_MAXIMUM_SPAWN_COUNT = "MaximumSpawnerCount";
-
- public static final short SPAWN_RANGE = 4;
- public static final short MIN_SPAWN_DELAY = 200;
- public static final short MAX_SPAWN_DELAY = 5000;
- public static final short MAX_NEARBY_ENTITIES = 16;
- public static final short REQUIRED_PLAYER_RANGE = 16;
- public static final short MINIMUM_SPAWN_COUNT = 1;
- public static final short MAXIMUM_SPAWN_COUNT = 4;
-
- public BlockEntitySpawner(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- this.entityId = this.namedTag.getInt(TAG_ENTITY_ID);
- }
-
- @Override
- protected void initBlockEntity() {
- if (!this.namedTag.contains(TAG_SPAWN_RANGE) || !(this.namedTag.get(TAG_SPAWN_RANGE) instanceof ShortTag)) {
- this.namedTag.putShort(TAG_SPAWN_RANGE, SPAWN_RANGE);
- }
-
- if (!this.namedTag.contains(TAG_MIN_SPAWN_DELAY) || !(this.namedTag.get(TAG_MIN_SPAWN_DELAY) instanceof ShortTag)) {
- this.namedTag.putShort(TAG_MIN_SPAWN_DELAY, MIN_SPAWN_DELAY);
- }
-
- if (!this.namedTag.contains(TAG_MAX_SPAWN_DELAY) || !(this.namedTag.get(TAG_MAX_SPAWN_DELAY) instanceof ShortTag)) {
- this.namedTag.putShort(TAG_MAX_SPAWN_DELAY, MAX_SPAWN_DELAY);
- }
-
- if (!this.namedTag.contains(TAG_MAX_NEARBY_ENTITIES) || !(this.namedTag.get(TAG_MAX_NEARBY_ENTITIES) instanceof ShortTag)) {
- this.namedTag.putShort(TAG_MAX_NEARBY_ENTITIES, MAX_NEARBY_ENTITIES);
- }
-
- if (!this.namedTag.contains(TAG_REQUIRED_PLAYER_RANGE) || !(this.namedTag.get(TAG_REQUIRED_PLAYER_RANGE) instanceof ShortTag)) {
- this.namedTag.putShort(TAG_REQUIRED_PLAYER_RANGE, REQUIRED_PLAYER_RANGE);
- }
-
- if (!this.namedTag.contains(TAG_MINIMUM_SPAWN_COUNT) || !(this.namedTag.get(TAG_MINIMUM_SPAWN_COUNT) instanceof ShortTag)) {
- this.namedTag.putShort(TAG_MINIMUM_SPAWN_COUNT, MINIMUM_SPAWN_COUNT);
- }
-
- if (!this.namedTag.contains(TAG_MAXIMUM_SPAWN_COUNT) || !(this.namedTag.get(TAG_MAXIMUM_SPAWN_COUNT) instanceof ShortTag)) {
- this.namedTag.putShort(TAG_MAXIMUM_SPAWN_COUNT, MAXIMUM_SPAWN_COUNT);
- }
-
- this.spawnRange = this.namedTag.getShort(TAG_SPAWN_RANGE);
- this.minSpawnDelay = this.namedTag.getShort(TAG_MIN_SPAWN_DELAY);
- this.maxSpawnDelay = this.namedTag.getShort(TAG_MAX_SPAWN_DELAY);
- this.maxNearbyEntities = this.namedTag.getShort(TAG_MAX_NEARBY_ENTITIES);
- this.requiredPlayerRange = this.namedTag.getShort(TAG_REQUIRED_PLAYER_RANGE);
- this.requiredPlayerRange2 = (int) Math.pow(this.requiredPlayerRange, 2);
- this.minSpawnCount = this.namedTag.getShort(TAG_MINIMUM_SPAWN_COUNT);
- this.maxSpawnCount = this.namedTag.getShort(TAG_MAXIMUM_SPAWN_COUNT);
-
- this.scheduleUpdate();
- super.initBlockEntity();
- }
-
- @Override
- public boolean onUpdate() {
- if (this.closed) {
- return false;
- }
-
- if (this.delay++ >= Utils.rand(this.minSpawnDelay, this.maxSpawnDelay)) {
- this.delay = 0;
-
- int nearbyEntities = 0;
- boolean playerInRange = false;
- for (Entity entity : this.level.getEntities()) {
- if (!playerInRange && entity instanceof Player) {
- if (entity.distanceSquared(this) <= this.requiredPlayerRange2) {
- playerInRange = true;
- }
- } else if (entity instanceof BaseEntity) {
- if (entity.distanceSquared(this) <= this.requiredPlayerRange2) {
- nearbyEntities++;
- }
- }
- }
-
- int amountToSpawn = minSpawnCount + Utils.nukkitRandom.nextBoundedInt(maxSpawnCount);
- for (int i = 0; i < amountToSpawn; i++) {
- if (playerInRange && nearbyEntities <= this.maxNearbyEntities) {
- Position pos = new Position
- (
- this.x + Utils.rand(-this.spawnRange, this.spawnRange),
- this.y,
- this.z + Utils.rand(-this.spawnRange, this.spawnRange),
- this.level
- );
- Block block = level.getBlock(pos);
- // Mobs shouldn't spawn in walls, and they shouldn't retry to
- if (
- block.getId() != 0 && block.getId() != BlockID.SIGN_POST && block.getId() != BlockID.WALL_SIGN &&
- block.getId() != BlockID.STILL_WATER && block.getId() != BlockID.WATER &&
- block.getId() != BlockID.LAVA && block.getId() != BlockID.STILL_LAVA
- ) {
- continue;
- }
-
- CreatureSpawnEvent ev = new CreatureSpawnEvent(this.entityId, pos, CreatureSpawnEvent.SpawnReason.SPAWNER);
- level.getServer().getPluginManager().callEvent(ev);
-
- if (ev.isCancelled()) {
- continue;
- }
-
- Entity entity = Entity.createEntity(this.entityId, pos);
- if (entity != null) {
- if (entity instanceof EntityMob && this.level.getBlockLightAt((int) x, (int) y, (int) z) > 3) {
- entity.close();
- continue;
- }
- entity.spawnToAll();
- nearbyEntities++;
- }
- }
- }
- }
-
- return true;
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
-
- this.namedTag.putInt(TAG_ENTITY_ID, this.entityId);
- this.namedTag.putString(TAG_ID, "MobSpawner");
- this.namedTag.putShort(TAG_SPAWN_RANGE, this.spawnRange);
- this.namedTag.putShort(TAG_MIN_SPAWN_DELAY, this.minSpawnDelay);
- this.namedTag.putShort(TAG_MAX_SPAWN_DELAY, this.maxSpawnDelay);
- this.namedTag.putShort(TAG_MAX_NEARBY_ENTITIES, this.maxNearbyEntities);
- this.namedTag.putShort(TAG_REQUIRED_PLAYER_RANGE, this.requiredPlayerRange);
- this.namedTag.putShort(TAG_MINIMUM_SPAWN_COUNT, this.minSpawnCount);
- this.namedTag.putShort(TAG_MAXIMUM_SPAWN_COUNT, this.maxSpawnCount);
- }
-
- @Override
- public CompoundTag getSpawnCompound() {
- return new CompoundTag()
- .putString(TAG_ID, BlockEntity.MOB_SPAWNER)
- .putInt(TAG_ENTITY_ID, this.entityId)
- .putInt(TAG_X, (int) this.x)
- .putInt(TAG_Y, (int) this.y)
- .putInt(TAG_Z, (int) this.z);
- }
-
- @Override
- public boolean isBlockEntityValid() {
- return this.getBlock().getId() == Block.MONSTER_SPAWNER;
- }
-
- public void setSpawnEntityType(int entityId) {
- this.entityId = entityId;
- this.spawnToAll();
- }
-
- public int getSpawnEntityType() {
- return this.entityId;
- }
-
- public void setMinSpawnDelay(int minDelay) {
- if (minDelay > this.maxSpawnDelay) {
- return;
- }
-
- this.minSpawnDelay = minDelay;
- }
-
- public void setMaxSpawnDelay(int maxDelay) {
- if (this.minSpawnDelay > maxDelay) {
- return;
- }
-
- this.maxSpawnDelay = maxDelay;
- }
-
- public void setSpawnDelay(int minDelay, int maxDelay) {
- if (minDelay > maxDelay) {
- return;
- }
-
- this.minSpawnDelay = minDelay;
- this.maxSpawnDelay = maxDelay;
- }
-
- public void setRequiredPlayerRange(int range) {
- this.requiredPlayerRange = range;
- this.requiredPlayerRange2 = (int) Math.pow(this.requiredPlayerRange, 2);
- }
-
- public void setMaxNearbyEntities(int count) {
- this.maxNearbyEntities = count;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/Command.java b/src/main/java/cn/nukkit/command/Command.java
deleted file mode 100644
index 9512a8a28..000000000
--- a/src/main/java/cn/nukkit/command/Command.java
+++ /dev/null
@@ -1,312 +0,0 @@
-package cn.nukkit.command;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.command.data.*;
-import cn.nukkit.lang.TextContainer;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.permission.Permissible;
-import cn.nukkit.utils.TextFormat;
-import co.aikar.timings.Timing;
-import co.aikar.timings.Timings;
-
-import java.util.*;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class Command {
-
- private static CommandData defaultDataTemplate = null;
-
- protected CommandData commandData;
-
- private final String name;
-
- private String nextLabel;
-
- private String label;
-
- private String[] aliases;
-
- private String[] activeAliases;
-
- private CommandMap commandMap = null;
-
- protected String description;
-
- protected String usageMessage;
-
- private String permission = null;
-
- private String permissionMessage = null;
-
- protected Map commandParameters = new HashMap<>();
-
- public Timing timing;
-
- public Command(String name) {
- this(name, "", null, new String[0]);
- }
-
- public Command(String name, String description) {
- this(name, description, null, new String[0]);
- }
-
- public Command(String name, String description, String usageMessage) {
- this(name, description, usageMessage, new String[0]);
- }
-
- public Command(String name, String description, String usageMessage, String[] aliases) {
- this.commandData = new CommandData();
- this.name = name.toLowerCase(); // Prevent client crash
- this.nextLabel = name;
- this.label = name;
- this.description = description;
- this.usageMessage = usageMessage == null ? '/' + name : usageMessage;
- this.aliases = aliases;
- this.activeAliases = aliases;
- this.timing = Timings.getCommandTiming(this);
- this.commandParameters.put("default", new CommandParameter[]{new CommandParameter("args", CommandParamType.RAWTEXT, true)});
- }
-
- /**
- * Returns an CommandData containing command data
- *
- * @return CommandData
- */
- public CommandData getDefaultCommandData() {
- return this.commandData;
- }
-
- public CommandParameter[] getCommandParameters(String key) {
- return commandParameters.get(key);
- }
-
- public Map getCommandParameters() {
- return commandParameters;
- }
-
- public void setCommandParameters(Map commandParameters) {
- this.commandParameters = commandParameters;
- }
-
- public void addCommandParameters(String key, CommandParameter[] parameters) {
- this.commandParameters.put(key, parameters);
- }
-
- /**
- * Generates modified command data for the specified player
- * for AvailableCommandsPacket.
- *
- * @param player player
- * @return CommandData|null
- */
- public CommandDataVersions generateCustomCommandData(Player player) {
- if (!this.testPermission(player)) {
- return null;
- }
-
- CommandData customData = this.commandData.clone();
- customData.description = player.getServer().getLanguage().translateString(this.description);
- this.commandParameters.forEach((key, par) -> {
- CommandOverload overload = new CommandOverload();
- overload.input.parameters = par;
- customData.overloads.put(key, overload);
- });
- if (customData.overloads.isEmpty()) customData.overloads.put("default", new CommandOverload());
- CommandDataVersions versions = new CommandDataVersions();
- versions.versions.add(customData);
- return versions;
- }
-
- public Map getOverloads() {
- return this.commandData.overloads;
- }
-
- public abstract boolean execute(CommandSender sender, String commandLabel, String[] args);
-
- public String getName() {
- return name;
- }
-
- public String getPermission() {
- return permission;
- }
-
- public void setPermission(String permission) {
- this.permission = permission;
- }
-
- public boolean testPermission(CommandSender target) {
- if (this.testPermissionSilent(target)) {
- return true;
- }
-
- if (this.permissionMessage == null) {
- target.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.unknown", this.name));
- } else if (!this.permissionMessage.isEmpty()) {
- target.sendMessage(this.permissionMessage.replace("", this.permission));
- }
-
- return false;
- }
-
- public boolean testPermissionSilent(CommandSender target) {
- if (this.permission == null || this.permission.isEmpty()) {
- return true;
- }
-
- String[] permissions = this.permission.split(";");
- for (String permission : permissions) {
- if (target.hasPermission(permission)) {
- return true;
- }
- }
-
- return false;
- }
-
- public String getLabel() {
- return label;
- }
-
- public boolean setLabel(String name) {
- this.nextLabel = name;
- if (!this.isRegistered()) {
- this.label = name;
- this.timing = Timings.getCommandTiming(this);
- return true;
- }
- return false;
- }
-
- public boolean register(CommandMap commandMap) {
- if (this.allowChangesFrom(commandMap)) {
- this.commandMap = commandMap;
- return true;
- }
- return false;
- }
-
- public boolean unregister(CommandMap commandMap) {
- if (this.allowChangesFrom(commandMap)) {
- this.commandMap = null;
- this.activeAliases = this.aliases;
- this.label = this.nextLabel;
- return true;
- }
- return false;
- }
-
- public boolean allowChangesFrom(CommandMap commandMap) {
- return commandMap != null && !commandMap.equals(this.commandMap);
- }
-
- public boolean isRegistered() {
- return this.commandMap != null;
- }
-
- public String[] getAliases() {
- return this.activeAliases;
- }
-
- public String getPermissionMessage() {
- return permissionMessage;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getUsage() {
- return usageMessage;
- }
-
- public void setAliases(String[] aliases) {
- this.aliases = aliases;
- if (!this.isRegistered()) {
- this.activeAliases = aliases;
- }
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public void setPermissionMessage(String permissionMessage) {
- this.permissionMessage = permissionMessage;
- }
-
- public void setUsage(String usageMessage) {
- this.usageMessage = usageMessage;
- }
-
- public static CommandData generateDefaultData() {
- return defaultDataTemplate.clone();
- }
-
- public static void broadcastCommandMessage(CommandSender source, String message) {
- broadcastCommandMessage(source, message, true);
- }
-
- public static void broadcastCommandMessage(CommandSender source, String message, boolean sendToSource) {
- Set users = source.getServer().getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
-
- TranslationContainer result = new TranslationContainer("chat.type.admin", source.getName(), message);
-
- TranslationContainer colored = new TranslationContainer(TextFormat.GRAY + "" + TextFormat.ITALIC + "%chat.type.admin", source.getName(), message);
-
- if (sendToSource && !(source instanceof ConsoleCommandSender)) {
- source.sendMessage(message);
- }
-
- for (Permissible user : users) {
- if (user instanceof CommandSender) {
- if (user instanceof ConsoleCommandSender) {
- ((ConsoleCommandSender) user).sendMessage(result);
- } else if (!user.equals(source)) {
- ((CommandSender) user).sendMessage(colored);
- }
- }
- }
- }
-
- public static void broadcastCommandMessage(CommandSender source, TextContainer message) {
- broadcastCommandMessage(source, message, true);
- }
-
- public static void broadcastCommandMessage(CommandSender source, TextContainer message, boolean sendToSource) {
- TextContainer m = message.clone();
- String resultStr = '[' + source.getName() + ": " + (!m.getText().equals(source.getServer().getLanguage().get(m.getText())) ? "%" : "") + m.getText() + ']';
-
- Set users = source.getServer().getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
-
- String coloredStr = TextFormat.GRAY + "" + TextFormat.ITALIC + resultStr;
-
- m.setText(resultStr);
- TextContainer result = m.clone();
- m.setText(coloredStr);
- TextContainer colored = m.clone();
-
- if (sendToSource && !(source instanceof ConsoleCommandSender)) {
- source.sendMessage(message);
- }
-
- for (Permissible user : users) {
- if (user instanceof CommandSender) {
- if (user instanceof ConsoleCommandSender) {
- ((ConsoleCommandSender) user).sendMessage(result);
- } else if (!user.equals(source)) {
- ((CommandSender) user).sendMessage(colored);
- }
- }
- }
- }
-
- @Override
- public String toString() {
- return this.name;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/CommandExecutor.java b/src/main/java/cn/nukkit/command/CommandExecutor.java
deleted file mode 100644
index d039da12a..000000000
--- a/src/main/java/cn/nukkit/command/CommandExecutor.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package cn.nukkit.command;
-
-/**
- * 能监听命令执行的类实现的接口。
- * An interface what can be implemented by classes which listens command executing.
- *
- * @author MagicDroidX(code) @ Nukkit Project
- * @author 粉鞋大妈(javadoc) @ Nukkit Project
- * @see cn.nukkit.plugin.PluginBase
- * @see cn.nukkit.command.CommandExecutor#onCommand
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
-public interface CommandExecutor {
- /**
- * 在命令执行时会调用的方法。
- * Called when a command is executed.
- *
- * 一个命令可以是{@code /a_LABEL an_arg1 AN_ARG2...}的形式,这时{@code label}变量的值为{@code "a_label"},
- * {@code args}数组的元素有{@code "an_arg1","AN_ARG2",...}。注意到{@code label}变量会被转化成小写,
- * 而{@code args}数组内字符串元素的大小写不变。
- * A command can be such a form like {@code /a_LABEL an_arg1 AN_ARG2...}. At this time, the value of
- * variable {@code label} is {@code "a_label"}, and the values of elements of array {@code args} are
- * {@code "an_arg1","AN_ARG2",...}. Notice that the value of variable {@code label} will be converted to
- * lower case, but the cases of elements of array {@code args} won't change.
- *
- * 关于返回值,如果返回{@code false},Nukkit会给sender发送这个命令的使用方法等信息,来表示这个命令没有使用成功。
- * 如果你的命令成功的发挥了作用,你应该返回{@code true}来表示这个命令已执行成功。
- * If this function returns {@code false}, Nukkit will send command usages to command sender, to explain that
- * the command didn't work normally. If your command works properly, a {@code true} should be returned to explain
- * that the command works.
- *
- * 如果你想测试一个命令发送者是否有权限执行这个命令,
- * 可以使用{@link cn.nukkit.command.Command#testPermissionSilent}。
- * If you want to test whether a command sender has the permission to execute a command,
- * you can use {@link cn.nukkit.command.Command#testPermissionSilent}.
- *
- * @param sender 这个命令的发送者,可以是玩家或控制台等。
- * The sender of this command, this can be a player or a console.
- * @param command 要被发送的命令。
- * The command to send.
- * @param label 这个命令的标签。
- * Label of the command.
- * @param args 这个命令的参数列表。
- * Arguments of this command.
- * @return 这个命令执行是否执行成功。
whether this command is executed successfully.
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- boolean onCommand(CommandSender sender, Command command, String label, String[] args);
-}
diff --git a/src/main/java/cn/nukkit/command/CommandMap.java b/src/main/java/cn/nukkit/command/CommandMap.java
deleted file mode 100644
index 7d1be68a5..000000000
--- a/src/main/java/cn/nukkit/command/CommandMap.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package cn.nukkit.command;
-
-import java.util.List;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public interface CommandMap {
-
- void registerAll(String fallbackPrefix, List extends Command> commands);
-
- boolean register(String fallbackPrefix, Command command);
-
- boolean register(String fallbackPrefix, Command command, String label);
-
- void registerSimpleCommands(Object object);
-
- boolean dispatch(CommandSender sender, String cmdLine);
-
- void clearCommands();
-
- Command getCommand(String name);
-}
diff --git a/src/main/java/cn/nukkit/command/CommandSender.java b/src/main/java/cn/nukkit/command/CommandSender.java
deleted file mode 100644
index bbab297c7..000000000
--- a/src/main/java/cn/nukkit/command/CommandSender.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package cn.nukkit.command;
-
-import cn.nukkit.Server;
-import cn.nukkit.lang.TextContainer;
-import cn.nukkit.permission.Permissible;
-
-/**
- * 能发送命令的人。
- * Who sends commands.
- *
- * 可以是一个玩家或者一个控制台。
- * That can be a player or a console.
- *
- * @author MagicDroidX(code) @ Nukkit Project
- * @author 粉鞋大妈(javadoc) @ Nukkit Project
- * @see cn.nukkit.command.CommandExecutor#onCommand
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
-public interface CommandSender extends Permissible {
-
- /**
- * 给命令发送者返回信息。
- * Sends a message to the command sender.
- *
- * @param message 要发送的信息。
Message to send.
- * @see cn.nukkit.utils.TextFormat
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- void sendMessage(String message);
-
- /**
- * 给命令发送者返回信息。
- * Sends a message to the command sender.
- *
- * @param message 要发送的信息。
Message to send.
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- void sendMessage(TextContainer message);
-
- /**
- * 返回命令发送者所在的服务器。
- * Returns the server of the command sender.
- *
- * @return 命令发送者所在的服务器。
the server of the command sender.
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- Server getServer();
-
- /**
- * 返回命令发送者的名称。
- * Returns the name of the command sender.
- *
- * 如果命令发送者是一个玩家,将会返回他的玩家名字(name)不是显示名字(display name)。
- * 如果命令发送者是控制台,将会返回{@code "CONSOLE"}。
- * If this command sender is a player, will return his/her player name(not display name).
- * If it is a console, will return {@code "CONSOLE"}.
- * 当你需要判断命令的执行者是不是控制台时,可以用这个:
- * When you need to determine if the sender is a console, use this:
- * {@code if (sender instanceof ConsoleCommandSender) .....;}
- *
- * @return 命令发送者的名称。
the name of the command sender.
- * @see cn.nukkit.Player#getName()
- * @see cn.nukkit.command.ConsoleCommandSender#getName()
- * @see cn.nukkit.plugin.PluginDescription
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
- String getName();
-
- boolean isPlayer();
-}
diff --git a/src/main/java/cn/nukkit/command/ConsoleCommandSender.java b/src/main/java/cn/nukkit/command/ConsoleCommandSender.java
deleted file mode 100644
index feef79423..000000000
--- a/src/main/java/cn/nukkit/command/ConsoleCommandSender.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package cn.nukkit.command;
-
-import cn.nukkit.Server;
-import cn.nukkit.lang.TextContainer;
-import cn.nukkit.permission.PermissibleBase;
-import cn.nukkit.permission.Permission;
-import cn.nukkit.permission.PermissionAttachment;
-import cn.nukkit.permission.PermissionAttachmentInfo;
-import cn.nukkit.plugin.Plugin;
-import cn.nukkit.utils.MainLogger;
-
-import java.util.Map;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class ConsoleCommandSender implements CommandSender {
-
- private final PermissibleBase perm;
-
- public ConsoleCommandSender() {
- this.perm = new PermissibleBase(this);
- }
-
- @Override
- public boolean isPermissionSet(String name) {
- return this.perm.isPermissionSet(name);
- }
-
- @Override
- public boolean isPermissionSet(Permission permission) {
- return this.perm.isPermissionSet(permission);
- }
-
- @Override
- public boolean hasPermission(String name) {
- return this.perm.hasPermission(name);
- }
-
- @Override
- public boolean hasPermission(Permission permission) {
- return this.perm.hasPermission(permission);
- }
-
- @Override
- public PermissionAttachment addAttachment(Plugin plugin) {
- return this.perm.addAttachment(plugin);
- }
-
- @Override
- public PermissionAttachment addAttachment(Plugin plugin, String name) {
- return this.perm.addAttachment(plugin, name);
- }
-
- @Override
- public PermissionAttachment addAttachment(Plugin plugin, String name, Boolean value) {
- return this.perm.addAttachment(plugin, name, value);
- }
-
- @Override
- public void removeAttachment(PermissionAttachment attachment) {
- this.perm.removeAttachment(attachment);
- }
-
- @Override
- public void recalculatePermissions() {
- this.perm.recalculatePermissions();
- }
-
- @Override
- public Map getEffectivePermissions() {
- return this.perm.getEffectivePermissions();
- }
-
- public boolean isPlayer() {
- return false;
- }
-
- @Override
- public Server getServer() {
- return Server.getInstance();
- }
-
- @Override
- public void sendMessage(String message) {
- message = this.getServer().getLanguage().translateString(message);
- for (String line : message.trim().split("\n")) {
- MainLogger.getLogger().info(line);
- }
- }
-
- @Override
- public void sendMessage(TextContainer message) {
- this.sendMessage(this.getServer().getLanguage().translate(message));
- }
-
- @Override
- public String getName() {
- return "CONSOLE";
- }
-
- @Override
- public boolean isOp() {
- return true;
- }
-
- @Override
- public void setOp(boolean value) {
- }
-}
diff --git a/src/main/java/cn/nukkit/command/FormattedCommandAlias.java b/src/main/java/cn/nukkit/command/FormattedCommandAlias.java
deleted file mode 100644
index d796cf776..000000000
--- a/src/main/java/cn/nukkit/command/FormattedCommandAlias.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package cn.nukkit.command;
-
-import cn.nukkit.Server;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.MainLogger;
-import cn.nukkit.utils.TextFormat;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class FormattedCommandAlias extends Command {
-
- private final String[] formatStrings;
-
- public FormattedCommandAlias(String alias, String[] formatStrings) {
- super(alias);
- this.formatStrings = formatStrings;
- }
-
- public FormattedCommandAlias(String alias, List formatStrings) {
- super(alias);
- this.formatStrings = formatStrings.toArray(new String[0]);
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- boolean result = false;
- ArrayList commands = new ArrayList<>();
- for (String formatString : formatStrings) {
- try {
- commands.add(buildCommand(formatString, args));
- } catch (Exception e) {
- if (e instanceof IllegalArgumentException) {
- sender.sendMessage(TextFormat.RED + e.getMessage());
- } else {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.exception"));
- MainLogger logger = sender.getServer().getLogger();
- if (logger != null) {
- logger.logException(e);
- }
- }
- return false;
- }
- }
-
- for (String command : commands) {
- result |= Server.getInstance().dispatchCommand(sender, command);
- }
-
- return result;
- }
-
- private String buildCommand(String formatString, String[] args) {
- int index = formatString.indexOf('$');
- while (index != -1) {
- int start = index;
-
- if (index > 0 && formatString.charAt(start - 1) == '\\') {
- formatString = formatString.substring(0, start - 1) + formatString.substring(start);
- index = formatString.indexOf('$', index);
- continue;
- }
-
- boolean required = false;
- if (formatString.charAt(index + 1) == '$') {
- required = true;
- // Move index past the second $
- index++;
- }
-
- // Move index past the $
- index++;
- int argStart = index;
- while (index < formatString.length() && inRange(((int) formatString.charAt(index)) - 48, 0, 9)) {
- // Move index past current digit
- index++;
- }
-
- // No numbers found
- if (argStart == index) {
- throw new IllegalArgumentException("Invalid replacement token");
- }
-
- int position = Integer.parseInt(formatString.substring(argStart, index));
-
- // Arguments are not 0 indexed
- if (position == 0) {
- throw new IllegalArgumentException("Invalid replacement token");
- }
-
- // Convert position to 0 index
- position--;
-
- boolean rest = false;
- if (index < formatString.length() && formatString.charAt(index) == '-') {
- rest = true;
- // Move index past the -
- index++;
- }
-
- int end = index;
-
- if (required && position >= args.length) {
- throw new IllegalArgumentException("Missing required argument " + (position + 1));
- }
-
- StringBuilder replacement = new StringBuilder();
- if (rest && position < args.length) {
- for (int i = position; i < args.length; i++) {
- if (i != position) {
- replacement.append(' ');
- }
- replacement.append(args[i]);
- }
- } else if (position < args.length) {
- replacement.append(args[position]);
- }
-
- formatString = formatString.substring(0, start) + replacement + formatString.substring(end);
- // Move index past the replaced data so we don't process it again
- index = start + replacement.length();
-
- // Move to the next replacement token
- index = formatString.indexOf('$', index);
- }
-
- return formatString;
- }
-
- private static boolean inRange(int i, int j, int k) {
- return i >= j && i <= k;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/PluginCommand.java b/src/main/java/cn/nukkit/command/PluginCommand.java
deleted file mode 100644
index 07d07da0a..000000000
--- a/src/main/java/cn/nukkit/command/PluginCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.nukkit.command;
-
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.plugin.Plugin;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class PluginCommand extends Command implements PluginIdentifiableCommand {
-
- private final T owningPlugin;
-
- private CommandExecutor executor;
-
- public PluginCommand(String name, T owner) {
- super(name);
- this.owningPlugin = owner;
- this.executor = owner;
- this.usageMessage = "";
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.owningPlugin.isEnabled()) {
- return false;
- }
-
- if (!this.testPermission(sender)) {
- return false;
- }
-
- boolean success = this.executor.onCommand(sender, this, commandLabel, args);
-
- if (!success && !this.usageMessage.isEmpty()) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- }
-
- return success;
- }
-
- public CommandExecutor getExecutor() {
- return executor;
- }
-
- public void setExecutor(CommandExecutor executor) {
- this.executor = (executor != null) ? executor : this.owningPlugin;
- }
-
- @Override
- public T getPlugin() {
- return this.owningPlugin;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/PluginIdentifiableCommand.java b/src/main/java/cn/nukkit/command/PluginIdentifiableCommand.java
deleted file mode 100644
index a22ab9446..000000000
--- a/src/main/java/cn/nukkit/command/PluginIdentifiableCommand.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package cn.nukkit.command;
-
-import cn.nukkit.plugin.Plugin;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public interface PluginIdentifiableCommand {
-
- Plugin getPlugin();
-}
diff --git a/src/main/java/cn/nukkit/command/RemoteConsoleCommandSender.java b/src/main/java/cn/nukkit/command/RemoteConsoleCommandSender.java
deleted file mode 100644
index 031959db9..000000000
--- a/src/main/java/cn/nukkit/command/RemoteConsoleCommandSender.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.command;
-
-import cn.nukkit.lang.TextContainer;
-
-/**
- * Represents an RCON command sender.
- *
- * @author Tee7even
- */
-public class RemoteConsoleCommandSender extends ConsoleCommandSender {
-
- private final StringBuilder messages = new StringBuilder();
-
- @Override
- public void sendMessage(String message) {
- message = this.getServer().getLanguage().translateString(message);
- this.messages.append(message.trim()).append('\n');
- if (messages.length() > 50000) {
- messages.delete(0, 49000);
- }
- }
-
- @Override
- public void sendMessage(TextContainer message) {
- this.sendMessage(this.getServer().getLanguage().translate(message));
- }
-
- public String getMessages() {
- return messages.toString();
- }
-
- @Override
- public String getName() {
- return "Rcon";
- }
-}
diff --git a/src/main/java/cn/nukkit/command/SimpleCommandMap.java b/src/main/java/cn/nukkit/command/SimpleCommandMap.java
deleted file mode 100644
index 3fc947685..000000000
--- a/src/main/java/cn/nukkit/command/SimpleCommandMap.java
+++ /dev/null
@@ -1,296 +0,0 @@
-package cn.nukkit.command;
-
-import cn.nukkit.Server;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.command.defaults.*;
-import cn.nukkit.command.simple.*;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.MainLogger;
-import cn.nukkit.utils.TextFormat;
-import cn.nukkit.utils.Utils;
-
-import java.lang.reflect.Method;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class SimpleCommandMap implements CommandMap {
-
- protected final Map knownCommands = new HashMap<>();
-
- private final Server server;
-
- public SimpleCommandMap(Server server) {
- this.server = server;
- this.setDefaultCommands();
- }
-
- private void setDefaultCommands() {
- this.register("nukkit", new VersionCommand("version"));
- this.register("nukkit", new PluginsCommand("plugins"));
- this.register("nukkit", new HelpCommand("help"));
- this.register("nukkit", new StopCommand("stop"));
- this.register("nukkit", new TellCommand("tell"));
- this.register("nukkit", new BanCommand("ban"));
- this.register("nukkit", new BanIpCommand("ban-ip"));
- this.register("nukkit", new BanListCommand("banlist"));
- this.register("nukkit", new PardonCommand("pardon"));
- this.register("nukkit", new PardonIpCommand("pardon-ip"));
- this.register("nukkit", new ListCommand("list"));
- this.register("nukkit", new KickCommand("kick"));
- this.register("nukkit", new OpCommand("op"));
- this.register("nukkit", new DeopCommand("deop"));
- this.register("nukkit", new SaveCommand("save-all"));
- this.register("nukkit", new GiveCommand("give"));
- this.register("nukkit", new EffectCommand("effect"));
- this.register("nukkit", new EnchantCommand("enchant"));
- this.register("nukkit", new GamemodeCommand("gamemode"));
- this.register("nukkit", new KillCommand("kill"));
- this.register("nukkit", new SetWorldSpawnCommand("setworldspawn"));
- this.register("nukkit", new TeleportCommand("tp"));
- this.register("nukkit", new TimeCommand("time"));
- this.register("nukkit", new ReloadCommand("reload"));
- this.register("nukkit", new WeatherCommand("weather"));
- this.register("nukkit", new XpCommand("xp"));
- this.register("nukkit", new StatusCommand("status"));
- this.register("nukkit", new SummonCommand("summon"));
- this.register("nukkit", new WorldCommand("world"));
- this.register("nukkit", new GenerateWorldCommand("genworld"));
- this.register("nukkit", new WhitelistCommand("whitelist"));
- this.register("nukkit", new GameruleCommand("gamerule"));
- this.register("nukkit", new SpawnCommand("spawn"));
- if (!Server.getInstance().suomiCraftPEMode()) {
- this.register("nukkit", new DefaultGamemodeCommand("defaultgamemode"));
- this.register("nukkit", new SayCommand("say"));
- this.register("nukkit", new MeCommand("me"));
- this.register("nukkit", new SaveOnCommand("save-on"));
- this.register("nukkit", new SaveOffCommand("save-off"));
- this.register("nukkit", new DifficultyCommand("difficulty"));
- this.register("nukkit", new ParticleCommand("particle"));
- this.register("nukkit", new SpawnpointCommand("spawnpoint"));
- this.register("nukkit", new TitleCommand("title"));
- this.register("nukkit", new TransferServerCommand("transfer"));
- this.register("nukkit", new SeedCommand("seed"));
- this.register("nukkit", new PlaySoundCommand("playsound"));
- this.register("nukkit", new DebugPasteCommand("debugpaste"));
- this.register("nukkit", new GarbageCollectorCommand("gc"));
- this.register("nukkit", new TimingsCommand("timings"));
- }
- }
-
- @Override
- public void registerAll(String fallbackPrefix, List extends Command> commands) {
- for (Command command : commands) {
- this.register(fallbackPrefix, command);
- }
- }
-
- @Override
- public boolean register(String fallbackPrefix, Command command) {
- return this.register(fallbackPrefix, command, null);
- }
-
- @Override
- public boolean register(String fallbackPrefix, Command command, String label) {
- if (label == null) {
- label = command.getName();
- }
- label = label.trim().toLowerCase();
- fallbackPrefix = fallbackPrefix.trim().toLowerCase();
-
- boolean registered = this.registerAlias(command, false, fallbackPrefix, label);
-
- List aliases = new ArrayList<>(Arrays.asList(command.getAliases()));
-
- for (Iterator iterator = aliases.iterator(); iterator.hasNext(); ) {
- String alias = iterator.next();
- if (!this.registerAlias(command, true, fallbackPrefix, alias)) {
- iterator.remove();
- }
- }
- command.setAliases(aliases.toArray(new String[0]));
-
- if (!registered) {
- command.setLabel(fallbackPrefix + ':' + label);
- }
-
- command.register(this);
-
- return registered;
- }
-
- @Override
- public void registerSimpleCommands(Object object) {
- for (Method method : object.getClass().getDeclaredMethods()) {
- cn.nukkit.command.simple.Command def = method.getAnnotation(cn.nukkit.command.simple.Command.class);
- if (def != null) {
- SimpleCommand sc = new SimpleCommand(object, method, def.name(), def.description(), def.usageMessage(), def.aliases());
-
- Arguments args = method.getAnnotation(Arguments.class);
- if (args != null) {
- sc.setMaxArgs(args.max());
- sc.setMinArgs(args.min());
- }
-
- CommandPermission perm = method.getAnnotation(CommandPermission.class);
- if (perm != null) {
- sc.setPermission(perm.value());
- }
-
- if (method.isAnnotationPresent(ForbidConsole.class)) {
- sc.setForbidConsole(true);
- }
-
- CommandParameters commandParameters = method.getAnnotation(CommandParameters.class);
- if (commandParameters != null) {
- Map map = Arrays.stream(commandParameters.parameters())
- .collect(Collectors.toMap(Parameters::name, parameters -> Arrays.stream(parameters.parameters())
- .map(parameter -> new CommandParameter(parameter.name(), parameter.type(), parameter.optional()))
- .distinct()
- .toArray(CommandParameter[]::new)));
-
- sc.commandParameters.putAll(map);
- }
-
- this.register(def.name(), sc);
- }
- }
- }
-
- private boolean registerAlias(Command command, boolean isAlias, String fallbackPrefix, String label) {
- this.knownCommands.put(fallbackPrefix + ':' + label, command);
-
- //if you're registering a command alias that is already registered, then return false
- boolean alreadyRegistered = this.knownCommands.containsKey(label);
- Command existingCommand = this.knownCommands.get(label);
- boolean existingCommandIsNotVanilla = alreadyRegistered && !(existingCommand instanceof VanillaCommand);
- //basically, if we're an alias and it's already registered, or we're a vanilla command, then we can't override it
- if ((command instanceof VanillaCommand || isAlias) && alreadyRegistered && existingCommandIsNotVanilla) {
- return false;
- }
-
- // If you're registering a name (alias or label) which is identical to another command who's primary name is the same
- // So basically we can't override the main name of a command, but we can override aliases if we're not an alias
-
- // Added the last statement which will allow us to override a VanillaCommand unconditionally
- if (alreadyRegistered && existingCommand.getLabel() != null && existingCommand.getLabel().equals(label) && existingCommandIsNotVanilla) {
- return false;
- }
-
- // You can now assume that the command is either uniquely named, or overriding another command's alias (and is not itself, an alias)
-
- if (!isAlias) {
- command.setLabel(label);
- }
-
- // Then we need to check if there isn't any command conflicts with vanilla commands
- ArrayList toRemove = new ArrayList<>();
-
- for (Entry entry : knownCommands.entrySet()) {
- Command cmd = entry.getValue();
- if (cmd.getLabel().equalsIgnoreCase(command.getLabel()) && !cmd.equals(command)) { // If the new command conflicts... (But if it isn't the same command)
- if (cmd instanceof VanillaCommand) { // And if the old command is a vanilla command...
- // Remove it!
- toRemove.add(entry.getKey());
- }
- }
- }
-
- // Now we loop the toRemove list to remove the command conflicts from the knownCommands map
- for (String cmd : toRemove) {
- knownCommands.remove(cmd);
- }
-
- this.knownCommands.put(label, command);
-
- return true;
- }
-
- private static ArrayList parseArguments(String cmdLine) {
- StringBuilder sb = new StringBuilder(cmdLine);
- ArrayList args = new ArrayList<>();
- boolean notQuoted = true;
- int start = 0;
-
- for (int i = 0; i < sb.length(); i++) {
- if (sb.charAt(i) == '\\') {
- sb.deleteCharAt(i);
- continue;
- }
-
- if (sb.charAt(i) == ' ' && notQuoted) {
- String arg = sb.substring(start, i);
- if (!arg.isEmpty()) {
- args.add(arg);
- }
- start = i + 1;
- } else if (sb.charAt(i) == '"') {
- sb.deleteCharAt(i);
- --i;
- notQuoted = !notQuoted;
- }
- }
-
- String arg = sb.substring(start);
- if (!arg.isEmpty()) {
- args.add(arg);
- }
- return args;
- }
-
- @Override
- public boolean dispatch(CommandSender sender, String cmdLine) {
- ArrayList parsed = parseArguments(cmdLine);
- if (parsed.isEmpty()) {
- return false;
- }
-
- String sentCommandLabel = parsed.remove(0).toLowerCase();
- String[] args = parsed.toArray(new String[0]);
- Command target = this.getCommand(sentCommandLabel);
-
- if (target == null) {
- return false;
- }
-
- if (target.timing != null) target.timing.startTiming();
- try {
- target.execute(sender, sentCommandLabel, args);
- } catch (Exception e) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.exception"));
- this.server.getLogger().critical(this.server.getLanguage().translateString("nukkit.command.exception", cmdLine, target.toString(), Utils.getExceptionMessage(e)));
- MainLogger logger = sender.getServer().getLogger();
- if (logger != null) {
- logger.logException(e);
- }
- }
- if (target.timing != null) target.timing.stopTiming();
-
- return true;
- }
-
- @Override
- public void clearCommands() {
- for (Command command : this.knownCommands.values()) {
- command.unregister(this);
- }
- this.knownCommands.clear();
- this.setDefaultCommands();
- }
-
- @Override
- public Command getCommand(String name) {
- if (this.knownCommands.containsKey(name)) {
- return this.knownCommands.get(name);
- }
- return null;
- }
-
- public Map getCommands() {
- return knownCommands;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/data/CommandArgs.java b/src/main/java/cn/nukkit/command/data/CommandArgs.java
deleted file mode 100644
index 1a6790682..000000000
--- a/src/main/java/cn/nukkit/command/data/CommandArgs.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package cn.nukkit.command.data;
-
-import com.google.gson.JsonElement;
-
-import java.util.HashMap;
-
-public class CommandArgs extends HashMap {
-}
diff --git a/src/main/java/cn/nukkit/command/data/CommandData.java b/src/main/java/cn/nukkit/command/data/CommandData.java
deleted file mode 100644
index c186dd363..000000000
--- a/src/main/java/cn/nukkit/command/data/CommandData.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package cn.nukkit.command.data;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class CommandData implements Cloneable {
-
- public CommandEnum aliases = null;
- public String description = "description";
- public Map overloads = new HashMap<>();
-
- public int flags;
- public int permission;
-
- @Override
- public CommandData clone() {
- try {
- return (CommandData) super.clone();
- } catch (Exception e) {
- return new CommandData();
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/command/data/CommandDataVersions.java b/src/main/java/cn/nukkit/command/data/CommandDataVersions.java
deleted file mode 100644
index 6950dee99..000000000
--- a/src/main/java/cn/nukkit/command/data/CommandDataVersions.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package cn.nukkit.command.data;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class CommandDataVersions {
-
- public List versions = new ArrayList<>();
-}
diff --git a/src/main/java/cn/nukkit/command/data/CommandEnum.java b/src/main/java/cn/nukkit/command/data/CommandEnum.java
deleted file mode 100644
index e9ba4e809..000000000
--- a/src/main/java/cn/nukkit/command/data/CommandEnum.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package cn.nukkit.command.data;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author CreeperFace
- */
-public class CommandEnum {
-
- /*public static final CommandEnum ENUM_BOOLEAN = new CommandEnum("Boolean", ImmutableList.of("true", "false"));
- public static final CommandEnum ENUM_GAMEMODE = new CommandEnum("GameMode",
- ImmutableList.of("survival", "creative", "s", "c", "adventure", "a", "spectator", "view", "v", "spc"));
- public static final CommandEnum ENUM_BLOCK;
- public static final CommandEnum ENUM_ITEM;
-
- static {
- ImmutableList.Builder blocks = ImmutableList.builder();
- for (Field field : BlockID.class.getDeclaredFields()) {
- blocks.add(field.getName().toLowerCase());
- }
- ENUM_BLOCK = new CommandEnum("Block", blocks.build());
-
- ImmutableList.Builder items = ImmutableList.builder();
- for (Field field : ItemID.class.getDeclaredFields()) {
- items.add(field.getName().toLowerCase());
- }
- items.addAll(ENUM_BLOCK.getValues());
- ENUM_ITEM = new CommandEnum("Item", items.build());
- }*/
-
- private final String name;
- private final List values;
-
- public CommandEnum(String name, String... values) {
- this(name, Arrays.asList(values));
- }
-
- public CommandEnum(String name, List values) {
- this.name = name;
- this.values = values;
- }
-
- public String getName() {
- return name;
- }
-
- public List getValues() {
- return values;
- }
-
- public int hashCode() {
- return name.hashCode();
- }
-}
diff --git a/src/main/java/cn/nukkit/command/data/CommandInput.java b/src/main/java/cn/nukkit/command/data/CommandInput.java
deleted file mode 100644
index 124e91632..000000000
--- a/src/main/java/cn/nukkit/command/data/CommandInput.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package cn.nukkit.command.data;
-
-public class CommandInput {
-
- public CommandParameter[] parameters = new CommandParameter[0];
-}
diff --git a/src/main/java/cn/nukkit/command/data/CommandOutput.java b/src/main/java/cn/nukkit/command/data/CommandOutput.java
deleted file mode 100644
index b3ff8811c..000000000
--- a/src/main/java/cn/nukkit/command/data/CommandOutput.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package cn.nukkit.command.data;
-
-public class CommandOutput {
-
- public String[] format_strings = new String[0];
-}
diff --git a/src/main/java/cn/nukkit/command/data/CommandOverload.java b/src/main/java/cn/nukkit/command/data/CommandOverload.java
deleted file mode 100644
index ab7c81908..000000000
--- a/src/main/java/cn/nukkit/command/data/CommandOverload.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package cn.nukkit.command.data;
-
-public class CommandOverload {
-
- public CommandInput input = new CommandInput();
- public CommandOutput output = new CommandOutput();
-}
diff --git a/src/main/java/cn/nukkit/command/data/CommandParamType.java b/src/main/java/cn/nukkit/command/data/CommandParamType.java
deleted file mode 100644
index 36bc0943c..000000000
--- a/src/main/java/cn/nukkit/command/data/CommandParamType.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.command.data;
-
-import static cn.nukkit.network.protocol.AvailableCommandsPacket.*;
-
-/**
- * @author CreeperFace
- */
-public enum CommandParamType {
-
- INT(ARG_TYPE_INT),
- FLOAT(ARG_TYPE_FLOAT),
- VALUE(ARG_TYPE_VALUE),
- WILDCARD_INT(ARG_TYPE_WILDCARD_INT),
- TARGET(ARG_TYPE_TARGET),
- WILDCARD_TARGET(ARG_TYPE_WILDCARD_TARGET),
- STRING(ARG_TYPE_STRING),
- BLOCK_POSITION(ARG_TYPE_BLOCK_POSITION),
- POSITION(ARG_TYPE_POSITION),
- MESSAGE(ARG_TYPE_MESSAGE),
- RAWTEXT(ARG_TYPE_RAWTEXT),
- JSON(ARG_TYPE_JSON),
- TEXT(ARG_TYPE_RAWTEXT),
- COMMAND(ARG_TYPE_COMMAND),
- FILE_PATH(ARG_TYPE_FILE_PATH),
- OPERATOR(ARG_TYPE_OPERATOR);
-
- private final int id;
-
- CommandParamType(int id) {
- this.id = id;
- }
-
- public int getId() {
- return id;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/command/data/CommandParameter.java b/src/main/java/cn/nukkit/command/data/CommandParameter.java
deleted file mode 100644
index 82d3cc71d..000000000
--- a/src/main/java/cn/nukkit/command/data/CommandParameter.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package cn.nukkit.command.data;
-
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-public class CommandParameter {
-
- public final static String ARG_TYPE_STRING = "string";
- public final static String ARG_TYPE_STRING_ENUM = "stringenum";
- public final static String ARG_TYPE_BOOL = "bool";
- public final static String ARG_TYPE_TARGET = "target";
- public final static String ARG_TYPE_PLAYER = "target";
- public final static String ARG_TYPE_BLOCK_POS = "blockpos";
- public final static String ARG_TYPE_RAW_TEXT = "rawtext";
- public final static String ARG_TYPE_INT = "int";
-
- public static final String ENUM_TYPE_ITEM_LIST = "Item";
- public static final String ENUM_TYPE_BLOCK_LIST = "Block";
- public static final String ENUM_TYPE_COMMAND_LIST = "commandName";
- public static final String ENUM_TYPE_ENCHANTMENT_LIST = "enchantmentType";
- public static final String ENUM_TYPE_ENTITY_LIST = "entityType";
- public static final String ENUM_TYPE_EFFECT_LIST = "effectType";
- public static final String ENUM_TYPE_PARTICLE_LIST = "particleType";
-
- public String name;
- public CommandParamType type;
- public boolean optional;
- public byte options = 0;
-
- public CommandEnum enumData;
- public String postFix;
-
- public CommandParameter(String name, String type, boolean optional) {
- this(name, fromString(type), optional);
- }
-
- public CommandParameter(String name, CommandParamType type, boolean optional) {
- this.name = name;
- this.type = type;
- this.optional = optional;
- }
-
- public CommandParameter(String name, boolean optional) {
- this(name, CommandParamType.RAWTEXT, optional);
- }
-
- public CommandParameter(String name) {
- this(name, false);
- }
-
- public CommandParameter(String name, boolean optional, String enumType) {
- this.name = name;
- this.type = CommandParamType.RAWTEXT;
- this.optional = optional;
- this.enumData = new CommandEnum(enumType, new ArrayList<>());
- }
-
- public CommandParameter(String name, boolean optional, String[] enumValues) {
- this.name = name;
- this.type = CommandParamType.RAWTEXT;
- this.optional = optional;
- this.enumData = new CommandEnum(name + "Enums", Arrays.asList(enumValues));
- }
-
- public CommandParameter(String name, String enumType) {
- this(name, false, enumType);
- }
-
- public CommandParameter(String name, String[] enumValues) {
- this(name, false, enumValues);
- }
-
- private CommandParameter(String name, boolean optional, CommandParamType type, CommandEnum enumData, String postFix) {
- this.name = name;
- this.optional = optional;
- this.type = type;
- this.enumData = enumData;
- this.postFix = postFix;
- }
-
- public static CommandParameter newType(String name, CommandParamType type) {
- return newType(name, false, type);
- }
-
- public static CommandParameter newType(String name, boolean optional, CommandParamType type) {
- return new CommandParameter(name, optional, type, null, null);
- }
-
- public static CommandParameter newEnum(String name, String[] values) {
- return newEnum(name, false, values);
- }
-
- public static CommandParameter newEnum(String name, boolean optional, String[] values) {
- return newEnum(name, optional, new CommandEnum(name + "Enums", values));
- }
-
- public static CommandParameter newEnum(String name, String type) {
- return newEnum(name, false, type);
- }
-
- public static CommandParameter newEnum(String name, boolean optional, String type) {
- return newEnum(name, optional, new CommandEnum(type, new ArrayList<>()));
- }
-
- public static CommandParameter newEnum(String name, CommandEnum data) {
- return newEnum(name, false, data);
- }
-
- public static CommandParameter newEnum(String name, boolean optional, CommandEnum data) {
- return new CommandParameter(name, optional, CommandParamType.RAWTEXT, data, null);
- }
-
- public static CommandParameter newPostfix(String name, String postfix) {
- return newPostfix(name, false, postfix);
- }
-
- public static CommandParameter newPostfix(String name, boolean optional, String postfix) {
- return new CommandParameter(name, optional, CommandParamType.RAWTEXT, null, postfix);
- }
-
- protected static CommandParamType fromString(String param) {
- switch (param) {
- case "string":
- case "stringenum":
- return CommandParamType.STRING;
- case "target":
- return CommandParamType.TARGET;
- case "blockpos":
- return CommandParamType.POSITION;
- case "rawtext":
- return CommandParamType.RAWTEXT;
- case "int":
- return CommandParamType.INT;
- }
-
- return CommandParamType.RAWTEXT;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/data/args/CommandArg.java b/src/main/java/cn/nukkit/command/data/args/CommandArg.java
deleted file mode 100644
index c2f8a888b..000000000
--- a/src/main/java/cn/nukkit/command/data/args/CommandArg.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.nukkit.command.data.args;
-
-public class CommandArg {
-
- private CommandArgRules[] rules;
- private String selector;
-
- public CommandArgRules[] getRules() {
- return rules;
- }
-
- public String getSelector() {
- return selector;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/data/args/CommandArgBlockVector.java b/src/main/java/cn/nukkit/command/data/args/CommandArgBlockVector.java
deleted file mode 100644
index 83cc78b7c..000000000
--- a/src/main/java/cn/nukkit/command/data/args/CommandArgBlockVector.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package cn.nukkit.command.data.args;
-
-public class CommandArgBlockVector {
-
- private int x;
- private int y;
- private int z;
- private boolean xrelative;
- private boolean yrelative;
- private boolean zrelative;
-
- public int getX() {
- return x;
- }
-
- public int getY() {
- return y;
- }
-
- public int getZ() {
- return z;
- }
-
- public boolean isXrelative() {
- return xrelative;
- }
-
- public boolean isYrelative() {
- return yrelative;
- }
-
- public boolean isZrelative() {
- return zrelative;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/data/args/CommandArgRules.java b/src/main/java/cn/nukkit/command/data/args/CommandArgRules.java
deleted file mode 100644
index e6bb1e05c..000000000
--- a/src/main/java/cn/nukkit/command/data/args/CommandArgRules.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package cn.nukkit.command.data.args;
-
-public class CommandArgRules {
-
- private boolean inverted;
- private String name;
- private String value;
-
- public boolean isInverted() {
- return inverted;
- }
-
- public String getName() {
- return name;
- }
-
- public String getValue() {
- return value;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/BanCommand.java b/src/main/java/cn/nukkit/command/defaults/BanCommand.java
deleted file mode 100644
index 7c17c5210..000000000
--- a/src/main/java/cn/nukkit/command/defaults/BanCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.event.player.PlayerKickEvent;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BanCommand extends VanillaCommand {
-
- public BanCommand(String name) {
- super(name, "%nukkit.command.ban.player.description", "%commands.ban.usage");
- this.setPermission("nukkit.command.ban.player");
- this.commandParameters.clear();
- this.commandParameters.put("default",
- new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("reason", CommandParamType.STRING, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return false;
- }
-
- String name = args[0].replace("@s", sender.getName());
- StringBuilder reason = new StringBuilder();
- for (int i = 1; i < args.length; i++) {
- reason.append(args[i]).append(' ');
- }
-
- if (reason.length() > 0) {
- reason = new StringBuilder(reason.substring(0, reason.length() - 1));
- }
-
- sender.getServer().getNameBans().addBan(name, reason.toString(), null, sender.getName());
-
- Player player = sender.getServer().getPlayerExact(name);
- if (player != null) {
- player.kick(PlayerKickEvent.Reason.NAME_BANNED, (reason.length() > 0) ? "You are banned! Reason: " + reason : "You are banned!", true, "source=" + sender.getName() + ", reason=" + reason);
- }
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.ban.success", player != null ? player.getName() : name));
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/BanIpCommand.java b/src/main/java/cn/nukkit/command/defaults/BanIpCommand.java
deleted file mode 100644
index 24e54711d..000000000
--- a/src/main/java/cn/nukkit/command/defaults/BanIpCommand.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.event.player.PlayerKickEvent;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.regex.Pattern;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class BanIpCommand extends VanillaCommand {
-
- public BanIpCommand(String name) {
- super(name, "%nukkit.command.ban.ip.description", "%commands.banip.usage");
- this.setPermission("nukkit.command.ban.ip");
- this.setAliases(new String[]{"banip"});
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("reason", CommandParamType.STRING, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return false;
- }
-
- String value = args[0];
- StringBuilder reason = new StringBuilder();
- for (int i = 1; i < args.length; i++) {
- reason.append(args[i]).append(' ');
- }
-
- if (reason.length() > 0) {
- reason = new StringBuilder(reason.substring(0, reason.length() - 1));
- }
-
- if (Pattern.matches("^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$", value)) {
- processIPBan(value, sender, reason.toString());
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.banip.success", value));
- } else {
- Player player = sender.getServer().getPlayer(value);
- if (player != null) {
- processIPBan(player.getAddress(), sender, reason.toString());
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.banip.success.players", player.getAddress(), player.getName()));
- } else {
- String name = value.toLowerCase();
- String path = sender.getServer().getDataPath() + "players/";
- File file = new File(path + name + ".dat");
- CompoundTag nbt = null;
- if (file.exists()) {
- try {
- nbt = NBTIO.readCompressed(new FileInputStream(file));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- if (nbt != null && nbt.contains("lastIP") && Pattern.matches("^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$", (value = nbt.getString("lastIP")))) {
- processIPBan(value, sender, reason.toString());
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.banip.success", value));
- } else {
- sender.sendMessage(new TranslationContainer("commands.banip.invalid"));
- return false;
- }
- }
- }
-
- return true;
- }
-
- private static void processIPBan(String ip, CommandSender sender, String reason) {
- sender.getServer().getIPBans().addBan(ip, reason, null, sender.getName());
-
- for (Player player : /*new ArrayList<>(*/sender.getServer().getOnlinePlayers().values()/*)*/) {
- if (player.getAddress().equals(ip)) {
- player.kick(PlayerKickEvent.Reason.IP_BANNED, !reason.isEmpty() ? reason : "IP banned", true, "source=" + sender.getName() + ", reason=" + reason);
- }
- }
-
- try {
- sender.getServer().getNetwork().blockAddress(InetAddress.getByName(ip), -1);
- } catch (UnknownHostException ignore) {}
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/BanListCommand.java b/src/main/java/cn/nukkit/command/defaults/BanListCommand.java
deleted file mode 100644
index 3da8e6395..000000000
--- a/src/main/java/cn/nukkit/command/defaults/BanListCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.permission.BanEntry;
-import cn.nukkit.permission.BanList;
-
-import java.util.Iterator;
-
-/**
- * Created on 2015/11/11 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class BanListCommand extends VanillaCommand {
-
- public BanListCommand(String name) {
- super(name, "%nukkit.command.banlist.description", "%commands.banlist.usage");
- this.setPermission("nukkit.command.ban.list");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("ips|players", true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- BanList list;
- boolean ips = false;
- if (args.length > 0) {
- switch (args[0].toLowerCase()) {
- case "ips":
- list = sender.getServer().getIPBans();
- ips = true;
- break;
- case "players":
- list = sender.getServer().getNameBans();
- break;
- default:
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
- } else {
- list = sender.getServer().getNameBans();
- }
-
- StringBuilder builder = new StringBuilder();
- Iterator itr = list.getEntires().values().iterator();
- while (itr.hasNext()) {
- builder.append(itr.next().getName());
- if (itr.hasNext()) {
- builder.append(", ");
- }
- }
-
- if (ips) {
- sender.sendMessage(new TranslationContainer("commands.banlist.ips", String.valueOf(list.getEntires().size())));
- } else {
- sender.sendMessage(new TranslationContainer("commands.banlist.players", String.valueOf(list.getEntires().size())));
- }
- sender.sendMessage(builder.toString());
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/DebugPasteCommand.java b/src/main/java/cn/nukkit/command/defaults/DebugPasteCommand.java
deleted file mode 100644
index ccd987e40..000000000
--- a/src/main/java/cn/nukkit/command/defaults/DebugPasteCommand.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Nukkit;
-import cn.nukkit.Server;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.network.protocol.ProtocolInfo;
-import cn.nukkit.plugin.Plugin;
-import cn.nukkit.plugin.PluginDescription;
-import cn.nukkit.scheduler.AsyncTask;
-import cn.nukkit.utils.HastebinUtility;
-import cn.nukkit.utils.MainLogger;
-import cn.nukkit.utils.Utils;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-
-public class DebugPasteCommand extends VanillaCommand {
-
- public DebugPasteCommand(String name) {
- super(name, "%nukkit.command.debug.description", "%commands.debug.usage");
- this.setPermission("nukkit.command.debug.perform");
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- Server server = Server.getInstance();
- sender.sendMessage("Uploading...");
- server.getScheduler().scheduleAsyncTask(new DebugPasteTask(server, sender));
- return true;
- }
-
- private static class DebugPasteTask extends AsyncTask {
-
- private final Server server;
- private final CommandSender sender;
-
- public DebugPasteTask(Server server, CommandSender sender) {
- this.server = server;
- this.sender = sender;
- }
-
- @Override
- public void onRun() {
- try {
- new StatusCommand("status").execute(server.getConsoleSender(), "status", new String[]{});
- String dataPath = server.getDataPath();
- String serverProperties = HastebinUtility.upload(new File(dataPath, "server.properties"));
- String latestLog = HastebinUtility.upload(new File(dataPath, "/logs/server.log"));
- String threadDump = HastebinUtility.upload(Utils.getAllThreadDumps());
-
- StringBuilder b = new StringBuilder();
- b.append("# Files\n");
- b.append("links.server_properties: ").append(serverProperties).append('\n');
- b.append("links.server_log: ").append(latestLog).append('\n');
- b.append("links.thread_dump: ").append(threadDump).append('\n');
- b.append("\n# Server Information\n");
-
- //b.append("version.api: ").append(server.getApiVersion()).append('\n');
- b.append("version.nukkit: ").append(Nukkit.NUKKIT).append('\n');
- b.append("version.build: ").append(Nukkit.getBranch()).append('/').append(Nukkit.VERSION.substring(4)).append('\n');
- b.append("version.minecraft: ").append(ProtocolInfo.MINECRAFT_VERSION).append('\n');
- b.append("version.protocol: ").append(ProtocolInfo.CURRENT_PROTOCOL).append('\n');
- b.append("plugins:");
-
- for (Plugin plugin : server.getPluginManager().getPlugins().values()) {
- boolean enabled = plugin.isEnabled();
- String name = plugin.getName();
- PluginDescription desc = plugin.getDescription();
- String version = desc.getVersion();
- b.append("\n ")
- .append(name)
- .append(":\n ")
- .append("version: '")
- .append(version)
- .append('\'')
- .append("\n enabled: ")
- .append(enabled);
- }
-
- b.append("\n\n# Java Details\n");
- Runtime runtime = Runtime.getRuntime();
- b.append("memory.free: ").append(runtime.freeMemory()).append('\n');
- b.append("memory.max: ").append(runtime.maxMemory()).append('\n');
- b.append("cpu.runtime: ").append(ManagementFactory.getRuntimeMXBean().getUptime()).append('\n');
- b.append("cpu.processors: ").append(runtime.availableProcessors()).append('\n');
- b.append("java.specification.version: '").append(System.getProperty("java.specification.version")).append("'\n");
- b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n");
- b.append("java.version: '").append(System.getProperty("java.version")).append("'\n");
- b.append("os.arch: '").append(System.getProperty("os.arch")).append("'\n");
- b.append("os.name: '").append(System.getProperty("os.name")).append("'\n");
- b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n");
- String link = HastebinUtility.upload(b.toString());
- sender.sendMessage(link);
- } catch (IOException e) {
- MainLogger.getLogger().logException(e);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/command/defaults/DefaultGamemodeCommand.java b/src/main/java/cn/nukkit/command/defaults/DefaultGamemodeCommand.java
deleted file mode 100644
index f1910832d..000000000
--- a/src/main/java/cn/nukkit/command/defaults/DefaultGamemodeCommand.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Server;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class DefaultGamemodeCommand extends VanillaCommand {
-
- public DefaultGamemodeCommand(String name) {
- super(name, "%nukkit.command.defaultgamemode.description", "%commands.defaultgamemode.usage");
- this.setPermission("nukkit.command.defaultgamemode");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("mode", CommandParamType.INT, false)
- });
- this.commandParameters.put("byString", new CommandParameter[]{
- new CommandParameter("mode", new String[]{"survival", "creative", "s", "c",
- "adventure", "a", "spectator", "view", "v"})
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", new String[]{this.usageMessage}));
- return false;
- }
- int gameMode = Server.getGamemodeFromString(args[0]);
- if (gameMode != -1) {
- sender.getServer().setPropertyInt("gamemode", gameMode);
- sender.sendMessage(new TranslationContainer("commands.defaultgamemode.success", new String[]{Server.getGamemodeString(gameMode)}));
- } else {
- sender.sendMessage("Unknown game mode");
- }
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/DeopCommand.java b/src/main/java/cn/nukkit/command/defaults/DeopCommand.java
deleted file mode 100644
index afe877993..000000000
--- a/src/main/java/cn/nukkit/command/defaults/DeopCommand.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.IPlayer;
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class DeopCommand extends VanillaCommand {
-
- public DeopCommand(String name) {
- super(name, "%nukkit.command.deop.description", "%commands.deop.description");
- this.setPermission("nukkit.command.op.take");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return false;
- }
-
- String playerName = args[0].replace("@s", sender.getName());
- IPlayer player = sender.getServer().getOfflinePlayer(playerName);
- player.setOp(false);
-
- if (player instanceof Player) {
- ((Player) player).sendMessage(new TranslationContainer(TextFormat.GRAY + "%commands.deop.message"));
- }
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.deop.success", new String[]{player.getName()}));
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/DifficultyCommand.java b/src/main/java/cn/nukkit/command/defaults/DifficultyCommand.java
deleted file mode 100644
index 993cf811b..000000000
--- a/src/main/java/cn/nukkit/command/defaults/DifficultyCommand.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Server;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.network.protocol.SetDifficultyPacket;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class DifficultyCommand extends VanillaCommand {
-
- public DifficultyCommand(String name) {
- super(name, "%nukkit.command.difficulty.description", "%commands.difficulty.usage");
- this.setPermission("nukkit.command.difficulty");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("difficulty", CommandParamType.INT, false)
- });
- this.commandParameters.put("byString", new CommandParameter[]{
- new CommandParameter("difficulty", new String[]{"peaceful", "p", "easy", "e",
- "normal", "n", "hard", "h"})
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length != 1) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
-
- int difficulty = Server.getDifficultyFromString(args[0]);
-
- if (sender.getServer().isHardcore()) {
- difficulty = 3;
- }
-
- if (difficulty != -1) {
- sender.getServer().setDifficulty(difficulty);
-
- SetDifficultyPacket pk = new SetDifficultyPacket();
- pk.difficulty = sender.getServer().getDifficulty();
- Server.broadcastPacket(/*new ArrayList<>(*/sender.getServer().getOnlinePlayers().values()/*)*/, pk);
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.difficulty.success", String.valueOf(difficulty)));
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return false;
- }
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/EffectCommand.java b/src/main/java/cn/nukkit/command/defaults/EffectCommand.java
deleted file mode 100644
index 4028cf425..000000000
--- a/src/main/java/cn/nukkit/command/defaults/EffectCommand.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.potion.Effect;
-import cn.nukkit.potion.InstantEffect;
-import cn.nukkit.utils.ServerException;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created by Snake1999 and Pub4Game on 2016/1/23.
- * Package cn.nukkit.command.defaults in project nukkit.
- */
-public class EffectCommand extends Command {
-
- public EffectCommand(String name) {
- super(name, "%nukkit.command.effect.description", "%commands.effect.usage");
- this.setPermission("nukkit.command.effect");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("effect", CommandParamType.STRING, false), //Do not use Enum here because of buggy behavior
- new CommandParameter("seconds", CommandParamType.INT, true),
- new CommandParameter("amplifier", true),
- new CommandParameter("hideParticle", true, new String[]{"true", "false"})
- });
- this.commandParameters.put("clear", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("clear", new String[]{"clear"})
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- if (args.length < 2) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- Player player = sender.getServer().getPlayer(args[0].replace("@s", sender.getName()));
- if (player == null) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
- return true;
- }
- if (args[1].equalsIgnoreCase("clear")) {
- for (Effect effect : player.getEffects().values()) {
- player.removeEffect(effect.getId());
- }
- sender.sendMessage(new TranslationContainer("commands.effect.success.removed.all", player.getDisplayName()));
- return true;
- }
- Effect effect;
- try {
- effect = Effect.getEffect(Integer.parseInt(args[1]));
- } catch (NumberFormatException | ServerException a) {
- try {
- effect = Effect.getEffectByName(args[1]);
- } catch (Exception e) {
- sender.sendMessage(new TranslationContainer("commands.effect.notFound", args[1]));
- return true;
- }
- }
- int duration = 300;
- int amplification = 1;
- if (args.length >= 3) {
- try {
- duration = Integer.parseInt(args[2]);
- } catch (NumberFormatException a) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- if (!(effect instanceof InstantEffect)) {
- duration *= 20;
- }
- } else if (effect instanceof InstantEffect) {
- duration = 1;
- }
- if (args.length >= 4) {
- try {
- amplification = Integer.parseInt(args[3]);
- } catch (NumberFormatException a) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- }
- if (args.length >= 5) {
- String v = args[4].toLowerCase();
- if (v.matches("(?i)|on|true|t|1")) {
- effect.setVisible(false);
- }
- }
- if (duration == 0) {
- if (!player.hasEffect(effect.getId())) {
- if (player.getEffects().isEmpty()) {
- sender.sendMessage(new TranslationContainer("commands.effect.failure.notActive.all", player.getDisplayName()));
- } else {
- sender.sendMessage(new TranslationContainer("commands.effect.failure.notActive", effect.getName(), player.getDisplayName()));
- }
- return true;
- }
- player.removeEffect(effect.getId());
- sender.sendMessage(new TranslationContainer("commands.effect.success.removed", effect.getName(), player.getDisplayName()));
- } else {
- effect.setDuration(duration).setAmplifier(amplification);
- player.addEffect(effect);
- Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.effect.success", effect.getName(), String.valueOf(effect.getAmplifier()), player.getDisplayName(), String.valueOf(effect.getDuration() / 20)));
- }
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/EnchantCommand.java b/src/main/java/cn/nukkit/command/defaults/EnchantCommand.java
deleted file mode 100644
index e614c92ea..000000000
--- a/src/main/java/cn/nukkit/command/defaults/EnchantCommand.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created by Pub4Game on 23.01.2016.
- */
-public class EnchantCommand extends VanillaCommand {
-
- public EnchantCommand(String name) {
- super(name, "%nukkit.command.enchant.description", "%commands.enchant.usage");
- this.setPermission("nukkit.command.enchant");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("enchantment ID", CommandParamType.INT, false),
- new CommandParameter("level", CommandParamType.INT, true)
- });
- this.commandParameters.put("byName", new CommandParameter[]{
- new CommandParameter("player", CommandParameter.ARG_TYPE_TARGET, false),
- new CommandParameter("id", false, CommandParameter.ENUM_TYPE_ENCHANTMENT_LIST),
- new CommandParameter("level", CommandParamType.INT, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- if (args.length < 2) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- Player player = sender.getServer().getPlayer(args[0].replace("@s", sender.getName()));
- if (player == null) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
- return true;
- }
- int enchantId;
- int enchantLevel;
- try {
- enchantId = getIdByName(args[1]);
- enchantLevel = args.length == 3 ? Integer.parseInt(args[2]) : 1;
- } catch (NumberFormatException e) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- Enchantment enchantment = Enchantment.getEnchantment(enchantId);
- if (enchantment == null) {
- sender.sendMessage(new TranslationContainer("commands.enchant.notFound", String.valueOf(enchantId)));
- return true;
- }
- enchantment.setLevel(enchantLevel);
- Item item = player.getInventory().getItemInHand();
- if (item.getId() <= 0) {
- sender.sendMessage(new TranslationContainer("commands.enchant.noItem"));
- return true;
- }
- item.addEnchantment(enchantment);
- player.getInventory().setItemInHand(item);
- Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.enchant.success"));
- return true;
- }
-
- public int getIdByName(String value) throws NumberFormatException {
- value = value.toLowerCase();
- switch (value) {
- case "protection":
- return 0;
- case "fire_protection":
- return 1;
- case "feather_falling":
- return 2;
- case "blast_protection":
- return 3;
- case "projectile_projection":
- return 4;
- case "thorns":
- return 5;
- case "respiration":
- return 6;
- case "aqua_affinity":
- return 7;
- case "depth_strider":
- return 8;
- case "sharpness":
- return 9;
- case "smite":
- return 10;
- case "bane_of_arthropods":
- return 11;
- case "knockback":
- return 12;
- case "fire_aspect":
- return 13;
- case "looting":
- return 14;
- case "efficiency":
- return 15;
- case "silk_touch":
- return 16;
- case "durability":
- case "unbreaking":
- return 17;
- case "fortune":
- return 18;
- case "power":
- return 19;
- case "punch":
- return 20;
- case "flame":
- return 21;
- case "infinity":
- return 22;
- case "luck_of_the_sea":
- return 23;
- case "lure":
- return 24;
- case "frost_walker":
- return 25;
- case "mending":
- return 26;
- case "binding_curse":
- return 27;
- case "vanishing_curse":
- return 28;
- case "impaling":
- return 29;
- case "riptide":
- return 30;
- case "loyalty":
- return 31;
- case "channeling":
- return 32;
- case "multishot":
- return 33;
- case "piercing":
- return 34;
- case "quick_charge":
- return 35;
- case "soul_speed":
- return 36;
- default:
- return Integer.parseInt(value);
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/GamemodeCommand.java b/src/main/java/cn/nukkit/command/defaults/GamemodeCommand.java
deleted file mode 100644
index 131b60168..000000000
--- a/src/main/java/cn/nukkit/command/defaults/GamemodeCommand.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/13 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class GamemodeCommand extends VanillaCommand {
-
- public GamemodeCommand(String name) {
- super(name, "%nukkit.command.gamemode.description", "%commands.gamemode.usage",
- new String[]{"gm"});
- this.setPermission("nukkit.command.gamemode.survival;" +
- "nukkit.command.gamemode.creative;" +
- "nukkit.command.gamemode.adventure;" +
- "nukkit.command.gamemode.spectator;" +
- "nukkit.command.gamemode.other");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("mode", CommandParamType.INT, false),
- new CommandParameter("player", CommandParamType.TARGET, true)
- });
- this.commandParameters.put("byString", new CommandParameter[]{
- new CommandParameter("mode", new String[]{"survival", "s", "creative", "c",
- "adventure", "a", "spectator", "spc", "view", "v"}),
- new CommandParameter("player", CommandParamType.TARGET, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
-
- int gameMode = Server.getGamemodeFromString(args[0]);
- if (gameMode == -1) {
- sender.sendMessage("Unknown game mode");
- return true;
- }
-
- CommandSender target = sender;
- if (args.length > 1) {
- if (sender.hasPermission("nukkit.command.gamemode.other")) {
- target = sender.getServer().getPlayer(args[1].replace("@s", sender.getName()));
- if (target == null) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
- return true;
- }
- } else {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
- return true;
- }
- } else if (!(sender instanceof Player)) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-
- if ((gameMode == 0 && !sender.hasPermission("nukkit.command.gamemode.survival")) ||
- (gameMode == 1 && !sender.hasPermission("nukkit.command.gamemode.creative")) ||
- (gameMode == 2 && !sender.hasPermission("nukkit.command.gamemode.adventure")) ||
- (gameMode == 3 && !sender.hasPermission("nukkit.command.gamemode.spectator"))) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
- return true;
- }
-
- if (!((Player) target).setGamemode(gameMode)) {
- sender.sendMessage("Game mode update for " + target.getName() + " failed");
- } else {
- if (target.equals(sender)) {
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.self", Server.getGamemodeString(gameMode)));
- } else {
- target.sendMessage(new TranslationContainer("gameMode.changed"));
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.gamemode.success.other", target.getName(), Server.getGamemodeString(gameMode)));
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/GameruleCommand.java b/src/main/java/cn/nukkit/command/defaults/GameruleCommand.java
deleted file mode 100644
index 19c83a6f7..000000000
--- a/src/main/java/cn/nukkit/command/defaults/GameruleCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.GameRule;
-import cn.nukkit.level.GameRules;
-
-import java.util.Arrays;
-import java.util.Optional;
-import java.util.StringJoiner;
-
-public class GameruleCommand extends VanillaCommand {
-
- public GameruleCommand(String name) {
- super(name, "%nukkit.command.gamerule.description", "%commands.gamerule.usage");
- this.setPermission("nukkit.command.gamerule");
- this.commandParameters.clear();
- this.commandParameters.put("byString", new CommandParameter[]{
- new CommandParameter("gamerule", true , GameRule.getNamesLowerCase()),
- new CommandParameter("value", CommandParamType.STRING, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (!sender.isPlayer()) {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- return true;
- }
- GameRules rules = ((Player) sender).getLevel().getGameRules();
-
- switch (args.length) {
- case 0:
- StringJoiner rulesJoiner = new StringJoiner(", ");
- for (GameRule rule: rules.getRules()) {
- rulesJoiner.add(rule.getName().toLowerCase());
- }
- sender.sendMessage(rulesJoiner.toString());
- return true;
- case 1:
- Optional gameRule = GameRule.parseString(args[0]);
- if (!gameRule.isPresent() || !rules.hasRule(gameRule.get())) {
- sender.sendMessage(new TranslationContainer("commands.generic.syntax", "/gamerule", args[0]));
- return true;
- }
-
- sender.sendMessage(gameRule.get().getName() + " = " + rules.getString(gameRule.get()));
- return true;
- default:
- Optional optionalRule = GameRule.parseString(args[0]);
-
- if (!optionalRule.isPresent()) {
- sender.sendMessage(new TranslationContainer("commands.generic.syntax", "/gamerule ", args[0], ' ' + String.join(" ", Arrays.copyOfRange(args, 1, args.length))));
- return true;
- }
-
- try {
- rules.setGameRules(optionalRule.get(), args[1]);
- sender.sendMessage(new TranslationContainer("commands.gamerule.success", optionalRule.get().getName(), args[1]));
- } catch (IllegalArgumentException e) {
- sender.sendMessage(new TranslationContainer("commands.generic.syntax", "/gamerule " + args[0] + ' ', args[1], ' ' + String.join(" ", Arrays.copyOfRange(args, 2, args.length))));
- }
- return true;
- }
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/command/defaults/GarbageCollectorCommand.java b/src/main/java/cn/nukkit/command/defaults/GarbageCollectorCommand.java
deleted file mode 100644
index 94cb5c126..000000000
--- a/src/main/java/cn/nukkit/command/defaults/GarbageCollectorCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.NukkitMath;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/11 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class GarbageCollectorCommand extends VanillaCommand {
-
- public GarbageCollectorCommand(String name) {
- super(name, "%nukkit.command.gc.description", "%nukkit.command.gc.usage");
- this.setPermission("nukkit.command.gc");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- int chunksCollected = 0;
- int entitiesCollected = 0;
- int tilesCollected = 0;
- long memory = Runtime.getRuntime().freeMemory();
-
- for (Level level : sender.getServer().getLevels().values()) {
- int chunksCount = level.getChunks().size();
- int entitiesCount = level.getEntities().length;
- int tilesCount = level.getBlockEntities().size();
- level.doChunkGarbageCollection();
- level.unloadChunks(true);
- chunksCollected += chunksCount - level.getChunks().size();
- entitiesCollected += entitiesCount - level.getEntities().length;
- tilesCollected += tilesCount - level.getBlockEntities().size();
- }
-
- System.gc();
-
- long freedMemory = Runtime.getRuntime().freeMemory() - memory;
-
- sender.sendMessage(TextFormat.GREEN + "---- " + TextFormat.WHITE + "Garbage collection result" + TextFormat.GREEN + " ----");
- sender.sendMessage(TextFormat.GOLD + "Chunks: " + TextFormat.RED + chunksCollected);
- sender.sendMessage(TextFormat.GOLD + "Entities: " + TextFormat.RED + entitiesCollected);
- sender.sendMessage(TextFormat.GOLD + "Block Entities: " + TextFormat.RED + tilesCollected);
- sender.sendMessage(TextFormat.GOLD + "Memory freed: " + TextFormat.RED + NukkitMath.round((freedMemory / 1024d / 1024d), 2) + " MB");
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/GenerateWorldCommand.java b/src/main/java/cn/nukkit/command/defaults/GenerateWorldCommand.java
deleted file mode 100644
index 9d1b469d5..000000000
--- a/src/main/java/cn/nukkit/command/defaults/GenerateWorldCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Server;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.level.generator.Generator;
-
-public class GenerateWorldCommand extends Command {
-
- public GenerateWorldCommand(String name) {
- super(name, "%nukkit.command.generateworld.description", "%nukkit.command.generateworld.usage");
- this.setPermission("nukkit.command.generateworld");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("name", CommandParamType.STRING, false),
- new CommandParameter("type", CommandParamType.STRING, false),
- new CommandParameter("seed", CommandParamType.INT, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 3) {
- if (Server.getInstance().isLevelGenerated(args[0])) {
- sender.sendMessage("\u00A7cWorld \u00A77" + args[0] + " \u00A7calready exists");
- return true;
- }
-
- long seed;
-
- try {
- seed = Long.parseLong(args[2]);
- } catch (NumberFormatException e) {
- sender.sendMessage("\u00A7cThe seed must be numeric");
- return true;
- }
-
- Server.getInstance().generateLevel(args[0], seed, Generator.getGenerator(args[1]));
-
- sender.sendMessage("\u00A72Generating world \u00A77" + args[0] + "\u00A72...");
-
- return true;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/GiveCommand.java b/src/main/java/cn/nukkit/command/defaults/GiveCommand.java
deleted file mode 100644
index 5678afeeb..000000000
--- a/src/main/java/cn/nukkit/command/defaults/GiveCommand.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.item.Item;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/12/9 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class GiveCommand extends VanillaCommand {
-
- public GiveCommand(String name) {
- super(name, "%nukkit.command.give.description", "%nukkit.command.give.usage");
- this.setPermission("nukkit.command.give");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("itemName", false, CommandParameter.ENUM_TYPE_ITEM_LIST),
- new CommandParameter("amount", CommandParamType.INT, true),
- new CommandParameter("meta", CommandParamType.INT, true),
- new CommandParameter("tags...", CommandParamType.RAWTEXT, true)
- });
- this.commandParameters.put("toPlayerById", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("item ID", CommandParamType.INT, false),
- new CommandParameter("amount", CommandParamType.INT, true),
- new CommandParameter("tags...", CommandParamType.RAWTEXT, true)
- });
- this.commandParameters.put("toPlayerByIdMeta", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("item ID:meta", CommandParamType.RAWTEXT, false),
- new CommandParameter("amount", CommandParamType.INT, true),
- new CommandParameter("tags...", CommandParamType.RAWTEXT, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length < 2) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return true;
- }
-
- Player player = sender.getServer().getPlayer(args[0].replace("@s", sender.getName()));
- Item item;
-
- try {
- item = Item.fromString(args[1]);
- } catch (Exception e) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-
- if (item.getDamage() < 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-
- try {
- item.setCount(Integer.parseInt(args[2]));
- } catch (Exception e) {
- item.setCount(item.getMaxStackSize());
- }
-
- if (player != null) {
- if (item.getId() == 0) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.give.item.notFound", args[1]));
- return true;
- }
- player.getInventory().addItem(item.clone());
- } else {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
-
- return true;
- }
- Command.broadcastCommandMessage(sender, new TranslationContainer(
- "%commands.give.success",
- item.getName() + " (" + item.getId() + ':' + item.getDamage() + ')',
- String.valueOf(item.getCount()),
- player.getName()));
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/HelpCommand.java b/src/main/java/cn/nukkit/command/defaults/HelpCommand.java
deleted file mode 100644
index 206f31c00..000000000
--- a/src/main/java/cn/nukkit/command/defaults/HelpCommand.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.ConsoleCommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class HelpCommand extends VanillaCommand {
-
- public HelpCommand(String name) {
- super(name, "%nukkit.command.help.description", "%commands.help.usage", new String[]{"?"});
- this.setPermission("nukkit.command.help");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("page", CommandParamType.INT, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- StringBuilder command = new StringBuilder();
- int pageNumber = 1;
- int pageHeight = 5;
- if (args.length != 0) {
- try {
- pageNumber = Integer.parseInt(args[args.length - 1]);
- if (pageNumber <= 0) {
- pageNumber = 1;
- }
-
- String[] newargs = new String[args.length - 1];
- System.arraycopy(args, 0, newargs, 0, newargs.length);
- args = newargs;
- /*if (args.length > 1) {
- args = Arrays.copyOfRange(args, 0, args.length - 2);
- } else {
- args = new String[0];
- }*/
- for (String arg : args) {
- if (command.length() > 0) {
- command.append(' ');
- }
- command.append(arg);
- }
- } catch (NumberFormatException e) {
- pageNumber = 1;
- for (String arg : args) {
- if (command.length() > 0) {
- command.append(' ');
- }
- command.append(arg);
- }
- }
- }
-
- if (sender instanceof ConsoleCommandSender) {
- pageHeight = Integer.MAX_VALUE;
- }
-
- if (command.length() == 0) {
- Map commands = new TreeMap<>();
- for (Command cmd : sender.getServer().getCommandMap().getCommands().values()) {
- if (cmd.testPermissionSilent(sender)) {
- commands.put(cmd.getName(), cmd);
- }
- }
- int totalPage = commands.size() % pageHeight == 0 ? commands.size() / pageHeight : commands.size() / pageHeight + 1;
- pageNumber = Math.min(pageNumber, totalPage);
- if (pageNumber < 1) {
- pageNumber = 1;
- }
-
- sender.sendMessage(new TranslationContainer("commands.help.header", String.valueOf(pageNumber), String.valueOf(totalPage)));
- int i = 1;
- for (Command command1 : commands.values()) {
- if (i >= (pageNumber - 1) * pageHeight + 1 && i <= Math.min(commands.size(), pageNumber * pageHeight)) {
- sender.sendMessage(TextFormat.DARK_GREEN + "/" + command1.getName() + ": " + TextFormat.WHITE + command1.getDescription());
- }
- i++;
- }
-
- return true;
- } else {
- Command cmd = sender.getServer().getCommandMap().getCommand(command.toString().toLowerCase());
- if (cmd != null) {
- if (cmd.testPermissionSilent(sender)) {
- String message = TextFormat.YELLOW + "--------- " + TextFormat.WHITE + " Help: /" + cmd.getName() + TextFormat.YELLOW + " ---------\n";
- message += TextFormat.GOLD + "Description: " + TextFormat.WHITE + cmd.getDescription() + '\n';
- StringBuilder usage = new StringBuilder();
- String[] usages = cmd.getUsage().split("\n");
- for (String u : usages) {
- if (usage.length() > 0) {
- usage.append("\n" + TextFormat.WHITE);
- }
- usage.append(u);
- }
- message += TextFormat.GOLD + "Usage: " + TextFormat.WHITE + usage + '\n';
- sender.sendMessage(message);
- return true;
- }
- }
-
- sender.sendMessage(TextFormat.RED + "No help for " + command.toString().toLowerCase());
- return true;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/KickCommand.java b/src/main/java/cn/nukkit/command/defaults/KickCommand.java
deleted file mode 100644
index db406fbea..000000000
--- a/src/main/java/cn/nukkit/command/defaults/KickCommand.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.event.player.PlayerKickEvent;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/11 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class KickCommand extends VanillaCommand {
-
- public KickCommand(String name) {
- super(name, "%nukkit.command.kick.description", "%commands.kick.usage");
- this.setPermission("nukkit.command.kick");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("reason", CommandParamType.STRING, false),
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
-
- String name = args[0].replace("@s", sender.getName());
-
- StringBuilder reason = new StringBuilder();
- for (int i = 1; i < args.length; i++) {
- reason.append(args[i]).append(' ');
- }
-
- if (reason.length() > 0) {
- reason = new StringBuilder(reason.substring(0, reason.length() - 1));
- }
-
- Player player = sender.getServer().getPlayer(name);
- if (player != null) {
- player.kick(PlayerKickEvent.Reason.KICKED_BY_ADMIN, reason.toString(), true, "source=" + sender.getName() + ", reason=" + reason.toString());
- if (reason.length() >= 1) {
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success.reason", player.getName(), reason.toString())
- );
- } else {
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kick.success", player.getName()));
- }
- } else {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
- }
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/KillCommand.java b/src/main/java/cn/nukkit/command/defaults/KillCommand.java
deleted file mode 100644
index 124d39689..000000000
--- a/src/main/java/cn/nukkit/command/defaults/KillCommand.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.entity.BaseEntity;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.EntityHuman;
-import cn.nukkit.entity.item.EntityItem;
-import cn.nukkit.event.entity.EntityDamageEvent;
-import cn.nukkit.event.entity.EntityDamageEvent.DamageCause;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.Level;
-import cn.nukkit.utils.TextFormat;
-
-import java.util.StringJoiner;
-
-/**
- * Created on 2015/12/08 by Pub4Game.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class KillCommand extends VanillaCommand {
-
- public KillCommand(String name) {
- super(name, "%nukkit.command.kill.description", "%nukkit.command.kill.usage", new String[]{"suicide"});
- this.setPermission("nukkit.command.kill.self;nukkit.command.kill.other");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- if (args.length >= 2) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
- if (args.length == 1) {
- if (!sender.hasPermission("nukkit.command.kill.other")) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
- return true;
- }
- Player player = sender.getServer().getPlayer(args[0]);
- if (player != null) {
- EntityDamageEvent ev = new EntityDamageEvent(player, DamageCause.SUICIDE, 1000);
- sender.getServer().getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return true;
- }
- player.setLastDamageCause(ev);
- player.setHealth(0);
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.kill.successful", player.getName()));
- } else if (args[0].equals("@e")) {
- StringJoiner joiner = new StringJoiner(", ");
- for (Level level : Server.getInstance().getLevels().values()) {
- for (Entity entity : level.getEntities()) {
- if (!(entity instanceof EntityHuman)) {
- joiner.add(entity.getName());
- if (!(entity instanceof BaseEntity)) {
- entity.close();
- } else {
- entity.attack(new EntityDamageEvent(entity, DamageCause.SUICIDE, 1000));
- }
- }
- }
- }
- String entities = joiner.toString();
- sender.sendMessage(new TranslationContainer("commands.kill.successful", entities.isEmpty() ? "0" : entities));
- } else if (args[0].equals("@b")) {
- StringJoiner joiner = new StringJoiner(", ");
- for (Level level : Server.getInstance().getLevels().values()) {
- for (Entity entity : level.getEntities()) {
- if (entity instanceof BaseEntity) {
- joiner.add(entity.getName());
- entity.attack(new EntityDamageEvent(entity, DamageCause.SUICIDE, 1000));
- }
- }
- }
- String entities = joiner.toString();
- sender.sendMessage(new TranslationContainer("commands.kill.successful", entities.isEmpty() ? "0" : entities));
- } else if (args[0].equals("@i")) {
- StringJoiner joiner = new StringJoiner(", ");
- for (Level level : Server.getInstance().getLevels().values()) {
- for (Entity entity : level.getEntities()) {
- if (entity instanceof EntityItem) {
- joiner.add(entity.getName());
- entity.close();
- }
- }
- }
- String entities = joiner.toString();
- sender.sendMessage(new TranslationContainer("commands.kill.successful", entities.isEmpty() ? "0" : entities));
- } else if (args[0].equals("@s") && sender instanceof Player) {
- if (!sender.hasPermission("nukkit.command.kill.self")) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
- return true;
- }
- EntityDamageEvent ev = new EntityDamageEvent((Player) sender, DamageCause.SUICIDE, 1000);
- sender.getServer().getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return true;
- }
- ((Player) sender).setLastDamageCause(ev);
- ((Player) sender).setHealth(0);
- sender.sendMessage(new TranslationContainer("commands.kill.successful", sender.getName()));
- } else if (args[0].equals("@a")) {
- if (!sender.hasPermission("nukkit.command.kill.other")) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
- return true;
- }
- for (Level level : Server.getInstance().getLevels().values()) {
- for (Entity entity : level.getEntities()) {
- if (entity instanceof Player) {
- entity.attack(new EntityDamageEvent(entity, DamageCause.SUICIDE, 1000));
- }
- }
- }
- sender.sendMessage(TextFormat.GOLD + "Killed all players");
- } else {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
- }
- return true;
- }
- if (sender instanceof Player) {
- if (!sender.hasPermission("nukkit.command.kill.self")) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
- return true;
- }
- EntityDamageEvent ev = new EntityDamageEvent((Player) sender, DamageCause.SUICIDE, 1000);
- sender.getServer().getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return true;
- }
- ((Player) sender).setLastDamageCause(ev);
- ((Player) sender).setHealth(0);
- sender.sendMessage(new TranslationContainer("commands.kill.successful", sender.getName()));
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/ListCommand.java b/src/main/java/cn/nukkit/command/defaults/ListCommand.java
deleted file mode 100644
index 60a0ca31a..000000000
--- a/src/main/java/cn/nukkit/command/defaults/ListCommand.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * Created on 2015/11/11 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class ListCommand extends VanillaCommand {
-
- public ListCommand(String name) {
- super(name, "%nukkit.command.list.description", "%commands.players.usage");
- this.setPermission("nukkit.command.list");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- StringBuilder online = new StringBuilder();
- int onlineCount = 0;
- for (Player player : sender.getServer().getOnlinePlayers().values()) {
- if (player.isOnline() && (!(sender instanceof Player) || ((Player) sender).canSee(player))) {
- online.append(player.getDisplayName()).append(", ");
- ++onlineCount;
- }
- }
-
- if (online.length() > 0) {
- online = new StringBuilder(online.substring(0, online.length() - 2));
- }
-
- sender.sendMessage(new TranslationContainer("commands.players.list", String.valueOf(onlineCount), String.valueOf(sender.getServer().getMaxPlayers())));
- sender.sendMessage(online.toString());
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/MeCommand.java b/src/main/java/cn/nukkit/command/defaults/MeCommand.java
deleted file mode 100644
index 70f4f81c8..000000000
--- a/src/main/java/cn/nukkit/command/defaults/MeCommand.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class MeCommand extends VanillaCommand {
-
- public MeCommand(String name) {
- super(name, "%nukkit.command.me.description", "%nukkit.command.me.usage");
- this.setPermission("nukkit.command.me");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("action ...", CommandParamType.RAWTEXT, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return false;
- }
-
- String name;
- if (sender instanceof Player) {
- name = ((Player) sender).getDisplayName();
- } else {
- name = sender.getName();
- }
-
- StringBuilder msg = new StringBuilder();
- for (String arg : args) {
- msg.append(arg).append(' ');
- }
-
- if (msg.length() > 0) {
- msg = new StringBuilder(msg.substring(0, msg.length() - 1));
- }
-
- sender.getServer().broadcastMessage(new TranslationContainer("chat.type.emote", name, TextFormat.WHITE + msg.toString()));
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/OpCommand.java b/src/main/java/cn/nukkit/command/defaults/OpCommand.java
deleted file mode 100644
index ca9e9d289..000000000
--- a/src/main/java/cn/nukkit/command/defaults/OpCommand.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.IPlayer;
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class OpCommand extends VanillaCommand {
-
- public OpCommand(String name) {
- super(name, "%nukkit.command.op.description", "%nukkit.command.op.usage");
- this.setPermission("nukkit.command.op.give");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (sender instanceof Player && !(Server.getInstance().opInGame)) {
- sender.sendMessage("\u00A7cCan't use this command in game");
- return true;
- }
-
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
-
- String name = args[0];
- IPlayer player = sender.getServer().getOfflinePlayer(name);
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.op.success", player.getName()));
- if (player instanceof Player) {
- ((Player) player).sendMessage(new TranslationContainer(TextFormat.GRAY + "%commands.op.message"));
- }
-
- player.setOp(true);
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/PardonCommand.java b/src/main/java/cn/nukkit/command/defaults/PardonCommand.java
deleted file mode 100644
index 5f4719692..000000000
--- a/src/main/java/cn/nukkit/command/defaults/PardonCommand.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class PardonCommand extends VanillaCommand {
-
- public PardonCommand(String name) {
- super(name, "%nukkit.command.unban.player.description", "%commands.unban.usage");
- this.setPermission("nukkit.command.unban.player");
- this.setAliases(new String[]{"unban"});
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length != 1) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return false;
- }
-
- sender.getServer().getNameBans().remove(args[0]);
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("%commands.unban.success", args[0]));
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/PardonIpCommand.java b/src/main/java/cn/nukkit/command/defaults/PardonIpCommand.java
deleted file mode 100644
index 91c8a113a..000000000
--- a/src/main/java/cn/nukkit/command/defaults/PardonIpCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.regex.Pattern;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class PardonIpCommand extends VanillaCommand {
-
- public PardonIpCommand(String name) {
- super(name, "%nukkit.command.unban.ip.description", "%commands.unbanip.usage");
- this.setPermission("nukkit.command.unban.ip");
- this.setAliases(new String[]{"unbanip", "unban-ip", "pardonip"});
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("ip")
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length != 1) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return false;
- }
-
- String value = args[0];
-
- if (Pattern.matches("^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$", value)) {
- sender.getServer().getIPBans().remove(value);
-
- try {
- sender.getServer().getNetwork().unblockAddress(InetAddress.getByName(value));
- } catch (UnknownHostException e) {
- sender.sendMessage(new TranslationContainer("commands.unbanip.invalid"));
- return true;
- }
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.unbanip.success", value));
- } else {
-
- sender.sendMessage(new TranslationContainer("commands.unbanip.invalid"));
- }
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/ParticleCommand.java b/src/main/java/cn/nukkit/command/defaults/ParticleCommand.java
deleted file mode 100644
index 3d5371523..000000000
--- a/src/main/java/cn/nukkit/command/defaults/ParticleCommand.java
+++ /dev/null
@@ -1,251 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.block.Block;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.item.Item;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.Position;
-import cn.nukkit.level.particle.*;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.math.Vector3f;
-import cn.nukkit.network.protocol.SpawnParticleEffectPacket;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class ParticleCommand extends VanillaCommand {
-
- private static final String[] ENUM_VALUES = new String[]{"explode", "hugeexplosion", "hugeexplosionseed", "bubble"
- , "splash", "wake", "water", "crit", "smoke", "spell", "instantspell", "dripwater", "driplava", "townaura"
- , "spore", "portal", "flame", "lava", "reddust", "snowballpoof", "slime", "itembreak", "terrain", "heart"
- , "ink", "droplet", "enchantmenttable", "happyvillager", "angryvillager", "forcefield"};
-
- public ParticleCommand(String name) {
- super(name, "%nukkit.command.particle.description", "%nukkit.command.particle.usage");
- this.setPermission("nukkit.command.particle");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("name", false, ENUM_VALUES),
- new CommandParameter("position", CommandParamType.POSITION, false),
- new CommandParameter("count", CommandParamType.INT, true),
- new CommandParameter("data", true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length < 4) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-
- Position defaultPosition;
- if (sender instanceof Player) {
- defaultPosition = ((Player) sender).getPosition();
- } else {
- defaultPosition = new Position(0, 0, 0, sender.getServer().getDefaultLevel());
- }
-
- String name = args[0].toLowerCase();
-
- double x;
- double y;
- double z;
-
- try {
- x = getDouble(args[1], defaultPosition.getX());
- y = getDouble(args[2], defaultPosition.getY());
- z = getDouble(args[3], defaultPosition.getZ());
- } catch (Exception e) {
- return false;
- }
- Position position = new Position(x, y, z, defaultPosition.getLevel());
-
- int count = 1;
- if (args.length > 4) {
- try {
- double c = Double.parseDouble(args[4]);
- count = (int) c;
- } catch (Exception ignored) {}
- }
- count = Math.max(1, count);
-
- int data = -1;
- if (args.length > 5) {
- try {
- double d = Double.parseDouble(args[8]);
- data = (int) d;
- } catch (Exception ignored) {}
- }
- if (showParticleEffect(name, position, position.getLevel(), count)) {
- sender.sendMessage(new TranslationContainer("commands.particle.success", name, String.valueOf(count)));
- } else {
- Particle particle = getParticle(name, position, data);
-
- if (particle == null) {
- position.level.addParticleEffect(position.asVector3f(), args[0], -1, position.level.getDimension());
- return true;
- }
-
- sender.sendMessage(new TranslationContainer("commands.particle.success", name, String.valueOf(count)));
-
- ThreadLocalRandom random = ThreadLocalRandom.current();
-
- for (int i = 0; i < count; i++) {
- particle.setComponents(
- position.x + (random.nextFloat() * 2 - 1),
- position.y + (random.nextFloat() * 2 - 1),
- position.z + (random.nextFloat() * 2 - 1)
- );
- position.getLevel().addParticle(particle);
- }
- }
-
- return true;
- }
-
- private static Particle getParticle(String name, Vector3 pos, int data) {
- switch (name) {
- case "explode":
- return new ExplodeParticle(pos);
- case "hugeexplosion":
- return new HugeExplodeParticle(pos);
- case "hugeexplosionseed":
- return new HugeExplodeSeedParticle(pos);
- case "bubble":
- return new BubbleParticle(pos);
- case "splash":
- return new SplashParticle(pos);
- case "wake":
- case "water":
- return new WaterParticle(pos);
- case "crit":
- return new CriticalParticle(pos);
- case "smoke":
- return new SmokeParticle(pos, data != -1 ? data : 0);
- case "spell":
- return new EnchantParticle(pos);
- case "instantspell":
- return new InstantEnchantParticle(pos);
- case "dripwater":
- return new WaterDripParticle(pos);
- case "driplava":
- return new LavaDripParticle(pos);
- case "townaura":
- case "spore":
- return new SporeParticle(pos);
- case "portal":
- return new PortalParticle(pos);
- case "flame":
- return new FlameParticle(pos);
- case "lava":
- return new LavaParticle(pos);
- case "reddust":
- return new RedstoneParticle(pos, data != -1 ? data : 1);
- case "snowballpoof":
- return new ItemBreakParticle(pos, Item.get(Item.SNOWBALL));
- case "slime":
- return new ItemBreakParticle(pos, Item.get(Item.SLIMEBALL));
- case "itembreak":
- if (data != -1 && data != 0) {
- return new ItemBreakParticle(pos, Item.get(data));
- }
- break;
- case "terrain":
- if (data != -1 && data != 0) {
- return new TerrainParticle(pos, Block.get(data));
- }
- break;
- case "heart":
- return new HeartParticle(pos, data != -1 ? data : 0);
- case "ink":
- return new InkParticle(pos, data != -1 ? data : 0);
- case "droplet":
- return new RainSplashParticle(pos);
- case "enchantmenttable":
- return new EnchantmentTableParticle(pos);
- case "happyvillager":
- return new HappyVillagerParticle(pos);
- case "angryvillager":
- return new AngryVillagerParticle(pos);
- case "forcefield":
- return new BlockForceFieldParticle(pos);
- }
-
- if (name.startsWith("iconcrack_")) {
- String[] d = name.split("_");
- if (d.length == 3) {
- return new ItemBreakParticle(pos, Item.get(Integer.parseInt(d[1]), Integer.valueOf(d[2])));
- }
- } else if (name.startsWith("blockcrack_")) {
- String[] d = name.split("_");
- if (d.length == 2) {
- return new TerrainParticle(pos, Block.get(Integer.parseInt(d[1]) & 0xff, Integer.parseInt(d[1]) >> 12));
- }
- } else if (name.startsWith("blockdust_")) {
- String[] d = name.split("_");
- if (d.length >= 4) {
- return new DustParticle(pos, Integer.parseInt(d[1]) & 0xff, Integer.parseInt(d[2]) & 0xff, Integer.parseInt(d[3]) & 0xff, d.length >= 5 ? Integer.parseInt(d[4]) & 0xff : 255);
- }
- }
-
- return null;
- }
-
- private static boolean showParticleEffect(String name, Vector3 pos, Level level, int count) {
- switch (name) {
- case "minecraft:test_beziercurve":
- case "minecraft:test_catmullromcurve":
- case "minecraft:test_combocurve":
- case "minecraft:test_linearcurve":
- case "minecraft:test_spiral":
- case "minecraft:test_sphere":
- case "minecraft:test_smoke_puff":
- case "minecraft:test_mule":
- case "minecraft:test_highrestitution":
- case "minecraft:test_bounce":
- case "minecraft:test_colorcurve":
- case "minecraft:mobflame_emitter":
- break;
- default:
- return false;
- }
-
- SpawnParticleEffectPacket pk = new SpawnParticleEffectPacket();
- pk.dimensionId = level.getDimension();
- pk.position = new Vector3f((int) pos.x, (int) pos.y, (int) pos.z);
- pk.identifier = name;
-
- for (Player p : level.getPlayers().values()) {
- if (p.protocol >= 313) {
- for (int i = 0; i < count; i++) {
- p.dataPacket(pk);
- }
- }
- }
-
- return true;
- }
-
- private static double getDouble(String arg, double defaultValue) {
- if (arg.startsWith("~")) {
- String relativePos = arg.substring(1);
- if (relativePos.isEmpty()) {
- return defaultValue;
- }
- return defaultValue + Double.parseDouble(relativePos);
- }
- return Double.parseDouble(arg);
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/PlaySoundCommand.java b/src/main/java/cn/nukkit/command/defaults/PlaySoundCommand.java
deleted file mode 100644
index 93ed6e02f..000000000
--- a/src/main/java/cn/nukkit/command/defaults/PlaySoundCommand.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * Created by PetteriM1
- */
-public class PlaySoundCommand extends VanillaCommand {
-
- public PlaySoundCommand(String name) {
- super(name, "%nukkit.command.playsound.description", "%commands.playsound.usage");
- this.setPermission("nukkit.command.playsound");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("sound", CommandParamType.STRING, false),
- new CommandParameter("player", CommandParamType.TARGET, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("%commands.playsound.usage", this.usageMessage));
- return false;
- }
-
- if (args.length == 1) {
- if (!(sender instanceof Player)) {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- return true;
- }
-
- Player p = (Player) sender;
-
- p.getLevel().addSound(p, args[0], p);
- p.sendMessage(new TranslationContainer("commands.playsound.success", args[0], p.getName()));
-
- return true;
- }
-
- if (args[1].equalsIgnoreCase("@a")) {
- for (Player p : Server.getInstance().getOnlinePlayers().values()) {
- p.getLevel().addSound(p, args[0], p);
- }
-
- sender.sendMessage(new TranslationContainer("commands.playsound.success", args[0], "@a"));
-
- return true;
- }
-
- if (args[1].equalsIgnoreCase("@s") && sender instanceof Player) {
- Player p = (Player) sender;
-
- p.getLevel().addSound(p, args[0], p);
- sender.sendMessage(new TranslationContainer("commands.playsound.success", args[0], p.getName()));
-
- return true;
- }
-
- Player p = Server.getInstance().getPlayer(args[1]);
-
- if (p == null) {
- sender.sendMessage(new TranslationContainer("commands.generic.player.notFound"));
- return true;
- }
-
- p.getLevel().addSound(p, args[0], p);
- sender.sendMessage(new TranslationContainer("commands.playsound.success", args[0], p.getName()));
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/command/defaults/PluginsCommand.java b/src/main/java/cn/nukkit/command/defaults/PluginsCommand.java
deleted file mode 100644
index c8afa9fa9..000000000
--- a/src/main/java/cn/nukkit/command/defaults/PluginsCommand.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.plugin.Plugin;
-import cn.nukkit.utils.TextFormat;
-
-import java.util.Map;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class PluginsCommand extends VanillaCommand {
-
- public PluginsCommand(String name) {
- super(name, "%nukkit.command.plugins.description", "%nukkit.command.plugins.usage");
- this.setPermission("nukkit.command.plugins");
- this.setAliases(new String[]{"pl"});
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- sendPluginList(sender);
- return true;
- }
-
- private static void sendPluginList(CommandSender sender) {
- StringBuilder list = new StringBuilder();
- Map plugins = sender.getServer().getPluginManager().getPlugins();
- for (Plugin plugin : plugins.values()) {
- if (list.length() > 0) {
- list.append(TextFormat.WHITE + ", ");
- }
- list.append(plugin.isEnabled() ? TextFormat.GREEN : TextFormat.RED);
- list.append(plugin.getDescription().getFullName());
- }
-
- sender.sendMessage(new TranslationContainer("nukkit.command.plugins.success", String.valueOf(plugins.size()), list.toString()));
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/ReloadCommand.java b/src/main/java/cn/nukkit/command/defaults/ReloadCommand.java
deleted file mode 100644
index cf584839a..000000000
--- a/src/main/java/cn/nukkit/command/defaults/ReloadCommand.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class ReloadCommand extends VanillaCommand {
-
- public ReloadCommand(String name) {
- super(name, "%nukkit.command.reload.description", "%commands.reload.usage");
- this.setPermission("nukkit.command.reload");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- Command.broadcastCommandMessage(sender, new TranslationContainer(TextFormat.YELLOW + "%nukkit.command.reload.reloading" + TextFormat.WHITE));
-
- sender.getServer().reload();
-
- Command.broadcastCommandMessage(sender, new TranslationContainer(TextFormat.YELLOW + "%nukkit.command.reload.reloaded" + TextFormat.WHITE));
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/SaveCommand.java b/src/main/java/cn/nukkit/command/defaults/SaveCommand.java
deleted file mode 100644
index 9e119f2d1..000000000
--- a/src/main/java/cn/nukkit/command/defaults/SaveCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.Level;
-
-/**
- * Created on 2015/11/13 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class SaveCommand extends VanillaCommand {
-
- public SaveCommand(String name) {
- super(name, "%nukkit.command.save.description", "%commands.save.usage");
- this.setPermission("nukkit.command.save.perform");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.start"));
-
- for (Player player : sender.getServer().getOnlinePlayers().values()) {
- player.save();
- }
-
- for (Level level : sender.getServer().getLevels().values()) {
- level.save(true);
- }
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.success"));
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/SaveOffCommand.java b/src/main/java/cn/nukkit/command/defaults/SaveOffCommand.java
deleted file mode 100644
index 762cd3140..000000000
--- a/src/main/java/cn/nukkit/command/defaults/SaveOffCommand.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * Created on 2015/11/13 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class SaveOffCommand extends VanillaCommand {
-
- public SaveOffCommand(String name) {
- super(name, "%nukkit.command.saveoff.description", "%commands.save-off.usage");
- this.setPermission("nukkit.command.save.disable");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- sender.getServer().setAutoSave(false);
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.disabled"));
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/SaveOnCommand.java b/src/main/java/cn/nukkit/command/defaults/SaveOnCommand.java
deleted file mode 100644
index a3f6a5dfd..000000000
--- a/src/main/java/cn/nukkit/command/defaults/SaveOnCommand.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * Created on 2015/11/13 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class SaveOnCommand extends VanillaCommand {
-
- public SaveOnCommand(String name) {
- super(name, "%nukkit.command.saveon.description", "%commands.save-on.usage");
- this.setPermission("nukkit.command.save.enable");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- sender.getServer().setAutoSave(true);
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.save.enabled"));
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/SayCommand.java b/src/main/java/cn/nukkit/command/defaults/SayCommand.java
deleted file mode 100644
index ae234c5f0..000000000
--- a/src/main/java/cn/nukkit/command/defaults/SayCommand.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.ConsoleCommandSender;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class SayCommand extends VanillaCommand {
-
- public SayCommand(String name) {
- super(name, "%nukkit.command.say.description", "%commands.say.usage");
- this.setPermission("nukkit.command.say");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("message")
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
-
- String senderString;
- if (sender instanceof Player) {
- senderString = ((Player) sender).getDisplayName();
- } else if (sender instanceof ConsoleCommandSender) {
- senderString = "Server";
- } else {
- senderString = sender.getName();
- }
-
- StringBuilder msg = new StringBuilder();
- for (String arg : args) {
- msg.append(arg).append(' ');
- }
- if (msg.length() > 0) {
- msg = new StringBuilder(msg.substring(0, msg.length() - 1));
- }
-
-
- sender.getServer().broadcastMessage(new TranslationContainer(
- TextFormat.LIGHT_PURPLE + "%chat.type.announcement",
- senderString, TextFormat.LIGHT_PURPLE + msg.toString()));
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/SeedCommand.java b/src/main/java/cn/nukkit/command/defaults/SeedCommand.java
deleted file mode 100644
index b269df22c..000000000
--- a/src/main/java/cn/nukkit/command/defaults/SeedCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class SeedCommand extends VanillaCommand {
-
- public SeedCommand(String name) {
- super(name, "%nukkit.command.seed.description", "%commands.seed.usage");
- this.setPermission("nukkit.command.seed");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- long seed;
- if (sender instanceof Player) {
- seed = ((Player) sender).getLevel().getSeed();
- } else {
- seed = sender.getServer().getDefaultLevel().getSeed();
- }
-
- sender.sendMessage(new TranslationContainer("commands.seed.success", String.valueOf(seed)));
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/SetWorldSpawnCommand.java b/src/main/java/cn/nukkit/command/defaults/SetWorldSpawnCommand.java
deleted file mode 100644
index 2da5ba32e..000000000
--- a/src/main/java/cn/nukkit/command/defaults/SetWorldSpawnCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.Vector3;
-
-import java.text.DecimalFormat;
-
-/**
- * Created on 2015/12/13 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class SetWorldSpawnCommand extends VanillaCommand {
-
- public SetWorldSpawnCommand(String name) {
- super(name, "%nukkit.command.setworldspawn.description", "%commands.setworldspawn.usage");
- this.setPermission("nukkit.command.setworldspawn");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("blockPos", CommandParamType.POSITION, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- Level level;
- Vector3 pos;
- if (args.length == 0) {
- if (sender instanceof Player) {
- level = ((Player) sender).getLevel();
- pos = ((Player) sender).round();
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- return true;
- }
- } else if (args.length == 3) {
- level = sender.getServer().getDefaultLevel();
- try {
- pos = new Vector3(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2]));
- } catch (NumberFormatException e1) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- level.setSpawnLocation(pos);
- DecimalFormat round2 = new DecimalFormat("##0.00");
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.setworldspawn.success", round2.format(pos.x), round2.format(pos.y), round2.format(pos.z)));
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/SpawnCommand.java b/src/main/java/cn/nukkit/command/defaults/SpawnCommand.java
deleted file mode 100644
index 21683cdc5..000000000
--- a/src/main/java/cn/nukkit/command/defaults/SpawnCommand.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.event.player.PlayerTeleportEvent;
-import cn.nukkit.lang.TranslationContainer;
-
-public class SpawnCommand extends VanillaCommand {
-
- public SpawnCommand(String name) {
- super(name, "%nukkit.command.spawn.description", "%commands.spawn.usage");
- this.setPermission("nukkit.command.spawn");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (sender instanceof Player) {
- ((Player) sender).teleport(((Player) sender).getLevel().getSafeSpawn(), PlayerTeleportEvent.TeleportCause.COMMAND);
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- }
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/SpawnpointCommand.java b/src/main/java/cn/nukkit/command/defaults/SpawnpointCommand.java
deleted file mode 100644
index 565c3f0c2..000000000
--- a/src/main/java/cn/nukkit/command/defaults/SpawnpointCommand.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.Level;
-import cn.nukkit.level.Position;
-import cn.nukkit.utils.TextFormat;
-
-import java.text.DecimalFormat;
-
-/**
- * Created on 2015/12/13 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class SpawnpointCommand extends VanillaCommand {
-
- public SpawnpointCommand(String name) {
- super(name, "%nukkit.command.spawnpoint.description", "%commands.spawnpoint.usage");
- this.setPermission("nukkit.command.spawnpoint");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("blockPos", CommandParamType.POSITION, true),
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- Player target;
- if (args.length == 0) {
- if (sender instanceof Player) {
- target = (Player) sender;
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- return true;
- }
- } else {
- target = sender.getServer().getPlayer(args[0]);
- if (target == null) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
- return true;
- }
- }
- Level level = target.getLevel();
- DecimalFormat round2 = new DecimalFormat("##0.00");
- if (args.length == 4) {
- if (level != null) {
- int x;
- int y;
- int z;
- try {
- x = Integer.parseInt(args[1]);
- y = Integer.parseInt(args[2]);
- z = Integer.parseInt(args[3]);
- } catch (NumberFormatException e1) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- if (y < 0) y = 0;
- if (y > 256) y = 256;
- target.setSpawn(new Position(x, y, z, level));
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.spawnpoint.success", target.getName(),
- round2.format(x),
- round2.format(y),
- round2.format(z)));
- return true;
- }
- } else if (args.length <= 1) {
- if (sender instanceof Player) {
- Position pos = (Position) sender;
- target.setSpawn(pos);
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.spawnpoint.success", target.getName(),
- round2.format(pos.x),
- round2.format(pos.y),
- round2.format(pos.z)));
- return true;
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- return true;
- }
- }
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/command/defaults/StatusCommand.java b/src/main/java/cn/nukkit/command/defaults/StatusCommand.java
deleted file mode 100644
index edf73b213..000000000
--- a/src/main/java/cn/nukkit/command/defaults/StatusCommand.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Nukkit;
-import cn.nukkit.Server;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.level.Level;
-import cn.nukkit.math.NukkitMath;
-import cn.nukkit.utils.TextFormat;
-
-import java.util.Objects;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Created on 2015/11/11 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class StatusCommand extends VanillaCommand {
-
- private static final String UPTIME_FORMAT = TextFormat.RED + "%d" + TextFormat.GOLD + " days " +
- TextFormat.RED + "%d" + TextFormat.GOLD + " hours " +
- TextFormat.RED + "%d" + TextFormat.GOLD + " minutes " +
- TextFormat.RED + "%d" + TextFormat.GOLD + " seconds";
-
- public StatusCommand(String name) {
- super(name, "%nukkit.command.status.description", "%nukkit.command.status.usage");
- this.setPermission("nukkit.command.status");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- Server server = sender.getServer();
- sender.sendMessage(TextFormat.GREEN + "---- " + TextFormat.WHITE + "Server status" + TextFormat.GREEN + " ----");
-
- long time = System.currentTimeMillis() - Nukkit.START_TIME;
-
- sender.sendMessage(TextFormat.GOLD + "Uptime: " + formatUptime(time));
-
- TextFormat tpsColor = TextFormat.GREEN;
- float tps = server.getTicksPerSecond();
- if (tps < 17) {
- tpsColor = TextFormat.GOLD;
- } else if (tps < 12) {
- tpsColor = TextFormat.RED;
- }
-
- sender.sendMessage(TextFormat.GOLD + "Current TPS: " + tpsColor + NukkitMath.round(tps, 2));
-
- sender.sendMessage(TextFormat.GOLD + "Load: " + tpsColor + server.getTickUsage() + '%');
-
- sender.sendMessage(TextFormat.GOLD + "Network upload: " + TextFormat.GREEN + NukkitMath.round((server.getNetwork().getUpload() / 1024 * 1000), 2) + " kB/s");
-
- sender.sendMessage(TextFormat.GOLD + "Network download: " + TextFormat.GREEN + NukkitMath.round((server.getNetwork().getDownload() / 1024 * 1000), 2) + " kB/s");
-
- sender.sendMessage(TextFormat.GOLD + "Thread count: " + TextFormat.GREEN + Thread.getAllStackTraces().size());
-
-
- Runtime runtime = Runtime.getRuntime();
- double totalMB = NukkitMath.round(((double) runtime.totalMemory()) / 1024 / 1024, 2);
- double usedMB = NukkitMath.round((double) (runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024, 2);
- double maxMB = NukkitMath.round(((double) runtime.maxMemory()) / 1024 / 1024, 2);
- double usage = usedMB / maxMB * 100;
- TextFormat usageColor = TextFormat.GREEN;
-
- if (usage > 85) {
- usageColor = TextFormat.GOLD;
- }
-
- sender.sendMessage(TextFormat.GOLD + "Used memory: " + usageColor + usedMB + " MB (" + NukkitMath.round(usage, 2) + "%)");
-
- sender.sendMessage(TextFormat.GOLD + "Total memory: " + TextFormat.RED + totalMB + " MB");
-
- sender.sendMessage(TextFormat.GOLD + "Maximum VM memory: " + TextFormat.RED + maxMB + " MB");
-
- sender.sendMessage(TextFormat.GOLD + "Available processors: " + TextFormat.GREEN + runtime.availableProcessors());
-
-
- int players = server.getOnlinePlayersCount();
-
- TextFormat playerColor = TextFormat.GREEN;
- if (((float) players / (float) server.getMaxPlayers()) > 0.85) {
- playerColor = TextFormat.GOLD;
- }
-
- sender.sendMessage(TextFormat.GOLD + "Players: " + playerColor + players + TextFormat.GREEN + " online, " +
- TextFormat.RED + server.getMaxPlayers() + TextFormat.GREEN + " max");
-
- for (Level level : server.getLevels().values()) {
- sender.sendMessage(
- TextFormat.GOLD + "World \"" + level.getFolderName() + '"' + (!Objects.equals(level.getFolderName(), level.getName()) ? " (" + level.getName() + ')' : "") + ": " +
- TextFormat.RED + level.getChunks().size() + TextFormat.GREEN + " chunks, " +
- TextFormat.RED + level.getEntities().length + TextFormat.GREEN + " entities, " +
- TextFormat.RED + level.getBlockEntities().size() + TextFormat.GREEN + " block entities." +
- " Time " + ((level.getTickRate() > 1 || level.getTickRateTime() > 40) ? TextFormat.RED : TextFormat.YELLOW) + NukkitMath.round(level.getTickRateTime(), 2) + "ms" +
- (level.getTickRate() > 1 ? " (tick rate " + level.getTickRate() + ')' : "")
- );
- }
-
- return true;
- }
-
- public static String formatUptime(long uptime) {
- long days = TimeUnit.MILLISECONDS.toDays(uptime);
- uptime -= TimeUnit.DAYS.toMillis(days);
- long hours = TimeUnit.MILLISECONDS.toHours(uptime);
- uptime -= TimeUnit.HOURS.toMillis(hours);
- long minutes = TimeUnit.MILLISECONDS.toMinutes(uptime);
- uptime -= TimeUnit.MINUTES.toMillis(minutes);
- long seconds = TimeUnit.MILLISECONDS.toSeconds(uptime);
- return String.format(UPTIME_FORMAT, days, hours, minutes, seconds);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/command/defaults/StopCommand.java b/src/main/java/cn/nukkit/command/defaults/StopCommand.java
deleted file mode 100644
index e268883b5..000000000
--- a/src/main/java/cn/nukkit/command/defaults/StopCommand.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Server;
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class StopCommand extends VanillaCommand {
-
- public StopCommand(String name) {
- super(name, "%nukkit.command.stop.description", "%commands.stop.usage");
- this.setPermission("nukkit.command.stop");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (sender instanceof Player && !(Server.getInstance().stopInGame)) {
- sender.sendMessage("\u00A7cCan't use this command in game");
- return true;
- }
-
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.stop.start"));
-
- sender.getServer().shutdown();
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/SummonCommand.java b/src/main/java/cn/nukkit/command/defaults/SummonCommand.java
deleted file mode 100644
index 428149a40..000000000
--- a/src/main/java/cn/nukkit/command/defaults/SummonCommand.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.level.Position;
-
-public class SummonCommand extends Command {
-
- public SummonCommand(String name) {
- super(name, "%nukkit.command.summon.description", "%nukkit.command.summon.usage");
- this.setPermission("nukkit.command.summon");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("entityType", false, CommandParameter.ENUM_TYPE_ENTITY_LIST),
- new CommandParameter("player", CommandParamType.TARGET, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 0 || (args.length == 1 && !(sender instanceof Player))) {
- return false;
- }
-
- // Convert Minecraft format to the format what Nukkit uses
- String mob = Character.toUpperCase(args[0].charAt(0)) + args[0].substring(1);
- int max = mob.length() - 1;
- for (int x = 2; x < max; x++) {
- if (mob.charAt(x) == '_') {
- mob = mob.substring(0, x) + Character.toUpperCase(mob.charAt(x + 1)) + mob.substring(x + 2);
- }
- }
-
- Player playerThatSpawns;
-
- if (args.length == 2) {
- playerThatSpawns = Server.getInstance().getPlayer(args[1].replace("@s", sender.getName()));
- } else {
- playerThatSpawns = (Player) sender;
- }
-
- if (playerThatSpawns != null) {
- Position pos = playerThatSpawns.getPosition().floor().add(0.5, 0, 0.5);
- Entity ent;
- if ((ent = Entity.createEntity(mob, pos)) != null) {
- ent.spawnToAll();
- sender.sendMessage("\u00A76Spawned " + mob + " to " + playerThatSpawns.getName());
- } else {
- sender.sendMessage("\u00A7cUnable to spawn " + mob);
- }
- } else {
- sender.sendMessage("\u00A7cUnknown player " + (args.length == 2 ? args[1] : sender.getName()));
- }
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/TeleportCommand.java b/src/main/java/cn/nukkit/command/defaults/TeleportCommand.java
deleted file mode 100644
index 9d0c320e8..000000000
--- a/src/main/java/cn/nukkit/command/defaults/TeleportCommand.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.event.player.PlayerTeleportEvent;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.Location;
-import cn.nukkit.math.NukkitMath;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/12 by Pub4Game and milkice.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class TeleportCommand extends VanillaCommand {
-
- public TeleportCommand(String name) {
- super(name, "%nukkit.command.tp.description", "%commands.tp.usage");
- this.setPermission("nukkit.command.teleport");
- this.commandParameters.clear();
- this.commandParameters.put("->Player", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- });
- this.commandParameters.put("Player->Player", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("target", CommandParamType.TARGET, false),
- });
- this.commandParameters.put("Player->Pos", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("blockPos", CommandParamType.POSITION, false),
- });
- this.commandParameters.put("->Pos", new CommandParameter[]{
- new CommandParameter("blockPos", CommandParamType.POSITION, false),
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- if (args.length < 1 || args.length > 6) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- CommandSender target;
- CommandSender origin = sender;
- if (args.length == 1 || args.length == 3) {
- if (sender instanceof Player) {
- target = sender;
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- return true;
- }
- if (args.length == 1) {
- target = sender.getServer().getPlayer(args[0].replace("@s", sender.getName()));
- if (target == null) {
- sender.sendMessage(TextFormat.RED + "Can't find player " + args[0]);
- return true;
- }
- }
- } else {
- target = sender.getServer().getPlayer(args[0].replace("@s", sender.getName()));
- if (target == null) {
- sender.sendMessage(TextFormat.RED + "Can't find player " + args[0]);
- return true;
- }
- if (args.length == 2) {
- origin = target;
- target = sender.getServer().getPlayer(args[1].replace("@s", sender.getName()));
- if (target == null) {
- sender.sendMessage(TextFormat.RED + "Can't find player " + args[1]);
- return true;
- }
- }
- }
- if (args.length < 3) {
- ((Player) origin).teleport((Player) target, PlayerTeleportEvent.TeleportCause.COMMAND);
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.tp.success", origin.getName(), target.getName()));
- return true;
- } else if (((Player) target).getLevel() != null) {
- int pos;
- if (args.length == 4 || args.length == 6) {
- pos = 1;
- } else {
- pos = 0;
- }
- double x;
- double y;
- double z;
- double yaw;
- double pitch;
- try {
- x = Double.parseDouble(args[pos++].replace("~", "" + ((Player) target).x));
- y = Double.parseDouble(args[pos++].replace("~", "" + ((Player) target).y));
- z = Double.parseDouble(args[pos++].replace("~", "" + ((Player) target).z));
- yaw = ((Player) target).getYaw();
- pitch = ((Player) target).getPitch();
- } catch (NumberFormatException e1) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-
- if (x < -30000000) x = -30000000;
- if (x > 30000000) x = 30000000;
- if (y < -30000000) y = -30000000;
- if (y > 30000000) y = 30000000;
- if (z < -30000000) z = -30000000;
- if (z > 30000000) z = 30000000;
-
- if (args.length == 6 || (args.length == 5 && pos == 3)) {
- yaw = Integer.parseInt(args[pos++]);
- pitch = Integer.parseInt(args[pos]);
- }
- ((Player) target).teleport(new Location(x, y, z, yaw, pitch, ((Player) target).getLevel()), PlayerTeleportEvent.TeleportCause.COMMAND);
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.tp.success.coordinates", target.getName(), String.valueOf(NukkitMath.round(x, 2)), String.valueOf(NukkitMath.round(y, 2)), String.valueOf(NukkitMath.round(z, 2))));
- return true;
- }
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/TellCommand.java b/src/main/java/cn/nukkit/command/defaults/TellCommand.java
deleted file mode 100644
index 18715300f..000000000
--- a/src/main/java/cn/nukkit/command/defaults/TellCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-import java.util.Objects;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class TellCommand extends VanillaCommand {
-
- public TellCommand(String name) {
- super(name, "%nukkit.command.tell.description", "%commands.message.usage", new String[]{"w", "msg"});
- this.setPermission("nukkit.command.tell");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("message", CommandParamType.TEXT, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length < 2) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
-
- String name = args[0].toLowerCase().replace("@s", sender.getName());
-
- Player player = sender.getServer().getPlayer(name);
- if (player == null) {
- sender.sendMessage(new TranslationContainer("commands.generic.player.notFound"));
- return true;
- }
-
- if (Objects.equals(player, sender)) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.message.sameTarget"));
- return true;
- }
-
- StringBuilder msg = new StringBuilder();
- for (int i = 1; i < args.length; i++) {
- msg.append(args[i]).append(' ');
- }
- if (msg.length() > 512) {
- sender.sendMessage(TextFormat.RED + "The message is too long");
- return true;
- } else if (msg.length() > 0) {
- msg = new StringBuilder(msg.substring(0, msg.length() - 1));
- }
-
- String displayName = (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName());
-
- sender.sendMessage('[' + sender.getName() + " -> " + player.getDisplayName() + "] " + msg);
- player.sendMessage('[' + displayName + " -> " + player.getName() + "] " + msg);
- if (sender instanceof Player) {
- sender.getServer().getLogger().info('[' + sender.getName() + " -> " + player.getDisplayName() + "] " + msg);
- }
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/TimeCommand.java b/src/main/java/cn/nukkit/command/defaults/TimeCommand.java
deleted file mode 100644
index 225990dd4..000000000
--- a/src/main/java/cn/nukkit/command/defaults/TimeCommand.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.Level;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/11 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class TimeCommand extends VanillaCommand {
-
- public TimeCommand(String name) {
- super(name, "%nukkit.command.time.description", "%nukkit.command.time.usage");
- this.setPermission("nukkit.command.time.add;nukkit.command.time.set;nukkit.command.time.start;nukkit.command.time.stop");
- this.commandParameters.clear();
- this.commandParameters.put("1arg", new CommandParameter[]{
- new CommandParameter("start|stop", CommandParamType.STRING, false)
- });
- this.commandParameters.put("2args", new CommandParameter[]{
- new CommandParameter("add|set", CommandParamType.STRING, false),
- new CommandParameter("value", CommandParamType.INT, false)
- });
- this.commandParameters.put("2args_", new CommandParameter[]{
- new CommandParameter("add|set", CommandParamType.STRING, false),
- new CommandParameter("value", CommandParamType.STRING, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (args.length < 1) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return false;
- }
-
- if ("start".equals(args[0])) {
- if (!sender.hasPermission("nukkit.command.time.start")) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
-
- return true;
- }
- for (Level level : sender.getServer().getLevels().values()) {
- level.checkTime();
- level.startTime();
- level.checkTime();
- }
- Command.broadcastCommandMessage(sender, "Restarted the time");
- return true;
- } else if ("stop".equals(args[0])) {
- if (!sender.hasPermission("nukkit.command.time.stop")) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
-
- return true;
- }
- for (Level level : sender.getServer().getLevels().values()) {
- level.checkTime();
- level.stopTime();
- level.checkTime();
- }
- Command.broadcastCommandMessage(sender, "Stopped the time");
- return true;
- } else if ("query".equals(args[0])) {
- if (!sender.hasPermission("nukkit.command.time.query")) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
-
- return true;
- }
- Level level;
- if (sender instanceof Player) {
- level = ((Player) sender).getLevel();
- } else {
- level = sender.getServer().getDefaultLevel();
- }
- sender.sendMessage(new TranslationContainer("commands.time.query.gametime", String.valueOf(level.getTime())));
- return true;
- }
-
-
- if (args.length < 2) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
-
- return false;
- }
-
- if ("set".equals(args[0])) {
- if (!sender.hasPermission("nukkit.command.time.set")) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
-
- return true;
- }
-
- int value;
- if ("day".equals(args[1])) {
- value = Level.TIME_DAY;
- } else if ("night".equals(args[1])) {
- value = Level.TIME_NIGHT;
- } else if ("midnight".equals(args[1])) {
- value = Level.TIME_MIDNIGHT;
- } else if ("noon".equals(args[1])) {
- value = Level.TIME_NOON;
- } else if ("sunrise".equals(args[1])) {
- value = Level.TIME_SUNRISE;
- } else if ("sunset".equals(args[1])) {
- value = Level.TIME_SUNSET;
- } else {
- try {
- value = Math.max(0, Integer.parseInt(args[1]));
- } catch (Exception e) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- }
-
- for (Level level : sender.getServer().getLevels().values()) {
- level.checkTime();
- level.setTime(value);
- level.checkTime();
- }
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.time.set", String.valueOf(value)));
- } else if ("add".equals(args[0])) {
- if (!sender.hasPermission("nukkit.command.time.add")) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
-
- return true;
- }
-
- int value;
- try {
- value = Math.max(0, Integer.parseInt(args[1]));
- } catch (Exception e) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-
- for (Level level : sender.getServer().getLevels().values()) {
- level.checkTime();
- level.setTime(level.getTime() + value);
- level.checkTime();
- }
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.time.added", String.valueOf(value)));
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- }
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/TimingsCommand.java b/src/main/java/cn/nukkit/command/defaults/TimingsCommand.java
deleted file mode 100644
index 27919cb69..000000000
--- a/src/main/java/cn/nukkit/command/defaults/TimingsCommand.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import co.aikar.timings.Timings;
-import co.aikar.timings.TimingsExport;
-
-/**
- * @author fromgate
- * @author Pub4Game
- */
-public class TimingsCommand extends VanillaCommand {
-
- public TimingsCommand(String name) {
- super(name, "%nukkit.command.timings.description", "%nukkit.command.timings.usage");
- this.setPermission("nukkit.command.timings");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("on|off|paste", CommandParameter.ARG_TYPE_STRING, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length != 1) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", usageMessage));
- return true;
- }
-
- String mode = args[0].toLowerCase();
-
- if (mode.equals("on")) {
- Timings.setTimingsEnabled(true);
- Timings.reset();
- sender.sendMessage(new TranslationContainer("nukkit.command.timings.enable"));
- return true;
- } else if (mode.equals("off")) {
- Timings.setTimingsEnabled(false);
- sender.sendMessage(new TranslationContainer("nukkit.command.timings.disable"));
- return true;
- }
-
- if (!Timings.isTimingsEnabled()) {
- sender.sendMessage(new TranslationContainer("nukkit.command.timings.timingsDisabled"));
- return true;
- }
-
- switch (mode) {
- case "verbon":
- sender.sendMessage(new TranslationContainer("nukkit.command.timings.verboseEnable"));
- Timings.setVerboseEnabled(true);
- break;
- case "verboff":
- sender.sendMessage(new TranslationContainer("nukkit.command.timings.verboseDisable"));
- Timings.setVerboseEnabled(false);
- break;
- case "reset":
- Timings.reset();
- sender.sendMessage(new TranslationContainer("nukkit.command.timings.reset"));
- break;
- case "report":
- case "paste":
- TimingsExport.reportTimings(sender);
- break;
- }
- return true;
- }
-}
-
diff --git a/src/main/java/cn/nukkit/command/defaults/TitleCommand.java b/src/main/java/cn/nukkit/command/defaults/TitleCommand.java
deleted file mode 100644
index ea208882b..000000000
--- a/src/main/java/cn/nukkit/command/defaults/TitleCommand.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * @author Tee7even
- */
-public class TitleCommand extends VanillaCommand {
-
- public TitleCommand(String name) {
- super(name, "%nukkit.command.title.description", "%nukkit.command.title.usage");
- this.setPermission("nukkit.command.title");
-
- this.commandParameters.clear();
- this.commandParameters.put("clear", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("clear", new String[]{"clear"})
- });
- this.commandParameters.put("reset", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("reset", new String[]{"reset"})
- });
- this.commandParameters.put("title", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("title", new String[]{"title"}),
- new CommandParameter("titleText", CommandParamType.STRING, false)
- });
- this.commandParameters.put("subtitle", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("subtitle", new String[]{"subtitle"}),
- new CommandParameter("titleText", CommandParamType.STRING, false)
- });
- this.commandParameters.put("actionbar", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("actionbar", new String[]{"actionbar"}),
- new CommandParameter("titleText", CommandParamType.STRING, false)
- });
- this.commandParameters.put("times", new CommandParameter[]{
- new CommandParameter("player", CommandParamType.TARGET, false),
- new CommandParameter("times", new String[]{"times"}),
- new CommandParameter("fadeIn", CommandParamType.INT, false),
- new CommandParameter("stay", CommandParamType.INT, false),
- new CommandParameter("fadeOut", CommandParamType.INT, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- if (args.length < 2) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
-
- Player player = Server.getInstance().getPlayer(args[0]);
- if (player == null) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
- return true;
- }
-
- if (args.length == 2) {
- switch (args[1].toLowerCase()) {
- case "clear":
- player.clearTitle();
- sender.sendMessage(new TranslationContainer("nukkit.command.title.clear", player.getName()));
- break;
- case "reset":
- player.resetTitleSettings();
- sender.sendMessage(new TranslationContainer("nukkit.command.title.reset", player.getName()));
- break;
- default:
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
- } else if (args.length == 3) {
- switch (args[1].toLowerCase()) {
- case "title":
- player.sendTitle(args[2]);
- sender.sendMessage(new TranslationContainer("nukkit.command.title.title",
- TextFormat.clean(args[2]), player.getName()));
- break;
- case "subtitle":
- player.setSubtitle(args[2]);
- sender.sendMessage(new TranslationContainer("nukkit.command.title.subtitle", TextFormat.clean(args[2]), player.getName()));
- break;
- case "actionbar":
- player.sendActionBar(args[2]);
- sender.sendMessage(new TranslationContainer("nukkit.command.title.actionbar", TextFormat.clean(args[2]), player.getName()));
- break;
- default:
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
- } else if (args.length == 5) {
- if (args[1].toLowerCase().equals("times")) {
- try {
- /*player.setTitleAnimationTimes(Integer.valueOf(args[2]), //fadeIn
- Integer.valueOf(args[3]), //stay
- Integer.valueOf(args[4])); //fadeOut*/
- sender.sendMessage(new TranslationContainer("nukkit.command.title.times.success",
- args[2], args[3], args[4], player.getName()));
- } catch (NumberFormatException exception) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%nukkit.command.title.times.fail"));
- }
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return false;
- }
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/command/defaults/TransferServerCommand.java b/src/main/java/cn/nukkit/command/defaults/TransferServerCommand.java
deleted file mode 100644
index 1758a293f..000000000
--- a/src/main/java/cn/nukkit/command/defaults/TransferServerCommand.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package cn.nukkit.command.defaults;
-
-
-import cn.nukkit.Player;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-
-/**
- * @author akkz
- */
-public class TransferServerCommand extends VanillaCommand {
-
- public TransferServerCommand(String name) {
- super(name, "%nukkit.command.transferserver.description", "%commands.transferserver.usage");
- this.setPermission("nukkit.command.transferserver");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("serverAddress", CommandParamType.STRING, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (!(sender instanceof Player)) {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- return false;
- }
-
- if (args.length == 0 || args.length > 2) {
- sender.sendMessage(new TranslationContainer("commands.transferserver.usage", this.usageMessage));
- return true;
- }
-
- int port = args.length == 2 ? Integer.parseInt(args[1]) : 19132;
- ((Player) sender).transfer(args[0], port);
-
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/VanillaCommand.java b/src/main/java/cn/nukkit/command/defaults/VanillaCommand.java
deleted file mode 100644
index ee7011726..000000000
--- a/src/main/java/cn/nukkit/command/defaults/VanillaCommand.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.Command;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class VanillaCommand extends Command {
-
- public VanillaCommand(String name) {
- super(name);
- }
-
- public VanillaCommand(String name, String description) {
- super(name, description);
- }
-
- public VanillaCommand(String name, String description, String usageMessage) {
- super(name, description, usageMessage);
- }
-
- public VanillaCommand(String name, String description, String usageMessage, String[] aliases) {
- super(name, description, usageMessage, aliases);
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/VersionCommand.java b/src/main/java/cn/nukkit/command/defaults/VersionCommand.java
deleted file mode 100644
index b289865ed..000000000
--- a/src/main/java/cn/nukkit/command/defaults/VersionCommand.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Nukkit;
-import cn.nukkit.command.CommandMap;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.network.protocol.ProtocolInfo;
-import cn.nukkit.plugin.Plugin;
-import cn.nukkit.plugin.PluginDescription;
-import cn.nukkit.utils.TextFormat;
-import com.google.gson.JsonParser;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class VersionCommand extends VanillaCommand {
-
- public VersionCommand(String name) {
- super(name,
- "%nukkit.command.version.description",
- "%nukkit.command.version.usage",
- new String[]{"ver", "about"}
- );
- this.setPermission("nukkit.command.version");
- this.commandParameters.clear();
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- /*if (!this.testPermission(sender)) {
- return true;
- }*/
- if (args.length == 0 || !sender.hasPermission("nukkit.command.version.plugins")) {
- sender.sendMessage("§e###############################################\n§cNukkit §aPetteriM1 Edition\n§6Build: §b" + Nukkit.getBranch() + '/' + Nukkit.VERSION.substring(4) + "\n§6Multiversion: §bUp to version " + ProtocolInfo.MINECRAFT_VERSION_NETWORK + "\n§dhttps://github.com/PetteriM1/NukkitPetteriM1Edition\n§e###############################################");
-
- if (sender.isOp()) {
- CompletableFuture.runAsync(() -> {
- try {
- URLConnection request = new URL(Nukkit.BRANCH).openConnection();
- request.connect();
- InputStreamReader content = new InputStreamReader((InputStream) request.getContent());
- String latest = "git-" + new JsonParser().parse(content).getAsJsonObject().get("sha").getAsString().substring(0, 7);
- content.close();
-
- if (Nukkit.getBranch().equals("master")) {
- if (!sender.getServer().getNukkitVersion().equals(latest) && !sender.getServer().getNukkitVersion().equals("git-null")) {
- sender.sendMessage("\u00A7c[Update] \u00A7eThere is a new build of Nukkit PetteriM1 Edition available! Current: " + sender.getServer().getNukkitVersion() + " Latest: " + latest);
- } else {
- sender.sendMessage("\u00A7aYou are running the latest version.");
- }
- }
- } catch (Exception ignore) {
- }
- });
- }
- } else {
- StringBuilder pluginName = new StringBuilder();
- for (String arg : args) pluginName.append(arg).append(' ');
- pluginName = new StringBuilder(pluginName.toString().trim());
- final boolean[] found = {false};
- final Plugin[] exactPlugin = {sender.getServer().getPluginManager().getPlugin(pluginName.toString())};
-
- if (exactPlugin[0] == null) {
- pluginName = new StringBuilder(pluginName.toString().toLowerCase());
- final String finalPluginName = pluginName.toString();
- sender.getServer().getPluginManager().getPlugins().forEach((s, p) -> {
- if (s.toLowerCase().contains(finalPluginName)) {
- exactPlugin[0] = p;
- found[0] = true;
- }
- });
- } else {
- found[0] = true;
- }
-
- if (found[0]) {
- PluginDescription desc = exactPlugin[0].getDescription();
- sender.sendMessage(TextFormat.DARK_GREEN + desc.getName() + TextFormat.WHITE + " version " + TextFormat.DARK_GREEN + desc.getVersion());
- if (desc.getDescription() != null) {
- sender.sendMessage(desc.getDescription());
- }
- if (desc.getWebsite() != null) {
- sender.sendMessage("Website: " + desc.getWebsite());
- }
- List authors = desc.getAuthors();
- final String[] authorsString = {""};
- authors.forEach((s) -> authorsString[0] += s);
- if (authors.size() == 1) {
- sender.sendMessage("Author: " + authorsString[0]);
- } else if (authors.size() >= 2) {
- sender.sendMessage("Authors: " + authorsString[0]);
- }
- } else {
- sender.sendMessage(new TranslationContainer("nukkit.command.version.noSuchPlugin"));
- }
- }
- return true;
- }
-
- @Override
- public boolean unregister(CommandMap commandMap) {
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/WeatherCommand.java b/src/main/java/cn/nukkit/command/defaults/WeatherCommand.java
deleted file mode 100644
index b0f9151ba..000000000
--- a/src/main/java/cn/nukkit/command/defaults/WeatherCommand.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.Level;
-
-/**
- * @author Angelic47
- * Nukkit Project
- */
-public class WeatherCommand extends VanillaCommand {
-
- public WeatherCommand(String name) {
- super(name, "%nukkit.command.weather.description", "%commands.weather.usage");
- this.setPermission("nukkit.command.weather");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("clear|rain|thunder", CommandParamType.STRING, false),
- new CommandParameter("duration in seconds", CommandParamType.INT, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
- if (args.length == 0 || args.length > 2) {
- sender.sendMessage(new TranslationContainer("commands.weather.usage", this.usageMessage));
- return false;
- }
-
- String weather = args[0];
- Level level;
- int seconds;
- if (args.length > 1) {
- try {
- seconds = Integer.parseInt(args[1]);
- } catch (Exception e) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- } else {
- seconds = 12000;
- }
-
- if (sender instanceof Player) {
- level = ((Player) sender).getLevel();
- } else {
- level = sender.getServer().getDefaultLevel();
- }
-
- switch (weather) {
- case "clear":
- level.setRaining(false);
- level.setThundering(false);
- level.setRainTime(seconds * 20);
- level.setThunderTime(seconds * 20);
- Command.broadcastCommandMessage(sender,
- new TranslationContainer("commands.weather.clear"));
- return true;
- case "rain":
- level.setRaining(true);
- level.setRainTime(seconds * 20);
- Command.broadcastCommandMessage(sender,
- new TranslationContainer("commands.weather.rain"));
- return true;
- case "thunder":
- level.setThundering(true);
- level.setRainTime(seconds * 20);
- level.setThunderTime(seconds * 20);
- Command.broadcastCommandMessage(sender,
- new TranslationContainer("commands.weather.thunder"));
- return true;
- default:
- sender.sendMessage(new TranslationContainer("commands.weather.usage", this.usageMessage));
- return false;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/WhitelistCommand.java b/src/main/java/cn/nukkit/command/defaults/WhitelistCommand.java
deleted file mode 100644
index 8b288edd8..000000000
--- a/src/main/java/cn/nukkit/command/defaults/WhitelistCommand.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created on 2015/11/12 by xtypr.
- * Package cn.nukkit.command.defaults in project Nukkit .
- */
-public class WhitelistCommand extends VanillaCommand {
-
- public WhitelistCommand(String name) {
- super(name, "%nukkit.command.whitelist.description", "%commands.whitelist.usage");
- this.setPermission(
- "nukkit.command.whitelist.reload;" +
- "nukkit.command.whitelist.enable;" +
- "nukkit.command.whitelist.disable;" +
- "nukkit.command.whitelist.list;" +
- "nukkit.command.whitelist.add;" +
- "nukkit.command.whitelist.remove"
- );
- this.commandParameters.clear();
- this.commandParameters.put("1arg", new CommandParameter[]{
- new CommandParameter("on|off|list|reload", CommandParamType.STRING, false)
- });
- this.commandParameters.put("2args", new CommandParameter[]{
- new CommandParameter("add|remove", CommandParamType.STRING, false),
- new CommandParameter("player", CommandParamType.TARGET, false)
- });
- }
-
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 0 || args.length > 2) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-
- if (args.length == 1) {
- if (badPerm(sender, args[0].toLowerCase())) {
- return false;
- }
- switch (args[0].toLowerCase()) {
- case "reload":
- sender.getServer().reloadWhitelist();
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.reloaded"));
- return true;
- case "on":
- sender.getServer().setPropertyBoolean("white-list", true);
- sender.getServer().whitelistEnabled = true;
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.enabled"));
- return true;
- case "off":
- sender.getServer().setPropertyBoolean("white-list", false);
- sender.getServer().whitelistEnabled = false;
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.disabled"));
- return true;
- case "list":
- StringBuilder result = new StringBuilder();
- int count = 0;
- for (String player : sender.getServer().getWhitelist().getAll().keySet()) {
- result.append(player).append(", ");
- ++count;
- }
- sender.sendMessage(new TranslationContainer("commands.whitelist.list", String.valueOf(count), String.valueOf(count)));
- sender.sendMessage(result.length() > 0 ? result.substring(0, result.length() - 2) : "");
-
- return true;
-
- case "add":
- sender.sendMessage(new TranslationContainer("commands.generic.usage", "%commands.whitelist.add.usage"));
- return true;
-
- case "remove":
- sender.sendMessage(new TranslationContainer("commands.generic.usage", "%commands.whitelist.remove.usage"));
- return true;
- }
- } else {
- if (badPerm(sender, args[0].toLowerCase())) {
- return false;
- }
- switch (args[0].toLowerCase()) {
- case "add":
- sender.getServer().getOfflinePlayer(args[1]).setWhitelisted(true);
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.add.success", args[1]));
-
- return true;
- case "remove":
- sender.getServer().getOfflinePlayer(args[1]).setWhitelisted(false);
- Command.broadcastCommandMessage(sender, new TranslationContainer("commands.whitelist.remove.success", args[1]));
-
- return true;
- }
- }
-
- return true;
- }
-
- private static boolean badPerm(CommandSender sender, String perm) {
- if (!sender.hasPermission("nukkit.command.whitelist." + perm)) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.permission"));
-
- return true;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/WorldCommand.java b/src/main/java/cn/nukkit/command/defaults/WorldCommand.java
deleted file mode 100644
index a6e7918eb..000000000
--- a/src/main/java/cn/nukkit/command/defaults/WorldCommand.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.event.player.PlayerTeleportEvent;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.level.Level;
-
-public class WorldCommand extends Command {
-
- public WorldCommand(String name) {
- super(name, "%nukkit.command.world.description", "%nukkit.command.world.usage");
- this.setPermission("nukkit.command.world");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("world", CommandParamType.STRING, false)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- if (args.length == 0 && !Server.getInstance().suomiCraftPEMode()) {
- sender.sendMessage("Available worlds:");
- for (Level level : Server.getInstance().getLevels().values()) {
- sender.sendMessage(level.getName());
- }
- return true;
- }
-
- if (args.length == 2) {
- if (!sender.hasPermission("nukkit.command.world.others")) {
- return false;
- }
-
- if (Server.getInstance().getPlayer(args[1].replace("@s", sender.getName())) == null) {
- sender.sendMessage("\u00A7cUnknown player");
- return true;
- }
- if (Server.getInstance().getLevelByName(args[0]) == null) {
- sender.sendMessage("\u00A7cUnknown level");
- return true;
- }
- Server.getInstance().getPlayer(args[1].replace("@s", sender.getName())).teleport(Server.getInstance().getLevelByName(args[0]).getSafeSpawn(), PlayerTeleportEvent.TeleportCause.COMMAND);
- return true;
- }
-
- if (!(sender instanceof Player)) {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- return true;
- }
-
- if (args.length == 1) {
- if (Server.getInstance().getLevelByName(args[0]) != null) {
- ((Player) sender).teleport(Server.getInstance().getLevelByName(args[0]).getSafeSpawn(), PlayerTeleportEvent.TeleportCause.COMMAND);
- } else {
- sender.sendMessage("\u00A7cUnknown level");
- }
- return true;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/command/defaults/XpCommand.java b/src/main/java/cn/nukkit/command/defaults/XpCommand.java
deleted file mode 100644
index c66a8bf93..000000000
--- a/src/main/java/cn/nukkit/command/defaults/XpCommand.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package cn.nukkit.command.defaults;
-
-import cn.nukkit.Player;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.data.CommandParamType;
-import cn.nukkit.command.data.CommandParameter;
-import cn.nukkit.lang.TranslationContainer;
-import cn.nukkit.utils.TextFormat;
-
-/**
- * Created by Snake1999 on 2016/1/22.
- * Package cn.nukkit.command.defaults in project nukkit.
- */
-public class XpCommand extends Command {
-
- public XpCommand(String name) {
- super(name, "%nukkit.command.xp.description", "%commands.xp.usage");
- this.setPermission("nukkit.command.xp");
- this.commandParameters.clear();
- this.commandParameters.put("default", new CommandParameter[]{
- new CommandParameter("amount|level", CommandParamType.INT, false),
- new CommandParameter("player", CommandParamType.TARGET, true)
- });
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (!this.testPermission(sender)) {
- return true;
- }
-
- // "/xp [player]" for adding exp
- // "/xp L [player]" for adding exp level
- String amountString;
- String playerName;
- Player player;
- if (!(sender instanceof Player)) {
- if (args.length != 2) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- amountString = args[0];
- playerName = args[1];
- player = sender.getServer().getPlayer(playerName);
- } else {
- if (args.length == 1) {
- amountString = args[0];
- player = (Player) sender;
- } else if (args.length == 2) {
- amountString = args[0];
- playerName = args[1].replace("@s", sender.getName());
- player = sender.getServer().getPlayer(playerName);
- } else {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- }
-
- if (player == null) {
- sender.sendMessage(new TranslationContainer(TextFormat.RED + "%commands.generic.player.notFound"));
- return true;
- }
-
- int amount;
- boolean isLevel = false;
- if (amountString.endsWith("l") || amountString.endsWith("L")) {
- amountString = amountString.substring(0, amountString.length() - 1);
- isLevel = true;
- }
-
- try {
- amount = Integer.parseInt(amountString);
- } catch (NumberFormatException e1) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
-
- if (isLevel) {
- int newLevel = player.getExperienceLevel();
- newLevel += amount;
- if (newLevel > 24791) newLevel = 24791;
- if (newLevel < 0) {
- player.setExperience(0, 0);
- } else {
- player.setExperience(player.getExperience(), newLevel);
- }
- if (amount > 0) {
- sender.sendMessage(new TranslationContainer("commands.xp.success.levels", String.valueOf(amount), player.getName()));
- } else {
- sender.sendMessage(new TranslationContainer("commands.xp.success.levels.minus", String.valueOf(-amount), player.getName()));
- }
- return true;
- } else {
- if (amount < 0) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- return true;
- }
- player.addExperience(amount);
- sender.sendMessage(new TranslationContainer("commands.xp.success", String.valueOf(amount), player.getName()));
- return true;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/command/simple/Arguments.java b/src/main/java/cn/nukkit/command/simple/Arguments.java
deleted file mode 100644
index 11b7045b1..000000000
--- a/src/main/java/cn/nukkit/command/simple/Arguments.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package cn.nukkit.command.simple;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author Tee7even
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Arguments {
- int min() default 0;
-
- int max() default 0;
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/command/simple/Command.java b/src/main/java/cn/nukkit/command/simple/Command.java
deleted file mode 100644
index 379f59158..000000000
--- a/src/main/java/cn/nukkit/command/simple/Command.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package cn.nukkit.command.simple;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author Tee7even
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Command {
- String name();
-
- String description() default "";
-
- String usageMessage() default "";
-
- String[] aliases() default {};
-}
\ No newline at end of file
diff --git a/src/main/java/cn/nukkit/command/simple/CommandParameters.java b/src/main/java/cn/nukkit/command/simple/CommandParameters.java
deleted file mode 100644
index 8dd0fbe68..000000000
--- a/src/main/java/cn/nukkit/command/simple/CommandParameters.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.nukkit.command.simple;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author nilsbrychzy
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface CommandParameters {
- Parameters[] parameters() default {};
-}
diff --git a/src/main/java/cn/nukkit/command/simple/CommandPermission.java b/src/main/java/cn/nukkit/command/simple/CommandPermission.java
deleted file mode 100644
index 175db0388..000000000
--- a/src/main/java/cn/nukkit/command/simple/CommandPermission.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.nukkit.command.simple;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author Tee7even
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface CommandPermission {
- String value();
-}
diff --git a/src/main/java/cn/nukkit/command/simple/ForbidConsole.java b/src/main/java/cn/nukkit/command/simple/ForbidConsole.java
deleted file mode 100644
index ac676f395..000000000
--- a/src/main/java/cn/nukkit/command/simple/ForbidConsole.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package cn.nukkit.command.simple;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author Tee7even
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ForbidConsole {
-}
diff --git a/src/main/java/cn/nukkit/command/simple/Parameter.java b/src/main/java/cn/nukkit/command/simple/Parameter.java
deleted file mode 100644
index 940daf77b..000000000
--- a/src/main/java/cn/nukkit/command/simple/Parameter.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package cn.nukkit.command.simple;
-
-import cn.nukkit.command.data.CommandParamType;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author nilsbrychzy
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Parameter {
- String name();
-
- CommandParamType type() default CommandParamType.RAWTEXT;
-
- boolean optional() default false;
-}
diff --git a/src/main/java/cn/nukkit/command/simple/Parameters.java b/src/main/java/cn/nukkit/command/simple/Parameters.java
deleted file mode 100644
index 9d54d9746..000000000
--- a/src/main/java/cn/nukkit/command/simple/Parameters.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package cn.nukkit.command.simple;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author nilsbrychzy
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Parameters {
- String name();
- Parameter[] parameters();
-}
diff --git a/src/main/java/cn/nukkit/command/simple/SimpleCommand.java b/src/main/java/cn/nukkit/command/simple/SimpleCommand.java
deleted file mode 100644
index 6b63f78ca..000000000
--- a/src/main/java/cn/nukkit/command/simple/SimpleCommand.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package cn.nukkit.command.simple;
-
-import cn.nukkit.Server;
-import cn.nukkit.command.Command;
-import cn.nukkit.command.CommandSender;
-import cn.nukkit.command.ConsoleCommandSender;
-import cn.nukkit.lang.TranslationContainer;
-
-import java.lang.reflect.Method;
-
-/**
- * @author Tee7even
- */
-public class SimpleCommand extends Command {
- private Object object;
- private Method method;
- private boolean forbidConsole;
- private int maxArgs;
- private int minArgs;
-
- public SimpleCommand(Object object, Method method, String name, String description, String usageMessage, String[] aliases) {
- super(name, description, usageMessage, aliases);
- this.object = object;
- this.method = method;
- }
-
- public void setForbidConsole(boolean forbidConsole) {
- this.forbidConsole = forbidConsole;
- }
-
- public void setMaxArgs(int maxArgs) {
- this.maxArgs = maxArgs;
- }
-
- public void setMinArgs(int minArgs) {
- this.minArgs = minArgs;
- }
-
- public void sendUsageMessage(CommandSender sender) {
- if (!this.usageMessage.isEmpty()) {
- sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
- }
- }
-
- public void sendInGameMessage(CommandSender sender) {
- sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
- }
-
- @Override
- public boolean execute(CommandSender sender, String commandLabel, String[] args) {
- if (this.forbidConsole && sender instanceof ConsoleCommandSender) {
- this.sendInGameMessage(sender);
- return false;
- } else if (!this.testPermission(sender)) {
- return false;
- } else if (this.maxArgs != 0 && args.length > this.maxArgs) {
- this.sendUsageMessage(sender);
- return false;
- } else if (this.minArgs != 0 && args.length < this.minArgs) {
- this.sendUsageMessage(sender);
- return false;
- }
-
- boolean success = false;
-
- try {
- success = (Boolean) this.method.invoke(this.object, sender, commandLabel, args);
- } catch (Exception exception) {
- Server.getInstance().getLogger().logException(exception);
- }
-
- if (!success) {
- this.sendUsageMessage(sender);
- }
-
- return success;
- }
-}
diff --git a/src/main/java/cn/nukkit/console/NukkitConsole.java b/src/main/java/cn/nukkit/console/NukkitConsole.java
deleted file mode 100644
index b7928bc56..000000000
--- a/src/main/java/cn/nukkit/console/NukkitConsole.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package cn.nukkit.console;
-
-import cn.nukkit.Nukkit;
-import cn.nukkit.Server;
-import cn.nukkit.event.server.ServerCommandEvent;
-import co.aikar.timings.Timings;
-import lombok.RequiredArgsConstructor;
-import net.minecrell.terminalconsole.SimpleTerminalConsole;
-import org.jline.reader.LineReader;
-import org.jline.reader.LineReaderBuilder;
-
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-@RequiredArgsConstructor
-public class NukkitConsole extends SimpleTerminalConsole {
-
- private final BlockingQueue consoleQueue = new LinkedBlockingQueue<>();
- private final AtomicBoolean executingCommands = new AtomicBoolean(false);
-
- @Override
- protected boolean isRunning() {
- return Server.getInstance().isRunning();
- }
-
- @Override
- protected void runCommand(String command) {
- if (executingCommands.get()) {
- if (Timings.serverCommandTimer != null) Timings.serverCommandTimer.startTiming();
- ServerCommandEvent event = new ServerCommandEvent(Server.getInstance().getConsoleSender(), command);
- if (Server.getInstance().getPluginManager() != null) {
- Server.getInstance().getPluginManager().callEvent(event);
- }
- if (!event.isCancelled()) {
- Server.getInstance().getScheduler().scheduleTask(() -> Server.getInstance().dispatchCommand(event.getSender(), event.getCommand()));
- }
- if (Timings.serverCommandTimer != null) Timings.serverCommandTimer.stopTiming();
- } else {
- consoleQueue.add(command);
- }
- }
-
- public String readLine() {
- try {
- return consoleQueue.take();
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- protected void shutdown() {
- Server.getInstance().shutdown();
- }
-
- @Override
- protected LineReader buildReader(LineReaderBuilder builder) {
- builder.completer(new NukkitConsoleCompleter());
- builder.appName(Nukkit.NUKKIT);
- builder.option(LineReader.Option.HISTORY_BEEP, false);
- builder.option(LineReader.Option.HISTORY_IGNORE_DUPS, true);
- builder.option(LineReader.Option.HISTORY_IGNORE_SPACE, true);
- return super.buildReader(builder);
- }
-
- public boolean isExecutingCommands() {
- return executingCommands.get();
- }
-
- public void setExecutingCommands(boolean executingCommands) {
- if (this.executingCommands.compareAndSet(!executingCommands, executingCommands) && executingCommands) {
- consoleQueue.clear();
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/console/NukkitConsoleCompleter.java b/src/main/java/cn/nukkit/console/NukkitConsoleCompleter.java
deleted file mode 100644
index e898cea8c..000000000
--- a/src/main/java/cn/nukkit/console/NukkitConsoleCompleter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package cn.nukkit.console;
-
-import cn.nukkit.Server;
-import lombok.RequiredArgsConstructor;
-import org.jline.reader.Candidate;
-import org.jline.reader.Completer;
-import org.jline.reader.LineReader;
-import org.jline.reader.ParsedLine;
-
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.function.Consumer;
-
-@RequiredArgsConstructor
-public class NukkitConsoleCompleter implements Completer {
-
- @Override
- public void complete(LineReader lineReader, ParsedLine parsedLine, List candidates) {
- if (parsedLine.wordIndex() == 0) {
- if (parsedLine.word().isEmpty()) {
- addCandidates(s -> candidates.add(new Candidate(s)));
- return;
- }
- SortedSet names = new TreeSet<>();
- addCandidates(names::add);
- for (String match : names) {
- if (!match.toLowerCase().startsWith(parsedLine.word())) {
- continue;
- }
-
- candidates.add(new Candidate(match));
- }
- } else if (parsedLine.wordIndex() > 0 && !parsedLine.word().isEmpty()) {
- String word = parsedLine.word();
- SortedSet names = new TreeSet<>();
- Server.getInstance().getOnlinePlayers().values().forEach((p) -> names.add(p.getName()));
- for (String match : names) {
- if (!match.toLowerCase().startsWith(word.toLowerCase())) {
- continue;
- }
-
- candidates.add(new Candidate(match));
- }
- }
- }
-
- private static void addCandidates(Consumer commandConsumer) {
- for (String command : Server.getInstance().getCommandMap().getCommands().keySet()) {
- if (!command.contains(":")) {
- commandConsumer.accept(command);
- }
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/BoatDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/BoatDispenseBehavior.java
deleted file mode 100644
index 02b8a675f..000000000
--- a/src/main/java/cn/nukkit/dispenser/BoatDispenseBehavior.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.block.BlockWater;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.item.EntityBoat;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-
-public class BoatDispenseBehavior extends DefaultDispenseBehavior {
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- Vector3 pos = block.getSide(face).multiply(1.125);
-
- Block target = block.getSide(face);
-
- if (target instanceof BlockWater) {
- pos.y += 1;
- } else if (target.getId() != BlockID.AIR || !(target.down() instanceof BlockWater)) {
- return super.dispense(block, face, item);
- }
-
- pos = target.getLocation().setYaw(face.getHorizontalAngle());
-
- EntityBoat boat = new EntityBoat(block.level.getChunk(target.getChunkX(), target.getChunkZ()),
- Entity.getDefaultNBT(pos)
- .putByte("woodID", item.getDamage())
- );
-
- boat.spawnToAll();
-
- return null;
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/BucketDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/BucketDispenseBehavior.java
deleted file mode 100644
index 884bedd36..000000000
--- a/src/main/java/cn/nukkit/dispenser/BucketDispenseBehavior.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.block.BlockLiquid;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemBucket;
-import cn.nukkit.item.ItemID;
-import cn.nukkit.math.BlockFace;
-
-/**
- * @author CreeperFace
- */
-public class BucketDispenseBehavior extends DefaultDispenseBehavior {
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- Block target = block.getSide(face);
-
- if (item.getDamage() > 0) {
- if (target.canBeFlowedInto()) {
- Block replace = Block.get(ItemBucket.getDamageByTarget(item.getDamage()));
-
- if (replace instanceof BlockLiquid) {
- block.level.setBlock(target, replace);
- return Item.get(ItemID.BUCKET);
- }
- }
- } else if (target instanceof BlockLiquid && target.getDamage() == 0) {
- target.level.setBlock(target, Block.get(BlockID.AIR));
- return new ItemBucket(ItemBucket.getDamageByTarget(target.getId()));
- }
-
- return super.dispense(block, face, item);
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/DefaultDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/DefaultDispenseBehavior.java
deleted file mode 100644
index 049e41dba..000000000
--- a/src/main/java/cn/nukkit/dispenser/DefaultDispenseBehavior.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.BlockFace.Axis;
-import cn.nukkit.math.Vector3;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * @author CreeperFace
- */
-public class DefaultDispenseBehavior implements DispenseBehavior {
-
- public boolean success = true;
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- Vector3 dispensePos = block.getDispensePosition();
-
- if (face.getAxis() == Axis.Y) {
- dispensePos.y -= 0.125;
- } else {
- dispensePos.y -= 0.15625;
- }
-
- ThreadLocalRandom rand = ThreadLocalRandom.current();
- Vector3 motion = new Vector3();
-
- double offset = rand.nextDouble() * 0.1 + 0.2;
-
- motion.x = face.getXOffset() * offset;
- motion.y = 0.20000000298023224;
- motion.z = face.getZOffset() * offset;
-
- motion.x += rand.nextGaussian() * 0.007499999832361937 * 6;
- motion.y += rand.nextGaussian() * 0.007499999832361937 * 6;
- motion.z += rand.nextGaussian() * 0.007499999832361937 * 6;
-
- Item i = item.clone();
- i.setCount(1);
- block.level.dropItem(dispensePos, i, motion);
- return null;
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/DispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/DispenseBehavior.java
deleted file mode 100644
index 54d2905a5..000000000
--- a/src/main/java/cn/nukkit/dispenser/DispenseBehavior.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-
-/**
- * @author CreeperFace
- */
-public interface DispenseBehavior {
-
- Item dispense(BlockDispenser block, BlockFace face, Item item);
-}
diff --git a/src/main/java/cn/nukkit/dispenser/DispenseBehaviorRegister.java b/src/main/java/cn/nukkit/dispenser/DispenseBehaviorRegister.java
deleted file mode 100644
index 2a8b31e3d..000000000
--- a/src/main/java/cn/nukkit/dispenser/DispenseBehaviorRegister.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.BlockID;
-import cn.nukkit.item.ItemID;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author CreeperFace
- */
-public final class DispenseBehaviorRegister {
-
- private static final Map behaviors = new HashMap<>();
- private static DispenseBehavior defaultBehavior = new DefaultDispenseBehavior();
-
- public static void registerBehavior(int itemId, DispenseBehavior behavior) {
- behaviors.put(itemId, behavior);
- }
-
- public static DispenseBehavior getBehavior(int id) {
- return behaviors.getOrDefault(id, defaultBehavior);
- }
-
- public static void removeDispenseBehavior(int id) {
- behaviors.remove(id);
- }
-
- public static void init() {
- registerBehavior(ItemID.BOAT, new BoatDispenseBehavior());
- registerBehavior(ItemID.BUCKET, new BucketDispenseBehavior());
- registerBehavior(ItemID.DYE, new DyeDispenseBehavior());
- registerBehavior(ItemID.FIREWORKS, new FireworksDispenseBehavior());
- registerBehavior(ItemID.FLINT_AND_STEEL, new FlintAndSteelDispenseBehavior());
- registerBehavior(BlockID.SHULKER_BOX, new ShulkerBoxDispenseBehavior());
- registerBehavior(ItemID.SPAWN_EGG, new SpawnEggDispenseBehavior());
- registerBehavior(BlockID.TNT, new TNTDispenseBehavior());
- registerBehavior(ItemID.FIRE_CHARGE, new FireChargeDispenseBehavior());
- registerBehavior(ItemID.ARROW, new ProjectileDispenseBehavior("Arrow") {
- @Override
- protected double getMotion() {
- return super.getMotion() * 1.5;
- }
- });
- //TODO: tipped arrow
- //TODO: spectral arrow
- registerBehavior(ItemID.EGG, new ProjectileDispenseBehavior("Egg"));
- registerBehavior(ItemID.SNOWBALL, new ProjectileDispenseBehavior("Snowball"));
- registerBehavior(ItemID.EXPERIENCE_BOTTLE, new ProjectileDispenseBehavior("ThrownExpBottle") {
- @Override
- protected float getAccuracy() {
- return super.getAccuracy() * 0.5f;
- }
-
- @Override
- protected double getMotion() {
- return super.getMotion() * 1.25;
- }
- });
- registerBehavior(ItemID.SPLASH_POTION, new ProjectileDispenseBehavior("ThrownPotion") {
- @Override
- protected float getAccuracy() {
- return super.getAccuracy() * 0.5f;
- }
-
- @Override
- protected double getMotion() {
- return super.getMotion() * 1.25;
- }
- });
- registerBehavior(ItemID.LINGERING_POTION, new ProjectileDispenseBehavior("LingeringPotion") {
- @Override
- protected float getAccuracy() {
- return super.getAccuracy() * 0.5f;
- }
-
- @Override
- protected double getMotion() {
- return super.getMotion() * 1.25;
- }
- });
- registerBehavior(ItemID.TRIDENT, new ProjectileDispenseBehavior("ThrownTrident") {
- @Override
- protected float getAccuracy() {
- return super.getAccuracy() * 0.5f;
- }
-
- @Override
- protected double getMotion() {
- return super.getMotion() * 1.25;
- }
- });
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/DyeDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/DyeDispenseBehavior.java
deleted file mode 100644
index c065af3b6..000000000
--- a/src/main/java/cn/nukkit/dispenser/DyeDispenseBehavior.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.*;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.utils.DyeColor;
-
-public class DyeDispenseBehavior extends DefaultDispenseBehavior {
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- Block target = block.getSide(face);
-
- if (DyeColor.getByDyeData(item.getDamage()) == DyeColor.WHITE) {
- if (target instanceof BlockCrops || target instanceof BlockSapling || target instanceof BlockTallGrass
- || target instanceof BlockDoublePlant || target instanceof BlockMushroom) {
- target.onActivate(item);
-
- } else {
- this.success = false;
- }
-
- return null;
- }
-
- return super.dispense(block, face, item);
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/FireChargeDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/FireChargeDispenseBehavior.java
deleted file mode 100644
index c67bbc146..000000000
--- a/src/main/java/cn/nukkit/dispenser/FireChargeDispenseBehavior.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.projectile.EntityProjectile;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-
-public class FireChargeDispenseBehavior extends DefaultDispenseBehavior {
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- Vector3 dispensePos = block.getDispensePosition();
-
- Entity projectile = Entity.createEntity("GhastFireBall", block.level.getChunk(dispensePos.getChunkX(), dispensePos.getChunkZ()), Entity.getDefaultNBT(dispensePos));
-
- if (!(projectile instanceof EntityProjectile)) {
- return super.dispense(block, face, item);
- }
-
- projectile.setMotion(new Vector3(face.getXOffset(), face.getYOffset() + 0.1f, face.getZOffset()).normalize().multiply(1.3));
- ((EntityProjectile) projectile).inaccurate(6f);
- ((EntityProjectile) projectile).updateRotation();
-
- projectile.spawnToAll();
- return null;
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/FireworksDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/FireworksDispenseBehavior.java
deleted file mode 100644
index 3943b2f08..000000000
--- a/src/main/java/cn/nukkit/dispenser/FireworksDispenseBehavior.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.item.EntityFirework;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-public class FireworksDispenseBehavior extends DefaultDispenseBehavior {
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- BlockFace opposite = face.getOpposite();
- Vector3 pos = block.getSide(face).add(0.5 + opposite.getXOffset() * 0.2, 0.5 + opposite.getYOffset() * 0.2, 0.5 + opposite.getZOffset() * 0.2);
- CompoundTag nbt = Entity.getDefaultNBT(pos);
- nbt.putCompound("FireworkItem", NBTIO.putItemHelper(item));
- new EntityFirework(block.level.getChunk(pos.getChunkX(), pos.getChunkZ()), nbt).spawnToAll();
- return null;
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/FlintAndSteelDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/FlintAndSteelDispenseBehavior.java
deleted file mode 100644
index 3b098800d..000000000
--- a/src/main/java/cn/nukkit/dispenser/FlintAndSteelDispenseBehavior.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-
-public class FlintAndSteelDispenseBehavior extends DefaultDispenseBehavior {
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- Block target = block.getSide(face);
-
- if (target.getId() == BlockID.AIR) {
- block.level.setBlock(target, Block.get(BlockID.FIRE));
- } else if (target.getId() == BlockID.TNT) {
- target.onActivate(item);
- } else {
- this.success = false;
- }
-
- return null;
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/ProjectileDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/ProjectileDispenseBehavior.java
deleted file mode 100644
index 5e5c64b00..000000000
--- a/src/main/java/cn/nukkit/dispenser/ProjectileDispenseBehavior.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.projectile.EntityProjectile;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-/**
- * @author CreeperFace
- */
-public class ProjectileDispenseBehavior extends DefaultDispenseBehavior {
-
- private final String entityType;
-
- public ProjectileDispenseBehavior(String entity) {
- this.entityType = entity;
- }
-
- @Override
- public Item dispense(BlockDispenser source, BlockFace face, Item item) {
- Vector3 dispensePos = source.getDispensePosition();
-
- CompoundTag nbt = Entity.getDefaultNBT(dispensePos);
- this.correctNBT(nbt);
-
- Entity projectile = Entity.createEntity(entityType, source.level.getChunk(dispensePos.getChunkX(), dispensePos.getChunkZ()), nbt);
-
- if (!(projectile instanceof EntityProjectile)) {
- return super.dispense(source, face, item);
- }
-
- Vector3 motion = new Vector3(face.getXOffset(), face.getYOffset() + 0.1f, face.getZOffset())
- .normalize();
-
- projectile.setMotion(motion);
- ((EntityProjectile) projectile).inaccurate(getAccuracy());
- projectile.setMotion(projectile.getMotion().multiply(getMotion()));
-
- ((EntityProjectile) projectile).updateRotation();
-
- projectile.spawnToAll();
- return null;
- }
-
- protected double getMotion() {
- return 1.1;
- }
-
- protected float getAccuracy() {
- return 6;
- }
-
- /**
- * you can add extra data of projectile here
- *
- * @param nbt tag
- */
- protected void correctNBT(CompoundTag nbt) {
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/ShulkerBoxDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/ShulkerBoxDispenseBehavior.java
deleted file mode 100644
index 8f383b61d..000000000
--- a/src/main/java/cn/nukkit/dispenser/ShulkerBoxDispenseBehavior.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.Block;
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.block.BlockID;
-import cn.nukkit.blockentity.BlockEntity;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-public class ShulkerBoxDispenseBehavior extends DefaultDispenseBehavior {
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- Block shulkerBox = Block.get(BlockID.SHULKER_BOX);
- Block target = block.getSide(face);
-
- this.success = block.level.getCollidingEntities(shulkerBox.getBoundingBox()).length == 0;
-
- if (this.success) {
- BlockFace shulkerBoxFace = target.down().getId() == BlockID.AIR ? face : BlockFace.UP;
-
- CompoundTag nbt = BlockEntity.getDefaultCompound(target, BlockEntity.SHULKER_BOX);
- nbt.putByte("facing", shulkerBoxFace.getIndex());
-
- if (item.hasCustomName()) {
- nbt.putString("CustomName", item.getCustomName());
- }
-
- CompoundTag tag = item.getNamedTag();
-
- if (tag != null) {
- if (tag.contains("Items")) {
- nbt.putList(tag.getList("Items"));
- }
- }
-
- BlockEntity.createBlockEntity(BlockEntity.SHULKER_BOX, block.level.getChunk(target.getChunkX(), target.getChunkZ()), nbt);
- block.level.updateComparatorOutputLevel(target);
- }
-
- return null;
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/SpawnEggDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/SpawnEggDispenseBehavior.java
deleted file mode 100644
index 04a36857f..000000000
--- a/src/main/java/cn/nukkit/dispenser/SpawnEggDispenseBehavior.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.EntityLiving;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-
-public class SpawnEggDispenseBehavior extends DefaultDispenseBehavior {
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- Vector3 pos = block.getSide(face).add(0.5, 0.7, 0.5);
-
- Entity entity = Entity.createEntity(item.getDamage(), block.level.getChunk(pos.getChunkX(), pos.getChunkZ()),
- Entity.getDefaultNBT(pos));
-
- this.success = entity != null;
-
- if (this.success) {
- if (item.hasCustomName() && entity instanceof EntityLiving) {
- entity.setNameTag(item.getCustomName());
- }
-
- entity.spawnToAll();
- return null;
- }
-
- return super.dispense(block, face, item);
- }
-}
diff --git a/src/main/java/cn/nukkit/dispenser/TNTDispenseBehavior.java b/src/main/java/cn/nukkit/dispenser/TNTDispenseBehavior.java
deleted file mode 100644
index 806adae78..000000000
--- a/src/main/java/cn/nukkit/dispenser/TNTDispenseBehavior.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package cn.nukkit.dispenser;
-
-import cn.nukkit.block.BlockDispenser;
-import cn.nukkit.entity.Entity;
-import cn.nukkit.entity.item.EntityPrimedTNT;
-import cn.nukkit.item.Item;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.math.Vector3;
-
-public class TNTDispenseBehavior extends DefaultDispenseBehavior {
-
- @Override
- public Item dispense(BlockDispenser block, BlockFace face, Item item) {
- Vector3 pos = block.getSide(face).add(0.5, 0, 0.5);
-
- EntityPrimedTNT tnt = new EntityPrimedTNT(block.level.getChunk(pos.getChunkX(), pos.getChunkZ()),
- Entity.getDefaultNBT(pos));
- tnt.spawnToAll();
-
- return null;
- }
-}
diff --git a/src/main/java/cn/nukkit/entity/Attribute.java b/src/main/java/cn/nukkit/entity/Attribute.java
deleted file mode 100644
index 37caf2139..000000000
--- a/src/main/java/cn/nukkit/entity/Attribute.java
+++ /dev/null
@@ -1,182 +0,0 @@
-package cn.nukkit.entity;
-
-import cn.nukkit.utils.ServerException;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Attribute
- *
- * @author Box, MagicDroidX(code), PeratX @ Nukkit Project
- * @since Nukkit 1.0 | Nukkit API 1.0.0
- */
-public class Attribute implements Cloneable {
-
- public static final int ABSORPTION = 0;
- public static final int SATURATION = 1;
- public static final int EXHAUSTION = 2;
- public static final int KNOCKBACK_RESISTANCE = 3;
- public static final int MAX_HEALTH = 4;
- public static final int MOVEMENT_SPEED = 5;
- public static final int FOLLOW_RANGE = 6;
- public static final int FOOD = 7, MAX_HUNGER = FOOD;
- public static final int ATTACK_DAMAGE = 8;
- public static final int EXPERIENCE_LEVEL = 9;
- public static final int EXPERIENCE = 10;
- public static final int UNDERWATER_MOVEMENT = 11;
- public static final int LUCK = 12;
- public static final int FALL_DAMAGE = 13;
- public static final int HORSE_JUMP_STRENGTH = 14;
- public static final int ZOMBIE_SPAWN_REINFORCEMENTS = 15;
- public static final int LAVA_MOVEMENT = 16;
-
- protected static Map attributes = new HashMap<>();
-
- protected float minValue;
- protected float maxValue;
- protected float defaultValue;
- protected float currentValue;
- protected String name;
- protected boolean shouldSend;
- private int id;
-
- private Attribute(int id, String name, float minValue, float maxValue, float defaultValue, boolean shouldSend) {
- this.id = id;
- this.name = name;
- this.minValue = minValue;
- this.maxValue = maxValue;
- this.defaultValue = defaultValue;
- this.shouldSend = shouldSend;
- this.currentValue = this.defaultValue;
- }
-
- public static void init() {
- addAttribute(ABSORPTION, "minecraft:absorption", 0.00f, 340282346638528859811704183484516925440.00f, 0.00f);
- addAttribute(SATURATION, "minecraft:player.saturation", 0.00f, 20.00f, 5.00f);
- addAttribute(EXHAUSTION, "minecraft:player.exhaustion", 0.00f, 5.00f, 0.00f, false);
- addAttribute(KNOCKBACK_RESISTANCE, "minecraft:knockback_resistance", 0.00f, 1.00f, 0.00f);
- addAttribute(MAX_HEALTH, "minecraft:health", 0.00f, 20.00f, 20.00f);
- addAttribute(MOVEMENT_SPEED, "minecraft:movement", 0.00f, 340282346638528859811704183484516925440.00f, 0.10f);
- addAttribute(FOLLOW_RANGE, "minecraft:follow_range", 0.00f, 2048.00f, 16.00f, false);
- addAttribute(MAX_HUNGER, "minecraft:player.hunger", 0.00f, 20.00f, 20.00f);
- addAttribute(ATTACK_DAMAGE, "minecraft:attack_damage", 0.00f, 340282346638528859811704183484516925440.00f, 1.00f, false);
- addAttribute(EXPERIENCE_LEVEL, "minecraft:player.level", 0.00f, 24791.00f, 0.00f);
- addAttribute(EXPERIENCE, "minecraft:player.experience", 0.00f, 1.00f, 0.00f);
- addAttribute(UNDERWATER_MOVEMENT, "minecraft:underwater_movement", 0.0f, 340282346638528859811704183484516925440.0f, 0.02f);
- addAttribute(LUCK, "minecraft:luck", -1024.0f, 1024.0f, 0.0f);
- addAttribute(FALL_DAMAGE, "minecraft:fall_damage", 0.0f, 340282346638528859811704183484516925440.0f, 1.0f);
- addAttribute(HORSE_JUMP_STRENGTH, "minecraft:horse.jump_strength", 0.0f, 2.0f, 0.7f);
- addAttribute(ZOMBIE_SPAWN_REINFORCEMENTS, "minecraft:zombie.spawn_reinforcements", 0.0f, 1.0f, 0.0f);
- addAttribute(LAVA_MOVEMENT, "minecraft:lava_movement", 0.00f, 340282346638528859811704183484516925440.00f, 0.02f);
- }
-
- public static Attribute addAttribute(int id, String name, float minValue, float maxValue, float defaultValue) {
- return addAttribute(id, name, minValue, maxValue, defaultValue, true);
- }
-
- public static Attribute addAttribute(int id, String name, float minValue, float maxValue, float defaultValue, boolean shouldSend) {
- if (minValue > maxValue || defaultValue > maxValue || defaultValue < minValue) {
- throw new IllegalArgumentException("Invalid ranges: min value: " + minValue + ", max value: " + maxValue + ", defaultValue: " + defaultValue);
- }
-
- return attributes.put(id, new Attribute(id, name, minValue, maxValue, defaultValue, shouldSend));
- }
-
- public static Attribute getAttribute(int id) {
- if (attributes.containsKey(id)) {
- return attributes.get(id).clone();
- }
- throw new ServerException("Attribute id: " + id + " not found");
- }
-
- /**
- * @param name name
- * @return null|Attribute
- */
- public static Attribute getAttributeByName(String name) {
- for (Attribute a : attributes.values()) {
- if (Objects.equals(a.name, name)) {
- return a.clone();
- }
- }
- return null;
- }
-
- public float getMinValue() {
- return this.minValue;
- }
-
- public Attribute setMinValue(float minValue) {
- if (minValue > this.maxValue) {
- throw new IllegalArgumentException("Value " + minValue + " is bigger than the maxValue!");
- }
- this.minValue = minValue;
- return this;
- }
-
- public float getMaxValue() {
- return this.maxValue;
- }
-
- public Attribute setMaxValue(float maxValue) {
- if (maxValue < this.minValue) {
- throw new IllegalArgumentException("Value " + maxValue + " is bigger than the minValue!");
- }
- this.maxValue = maxValue;
- return this;
- }
-
- public float getDefaultValue() {
- return this.defaultValue;
- }
-
- public Attribute setDefaultValue(float defaultValue) {
- if (defaultValue > this.maxValue || defaultValue < this.minValue) {
- throw new IllegalArgumentException("Value " + defaultValue + " exceeds the range!");
- }
- this.defaultValue = defaultValue;
- return this;
- }
-
- public float getValue() {
- return this.currentValue;
- }
-
- public Attribute setValue(float value) {
- return setValue(value, true);
- }
-
- public Attribute setValue(float value, boolean fit) {
- if (value > this.maxValue || value < this.minValue) {
- if (!fit) {
- throw new IllegalArgumentException("Value " + value + " exceeds the range!");
- }
- value = Math.min(Math.max(value, this.minValue), this.maxValue);
- }
- this.currentValue = value;
- return this;
- }
-
- public String getName() {
- return this.name;
- }
-
- public int getId() {
- return this.id;
- }
-
- public boolean isSyncable() {
- return this.shouldSend;
- }
-
- @Override
- public Attribute clone() {
- try {
- return (Attribute) super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/entity/BaseEntity.java b/src/main/java/cn/nukkit/entity/BaseEntity.java
deleted file mode 100644
index e459893e0..000000000
--- a/src/main/java/cn/nukkit/entity/BaseEntity.java
+++ /dev/null
@@ -1,541 +0,0 @@
-package cn.nukkit.entity;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.block.Block;
-import cn.nukkit.entity.mob.EntityEnderDragon;
-import cn.nukkit.entity.mob.EntityFlyingMob;
-import cn.nukkit.entity.mob.EntityMob;
-import cn.nukkit.entity.mob.EntityRavager;
-import cn.nukkit.entity.projectile.EntityProjectile;
-import cn.nukkit.event.entity.EntityDamageByEntityEvent;
-import cn.nukkit.event.entity.EntityDamageEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.level.particle.HeartParticle;
-import cn.nukkit.math.AxisAlignedBB;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.utils.Utils;
-import co.aikar.timings.Timings;
-import org.apache.commons.math3.util.FastMath;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * The base class of all entities that have an AI
- */
-public abstract class BaseEntity extends EntityCreature implements EntityAgeable {
-
- public int stayTime = 0;
- protected int moveTime = 0;
-
- protected float moveMultiplier = 1.0f;
-
- protected Vector3 target = null;
- protected Entity followTarget = null;
- protected int attackDelay = 0;
- private short inLoveTicks = 0;
-
- private boolean baby = false;
- private boolean movement = true;
- private boolean friendly = false;
-
- public Item[] armor;
-
- public BaseEntity(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- this.setHealth(this.getMaxHealth());
- this.setAirTicks(400);
- }
-
- public abstract Vector3 updateMove(int tickDiff);
-
- public abstract int getKillExperience();
-
- public boolean isFriendly() {
- return this.friendly;
- }
-
- public boolean isMovement() {
- return this.getServer().getMobAiEnabled() && this.movement;
- }
-
- public boolean isKnockback() {
- return this.attackTime > 0;
- }
-
- public void setFriendly(boolean bool) {
- this.friendly = bool;
- }
-
- public void setMovement(boolean value) {
- this.movement = value;
- }
-
- public double getSpeed() {
- if (this.baby) {
- return 1.2;
- }
- return 1;
- }
-
- public int getAge() {
- return this.age;
- }
-
- public Entity getTarget() {
- return this.followTarget != null ? this.followTarget : (this.target instanceof Entity ? (Entity) this.target : null);
- }
-
- public void setTarget(Entity target) {
- this.followTarget = target;
- this.moveTime = 0;
- this.stayTime = 0;
- this.target = null;
- }
-
- @Override
- public boolean isBaby() {
- return this.baby;
- }
-
- @Override
- public void setBaby(boolean baby) {
- this.baby = baby;
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_BABY, baby);
- if (baby) {
- this.setScale(0.5f);
- } else {
- this.setScale(1.0f);
- }
- }
-
- @Override
- protected void initEntity() {
- super.initEntity();
-
- if (this.namedTag.contains("Movement")) {
- this.setMovement(this.namedTag.getBoolean("Movement"));
- }
-
- if (this.namedTag.contains("Age")) {
- this.age = this.namedTag.getShort("Age");
- }
-
- if (this.namedTag.getBoolean("Baby")) {
- this.setBaby(true);
- }
- }
-
- public void saveNBT() {
- super.saveNBT();
-
- this.namedTag.putBoolean("Baby", this.baby);
- this.namedTag.putBoolean("Movement", this.isMovement());
- this.namedTag.putShort("Age", this.age);
- }
-
- public boolean targetOption(EntityCreature creature, double distance) {
- if (this instanceof EntityMob) {
- if (creature instanceof Player) {
- Player player = (Player) creature;
- return !player.closed && player.spawned && player.isAlive() && (player.isSurvival() || player.isAdventure()) && distance <= 100;
- }
- return creature.isAlive() && !creature.closed && distance <= 100;
- }
- return false;
- }
-
- @Override
- public boolean entityBaseTick(int tickDiff) {
- if (Timings.entityBaseTickTimer != null) Timings.entityBaseTickTimer.startTiming();
-
- if (this.canDespawn() && this.age > Server.getInstance().mobDespawnTicks && !this.hasCustomName() && !(this instanceof EntityBoss)) {
- this.close();
- if (Timings.entityBaseTickTimer != null) Timings.entityBaseTickTimer.stopTiming();
- return true;
- }
-
- if (this instanceof EntityMob && this.attackDelay < 200) {
- this.attackDelay++;
- }
-
- boolean hasUpdate = super.entityBaseTick(tickDiff);
-
- if (this.moveTime > 0) {
- this.moveTime -= tickDiff;
- }
-
- if (this.isInLove()) {
- this.inLoveTicks -= tickDiff;
- if (this.age % 20 == 0) {
- for (int i = 0; i < 3; i++) {
- this.level.addParticle(new HeartParticle(this.add(Utils.rand(-1.0, 1.0), this.getMountedYOffset() + Utils.rand(-1.0, 1.0), Utils.rand(-1.0, 1.0))));
- }
- }
- }
-
- if (Timings.entityBaseTickTimer != null) Timings.entityBaseTickTimer.stopTiming();
-
- return hasUpdate;
- }
-
- @Override
- public boolean attack(EntityDamageEvent source) {
- if (this.isKnockback() && source instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) source).getDamager() instanceof Player) {
- return false;
- }
-
- if (this.fireProof && (source.getCause() == EntityDamageEvent.DamageCause.FIRE || source.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK || source.getCause() == EntityDamageEvent.DamageCause.LAVA || source.getCause() == EntityDamageEvent.DamageCause.MAGMA)) {
- return false;
- }
-
- if (source instanceof EntityDamageByEntityEvent) {
- if (this instanceof EntityRavager && Utils.rand()) {
- ((EntityDamageByEntityEvent) source).setKnockBack(0f);
- } else {
- ((EntityDamageByEntityEvent) source).setKnockBack(0.25f);
- }
- }
-
- super.attack(source);
-
- if (!source.isCancelled()) {
- this.target = null;
- this.stayTime = 0;
- }
-
- return true;
- }
-
- @Override
- public boolean setMotion(Vector3 motion) {
- if (this.getServer().getMobAiEnabled()) {
- super.setMotion(motion);
- }
- return false;
- }
-
- @Override
- public boolean move(double dx, double dy, double dz) {
- if (dy < -10 || dy > 10) {
- if (!(this instanceof EntityFlyingMob)) {
- this.kill();
- }
- return false;
- }
-
- if (dx == 0 && dz == 0 && dy == 0) {
- return false;
- }
-
- if (Timings.entityMoveTimer != null) Timings.entityMoveTimer.startTiming();
-
- this.blocksAround = null;
-
- double movX = dx * moveMultiplier;
- double movY = dy;
- double movZ = dz * moveMultiplier;
-
- AxisAlignedBB[] list = this.level.getCollisionCubes(this, this.boundingBox.addCoord(dx, dy, dz), false);
-
- for (AxisAlignedBB bb : list) {
- dx = bb.calculateXOffset(this.boundingBox, dx);
- }
- this.boundingBox.offset(dx, 0, 0);
-
- for (AxisAlignedBB bb : list) {
- dz = bb.calculateZOffset(this.boundingBox, dz);
- }
- this.boundingBox.offset(0, 0, dz);
-
- for (AxisAlignedBB bb : list) {
- dy = bb.calculateYOffset(this.boundingBox, dy);
- }
- this.boundingBox.offset(0, dy, 0);
-
- this.setComponents(this.x + dx, this.y + dy, this.z + dz);
- this.checkChunks();
-
- this.checkGroundState(movX, movY, movZ, dx, dy, dz);
- this.updateFallState(this.onGround);
-
- if (Timings.entityMoveTimer != null) Timings.entityMoveTimer.stopTiming();
- return true;
- }
-
- @Override
- public boolean onInteract(Player player, Item item, Vector3 clickedPos) {
- if (item.getId() == Item.NAME_TAG) {
- if (item.hasCustomName() && !(this instanceof EntityEnderDragon)) {
- this.setNameTag(item.getCustomName());
- this.setNameTagVisible(true);
- player.getInventory().decreaseCount(player.getInventory().getHeldItemIndex());
- return true;
- }
- }
-
- return false;
- }
-
- public void setInLove() {
- this.inLoveTicks = 600;
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_INLOVE, true);
- }
-
- public boolean isInLove() {
- return inLoveTicks > 0;
- }
-
- public Item[] getRandomArmor() {
- Item[] slots = new Item[4];
- Item helmet = Item.get(0);
- Item chestplate = Item.get(0);
- Item leggings = Item.get(0);
- Item boots = Item.get(0);
-
- switch (Utils.rand(1, 5)) {
- case 1:
- if (Utils.rand(1, 100) < 39) {
- if (Utils.rand(0, 1) == 0) {
- helmet = Item.get(Item.LEATHER_HELMET, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 2:
- if (Utils.rand(1, 100) < 50) {
- if (Utils.rand(0, 1) == 0) {
- helmet = Item.get(Item.GOLD_HELMET, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 3:
- if (Utils.rand(1, 100) < 14) {
- if (Utils.rand(0, 1) == 0) {
- helmet = Item.get(Item.CHAIN_HELMET, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 4:
- if (Utils.rand(1, 100) < 3) {
- if (Utils.rand(0, 1) == 0) {
- helmet = Item.get(Item.IRON_HELMET, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 5:
- if (Utils.rand(1, 100) == 100) {
- if (Utils.rand(0, 1) == 0) {
- helmet = Item.get(Item.DIAMOND_HELMET, 0, 1);
- this.addHealth(2);
- }
- }
- break;
- }
-
- slots[0] = helmet;
-
- if (Utils.rand(1, 4) != 1) {
- switch (Utils.rand(1, 5)) {
- case 1:
- if (Utils.rand(1, 100) < 39) {
- if (Utils.rand(0, 1) == 0) {
- chestplate = Item.get(Item.LEATHER_CHESTPLATE, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 2:
- if (Utils.rand(1, 100) < 50) {
- if (Utils.rand(0, 1) == 0) {
- chestplate = Item.get(Item.GOLD_CHESTPLATE, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 3:
- if (Utils.rand(1, 100) < 14) {
- if (Utils.rand(0, 1) == 0) {
- chestplate = Item.get(Item.CHAIN_CHESTPLATE, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 4:
- if (Utils.rand(1, 100) < 3) {
- if (Utils.rand(0, 1) == 0) {
- chestplate = Item.get(Item.IRON_CHESTPLATE, 0, 1);
- this.addHealth(2);
- }
- }
- break;
- case 5:
- if (Utils.rand(1, 100) == 100) {
- if (Utils.rand(0, 1) == 0) {
- chestplate = Item.get(Item.DIAMOND_CHESTPLATE, 0, 1);
- this.addHealth(3);
- }
- }
- break;
- }
- }
-
- slots[1] = chestplate;
-
- if (Utils.rand(1, 2) == 2) {
- switch (Utils.rand(1, 5)) {
- case 1:
- if (Utils.rand(1, 100) < 39) {
- if (Utils.rand(0, 1) == 0) {
- leggings = Item.get(Item.LEATHER_LEGGINGS, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 2:
- if (Utils.rand(1, 100) < 50) {
- if (Utils.rand(0, 1) == 0) {
- leggings = Item.get(Item.GOLD_LEGGINGS, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 3:
- if (Utils.rand(1, 100) < 14) {
- if (Utils.rand(0, 1) == 0) {
- leggings = Item.get(Item.CHAIN_LEGGINGS, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 4:
- if (Utils.rand(1, 100) < 3) {
- if (Utils.rand(0, 1) == 0) {
- leggings = Item.get(Item.IRON_LEGGINGS, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 5:
- if (Utils.rand(1, 100) == 100) {
- if (Utils.rand(0, 1) == 0) {
- leggings = Item.get(Item.DIAMOND_LEGGINGS, 0, 1);
- this.addHealth(2);
- }
- }
- break;
- }
- }
-
- slots[2] = leggings;
-
- if (Utils.rand(1, 5) < 3) {
- switch (Utils.rand(1, 5)) {
- case 1:
- if (Utils.rand(1, 100) < 39) {
- if (Utils.rand(0, 1) == 0) {
- boots = Item.get(Item.LEATHER_BOOTS, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 2:
- if (Utils.rand(1, 100) < 50) {
- if (Utils.rand(0, 1) == 0) {
- boots = Item.get(Item.GOLD_BOOTS, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 3:
- if (Utils.rand(1, 100) < 14) {
- if (Utils.rand(0, 1) == 0) {
- boots = Item.get(Item.CHAIN_BOOTS, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 4:
- if (Utils.rand(1, 100) < 3) {
- if (Utils.rand(0, 1) == 0) {
- boots = Item.get(Item.IRON_BOOTS, 0, 1);
- this.addHealth(1);
- }
- }
- break;
- case 5:
- if (Utils.rand(1, 100) == 100) {
- if (Utils.rand(0, 1) == 0) {
- boots = Item.get(Item.DIAMOND_BOOTS, 0, 1);
- this.addHealth(2);
- }
- }
- break;
- }
- }
-
- slots[3] = boots;
-
- return slots;
- }
-
- private void addHealth(int health) {
- this.maxHealth = this.maxHealth + health;
- this.setHealth(this.getHealth() + health);
- }
-
- public boolean canDespawn() {
- return Server.getInstance().despawnMobs;
- }
-
- public int nearbyDistanceMultiplier() {
- return 1;
- }
-
- @Override
- protected void checkGroundState(double movX, double movY, double movZ, double dx, double dy, double dz) {
- if (onGround && movX == 0 && movY == 0 && movZ == 0 && dx == 0 && dy == 0 && dz == 0) {
- return;
- }
- this.isCollidedVertically = movY != dy;
- this.isCollidedHorizontally = (movX != dx || movZ != dz);
- this.isCollided = (this.isCollidedHorizontally || this.isCollidedVertically);
- this.onGround = (movY != dy && movY < 0);
- }
-
- public static void setProjectileMotion(EntityProjectile projectile, double pitch, double yawR, double pitchR, double speed) {
- double verticalMultiplier = Math.cos(pitchR);
- double x = verticalMultiplier * Math.sin(-yawR);
- double z = verticalMultiplier * Math.cos(yawR);
- double y = Math.sin(-(FastMath.toRadians(pitch)));
- double magnitude = Math.sqrt(x * x + y * y + z * z);
- if (magnitude > 0) {
- x += (x * (speed - magnitude)) / magnitude;
- y += (y * (speed - magnitude)) / magnitude;
- z += (z * (speed - magnitude)) / magnitude;
- }
- ThreadLocalRandom rand = ThreadLocalRandom.current();
- x += rand.nextGaussian() * 0.007499999832361937 * 6;
- y += rand.nextGaussian() * 0.007499999832361937 * 6;
- z += rand.nextGaussian() * 0.007499999832361937 * 6;
- projectile.setMotion(new Vector3(x, y, z));
- }
-
- public boolean canTarget(Entity entity) {
- return entity instanceof Player && entity.canBeFollowed();
- }
-
- @Override
- protected void checkBlockCollision() {
- for (Block block : this.getCollisionBlocks()) {
- block.onEntityCollide(this);
- }
-
- // TODO: portals
- }
-}
diff --git a/src/main/java/cn/nukkit/entity/Entity.java b/src/main/java/cn/nukkit/entity/Entity.java
deleted file mode 100644
index bc747fa1d..000000000
--- a/src/main/java/cn/nukkit/entity/Entity.java
+++ /dev/null
@@ -1,2691 +0,0 @@
-package cn.nukkit.entity;
-
-import cn.nukkit.Player;
-import cn.nukkit.Server;
-import cn.nukkit.block.*;
-import cn.nukkit.entity.data.*;
-import cn.nukkit.entity.item.EntityVehicle;
-import cn.nukkit.entity.mob.EntityCreeper;
-import cn.nukkit.entity.mob.EntityWolf;
-import cn.nukkit.event.Event;
-import cn.nukkit.event.entity.*;
-import cn.nukkit.event.entity.EntityDamageEvent.DamageCause;
-import cn.nukkit.event.player.PlayerInteractEvent;
-import cn.nukkit.event.player.PlayerInteractEvent.Action;
-import cn.nukkit.event.player.PlayerTeleportEvent;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemID;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.level.*;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.math.*;
-import cn.nukkit.metadata.MetadataValue;
-import cn.nukkit.metadata.Metadatable;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.DoubleTag;
-import cn.nukkit.nbt.tag.FloatTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.network.protocol.*;
-import cn.nukkit.network.protocol.types.EntityLink;
-import cn.nukkit.plugin.Plugin;
-import cn.nukkit.potion.Effect;
-import cn.nukkit.utils.ChunkException;
-import cn.nukkit.utils.MainLogger;
-import cn.nukkit.utils.Utils;
-import co.aikar.timings.Timing;
-import co.aikar.timings.Timings;
-import co.aikar.timings.TimingsHistory;
-import com.google.common.collect.Iterables;
-import org.apache.commons.math3.util.FastMath;
-
-import java.lang.reflect.Constructor;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static cn.nukkit.network.protocol.SetEntityLinkPacket.*;
-
-/**
- * @author MagicDroidX
- */
-@SuppressWarnings("rawtypes")
-public abstract class Entity extends Location implements Metadatable {
-
- public static final int NETWORK_ID = -1;
-
- public abstract int getNetworkId();
-
- public static final int DATA_TYPE_BYTE = 0;
- public static final int DATA_TYPE_SHORT = 1;
- public static final int DATA_TYPE_INT = 2;
- public static final int DATA_TYPE_FLOAT = 3;
- public static final int DATA_TYPE_STRING = 4;
- public static final int DATA_TYPE_NBT = 5;
- public static final int DATA_TYPE_POS = 6;
- public static final int DATA_TYPE_LONG = 7;
- public static final int DATA_TYPE_VECTOR3F = 8;
-
- public static final int DATA_FLAGS = 0;
- public static final int DATA_HEALTH = 1; //int (minecart/boat)
- public static final int DATA_VARIANT = 2; //int
- public static final int DATA_COLOR = 3, DATA_COLOUR = DATA_COLOR; //byte
- public static final int DATA_NAMETAG = 4; //string
- public static final int DATA_OWNER_EID = 5; //long
- public static final int DATA_TARGET_EID = 6; //long
- public static final int DATA_AIR = 7; //short
- public static final int DATA_POTION_COLOR = 8; //int (ARGB!)
- public static final int DATA_POTION_AMBIENT = 9; //byte
- public static final int DATA_JUMP_DURATION = 10; //long
- public static final int DATA_HURT_TIME = 11; //int (minecart/boat)
- public static final int DATA_HURT_DIRECTION = 12; //int (minecart/boat)
- public static final int DATA_PADDLE_TIME_LEFT = 13; //float
- public static final int DATA_PADDLE_TIME_RIGHT = 14; //float
- public static final int DATA_EXPERIENCE_VALUE = 15; //int (xp orb)
- public static final int DATA_DISPLAY_ITEM = 16; //int (id | (data << 16))
- public static final int DATA_DISPLAY_OFFSET = 17; //int
- public static final int DATA_HAS_DISPLAY = 18; //byte (must be 1 for minecart to show block inside)
- public static final int DATA_SWELL = 19;
- public static final int DATA_OLD_SWELL = 20;
- public static final int DATA_SWELL_DIR = 21;
- public static final int DATA_CHARGE_AMOUNT = 22;
- public static final int DATA_ENDERMAN_HELD_RUNTIME_ID = 23; //int (block runtime id)
- public static final int DATA_ENTITY_AGE = 24; //short
- public static final int DATA_PLAYER_FLAGS = 26; //byte
- public static final int DATA_PLAYER_INDEX = 27;
- public static final int DATA_PLAYER_BED_POSITION = 28; //block coords
- public static final int DATA_FIREBALL_POWER_X = 29; //float
- public static final int DATA_FIREBALL_POWER_Y = 30;
- public static final int DATA_FIREBALL_POWER_Z = 31;
- public static final int DATA_AUX_POWER = 32;
- public static final int DATA_FISH_X = 33;
- public static final int DATA_FISH_Z = 34;
- public static final int DATA_FISH_ANGLE = 35;
- public static final int DATA_POTION_AUX_VALUE = 36; //short
- public static final int DATA_LEAD_HOLDER_EID = 37; //long
- public static final int DATA_SCALE = 38; //float
- public static final int DATA_HAS_NPC_COMPONENT = 39; //byte
- public static final int DATA_NPC_SKIN_ID = 40; //string
- public static final int DATA_URL_TAG = 41; //string
- public static final int DATA_MAX_AIR = 42; //short
- public static final int DATA_MARK_VARIANT = 43; //int
- public static final int DATA_CONTAINER_TYPE = 44; //byte
- public static final int DATA_CONTAINER_BASE_SIZE = 45; //int
- public static final int DATA_CONTAINER_EXTRA_SLOTS_PER_STRENGTH = 46; //int
- public static final int DATA_BLOCK_TARGET = 47; //block coords (ender crystal)
- public static final int DATA_WITHER_INVULNERABLE_TICKS = 48; //int
- public static final int DATA_WITHER_TARGET_1 = 49; //long
- public static final int DATA_WITHER_TARGET_2 = 50; //long
- public static final int DATA_WITHER_TARGET_3 = 51; //long
- public static final int DATA_AERIAL_ATTACK = 52;
- public static final int DATA_BOUNDING_BOX_WIDTH = 53; //float
- public static final int DATA_BOUNDING_BOX_HEIGHT = 54; //float
- public static final int DATA_FUSE_LENGTH = 55; //int
- public static final int DATA_RIDER_SEAT_POSITION = 56; //vector3f
- public static final int DATA_RIDER_ROTATION_LOCKED = 57; //byte
- public static final int DATA_RIDER_MAX_ROTATION = 58; //float
- public static final int DATA_RIDER_MIN_ROTATION = 59; //float
- public static final int DATA_RIDER_ROTATION_OFFSET = 60;
- public static final int DATA_AREA_EFFECT_CLOUD_RADIUS = 61; //float
- public static final int DATA_AREA_EFFECT_CLOUD_WAITING = 62; //int
- public static final int DATA_AREA_EFFECT_CLOUD_PARTICLE_ID = 63; //int
- public static final int DATA_SHULKER_PEEK_ID = 64; //int
- public static final int DATA_SHULKER_ATTACH_FACE = 65; //byte
- public static final int DATA_SHULKER_ATTACHED = 66; //short
- public static final int DATA_SHULKER_ATTACH_POS = 67; //block coords
- public static final int DATA_TRADING_PLAYER_EID = 68; //long
- public static final int DATA_TRADING_CAREER = 69;
- public static final int DATA_HAS_COMMAND_BLOCK = 70;
- public static final int DATA_COMMAND_BLOCK_COMMAND = 71; //string
- public static final int DATA_COMMAND_BLOCK_LAST_OUTPUT = 72; //string
- public static final int DATA_COMMAND_BLOCK_TRACK_OUTPUT = 73; //byte
- public static final int DATA_CONTROLLING_RIDER_SEAT_NUMBER = 74; //byte
- public static final int DATA_STRENGTH = 75; //int
- public static final int DATA_MAX_STRENGTH = 76; //int
- public static final int DATA_SPELL_CASTING_COLOR = 77; //int
- public static final int DATA_LIMITED_LIFE = 78;
- public static final int DATA_ARMOR_STAND_POSE_INDEX = 79; // int
- public static final int DATA_ENDER_CRYSTAL_TIME_OFFSET = 80; // int
- public static final int DATA_ALWAYS_SHOW_NAMETAG = 81; // byte
- public static final int DATA_COLOR_2 = 82; // byte
- public static final int DATA_NAME_AUTHOR = 83;
- public static final int DATA_SCORE_TAG = 84; // String
- public static final int DATA_BALLOON_ATTACHED_ENTITY = 85; // long
- public static final int DATA_PUFFERFISH_SIZE = 86;
- public static final int DATA_BUBBLE_TIME = 87;
- public static final int DATA_AGENT = 88;
- public static final int DATA_SITTING_AMOUNT = 89;
- public static final int DATA_SITTING_AMOUNT_PREVIOUS = 90;
- public static final int DATA_EATING_COUNTER = 91;
- public static final int DATA_FLAGS_EXTENDED = 92, DATA_FLAGS2 = DATA_FLAGS_EXTENDED; //long (extended data flags)
- public static final int DATA_LAYING_AMOUNT = 93;
- public static final int DATA_LAYING_AMOUNT_PREVIOUS = 94;
- public static final int DATA_DURATION = 95;
- public static final int DATA_SPAWN_TIME = 96;
- public static final int DATA_CHANGE_RATE = 97;
- public static final int DATA_CHANGE_ON_PICKUP = 98;
- public static final int DATA_PICKUP_COUNT = 99;
- public static final int DATA_INTERACTIVE_TAG = 100; //string (button text)
- public static final int DATA_TRADE_TIER = 101;
- public static final int DATA_MAX_TRADE_TIER = 102;
- public static final int DATA_TRADE_EXPERIENCE = 103;
- public static final int DATA_SKIN_ID = 104; // int
- public static final int DATA_SPAWNING_FRAMES = 105;
- public static final int DATA_COMMAND_BLOCK_TICK_DELAY = 106; //int
- public static final int DATA_COMMAND_BLOCK_EXECUTE_ON_FIRST_TICK = 107; //byte
- public static final int DATA_AMBIENT_SOUND_INTERVAL = 108;
- public static final int DATA_AMBIENT_SOUND_INTERVAL_RANGE = 109;
- public static final int DATA_AMBIENT_SOUND_EVENT_NAME = 110;
- public static final int DATA_FALL_DAMAGE_MULTIPLIER = 111;
- public static final int DATA_NAME_RAW_TEXT = 112;
- public static final int DATA_CAN_RIDE_TARGET = 113;
- public static final int DATA_LOW_TIER_CURED_DISCOUNT = 114;
- public static final int DATA_HIGH_TIER_CURED_DISCOUNT = 115;
- public static final int DATA_NEARBY_CURED_DISCOUNT = 116;
- public static final int DATA_NEARBY_CURED_DISCOUNT_TIMESTAMP = 117;
- public static final int DATA_HITBOX = 118;
- public static final int DATA_IS_BUOYANT = 119;
- public static final int DATA_BASE_RUNTIME_ID = 120;
- public static final int DATA_FREEZING_EFFECT_STRENGTH = 121;
- public static final int DATA_BUOYANCY_DATA = 122;
- public static final int DATA_GOAT_HORN_COUNT = 123;
- public static final int DATA_UPDATE_PROPERTIES = 124;
-
- // Flags
- public static final int DATA_FLAG_ONFIRE = 0;
- public static final int DATA_FLAG_SNEAKING = 1;
- public static final int DATA_FLAG_RIDING = 2;
- public static final int DATA_FLAG_SPRINTING = 3;
- public static final int DATA_FLAG_ACTION = 4;
- public static final int DATA_FLAG_INVISIBLE = 5;
- public static final int DATA_FLAG_TEMPTED = 6;
- public static final int DATA_FLAG_INLOVE = 7;
- public static final int DATA_FLAG_SADDLED = 8;
- public static final int DATA_FLAG_POWERED = 9;
- public static final int DATA_FLAG_IGNITED = 10;
- public static final int DATA_FLAG_BABY = 11;
- public static final int DATA_FLAG_CONVERTING = 12;
- public static final int DATA_FLAG_CRITICAL = 13;
- public static final int DATA_FLAG_CAN_SHOW_NAMETAG = 14;
- public static final int DATA_FLAG_ALWAYS_SHOW_NAMETAG = 15;
- public static final int DATA_FLAG_IMMOBILE = 16, DATA_FLAG_NO_AI = DATA_FLAG_IMMOBILE;
- public static final int DATA_FLAG_SILENT = 17;
- public static final int DATA_FLAG_WALLCLIMBING = 18;
- public static final int DATA_FLAG_CAN_CLIMB = 19;
- public static final int DATA_FLAG_SWIMMER = 20;
- public static final int DATA_FLAG_CAN_FLY = 21;
- public static final int DATA_FLAG_WALKER = 22;
- public static final int DATA_FLAG_RESTING = 23;
- public static final int DATA_FLAG_SITTING = 24;
- public static final int DATA_FLAG_ANGRY = 25;
- public static final int DATA_FLAG_INTERESTED = 26;
- public static final int DATA_FLAG_CHARGED = 27;
- public static final int DATA_FLAG_TAMED = 28;
- public static final int DATA_FLAG_ORPHANED = 29;
- public static final int DATA_FLAG_LEASHED = 30;
- public static final int DATA_FLAG_SHEARED = 31;
- public static final int DATA_FLAG_GLIDING = 32;
- public static final int DATA_FLAG_ELDER = 33;
- public static final int DATA_FLAG_MOVING = 34;
- public static final int DATA_FLAG_BREATHING = 35;
- public static final int DATA_FLAG_CHESTED = 36;
- public static final int DATA_FLAG_STACKABLE = 37;
- public static final int DATA_FLAG_SHOWBASE = 38;
- public static final int DATA_FLAG_REARING = 39;
- public static final int DATA_FLAG_VIBRATING = 40;
- public static final int DATA_FLAG_IDLING = 41;
- public static final int DATA_FLAG_EVOKER_SPELL = 42;
- public static final int DATA_FLAG_CHARGE_ATTACK = 43;
- public static final int DATA_FLAG_WASD_CONTROLLED = 44;
- public static final int DATA_FLAG_CAN_POWER_JUMP = 45;
- public static final int DATA_FLAG_LINGER = 46;
- public static final int DATA_FLAG_HAS_COLLISION = 47;
- public static final int DATA_FLAG_GRAVITY = 48;
- public static final int DATA_FLAG_FIRE_IMMUNE = 49;
- public static final int DATA_FLAG_DANCING = 50;
- public static final int DATA_FLAG_ENCHANTED = 51;
- public static final int DATA_FLAG_SHOW_TRIDENT_ROPE = 52;
- public static final int DATA_FLAG_CONTAINER_PRIVATE = 53;
- public static final int DATA_FLAG_IS_TRANSFORMING = 54;
- public static final int DATA_FLAG_SPIN_ATTACK = 55;
- public static final int DATA_FLAG_SWIMMING = 56;
- public static final int DATA_FLAG_BRIBED = 57;
- public static final int DATA_FLAG_PREGNANT = 58;
- public static final int DATA_FLAG_LAYING_EGG = 59;
- public static final int DATA_FLAG_RIDER_CAN_PICK = 60;
- public static final int DATA_FLAG_TRANSITION_SETTING = 61;
- public static final int DATA_FLAG_EATING = 62;
- public static final int DATA_FLAG_LAYING_DOWN = 63;
- public static final int DATA_FLAG_SNEEZING = 64;
- public static final int DATA_FLAG_TRUSTING = 65;
- public static final int DATA_FLAG_ROLLING = 66;
- public static final int DATA_FLAG_SCARED = 67;
- public static final int DATA_FLAG_IN_SCAFFOLDING = 68;
- public static final int DATA_FLAG_OVER_SCAFFOLDING = 69;
- public static final int DATA_FLAG_FALL_THROUGH_SCAFFOLDING = 70;
- public static final int DATA_FLAG_BLOCKING = 71;
- public static final int DATA_FLAG_TRANSITION_BLOCKING = 72;
- public static final int DATA_FLAG_BLOCKED_USING_SHIELD = 73;
- public static final int DATA_FLAG_BLOCKED_USING_DAMAGED_SHIELD = 74;
- public static final int DATA_FLAG_SLEEPING = 75;
- public static final int DATA_FLAG_ENTITY_GROW_UP = 76;
- public static final int DATA_FLAG_TRADE_INTEREST = 77;
- public static final int DATA_FLAG_DOOR_BREAKER = 78;
- public static final int DATA_FLAG_BREAKING_OBSTRUCTION = 79;
- public static final int DATA_FLAG_DOOR_OPENER = 80;
- public static final int DATA_FLAG_IS_ILLAGER_CAPTAIN = 81;
- public static final int DATA_FLAG_STUNNED = 82;
- public static final int DATA_FLAG_ROARING = 83;
- public static final int DATA_FLAG_DELAYED_ATTACK = 84;
- public static final int DATA_FLAG_IS_AVOIDING_MOBS = 85;
- public static final int DATA_FLAG_IS_AVOIDING_BLOCKS = 86;
- public static final int DATA_FLAG_FACING_TARGET_TO_RANGE_ATTACK = 87;
- public static final int DATA_FLAG_HIDDEN_WHEN_INVISIBLE = 88;
- public static final int DATA_FLAG_IS_IN_UI = 89;
- public static final int DATA_FLAG_STALKING = 90;
- public static final int DATA_FLAG_EMOTING = 91;
- public static final int DATA_FLAG_CELEBRATING = 92;
- public static final int DATA_FLAG_ADMIRING = 93;
- public static final int DATA_FLAG_CELEBRATING_SPECIAL = 94;
- public static final int DATA_FLAG_RAM_ATTACK = 96;
- public static final int DATA_FLAG_PLAYING_DEAD = 97;
- public static final int DATA_FLAG_IN_ASCENDABLE_BLOCK = 98;
- public static final int DATA_FLAG_OVER_DESCENDABLE_BLOCK = 99;
-
- public static final double STEP_CLIP_MULTIPLIER = 0.4;
-
- public static long entityCount = 1;
-
- private static final Map> knownEntities = new HashMap<>();
- private static final Map shortNames = new HashMap<>();
-
- public final Map hasSpawned = new HashMap<>();
-
- protected final Map effects = new ConcurrentHashMap<>();
-
- protected long id;
-
- protected final EntityMetadata dataProperties = new EntityMetadata()
- .putLong(DATA_FLAGS, 0)
- .putByte(DATA_COLOR, 0)
- .putShort(DATA_AIR, 400)
- .putShort(DATA_MAX_AIR, 400)
- .putString(DATA_NAMETAG, "")
- .putLong(DATA_LEAD_HOLDER_EID, -1)
- .putFloat(DATA_SCALE, 1f);
-
- public final List passengers = new ArrayList<>();
-
- public Entity riding = null;
-
- public FullChunk chunk;
-
- protected EntityDamageEvent lastDamageCause = null;
-
- public List blocksAround = new ArrayList<>();
- public List collisionBlocks = new ArrayList<>();
-
- public double lastX;
- public double lastY;
- public double lastZ;
-
- public boolean firstMove = true;
-
- public double motionX;
- public double motionY;
- public double motionZ;
-
- public Vector3 temporalVector;
- public double lastMotionX;
- public double lastMotionY;
- public double lastMotionZ;
-
- public double lastYaw;
- public double lastPitch;
- public double lastHeadYaw;
-
- public double entityCollisionReduction = 0; // Higher than 0.9 will result a fast collisions
- public AxisAlignedBB boundingBox;
- public boolean onGround;
- public int deadTicks = 0;
- public int age = 0;
- public int ticksLived = 0;
- protected int airTicks = 0;
-
- protected float health = 20;
- protected int maxHealth = 20;
-
- protected float absorption = 0;
-
- protected float ySize = 0;
- public boolean keepMovement = false;
-
- public float fallDistance = 0;
- public int lastUpdate;
- public int fireTicks = 0;
- public int inPortalTicks = 0;
- public int inEndPortalTicks = 0;
- public Position portalPos = null;
-
- public float scale = 1;
-
- public CompoundTag namedTag;
-
- public boolean isCollided = false;
- public boolean isCollidedHorizontally = false;
- public boolean isCollidedVertically = false;
-
- public int noDamageTicks;
- public boolean justCreated;
- public boolean fireProof;
- public boolean invulnerable;
-
- private boolean gliding;
- private boolean immobile;
- private boolean sprinting;
- private boolean swimming;
- private boolean sneaking;
-
- protected Server server;
-
- public double highestPosition;
-
- public boolean closed = false;
-
- protected Timing timing;
-
- public final boolean isPlayer;
-
- private volatile boolean init;
- private volatile boolean initEntity;
-
- public float getHeight() {
- return 0;
- }
-
- public float getEyeHeight() {
- return this.getHeight() / 2 + 0.1f;
- }
-
- protected float getBreathableHeight() {
- return isSwimming() || isGliding() ? -1f : 1.62f; // Hack: fix air while swimming in one block deep water
- }
-
- public float getWidth() {
- return 0;
- }
-
- public float getLength() {
- return 0;
- }
-
- protected double getStepHeight() {
- return 0;
- }
-
- public boolean canCollide() {
- return true;
- }
-
- public boolean canBeFollowed() {
- return true;
- }
-
- protected float getGravity() {
- return 0;
- }
-
- protected float getDrag() {
- return 0;
- }
-
- protected float getBaseOffset() {
- return 0;
- }
-
- public Entity(FullChunk chunk, CompoundTag nbt) {
- this.isPlayer = this instanceof Player;
- if (!this.isPlayer) {
- this.init(chunk, nbt);
- }
- }
-
- protected void initEntity() {
- if (this.initEntity) {
- throw new RuntimeException("Entity is already initialized: " + this.getName() + " (" + this.id + ')');
- }
-
- this.initEntity = true;
-
- if (this.namedTag.contains("ActiveEffects")) {
- ListTag effects = this.namedTag.getList("ActiveEffects", CompoundTag.class);
- for (CompoundTag e : effects.getAll()) {
- Effect effect = Effect.getEffect(e.getByte("Id"));
- if (effect == null) {
- continue;
- }
-
- effect.setAmplifier(e.getByte("Amplifier")).setDuration(e.getInt("Duration")).setVisible(e.getBoolean("ShowParticles"));
-
- this.addEffect(effect);
- }
- }
-
- if (this.namedTag.contains("CustomName")) {
- this.setNameTag(this.namedTag.getString("CustomName"));
-
- if (this.namedTag.contains("CustomNameVisible")) {
- this.setNameTagVisible(this.namedTag.getBoolean("CustomNameVisible"));
- }
-
- if (this.namedTag.contains("CustomNameAlwaysVisible")) {
- this.setNameTagAlwaysVisible(this.namedTag.getBoolean("CustomNameAlwaysVisible"));
- }
- }
-
- this.dataProperties.put(new LongEntityData(DATA_FLAGS, this.getDataPropertyLong(DATA_FLAGS) ^ 1L << DATA_FLAG_HAS_COLLISION));
- this.dataProperties.putFloat(DATA_BOUNDING_BOX_HEIGHT, this.getHeight());
- this.dataProperties.putFloat(DATA_BOUNDING_BOX_WIDTH, this.getWidth());
- this.dataProperties.putInt(DATA_HEALTH, (int) this.health);
-
- this.scheduleUpdate();
-
- if (this.isPlayer) {
- this.sendData((Player) this);
- }
- }
-
- protected final void init(FullChunk chunk, CompoundTag nbt) {
- if ((chunk == null || chunk.getProvider() == null)) {
- throw new ChunkException("Invalid garbage Chunk given to Entity");
- }
-
- if (this.init) {
- throw new RuntimeException("Entity is already initialized: " + this.getName() + " (" + this.id + ')');
- }
-
- this.init = true;
-
- this.timing = Timings.getEntityTiming(this);
-
- this.temporalVector = new Vector3();
-
- this.id = entityCount++;
- this.justCreated = true;
- this.namedTag = nbt;
-
- this.chunk = chunk;
- this.setLevel(chunk.getProvider().getLevel());
- this.server = chunk.getProvider().getLevel().getServer();
-
- this.boundingBox = new AxisAlignedBB(0, 0, 0, 0, 0, 0);
-
- ListTag posList = this.namedTag.getList("Pos", DoubleTag.class);
- ListTag rotationList = this.namedTag.getList("Rotation", FloatTag.class);
- ListTag motionList = this.namedTag.getList("Motion", DoubleTag.class);
- this.setPositionAndRotation(
- this.temporalVector.setComponents(
- posList.get(0).data,
- posList.get(1).data,
- posList.get(2).data
- ),
- rotationList.get(0).data,
- rotationList.get(1).data
- );
-
- this.setMotion(this.temporalVector.setComponents(
- motionList.get(0).data,
- motionList.get(1).data,
- motionList.get(2).data
- ));
-
- if (!this.namedTag.contains("FallDistance")) {
- this.namedTag.putFloat("FallDistance", 0);
- }
- this.fallDistance = this.namedTag.getFloat("FallDistance");
- this.highestPosition = this.y + this.namedTag.getFloat("FallDistance");
-
- if (!this.namedTag.contains("Fire") || this.namedTag.getShort("Fire") > 32767) {
- this.namedTag.putShort("Fire", 0);
- }
- this.fireTicks = this.namedTag.getShort("Fire");
-
- if (!this.namedTag.contains("Air")) {
- this.namedTag.putShort("Air", 300);
- }
- this.setDataProperty(new ShortEntityData(DATA_AIR, this.namedTag.getShort("Air")), false);
-
- if (!this.namedTag.contains("OnGround")) {
- this.namedTag.putBoolean("OnGround", false);
- }
- this.onGround = this.namedTag.getBoolean("OnGround");
-
- if (!this.namedTag.contains("Invulnerable")) {
- this.namedTag.putBoolean("Invulnerable", false);
- }
- this.invulnerable = this.namedTag.getBoolean("Invulnerable");
-
- if (!this.namedTag.contains("Scale")) {
- this.namedTag.putFloat("Scale", 1);
- }
- this.scale = this.namedTag.getFloat("Scale");
- this.setDataProperty(new FloatEntityData(DATA_SCALE, scale), false);
-
- this.chunk.addEntity(this);
- this.level.addEntity(this);
-
- this.initEntity();
-
- this.lastUpdate = this.server.getTick();
- this.server.getPluginManager().callEvent(new EntitySpawnEvent(this));
-
- this.scheduleUpdate();
- }
-
- public boolean hasCustomName() {
- return !this.getNameTag().isEmpty();
- }
-
- public String getNameTag() {
- return this.getDataPropertyString(DATA_NAMETAG);
- }
-
- public boolean isNameTagVisible() {
- return this.getDataFlag(DATA_FLAGS, DATA_FLAG_CAN_SHOW_NAMETAG);
- }
-
- public boolean isNameTagAlwaysVisible() {
- return this.getDataPropertyByte(DATA_ALWAYS_SHOW_NAMETAG) == 1;
- }
-
- public void setNameTag(String name) {
- this.setDataProperty(new StringEntityData(DATA_NAMETAG, name));
- }
-
- public void setNameTagVisible() {
- this.setNameTagVisible(true);
- }
-
- public void setNameTagVisible(boolean value) {
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_CAN_SHOW_NAMETAG, value);
- }
-
- public void setNameTagAlwaysVisible() {
- this.setNameTagAlwaysVisible(true);
- }
-
- public void setNameTagAlwaysVisible(boolean value) {
- this.setDataProperty(new ByteEntityData(DATA_ALWAYS_SHOW_NAMETAG, value ? 1 : 0));
- }
-
- public void setScoreTag(String score) {
- this.setDataProperty(new StringEntityData(DATA_SCORE_TAG, score));
- }
-
- public String getScoreTag() {
- return this.getDataPropertyString(DATA_SCORE_TAG);
- }
-
- public boolean isSneaking() {
- return this.sneaking;
- }
-
- public void setSneaking() {
- this.setSneaking(true);
- }
-
- public void setSneaking(boolean value) {
- this.sneaking = value;
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_SNEAKING, value);
- }
-
- public boolean isSwimming() {
- return this.swimming;
- }
-
- public void setSwimming() {
- this.setSwimming(true);
- }
-
- public void setSwimming(boolean value) {
- if (this.swimming != value) {
- this.swimming = value;
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_SWIMMING, value);
- this.recalculateBoundingBox(true);
- }
- }
-
- public boolean isSprinting() {
- return this.sprinting;
- }
-
- public void setSprinting() {
- this.setSprinting(true);
- }
-
- public void setSprinting(boolean value) {
- if (this.sprinting != value) {
- this.sprinting = value;
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_SPRINTING, value);
- }
- }
-
- public boolean isGliding() {
- return this.gliding;
- }
-
- public void setGliding() {
- this.setGliding(true);
- }
-
- public void setGliding(boolean value) {
- if (this.gliding != value) {
- this.gliding = value;
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_GLIDING, value);
- this.recalculateBoundingBox(true);
- }
- }
-
- public boolean isImmobile() {
- return this.immobile;
- }
-
- public void setImmobile() {
- this.setImmobile(true);
- }
-
- public void setImmobile(boolean value) {
- this.immobile = value;
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_IMMOBILE, value);
- }
-
- public boolean canClimb() {
- return this.getDataFlag(DATA_FLAGS, DATA_FLAG_CAN_CLIMB);
- }
-
- public void setCanClimb() {
- this.setCanClimb(true);
- }
-
- public void setCanClimb(boolean value) {
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_CAN_CLIMB, value);
- }
-
- public boolean canClimbWalls() {
- return this.getDataFlag(DATA_FLAGS, DATA_FLAG_WALLCLIMBING);
- }
-
- public void setCanClimbWalls() {
- this.setCanClimbWalls(true);
- }
-
- public void setCanClimbWalls(boolean value) {
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_WALLCLIMBING, value);
- }
-
- public void setScale(float scale) {
- if (this.scale != scale) {
- this.scale = scale;
- this.setDataProperty(new FloatEntityData(DATA_SCALE, this.scale));
- this.recalculateBoundingBox(true);
- }
- }
-
- public float getScale() {
- return this.scale;
- }
-
- public List getPassengers() {
- return passengers;
- }
-
- public Entity getPassenger() {
- return Iterables.getFirst(this.passengers, null);
- }
-
- public boolean isPassenger(Entity entity) {
- return this.passengers.contains(entity);
- }
-
- public boolean isControlling(Entity entity) {
- return this.passengers.indexOf(entity) == 0;
- }
-
- public boolean hasControllingPassenger() {
- return !this.passengers.isEmpty() && isControlling(this.passengers.get(0));
- }
-
- public Entity getRiding() {
- return riding;
- }
-
- public Map getEffects() {
- return effects;
- }
-
- public void removeAllEffects() {
- for (Effect effect : this.effects.values()) {
- this.removeEffect(effect.getId());
- }
- }
-
- public void removeEffect(int effectId) {
- if (this.effects.containsKey(effectId)) {
- Effect effect = this.effects.get(effectId);
- this.effects.remove(effectId);
- effect.remove(this);
- this.recalculateEffectColor();
- }
- }
-
- public Effect getEffect(int effectId) {
- return this.effects.getOrDefault(effectId, null);
- }
-
- public boolean hasEffect(int effectId) {
- return this.effects.containsKey(effectId);
- }
-
- public void addEffect(Effect effect) {
- if (effect == null) {
- return; //here add null means add nothing
- }
-
- effect.add(this);
-
- this.effects.put(effect.getId(), effect);
-
- this.recalculateEffectColor();
-
- if (effect.getId() == Effect.HEALTH_BOOST) {
- this.setHealth(this.health + ((effect.getAmplifier() + 1) << 2));
- }
- }
-
- public void recalculateBoundingBox() {
- this.recalculateBoundingBox(false);
- }
-
- public void recalculateBoundingBox(boolean send) {
- float height = this.getHeight();
- double radius = (this.getWidth() * this.scale) / 2d;
- this.boundingBox.setBounds(
- this.x - radius,
- this.y + this.ySize,
- z - radius,
- x + radius,
- y + height * this.scale + this.ySize,
- z + radius
- );
-
- if (send) {
- FloatEntityData bbH = new FloatEntityData(DATA_BOUNDING_BOX_HEIGHT, height);
- FloatEntityData bbW = new FloatEntityData(DATA_BOUNDING_BOX_WIDTH, this.getWidth());
- this.dataProperties.put(bbH);
- this.dataProperties.put(bbW);
- sendData(this.hasSpawned.values().toArray(new Player[0]), new EntityMetadata().put(bbH).put(bbW));
- }
- }
-
- protected void recalculateEffectColor() {
- int[] color = new int[3];
- int count = 0;
- boolean ambient = true;
- for (Effect effect : this.effects.values()) {
- if (effect.isVisible()) {
- int[] c = effect.getColor();
- color[0] += c[0] * (effect.getAmplifier() + 1);
- color[1] += c[1] * (effect.getAmplifier() + 1);
- color[2] += c[2] * (effect.getAmplifier() + 1);
- count += effect.getAmplifier() + 1;
- if (!effect.isAmbient()) {
- ambient = false;
- }
- }
- }
-
- if (count > 0) {
- int r = (color[0] / count) & 0xff;
- int g = (color[1] / count) & 0xff;
- int b = (color[2] / count) & 0xff;
-
- this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, (r << 16) + (g << 8) + b));
- this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, ambient ? 1 : 0));
- } else {
- this.setDataProperty(new IntEntityData(Entity.DATA_POTION_COLOR, 0));
- this.setDataProperty(new ByteEntityData(Entity.DATA_POTION_AMBIENT, 0));
- }
- }
-
- public static Entity createEntity(String name, Position pos, Object... args) {
- return createEntity(name, pos.getChunk(), getDefaultNBT(pos), args);
- }
-
- public static Entity createEntity(int type, Position pos, Object... args) {
- return createEntity(String.valueOf(type), pos.getChunk(), getDefaultNBT(pos), args);
- }
-
- public static Entity createEntity(String name, FullChunk chunk, CompoundTag nbt, Object... args) {
- Entity entity = null;
-
- if (knownEntities.containsKey(name)) {
- Class extends Entity> clazz = knownEntities.get(name);
-
- if (clazz == null) {
- return null;
- }
-
- for (Constructor constructor : clazz.getConstructors()) {
- if (entity != null) {
- break;
- }
-
- if (constructor.getParameterCount() != (args == null ? 2 : args.length + 2)) {
- continue;
- }
-
- try {
- if (args == null || args.length == 0) {
- entity = (Entity) constructor.newInstance(chunk, nbt);
- } else {
- Object[] objects = new Object[args.length + 2];
-
- objects[0] = chunk;
- objects[1] = nbt;
- System.arraycopy(args, 0, objects, 2, args.length);
- entity = (Entity) constructor.newInstance(objects);
-
- }
- } catch (Exception e) {
- MainLogger.getLogger().logException(e);
- }
- }
- }
-
- return entity;
- }
-
- public static Entity createEntity(int type, FullChunk chunk, CompoundTag nbt, Object... args) {
- return createEntity(String.valueOf(type), chunk, nbt, args);
- }
-
- public static boolean registerEntity(String name, Class extends Entity> clazz) {
- return registerEntity(name, clazz, false);
- }
-
- public static boolean registerEntity(String name, Class extends Entity> clazz, boolean force) {
- if (clazz == null) {
- return false;
- }
- try {
- int networkId = clazz.getField("NETWORK_ID").getInt(null);
- knownEntities.put(String.valueOf(networkId), clazz);
- } catch (Exception e) {
- if (!force) {
- return false;
- }
- }
-
- knownEntities.put(name, clazz);
- shortNames.put(clazz.getSimpleName(), name);
- return true;
- }
-
- public static CompoundTag getDefaultNBT(Vector3 pos) {
- return getDefaultNBT(pos, null);
- }
-
- public static CompoundTag getDefaultNBT(Vector3 pos, Vector3 motion) {
- Location loc = pos instanceof Location ? (Location) pos : null;
-
- if (loc != null) {
- return getDefaultNBT(pos, motion, (float) loc.getYaw(), (float) loc.getPitch());
- }
-
- return getDefaultNBT(pos, motion, 0, 0);
- }
-
- public static CompoundTag getDefaultNBT(Vector3 pos, Vector3 motion, float yaw, float pitch) {
- return new CompoundTag()
- .putList(new ListTag("Pos")
- .add(new DoubleTag("", pos.x))
- .add(new DoubleTag("", pos.y))
- .add(new DoubleTag("", pos.z)))
- .putList(new ListTag("Motion")
- .add(new DoubleTag("", motion != null ? motion.x : 0))
- .add(new DoubleTag("", motion != null ? motion.y : 0))
- .add(new DoubleTag("", motion != null ? motion.z : 0)))
- .putList(new ListTag("Rotation")
- .add(new FloatTag("", yaw))
- .add(new FloatTag("", pitch)));
- }
-
- public void saveNBT() {
- if (!this.isPlayer) {
- this.namedTag.putString("id", this.getSaveId());
- if (!this.getNameTag().isEmpty()) {
- this.namedTag.putString("CustomName", this.getNameTag());
- this.namedTag.putBoolean("CustomNameVisible", this.isNameTagVisible());
- this.namedTag.putBoolean("CustomNameAlwaysVisible", this.isNameTagAlwaysVisible());
- } else {
- this.namedTag.remove("CustomName");
- this.namedTag.remove("CustomNameVisible");
- this.namedTag.remove("CustomNameAlwaysVisible");
- }
- }
-
- this.namedTag.putList(new ListTag("Pos")
- .add(new DoubleTag("0", this.x))
- .add(new DoubleTag("1", this.y))
- .add(new DoubleTag("2", this.z))
- );
-
- this.namedTag.putList(new ListTag("Motion")
- .add(new DoubleTag("0", this.motionX))
- .add(new DoubleTag("1", this.motionY))
- .add(new DoubleTag("2", this.motionZ))
- );
-
- this.namedTag.putList(new ListTag("Rotation")
- .add(new FloatTag("0", (float) this.yaw))
- .add(new FloatTag("1", (float) this.pitch))
- );
-
- this.namedTag.putFloat("FallDistance", this.fallDistance);
- this.namedTag.putShort("Fire", this.fireTicks);
- this.namedTag.putShort("Air", this.airTicks);
- this.namedTag.putBoolean("OnGround", this.onGround);
- this.namedTag.putBoolean("Invulnerable", this.invulnerable);
- this.namedTag.putFloat("Scale", this.scale);
-
- if (!this.effects.isEmpty()) {
- ListTag list = new ListTag<>("ActiveEffects");
- for (Effect effect : this.effects.values()) {
- list.add(new CompoundTag(String.valueOf(effect.getId()))
- .putByte("Id", effect.getId())
- .putByte("Amplifier", effect.getAmplifier())
- .putInt("Duration", effect.getDuration())
- .putBoolean("Ambient", false)
- .putBoolean("ShowParticles", effect.isVisible())
- );
- }
-
- this.namedTag.putList(list);
- } else {
- this.namedTag.remove("ActiveEffects");
- }
- }
-
- public String getName() {
- if (this.hasCustomName()) {
- return this.getNameTag();
- } else {
- return this.getSaveId();
- }
- }
-
- public final String getSaveId() {
- return shortNames.getOrDefault(this.getClass().getSimpleName(), "");
- }
-
- public void spawnTo(Player player) {
- if (!init || !initEntity) {
- this.server.getLogger().warning("(BUG) Spawned an entity that is not initialized yet: " + this.getName() + " (" + this.id + ')');
- }
-
- if (!this.hasSpawned.containsKey(player.getLoaderId()) && player.usedChunks.containsKey(Level.chunkHash(this.chunk.getX(), this.chunk.getZ()))) {
- player.dataPacket(createAddEntityPacket());
- this.hasSpawned.put(player.getLoaderId(), player);
-
- if (this.riding != null) {
- this.riding.spawnTo(player);
-
- SetEntityLinkPacket pkk = new SetEntityLinkPacket();
- pkk.vehicleUniqueId = this.riding.id;
- pkk.riderUniqueId = this.id;
- pkk.type = 1;
- pkk.immediate = 1;
-
- player.dataPacket(pkk);
- }
-
- if (this.server.vanillaBossBar && this instanceof EntityBoss) {
- BossEventPacket pkBoss = new BossEventPacket();
- pkBoss.bossEid = this.id;
- pkBoss.type = BossEventPacket.TYPE_SHOW;
- pkBoss.title = this.getName();
- pkBoss.healthPercent = player.protocol >= 361 ? this.health / 100 : this.health;
- player.dataPacket(pkBoss);
- }
- }
- }
-
- protected DataPacket createAddEntityPacket() {
- AddEntityPacket addEntity = new AddEntityPacket();
- addEntity.type = this.getNetworkId();
- addEntity.entityUniqueId = this.id;
- addEntity.entityRuntimeId = this.id;
- addEntity.yaw = (float) this.yaw;
- addEntity.headYaw = (float) this.yaw;
- addEntity.pitch = (float) this.pitch;
- addEntity.x = (float) this.x;
- addEntity.y = (float) this.y;
- addEntity.z = (float) this.z;
- addEntity.speedX = (float) this.motionX;
- addEntity.speedY = (float) this.motionY;
- addEntity.speedZ = (float) this.motionZ;
- addEntity.metadata = this.dataProperties.clone();
-
- addEntity.links = new EntityLink[this.passengers.size()];
- for (int i = 0; i < addEntity.links.length; i++) {
- addEntity.links[i] = new EntityLink(this.id, this.passengers.get(i).id, i == 0 ? EntityLink.TYPE_RIDER : TYPE_PASSENGER, false, false);
- }
-
- return addEntity;
- }
-
- public Map getViewers() {
- return hasSpawned;
- }
-
- public void sendPotionEffects(Player player) {
- for (Effect effect : this.effects.values()) {
- MobEffectPacket pk = new MobEffectPacket();
- pk.eid = this.id;
- pk.effectId = effect.getId();
- pk.amplifier = effect.getAmplifier();
- pk.particles = effect.isVisible();
- pk.duration = effect.getDuration();
- pk.eventId = MobEffectPacket.EVENT_ADD;
-
- player.dataPacket(pk);
- }
- }
-
- public void sendData(Player player) {
- this.sendData(player, null);
- }
-
- public void sendData(Player player, EntityMetadata data) {
- SetEntityDataPacket pk = new SetEntityDataPacket();
- pk.eid = this.id;
- pk.metadata = data == null ? this.dataProperties.clone() : data;
-
- //player.dataPacket(pk);
- player.batchDataPacket(pk);
- }
-
- public void sendData(Player[] players) {
- this.sendData(players, null);
- }
-
- public void sendData(Player[] players, EntityMetadata data) {
- SetEntityDataPacket pk = new SetEntityDataPacket();
- pk.eid = this.id;
- //pk.metadata = data == null ? this.dataProperties : data;
-
- for (Player player : players) {
- if (player == this) {
- continue;
- }
- pk.metadata = data == null ? this.dataProperties.clone() : data;
- //player.dataPacket(pk/*.clone()*/);
- player.batchDataPacket(pk.clone());
- }
- if (this.isPlayer) {
- pk.metadata = data == null ? this.dataProperties.clone() : data;
- //((Player) this).dataPacket(pk);
- ((Player) this).batchDataPacket(pk);
- }
- }
-
- public void despawnFrom(Player player) {
- if (this.hasSpawned.containsKey(player.getLoaderId())) {
- RemoveEntityPacket pk = new RemoveEntityPacket();
- pk.eid = this.id;
- player.dataPacket(pk);
- this.hasSpawned.remove(player.getLoaderId());
- }
- }
-
- public boolean attack(EntityDamageEvent source) {
- if (hasEffect(Effect.FIRE_RESISTANCE)
- && (source.getCause() == DamageCause.FIRE
- || source.getCause() == DamageCause.FIRE_TICK
- || source.getCause() == DamageCause.LAVA)) {
- return false;
- }
-
- server.getPluginManager().callEvent(source);
- if (source.isCancelled()) {
- return false;
- }
-
- if (source instanceof EntityDamageByEntityEvent) {
- // Make fire aspect to set the target in fire before dealing any damage so the target is in fire on death even if killed by the first hit
- Enchantment[] enchantments = ((EntityDamageByEntityEvent) source).getWeaponEnchantments();
- if (enchantments != null) {
- for (Enchantment enchantment : enchantments) {
- enchantment.doAttack(((EntityDamageByEntityEvent) source).getDamager(), this);
- }
- }
-
- // Wolf targets
- if (source.getEntity() instanceof Player) {
- for (Entity entity : source.getEntity().getLevel().getNearbyEntities(source.getEntity().getBoundingBox().grow(17, 17, 17), source.getEntity())) {
- if (entity instanceof EntityWolf) {
- if (((EntityWolf) entity).hasOwner()) {
- ((EntityWolf) entity).isAngryTo = ((EntityDamageByEntityEvent) source).getDamager().getId();
- ((EntityWolf) entity).setAngry(true);
- }
- }
- }
- } else if (((EntityDamageByEntityEvent) source).getDamager() instanceof Player) {
- for (Entity entity : ((EntityDamageByEntityEvent) source).getDamager().getLevel().getNearbyEntities(((EntityDamageByEntityEvent) source).getDamager().getBoundingBox().grow(17, 17, 17), ((EntityDamageByEntityEvent) source).getDamager())) {
- if (entity.getId() != source.getEntity().getId()) {
- if (entity instanceof EntityWolf) {
- if (((EntityWolf) entity).hasOwner()) {
- if (((EntityWolf) entity).getOwner().equals(((EntityDamageByEntityEvent) source).getDamager())) {
- ((EntityWolf) entity).isAngryTo = source.getEntity().getId();
- ((EntityWolf) entity).setAngry(true);
- }
- }
- }
- }
- }
- }
- }
-
- if (this.absorption > 0) { // Damage Absorption
- this.setAbsorption(Math.max(0, this.absorption + source.getDamage(EntityDamageEvent.DamageModifier.ABSORPTION)));
- }
- setLastDamageCause(source);
- float newHealth = health - source.getFinalDamage();
- if (newHealth < 1 && this.isPlayer) {
- if (source.getCause() != DamageCause.VOID && source.getCause() != DamageCause.SUICIDE) {
- Player p = (Player) this;
- boolean totem = false;
- if (p.getOffhandInventory().getItemFast(0).getId() == ItemID.TOTEM) {
- p.getOffhandInventory().clear(0);
- totem = true;
- } else if (p.getInventory().getItemInHandFast().getId() == ItemID.TOTEM) {
- p.getInventory().clear(p.getInventory().getHeldItemIndex());
- totem = true;
- }
- if (totem) {
- this.getLevel().addLevelEvent(this, LevelEventPacket.EVENT_SOUND_TOTEM);
- this.getLevel().addParticleEffect(this, ParticleEffect.TOTEM);
-
- this.extinguish();
- this.removeAllEffects();
- this.setHealth(1);
-
- this.addEffect(Effect.getEffect(Effect.REGENERATION).setDuration(800).setAmplifier(1));
- this.addEffect(Effect.getEffect(Effect.FIRE_RESISTANCE).setDuration(800));
- this.addEffect(Effect.getEffect(Effect.ABSORPTION).setDuration(100).setAmplifier(1));
-
- EntityEventPacket pk = new EntityEventPacket();
- pk.eid = this.getId();
- pk.event = EntityEventPacket.CONSUME_TOTEM;
- p.dataPacket(pk);
-
- source.setCancelled(true);
- return false;
- }
- }
- }
- setHealth(newHealth);
- return true;
- }
-
- public boolean attack(float damage) {
- return this.attack(new EntityDamageEvent(this, DamageCause.CUSTOM, damage));
- }
-
- public void heal(EntityRegainHealthEvent source) {
- this.server.getPluginManager().callEvent(source);
- if (source.isCancelled()) {
- return;
- }
- this.setHealth(this.health + source.getAmount());
- }
-
- public void heal(float amount) {
- this.heal(new EntityRegainHealthEvent(this, amount, EntityRegainHealthEvent.CAUSE_REGEN));
- }
-
- public float getHealth() {
- return health;
- }
-
- public boolean isAlive() {
- return this.health >= 1;
- }
-
- public boolean isClosed() {
- return closed;
- }
-
- public void setHealth(float health) {
- if (this.health == health) {
- return;
- }
-
- if (health < 1) {
- if (this.isAlive()) {
- this.kill();
- }
- } else if (health <= this.getMaxHealth() || health < this.health) {
- this.health = health;
- } else {
- this.health = this.getMaxHealth();
- }
-
- setDataProperty(new IntEntityData(DATA_HEALTH, (int) this.health), this.isPlayer || this instanceof EntityRideable);
- }
-
- public void setLastDamageCause(EntityDamageEvent type) {
- this.lastDamageCause = type;
- }
-
- public EntityDamageEvent getLastDamageCause() {
- return lastDamageCause;
- }
-
- public int getMaxHealth() {
- return maxHealth + (this.hasEffect(Effect.HEALTH_BOOST) ? (this.getEffect(Effect.HEALTH_BOOST).getAmplifier() + 1) << 2 : 0);
- }
-
- public void setMaxHealth(int maxHealth) {
- this.maxHealth = maxHealth;
- }
-
- public boolean canCollideWith(Entity entity) {
- return !this.justCreated && this != entity;
- }
-
- protected boolean checkObstruction(double x, double y, double z) {
- if (this.level.getCollisionCubes(this, this.boundingBox, false).length == 0) {
- return false;
- }
-
- int i = NukkitMath.floorDouble(x);
- int j = NukkitMath.floorDouble(y);
- int k = NukkitMath.floorDouble(z);
-
- double diffX = x - i;
- double diffY = y - j;
- double diffZ = z - k;
-
- if (!Block.transparent[this.level.getBlockIdAt(i, j, k)]) {
- boolean flag = Block.transparent[this.level.getBlockIdAt(i - 1, j, k)];
- boolean flag1 = Block.transparent[this.level.getBlockIdAt(i + 1, j, k)];
- boolean flag2 = Block.transparent[this.level.getBlockIdAt(i, j - 1, k)];
- boolean flag3 = Block.transparent[this.level.getBlockIdAt(i, j + 1, k)];
- boolean flag4 = Block.transparent[this.level.getBlockIdAt(i, j, k - 1)];
- boolean flag5 = Block.transparent[this.level.getBlockIdAt(i, j, k + 1)];
-
- int direction = -1;
- double limit = 9999;
-
- if (flag) {
- limit = diffX;
- direction = 0;
- }
-
- if (flag1 && 1 - diffX < limit) {
- limit = 1 - diffX;
- direction = 1;
- }
-
- if (flag2 && diffY < limit) {
- limit = diffY;
- direction = 2;
- }
-
- if (flag3 && 1 - diffY < limit) {
- limit = 1 - diffY;
- direction = 3;
- }
-
- if (flag4 && diffZ < limit) {
- limit = diffZ;
- direction = 4;
- }
-
- if (flag5 && 1 - diffZ < limit) {
- direction = 5;
- }
-
- double force = Utils.random.nextDouble() * 0.2 + 0.1;
-
- if (direction == 0) {
- this.motionX = -force;
-
- return true;
- }
-
- if (direction == 1) {
- this.motionX = force;
-
- return true;
- }
-
- if (direction == 2) {
- this.motionY = -force;
-
- return true;
- }
-
- if (direction == 3) {
- this.motionY = force;
-
- return true;
- }
-
- if (direction == 4) {
- this.motionZ = -force;
-
- return true;
- }
-
- if (direction == 5) {
- this.motionZ = force;
-
- return true;
- }
- }
-
- return false;
- }
-
- public boolean entityBaseTick() {
- return this.entityBaseTick(1);
- }
-
- public boolean entityBaseTick(int tickDiff) {
- if (Timings.entityBaseTickTimer != null) Timings.entityBaseTickTimer.startTiming();
-
- if (!this.isPlayer) {
- //this.blocksAround = null; // Use only when entity moves for better performance
- this.collisionBlocks = null;
- }
-
- this.justCreated = false;
-
- if (!this.isAlive()) {
- //this.removeAllEffects(); // Why to remove them if the entity is dead anyways?
- this.despawnFromAll();
- if (!this.isPlayer) {
- this.close();
- }
- if (Timings.entityBaseTickTimer != null) Timings.entityBaseTickTimer.stopTiming();
- return false;
- }
- /*if (riding != null && !riding.isAlive() && riding instanceof EntityRideable) {
- ((EntityRideable) riding).mountEntity(this);
- }*/
-
- updatePassengers();
-
- if (!this.effects.isEmpty()) {
- for (Effect effect : this.effects.values()) {
- if (effect.canTick()) {
- effect.applyEffect(this);
- }
- effect.setDuration(effect.getDuration() - tickDiff);
-
- if (effect.getDuration() <= 0) {
- this.removeEffect(effect.getId());
- }
- }
- }
-
- boolean hasUpdate = false;
-
- this.checkBlockCollision();
-
- if (this.y <= -16 && this.isAlive()) {
- if (this.isPlayer) {
- if (((Player) this).getGamemode() != Player.CREATIVE) this.attack(new EntityDamageEvent(this, DamageCause.VOID, 10));
- } else {
- this.attack(new EntityDamageEvent(this, DamageCause.VOID, 10));
- hasUpdate = true;
- }
- }
-
- if (this.fireTicks > 0) {
- if (this.fireProof) {
- this.fireTicks -= tickDiff << 2;
- if (this.fireTicks < 0) {
- this.fireTicks = 0;
- }
- } else {
- if (!this.hasEffect(Effect.FIRE_RESISTANCE) && ((this.fireTicks % 20) == 0 || tickDiff > 20)) {
- this.attack(new EntityDamageEvent(this, DamageCause.FIRE_TICK, 1));
- }
- this.fireTicks -= tickDiff;
- }
- if (this.fireTicks <= 0) {
- this.extinguish();
- } else if (!this.fireProof && (!this.isPlayer || !((Player) this).isSpectator())) {
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_ONFIRE, true);
- hasUpdate = true;
- }
- }
-
- if (this.noDamageTicks > 0) {
- this.noDamageTicks -= tickDiff;
- if (this.noDamageTicks < 0) {
- this.noDamageTicks = 0;
- }
- }
-
- if (this.inPortalTicks == 80 && Server.getInstance().isNetherAllowed() && this instanceof BaseEntity) {
- EntityPortalEnterEvent ev = new EntityPortalEnterEvent(this, EntityPortalEnterEvent.PortalType.NETHER);
- this.server.getPluginManager().callEvent(ev);
-
- if (!ev.isCancelled()) {
- if (this.getLevel().getDimension() == Level.DIMENSION_NETHER) {
- this.switchLevel(server.getDefaultLevel());
- } else {
- this.switchLevel(server.getNetherWorld(this.level.getName()));
- }
- }
- }
-
- this.age += tickDiff;
- this.ticksLived += tickDiff;
- TimingsHistory.activatedEntityTicks++;
-
- if (Timings.entityBaseTickTimer != null) Timings.entityBaseTickTimer.stopTiming();
- return hasUpdate;
- }
-
- public void updateMovement() {
- double diffPosition = (this.x - this.lastX) * (this.x - this.lastX) + (this.y - this.lastY) * (this.y - this.lastY) + (this.z - this.lastZ) * (this.z - this.lastZ);
- double diffRotation = (this.yaw - this.lastYaw) * (this.yaw - this.lastYaw) + (this.pitch - this.lastPitch) * (this.pitch - this.lastPitch);
-
- double diffMotion = (this.motionX - this.lastMotionX) * (this.motionX - this.lastMotionX) + (this.motionY - this.lastMotionY) * (this.motionY - this.lastMotionY) + (this.motionZ - this.lastMotionZ) * (this.motionZ - this.lastMotionZ);
-
- if (diffPosition > 0.0001 || diffRotation > 1.0) { //0.2 ** 2, 1.5 ** 2
- this.lastX = this.x;
- this.lastY = this.y;
- this.lastZ = this.z;
-
- this.lastYaw = this.yaw;
- this.lastPitch = this.pitch;
- this.lastHeadYaw = this.headYaw;
-
- this.addMovement(this.x, this.y + this.getBaseOffset(), this.z, this.yaw, this.pitch, this.yaw);
- }
-
- if (diffMotion > 0.0025 || (diffMotion > 0.0001 && this.getMotion().lengthSquared() <= 0.0001)) { //0.05 ** 2
- this.lastMotionX = this.motionX;
- this.lastMotionY = this.motionY;
- this.lastMotionZ = this.motionZ;
-
- this.addMotion(this.motionX, this.motionY, this.motionZ);
- }
- }
-
- public void addMovement(double x, double y, double z, double yaw, double pitch, double headYaw) {
- this.level.addEntityMovement(this, x, y, z, yaw, pitch, headYaw);
- }
-
- public void addMotion(double motionX, double motionY, double motionZ) {
- SetEntityMotionPacket pk = new SetEntityMotionPacket();
- pk.eid = this.id;
- pk.motionX = (float) motionX;
- pk.motionY = (float) motionY;
- pk.motionZ = (float) motionZ;
- for (Player p : this.hasSpawned.values()) {
- p.batchDataPacket(pk); // Server.broadcastPacket would only use batching for >= 1.16.100
- }
- }
-
- public Vector3 getDirectionVector() {
- Vector3 vector = super.getDirectionVector();
- return this.temporalVector.setComponents(vector.x, vector.y, vector.z);
- }
-
- public Vector2 getDirectionPlane() {
- return (new Vector2((float) (-Math.cos(FastMath.toRadians(this.yaw) - 1.5707963267948966)), (float) (-Math.sin(FastMath.toRadians(this.yaw) - 1.5707963267948966)))).normalize();
- }
-
- public BlockFace getHorizontalFacing() {
- return BlockFace.fromHorizontalIndex(NukkitMath.floorDouble((this.yaw * 4.0F / 360.0F) + 0.5D) & 3);
- }
-
- public boolean onUpdate(int currentTick) {
- if (this.closed) {
- return false;
- }
-
- if (!this.isAlive()) {
- ++this.deadTicks;
- if (this.deadTicks >= 10) {
- this.despawnFromAll();
- if (!this.isPlayer) {
- this.close();
- }
- }
- return this.deadTicks < 10;
- }
-
- int tickDiff = currentTick - this.lastUpdate;
-
- if (tickDiff <= 0) {
- return false;
- }
-
- this.lastUpdate = currentTick;
-
- boolean hasUpdate = this.entityBaseTick(tickDiff);
-
- this.updateMovement();
-
- /*if (server.vanillaBB && this instanceof EntityBoss && currentTick % 100 == 0) { //TODO: Figure out why doesn't the boss bar length change
- for (Player p : this.hasSpawned.values()) {
- BossEventPacket pkBoss = new BossEventPacket();
- pkBoss.bossEid = this.id;
- pkBoss.type = BossEventPacket.TYPE_HEALTH_PERCENT;
- pkBoss.title = this.getName();
- pkBoss.healthPercent = p.protocol >= 361 ? this.health / 100 : this.health;
- p.dataPacket(pkBoss);
- }
- }*/
-
- return hasUpdate;
- }
-
- public boolean mountEntity(Entity entity) {
- return mountEntity(entity, TYPE_RIDE);
- }
-
- /**
- * Mount or Dismounts an Entity from a/into vehicle
- *
- * @param entity The target Entity
- * @return {@code true} if the mounting successful
- */
- public boolean mountEntity(Entity entity, byte mode) {
- Objects.requireNonNull(entity, "The target of the mounting entity can't be null");
-
- if (entity.riding != null) {
- dismountEntity(entity);
- } else {
- if (isPassenger(entity)) {
- return false;
- }
- // Entity entering a vehicle
- EntityVehicleEnterEvent ev = new EntityVehicleEnterEvent(entity, (EntityVehicle) this);
- server.getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return false;
- }
- broadcastLinkPacket(entity, mode);
-
- // Add variables to entity
- entity.riding = this;
- entity.setDataFlag(DATA_FLAGS, DATA_FLAG_RIDING, true);
- passengers.add(entity);
-
- entity.setSeatPosition(getMountedOffset(entity));
- updatePassengerPosition(entity);
- }
- return true;
- }
-
- public boolean dismountEntity(Entity entity) {
- if (this instanceof EntityVehicle) {
- // Run the events
- EntityVehicleExitEvent ev = new EntityVehicleExitEvent(entity, (EntityVehicle) this);
- server.getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return false;
- }
- }
-
- broadcastLinkPacket(entity, TYPE_REMOVE);
-
- // Refurbish the entity
- entity.riding = null;
- entity.setDataFlag(DATA_FLAGS, DATA_FLAG_RIDING, false);
- passengers.remove(entity);
-
- entity.setSeatPosition(new Vector3f());
- updatePassengerPosition(entity);
-
- // Avoid issues with anti fly
- entity.resetFallDistance();
- return true;
- }
-
- protected void broadcastLinkPacket(Entity rider, byte type) {
- SetEntityLinkPacket pk = new SetEntityLinkPacket();
- pk.vehicleUniqueId = id; // To the?
- pk.riderUniqueId = rider.id; // From who?
- pk.type = type;
-
- Server.broadcastPacket(this.hasSpawned.values(), pk);
- }
-
- public void updatePassengers() {
- if (this.passengers.isEmpty()) {
- return;
- }
-
- for (Entity passenger : new ArrayList<>(this.passengers)) {
- if (!passenger.isAlive()) {
- dismountEntity(passenger);
- continue;
- }
-
- updatePassengerPosition(passenger);
- }
- }
-
- protected void updatePassengerPosition(Entity passenger) {
- passenger.setPosition(this.add(passenger.getSeatPosition().asVector3()));
- }
-
- public void setSeatPosition(Vector3f pos) {
- this.setDataProperty(new Vector3fEntityData(DATA_RIDER_SEAT_POSITION, pos));
- }
-
- public Vector3f getSeatPosition() {
- return this.getDataPropertyVector3f(DATA_RIDER_SEAT_POSITION);
- }
-
- public Vector3f getMountedOffset(Entity entity) {
- return new Vector3f(0, getHeight() * 0.75f);
- }
-
- public final void scheduleUpdate() {
- this.level.updateEntities.put(this.id, this);
- }
-
- public boolean isOnFire() {
- return this.fireTicks > 0;
- }
-
- public void setOnFire(int seconds) {
- int ticks = seconds * 20;
- if (ticks > this.fireTicks) {
- this.fireTicks = ticks;
- }
- }
-
- public float getAbsorption() {
- return absorption;
- }
-
- public void setAbsorption(float absorption) {
- if (absorption != this.absorption) {
- this.absorption = absorption;
- if (this.isPlayer) ((Player) this).setAttribute(Attribute.getAttribute(Attribute.ABSORPTION).setValue(absorption));
- }
- }
-
- public BlockFace getDirection() {
- double rotation = this.yaw % 360;
- if (rotation < 0) {
- rotation += 360.0;
- }
- if ((0 <= rotation && rotation < 45) || (315 <= rotation && rotation < 360)) {
- return BlockFace.SOUTH;
- } else if (45 <= rotation && rotation < 135) {
- return BlockFace.WEST;
- } else if (135 <= rotation && rotation < 225) {
- return BlockFace.NORTH;
- } else if (225 <= rotation && rotation < 315) {
- return BlockFace.EAST;
- } else {
- return null;
- }
- }
-
- public void extinguish() {
- this.fireTicks = 0;
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_ONFIRE, false);
- }
-
- public boolean canTriggerWalking() {
- return true;
- }
-
- public void resetFallDistance() {
- this.highestPosition = this.y;
- }
-
- protected void updateFallState(boolean onGround) {
- if (onGround) {
- fallDistance = (float) (this.highestPosition - this.y);
-
- if (fallDistance > 0) {
- // check if we fell into at least 1 block of water
- if (this instanceof EntityLiving && !(this.getLevelBlock() instanceof BlockWater) && !(this instanceof EntityFlying)) {
- this.fall(fallDistance);
- }
- this.resetFallDistance();
- }
- }
- }
-
- public AxisAlignedBB getBoundingBox() {
- return this.boundingBox;
- }
-
- public void fall(float fallDistance) {
- if (fallDistance > 0.75) {
- if (!this.hasEffect(Effect.SLOW_FALLING)) {
- float damage = (float) Math.floor(fallDistance - 3 - (this.hasEffect(Effect.JUMP) ? this.getEffect(Effect.JUMP).getAmplifier() + 1 : 0));
-
- Block down = this.level.getBlock(this.floor().down());
- if (down.getId() == BlockID.HAY_BALE) {
- damage -= (damage * 0.8f);
- }
-
- if (damage > 0) {
- if (!this.isPlayer || level.getGameRules().getBoolean(GameRule.FALL_DAMAGE)) {
- this.attack(new EntityDamageEvent(this, DamageCause.FALL, damage));
- }
- }
-
- if (down.getId() == BlockID.FARMLAND) {
- Event ev;
-
- if (this.isPlayer) {
- ev = new PlayerInteractEvent((Player) this, null, down, null, Action.PHYSICAL);
- } else {
- ev = new EntityInteractEvent(this, down);
- }
-
- this.server.getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return;
- }
- this.level.setBlock(down, Block.get(BlockID.DIRT), true, true);
- }
- }
- }
- }
-
- public void moveFlying(float strafe, float forward, float friction) {
- // This is special for Nukkit! :)
- float speed = strafe * strafe + forward * forward;
- if (speed >= 1.0E-4F) {
- speed = MathHelper.sqrt(speed);
- if (speed < 1.0F) {
- speed = 1.0F;
- }
- speed = friction / speed;
- strafe *= speed;
- forward *= speed;
- float nest = MathHelper.sin((float) (this.yaw * 3.1415927F / 180.0F));
- float place = MathHelper.cos((float) (this.yaw * 3.1415927F / 180.0F));
- this.motionX += strafe * place - forward * nest;
- this.motionZ += forward * place + strafe * nest;
- }
- }
-
- public void applyEntityCollision(Entity entity) {
- if (entity.riding != this && !entity.passengers.contains(this)) {
- double dx = entity.x - this.x;
- double dy = entity.z - this.z;
- double dz = NukkitMath.getDirection(dx, dy);
-
- if (dz >= 0.009999999776482582D) {
- dz = MathHelper.sqrt((float) dz);
- dx /= dz;
- dy /= dz;
- double d3 = 1.0D / dz;
-
- if (d3 > 1.0D) {
- d3 = 1.0D;
- }
-
- dx *= d3;
- dy *= d3;
- dx *= 0.05000000074505806;
- dy *= 0.05000000074505806;
- dx *= 1F + entityCollisionReduction;
- if (this.riding == null) {
- motionX -= dx;
- motionZ -= dy;
- }
- }
- }
- }
-
- public void onStruckByLightning(Entity entity) {
- if (this.attack(new EntityDamageByEntityEvent(entity, this, DamageCause.LIGHTNING, 5))) {
- if (this.fireTicks < 160) {
- this.setOnFire(8);
- }
-
- if (this instanceof EntityCreeper) {
- ((EntityCreeper) this).setPowered(true);
- }
- }
- }
-
- public boolean onInteract(Player player, Item item, Vector3 clickedPos) {
- return onInteract(player, item);
- }
-
- public boolean onInteract(Player player, Item item) {
- return false;
- }
-
- protected boolean switchLevel(Level targetLevel) {
- if (this.closed) {
- return false;
- }
-
- if (this.isValid()) {
- EntityLevelChangeEvent ev = new EntityLevelChangeEvent(this, this.level, targetLevel);
- this.server.getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return false;
- }
-
- this.level.removeEntity(this);
- if (this.chunk != null) {
- this.chunk.removeEntity(this);
- }
- this.despawnFromAll();
-
- if (this.isPlayer) {
- this.preSwitchLevel();
- }
- }
-
- this.setLevel(targetLevel);
- this.level.addEntity(this);
- this.chunk = null;
-
- if (this.isPlayer) {
- this.afterSwitchLevel();
- }
- return true;
- }
-
- protected void preSwitchLevel() {
- // Override in Player
- }
-
- protected void afterSwitchLevel() {
- // Override in Player
- }
-
- public Position getPosition() {
- return new Position(this.x, this.y, this.z, this.level);
- }
-
- public Location getLocation() {
- return new Location(this.x, this.y, this.z, this.yaw, this.pitch, this.headYaw, this.level);
- }
-
- public boolean isSubmerged() {
- double y = this.y + this.getBreathableHeight();
- Block block = this.level.getBlock(this.temporalVector.setComponents(NukkitMath.floorDouble(this.x), NukkitMath.floorDouble(y), NukkitMath.floorDouble(this.z)));
-
- if (block instanceof BlockWater) {
- return y < (block.y + 0.9);
- }
-
- return false;
- }
-
- public boolean isInsideOfWater() {
- /*Block block = this.level.getBlock(this.temporalVector.setComponents(NukkitMath.floorDouble(this.x), NukkitMath.floorDouble(this.y), NukkitMath.floorDouble(this.z)));
-
- if (block instanceof BlockWater) {
- return this.y < (block.y + 0.9);
- }
-
- return false;*/
- int bid = level.getBlockIdAt(chunk, this.getFloorX(), this.getFloorY(), this.getFloorZ());
- return bid == BlockID.WATER || bid == BlockID.STILL_WATER;
- }
-
- public boolean isInsideOfSolid() {
- double y = this.y + this.getBreathableHeight();
- Block block = this.level.getBlock(
- this.temporalVector.setComponents(
- NukkitMath.floorDouble(this.x),
- NukkitMath.floorDouble(y),
- NukkitMath.floorDouble(this.z))
- );
-
- AxisAlignedBB bb = block.getBoundingBox();
-
- return bb != null && block.isSolid() && !block.isTransparent() && bb.intersectsWith(this.boundingBox) && !(block instanceof BlockSlab); // The instanceof BlockSlab check is a hack to fix issues with the solid slab hack
- }
-
- public boolean isInsideOfFire() {
- for (Block block : this.getCollisionBlocks()) {
- if (block instanceof BlockFire) {
- return true;
- }
- }
-
- return false;
- }
-
- public boolean fastMove(double dx, double dy, double dz) {
- if (!this.isPlayer) {
- this.blocksAround = null;
- }
-
- if (dx == 0 && dy == 0 && dz == 0) {
- return true;
- }
-
- if (Timings.entityMoveTimer != null) Timings.entityMoveTimer.startTiming();
-
- AxisAlignedBB newBB = this.boundingBox.getOffsetBoundingBox(dx, dy, dz);
-
- if (server.getAllowFlight() || !this.level.hasCollision(this, newBB, false)) {
- this.boundingBox = newBB;
- }
-
- this.x = (this.boundingBox.minX + this.boundingBox.maxX) / 2;
- this.y = this.boundingBox.minY - this.ySize;
- this.z = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2;
-
- this.checkChunks();
-
- if (!this.onGround || dy != 0) {
- AxisAlignedBB bb = this.boundingBox.growNoUp(0.1, 0.1, 0.1);
- bb.minY -= 0.75;
-
- this.onGround = this.level.hasCollisionBlocks(bb);
- }
- this.isCollided = this.onGround;
- this.updateFallState(this.onGround);
- if (Timings.entityMoveTimer != null) Timings.entityMoveTimer.stopTiming();
- return true;
- }
-
- public boolean move(double dx, double dy, double dz) {
- if (dx == 0 && dz == 0 && dy == 0) {
- return false;
- }
-
- if (!this.isPlayer) {
- this.blocksAround = null;
- }
-
- if (this.keepMovement) {
- this.boundingBox.offset(dx, dy, dz);
- this.setPosition(this.temporalVector.setComponents((this.boundingBox.minX + this.boundingBox.maxX) / 2, this.boundingBox.minY, (this.boundingBox.minZ + this.boundingBox.maxZ) / 2));
- this.onGround = this.isPlayer;
- return true;
- } else {
- if (Timings.entityMoveTimer != null) Timings.entityMoveTimer.startTiming();
-
- this.ySize *= STEP_CLIP_MULTIPLIER;
-
- double movX = dx;
- double movY = dy;
- double movZ = dz;
-
- AxisAlignedBB axisalignedbb = this.boundingBox.clone();
-
- AxisAlignedBB[] list = this.level.getCollisionCubes(this, this.boundingBox.addCoord(dx, dy, dz), false);
-
- for (AxisAlignedBB bb : list) {
- dy = bb.calculateYOffset(this.boundingBox, dy);
- }
-
- this.boundingBox.offset(0, dy, 0);
-
- boolean fallingFlag = (this.onGround || (dy != movY && movY < 0));
-
- for (AxisAlignedBB bb : list) {
- dx = bb.calculateXOffset(this.boundingBox, dx);
- }
-
- this.boundingBox.offset(dx, 0, 0);
-
- for (AxisAlignedBB bb : list) {
- dz = bb.calculateZOffset(this.boundingBox, dz);
- }
-
- this.boundingBox.offset(0, 0, dz);
-
- if (this.getStepHeight() > 0 && fallingFlag && (movX != dx || movZ != dz)) {
- double cx = dx;
- double cy = dy;
- double cz = dz;
- dx = movX;
- dy = this.getStepHeight();
- dz = movZ;
-
- AxisAlignedBB axisalignedbb1 = this.boundingBox.clone();
-
- this.boundingBox.setBB(axisalignedbb);
-
- list = this.level.getCollisionCubes(this, this.boundingBox.addCoord(dx, dy, dz), false);
-
- for (AxisAlignedBB bb : list) {
- dy = bb.calculateYOffset(this.boundingBox, dy);
- }
-
- this.boundingBox.offset(0, dy, 0);
-
- for (AxisAlignedBB bb : list) {
- dx = bb.calculateXOffset(this.boundingBox, dx);
- }
-
- this.boundingBox.offset(dx, 0, 0);
-
- for (AxisAlignedBB bb : list) {
- dz = bb.calculateZOffset(this.boundingBox, dz);
- }
-
- this.boundingBox.offset(0, 0, dz);
-
- double reverseDY = -dy;
- for (AxisAlignedBB bb : list) {
- reverseDY = bb.calculateYOffset(this.boundingBox, reverseDY);
- }
- dy += reverseDY;
- this.boundingBox.offset(0, reverseDY, 0);
-
- if ((cx * cx + cz * cz) >= (dx * dx + dz * dz)) {
- dx = cx;
- dy = cy;
- dz = cz;
- this.boundingBox.setBB(axisalignedbb1);
- } else {
- this.ySize += dy;
- }
- }
-
- this.x = (this.boundingBox.minX + this.boundingBox.maxX) / 2;
- this.y = this.boundingBox.minY - this.ySize;
- this.z = (this.boundingBox.minZ + this.boundingBox.maxZ) / 2;
-
- this.checkChunks();
-
- this.checkGroundState(movX, movY, movZ, dx, dy, dz);
- this.updateFallState(this.onGround);
-
- if (movX != dx) {
- this.motionX = 0;
- }
-
- if (movY != dy) {
- this.motionY = 0;
- }
-
- if (movZ != dz) {
- this.motionZ = 0;
- }
-
- if (Timings.entityMoveTimer != null) Timings.entityMoveTimer.stopTiming();
- return true;
- }
- }
-
- protected void checkGroundState(double movX, double movY, double movZ, double dx, double dy, double dz) {
- this.isCollidedVertically = movY != dy;
- this.isCollidedHorizontally = (movX != dx || movZ != dz);
- this.isCollided = (this.isCollidedHorizontally || this.isCollidedVertically);
- this.onGround = (movY != dy && movY < 0);
- }
-
- public List getBlocksAround() {
- if (this.blocksAround == null) {
- int minX = NukkitMath.floorDouble(this.boundingBox.minX);
- int minY = NukkitMath.floorDouble(this.boundingBox.minY);
- int minZ = NukkitMath.floorDouble(this.boundingBox.minZ);
- int maxX = NukkitMath.ceilDouble(this.boundingBox.maxX);
- int maxY = NukkitMath.ceilDouble(this.boundingBox.maxY);
- int maxZ = NukkitMath.ceilDouble(this.boundingBox.maxZ);
-
- this.blocksAround = new ArrayList<>();
-
- for (int z = minZ; z <= maxZ; ++z) {
- for (int x = minX; x <= maxX; ++x) {
- for (int y = minY; y <= maxY; ++y) {
- Block block = this.level.getBlock(x, y, z, false);
- this.blocksAround.add(block);
- }
- }
- }
- }
-
- return this.blocksAround;
- }
-
- public List getCollisionBlocks() {
- if (this.collisionBlocks == null) {
- this.collisionBlocks = new ArrayList<>();
-
- List bl = this.getBlocksAround();
- for (Block b : bl) {
- if (b.collidesWithBB(this.boundingBox, true)) {
- this.collisionBlocks.add(b);
- }
- }
- }
-
- return this.collisionBlocks;
- }
-
- /**
- * Returns whether this entity can be moved by currents in liquids.
- *
- * @return boolean
- */
- public boolean canBeMovedByCurrents() {
- return true;
- }
-
- protected void checkBlockCollision() {
- Vector3 vector = new Vector3(0, 0, 0);
- boolean portal = false;
-
- for (Block block : this.getCollisionBlocks()) {
- if (block.getId() == Block.NETHER_PORTAL) {
- portal = true;
- continue;
- }
-
- block.onEntityCollide(this);
- block.addVelocityToEntity(this, vector);
- }
-
- if (portal) {
- inPortalTicks++;
- } else {
- this.inPortalTicks = 0;
- }
-
- if (vector.lengthSquared() > 0) {
- vector = vector.normalize();
- double d = 0.014d;
- this.motionX += vector.x * d;
- this.motionY += vector.y * d;
- this.motionZ += vector.z * d;
- }
- }
-
- public boolean setPositionAndRotation(Vector3 pos, double yaw, double pitch) {
- return this.setPositionAndRotation(pos, yaw, pitch, yaw);
- }
-
- public boolean setPositionAndRotation(Vector3 pos, double yaw, double pitch, double headYaw) {
- if (this.setPosition(pos)) {
- this.setRotation(yaw, pitch, headYaw);
- return true;
- }
-
- return false;
- }
-
- public void setRotation(double yaw, double pitch) {
- this.setRotation(yaw, pitch, yaw);
- }
-
- public void setRotation(double yaw, double pitch, double headYaw) {
- this.yaw = yaw;
- this.pitch = pitch;
- this.headYaw = headYaw;
- this.scheduleUpdate();
- }
-
- /**
- * Whether the entity can active pressure plates.
- * Used for {@link cn.nukkit.entity.passive.EntityBat}s only.
- *
- * @return triggers pressure plate
- */
- public boolean doesTriggerPressurePlate() {
- return true;
- }
-
- public boolean canPassThrough() {
- return true;
- }
-
- protected void checkChunks() {
- int cx = (int) this.x >> 4;
- int cz = (int) this.z >> 4;
- if (this.chunk == null || (this.chunk.getX() != cx) || this.chunk.getZ() != cz) {
- if (this.chunk != null) {
- this.chunk.removeEntity(this);
- }
- this.chunk = this.level.getChunk(cx, cz, true);
-
- if (!this.justCreated) {
- Map newChunk = this.level.getChunkPlayers(cx, cz);
- for (Player player : new ArrayList<>(this.hasSpawned.values())) {
- if (!newChunk.containsKey(player.getLoaderId())) {
- this.despawnFrom(player);
- } else {
- newChunk.remove(player.getLoaderId());
- }
- }
-
- for (Player player : newChunk.values()) {
- this.spawnTo(player);
- }
- }
-
- if (this.chunk == null) {
- return;
- }
-
- this.chunk.addEntity(this);
- }
- }
-
- public boolean setPosition(Vector3 pos) {
- if (this.closed) {
- return false;
- }
-
- if (pos instanceof Position) {
- Level oldLevel = this.level;
- Level newLevel = ((Position) pos).level;
-
- if (newLevel != null && newLevel != oldLevel) {
- if (!this.switchLevel(newLevel)) {
- return false;
- }
-
- this.x = pos.x;
- this.y = pos.y;
- this.z = pos.z;
-
- // Dimension change
- if (this.isPlayer && this.server.dimensionsEnabled && newLevel.getDimension() != oldLevel.getDimension()) {
- ((Player) this).setDimension(newLevel.getDimension());
- }
- } else {
- this.x = pos.x;
- this.y = pos.y;
- this.z = pos.z;
- }
- } else {
- this.x = pos.x;
- this.y = pos.y;
- this.z = pos.z;
- }
-
- this.recalculateBoundingBox();
-
- if (!this.isPlayer) {
- this.blocksAround = null;
- }
-
- this.checkChunks();
-
- return true;
- }
-
- public Vector3 getMotion() {
- return new Vector3(this.motionX, this.motionY, this.motionZ);
- }
-
- public boolean setMotion(Vector3 motion) {
- if (server.callEntityMotionEv && !this.justCreated) {
- EntityMotionEvent ev = new EntityMotionEvent(this, motion);
- this.server.getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return false;
- }
- }
-
- this.motionX = motion.x;
- this.motionY = motion.y;
- this.motionZ = motion.z;
-
- if (!this.justCreated) {
- this.updateMovement();
- }
-
- return true;
- }
-
- public boolean isOnGround() {
- return onGround;
- }
-
- public void kill() {
- this.health = 0;
- this.scheduleUpdate();
-
- for (Entity passenger : new ArrayList<>(this.passengers)) {
- dismountEntity(passenger);
- }
- }
-
- public boolean teleport(Vector3 pos) {
- return this.teleport(pos, PlayerTeleportEvent.TeleportCause.PLUGIN);
- }
-
- public boolean teleport(Vector3 pos, PlayerTeleportEvent.TeleportCause cause) {
- return this.teleport(Location.fromObject(pos, this.level, this.yaw, this.pitch, this.headYaw), cause);
- }
-
- public boolean teleport(Position pos) {
- return this.teleport(pos, PlayerTeleportEvent.TeleportCause.PLUGIN);
- }
-
- public boolean teleport(Position pos, PlayerTeleportEvent.TeleportCause cause) {
- return this.teleport(Location.fromObject(pos, pos.level, this.yaw, this.pitch, this.headYaw), cause);
- }
-
- public boolean teleport(Location location) {
- return this.teleport(location, PlayerTeleportEvent.TeleportCause.PLUGIN);
- }
-
- public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
- double yaw = location.yaw;
- double pitch = location.pitch;
-
- Location from = this.getLocation();
- Location to = location;
- if (cause != null) {
- EntityTeleportEvent ev = new EntityTeleportEvent(this, from, to);
- this.server.getPluginManager().callEvent(ev);
- if (ev.isCancelled()) {
- return false;
- }
- to = ev.getTo();
- }
-
- if (riding != null) {
- riding.dismountEntity(this);
- }
-
- this.ySize = 0;
-
- if (cause != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
- this.setMotion(this.temporalVector.setComponents(0, 0, 0));
- }
-
- if (this.setPositionAndRotation(to, yaw, pitch)) {
- this.resetFallDistance();
- this.onGround = true;
-
- this.updateMovement();
-
- return true;
- }
-
- return false;
- }
-
- public long getId() {
- return this.id;
- }
-
- public void respawnToAll() {
- Collection players = new ArrayList<>(this.hasSpawned.values());
- this.hasSpawned.clear();
-
- for (Player player : players) {
- this.spawnTo(player);
- }
- }
-
- public void spawnToAll() {
- if (this.chunk == null || this.closed) {
- return;
- }
-
- for (Player player : this.level.getChunkPlayers(this.chunk.getX(), this.chunk.getZ()).values()) {
- if (player.isOnline()) {
- this.spawnTo(player);
- }
- }
- }
-
- public void despawnFromAll() {
- for (Player player : new ArrayList<>(this.hasSpawned.values())) {
- this.despawnFrom(player);
- }
- }
-
- public void close() {
- if (!this.closed) {
- this.closed = true;
- this.server.getPluginManager().callEvent(new EntityDespawnEvent(this));
- this.despawnFromAll();
- if (this.chunk != null) {
- this.chunk.removeEntity(this);
- }
-
- if (this.level != null) {
- this.level.removeEntity(this);
- }
- }
- }
-
- public boolean setDataProperty(EntityData data) {
- return this.setDataProperty(data, true);
- }
-
- public boolean setDataProperty(EntityData data, boolean send) {
- if (Objects.equals(data, this.dataProperties.get(data.getId()))) {
- return false;
- }
-
- this.dataProperties.put(data);
- if (send) {
- EntityMetadata metadata = new EntityMetadata();
- metadata.put(this.dataProperties.get(data.getId()));
- if (data.getId() == DATA_FLAGS2) {
- metadata.put(this.dataProperties.get(DATA_FLAGS));
- }
- this.sendData(this.hasSpawned.values().toArray(new Player[0]), metadata);
- }
- return true;
- }
-
- public boolean setDataPropertyAndSendOnlyToSelf(EntityData data) {
- if (!Objects.equals(data, this.dataProperties.get(data.getId()))) {
- this.dataProperties.put(data);
- if (this.isPlayer) {
- EntityMetadata d = new EntityMetadata().put(this.dataProperties.get(data.getId()));
- SetEntityDataPacket pk = new SetEntityDataPacket();
- pk.eid = this.id;
- pk.metadata = d == null ? this.dataProperties.clone() : d;
- //((Player) this).dataPacket(pk);
- ((Player) this).batchDataPacket(pk);
- }
- return true;
- }
- return false;
- }
-
- public EntityMetadata getDataProperties() {
- return this.dataProperties;
- }
-
- public EntityData getDataProperty(int id) {
- return this.dataProperties.get(id);
- }
-
- public int getDataPropertyInt(int id) {
- return this.dataProperties.getInt(id);
- }
-
- public int getDataPropertyShort(int id) {
- return this.dataProperties.getShort(id);
- }
-
- public int getDataPropertyByte(int id) {
- return this.dataProperties.getByte(id);
- }
-
- public boolean getDataPropertyBoolean(int id) {
- return this.dataProperties.getBoolean(id);
- }
-
- public long getDataPropertyLong(int id) {
- return this.dataProperties.getLong(id);
- }
-
- public String getDataPropertyString(int id) {
- return this.dataProperties.getString(id);
- }
-
- public float getDataPropertyFloat(int id) {
- return this.dataProperties.getFloat(id);
- }
-
- public CompoundTag getDataPropertyNBT(int id) {
- return this.dataProperties.getNBT(id);
- }
-
- public Vector3 getDataPropertyPos(int id) {
- return this.dataProperties.getPosition(id);
- }
-
- public Vector3f getDataPropertyVector3f(int id) {
- return this.dataProperties.getFloatPosition(id);
- }
-
- public int getDataPropertyType(int id) {
- return this.dataProperties.exists(id) ? this.getDataProperty(id).getType() : -1;
- }
-
- public void setDataFlag(int propertyId, int id) {
- this.setDataFlag(propertyId, id, true);
- }
-
- public void setDataFlag(int propertyId, int id, boolean value) {
- this.setDataFlag(propertyId, id, value, true);
- }
-
- public void setDataFlag(int propertyId, int id, boolean value, boolean send) {
- if (this.getDataFlag(propertyId, id) != value) {
- if (propertyId == EntityHuman.DATA_PLAYER_FLAGS) {
- byte flags = (byte) this.getDataPropertyByte(propertyId);
- flags ^= 1 << id;
- this.setDataProperty(new ByteEntityData(propertyId, flags), send);
- } else {
- long flags = this.getDataPropertyLong(propertyId);
- flags ^= 1L << id;
- this.setDataProperty(new LongEntityData(propertyId, flags), send);
- }
- }
- }
-
- public void setDataFlagSelfOnly(int propertyId, int id, boolean value) {
- if (this.getDataFlag(propertyId, id) != value) {
- if (propertyId == EntityHuman.DATA_PLAYER_FLAGS) {
- byte flags = (byte) this.getDataPropertyByte(propertyId);
- flags ^= 1 << id;
- this.setDataPropertyAndSendOnlyToSelf(new ByteEntityData(propertyId, flags));
- } else {
- long flags = this.getDataPropertyLong(propertyId);
- flags ^= 1L << id;
- this.setDataPropertyAndSendOnlyToSelf(new LongEntityData(propertyId, flags));
- }
- }
- }
-
- public boolean getDataFlag(int propertyId, int id) {
- return (((propertyId == EntityHuman.DATA_PLAYER_FLAGS ? this.getDataPropertyByte(propertyId) & 0xff : this.getDataPropertyLong(propertyId))) & (1L << id)) > 0;
- }
-
- public void setGenericFlag(int propertyId, boolean value) {
- this.setDataFlag(propertyId >= 64 ? DATA_FLAGS2 : DATA_FLAGS, propertyId % 64, value);
- }
-
- public boolean getGenericFlag(int propertyId) {
- return this.getDataFlag(propertyId >= 64 ? DATA_FLAGS2 : DATA_FLAGS, propertyId % 64);
- }
-
- @Override
- public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
- this.server.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);
- }
-
- @Override
- public List getMetadata(String metadataKey) {
- return this.server.getEntityMetadata().getMetadata(this, metadataKey);
- }
-
- @Override
- public boolean hasMetadata(String metadataKey) {
- return this.server.getEntityMetadata().hasMetadata(this, metadataKey);
- }
-
- @Override
- public void removeMetadata(String metadataKey, Plugin owningPlugin) {
- this.server.getEntityMetadata().removeMetadata(this, metadataKey, owningPlugin);
- }
-
- public Server getServer() {
- return server;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Entity other = (Entity) obj;
- return this.id == other.id;
- }
-
- @Override
- public int hashCode() {
- return (int) (203 + this.id);
- }
-
- public static Entity create(Object type, Position source, Object... args) {
- FullChunk chunk = source.getLevel().getChunk((int) source.x >> 4, (int) source.z >> 4, true);
- if (!chunk.isGenerated()) {
- chunk.setGenerated();
- }
- if (!chunk.isPopulated()) {
- chunk.setPopulated();
- }
-
- CompoundTag nbt = new CompoundTag().putList(new ListTag("Pos").add(new DoubleTag("", source.x)).add(new DoubleTag("", source.y)).add(new DoubleTag("", source.z)))
- .putList(new ListTag("Motion").add(new DoubleTag("", 0)).add(new DoubleTag("", 0)).add(new DoubleTag("", 0)))
- .putList(new ListTag("Rotation").add(new FloatTag("", source instanceof Location ? (float) ((Location) source).yaw : 0))
- .add(new FloatTag("", source instanceof Location ? (float) ((Location) source).pitch : 0)));
-
- return Entity.createEntity(type.toString(), chunk, nbt, args);
- }
-
- public boolean isOnLadder() {
- int b = this.level.getBlockIdAt(chunk, this.getFloorX(), this.getFloorY(), this.getFloorZ());
- return b == Block.LADDER || b == Block.VINES || b == Block.COBWEB;
- }
-
- public float getMountedYOffset() {
- return getHeight() * 0.75F;
- }
-
- /**
- * Check whether there is blocks above the entity
- *
- * @return no blocks above
- */
- public boolean canSeeSky() {
- int px = this.getFloorX();
- int py = this.getFloorY();
- int pz = this.getFloorZ();
- for (int i = 255; i >= py; i--) {
- if (level.getBlockIdAt(chunk, px, i, pz) != 0) {
- return false;
- }
- }
- return true;
- }
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityAgeable.java b/src/main/java/cn/nukkit/entity/EntityAgeable.java
deleted file mode 100644
index c9191eed9..000000000
--- a/src/main/java/cn/nukkit/entity/EntityAgeable.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package cn.nukkit.entity;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public interface EntityAgeable {
-
- boolean isBaby();
-
- void setBaby(boolean baby);
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityArthropod.java b/src/main/java/cn/nukkit/entity/EntityArthropod.java
deleted file mode 100644
index 35ea6532d..000000000
--- a/src/main/java/cn/nukkit/entity/EntityArthropod.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package cn.nukkit.entity;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public interface EntityArthropod {
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityBoss.java b/src/main/java/cn/nukkit/entity/EntityBoss.java
deleted file mode 100644
index 9c2127c08..000000000
--- a/src/main/java/cn/nukkit/entity/EntityBoss.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package cn.nukkit.entity;
-
-public interface EntityBoss {
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityControllable.java b/src/main/java/cn/nukkit/entity/EntityControllable.java
deleted file mode 100644
index e98aa464c..000000000
--- a/src/main/java/cn/nukkit/entity/EntityControllable.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package cn.nukkit.entity;
-
-import cn.nukkit.Player;
-
-public interface EntityControllable {
-
- void onPlayerInput(Player player, double strafe, double forward);
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityCreature.java b/src/main/java/cn/nukkit/entity/EntityCreature.java
deleted file mode 100644
index 2324c772f..000000000
--- a/src/main/java/cn/nukkit/entity/EntityCreature.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.nukkit.entity;
-
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class EntityCreature extends EntityLiving {
-
- public EntityCreature(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityDamageable.java b/src/main/java/cn/nukkit/entity/EntityDamageable.java
deleted file mode 100644
index 9f6bd2520..000000000
--- a/src/main/java/cn/nukkit/entity/EntityDamageable.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package cn.nukkit.entity;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public interface EntityDamageable {
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityExplosive.java b/src/main/java/cn/nukkit/entity/EntityExplosive.java
deleted file mode 100644
index f69f05844..000000000
--- a/src/main/java/cn/nukkit/entity/EntityExplosive.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package cn.nukkit.entity;
-
-/**
- * @author Nukkit Project Team
- */
-public interface EntityExplosive {
-
- void explode();
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityFlying.java b/src/main/java/cn/nukkit/entity/EntityFlying.java
deleted file mode 100644
index d5cf6f5ed..000000000
--- a/src/main/java/cn/nukkit/entity/EntityFlying.java
+++ /dev/null
@@ -1,161 +0,0 @@
-package cn.nukkit.entity;
-
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.math.Vector2;
-import cn.nukkit.math.Vector3;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.utils.Utils;
-import org.apache.commons.math3.util.FastMath;
-
-public abstract class EntityFlying extends BaseEntity {
-
- public EntityFlying(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- protected void checkTarget() {
- if (this.isKnockback()) {
- return;
- }
-
- Vector3 target = this.target;
- if (!(target instanceof EntityCreature) || (!((EntityCreature) target).closed && !this.targetOption((EntityCreature) target, this.distanceSquared(target))) || !((Entity) target).canBeFollowed()) {
- double near = Integer.MAX_VALUE;
- for (Entity entity : this.getLevel().getEntities()) {
- if (entity == this || !(entity instanceof EntityCreature) || entity.closed || !this.canTarget(entity)) {
- continue;
- }
-
- EntityCreature creature = (EntityCreature) entity;
- if (creature instanceof BaseEntity && ((BaseEntity) creature).isFriendly() == this.isFriendly()) {
- continue;
- }
-
- double distance = this.distanceSquared(creature);
- if (distance > near || !this.targetOption(creature, distance)) {
- continue;
- }
- near = distance;
-
- this.moveTime = 0;
- this.target = creature;
- }
- }
-
- if (this.target instanceof EntityCreature && ((EntityCreature) this.target).isAlive()) {
- return;
- }
-
- int x, y, z;
- int maxY = Math.max(this.getLevel().getHighestBlockAt((int) this.x, (int) this.z) + 15, 120);
- if (this.stayTime > 0) {
- if (Utils.rand(1, 100) > 5) {
- return;
- }
-
- x = Utils.rand(10, 30);
- z = Utils.rand(10, 30);
- if (this.y > maxY) {
- y = Utils.rand(-12, -4);
- } else {
- y = Utils.rand(-10, 10);
- }
- this.target = this.add(Utils.rand() ? x : -x, y, Utils.rand() ? z : -z);
- } else if (Utils.rand(1, 100) == 1) {
- x = Utils.rand(10, 30);
- z = Utils.rand(10, 30);
- if (this.y > maxY) {
- y = Utils.rand(-12, -4);
- } else {
- y = Utils.rand(-10, 10);
- }
- this.stayTime = Utils.rand(100, 200);
- this.target = this.add(Utils.rand() ? x : -x, y, Utils.rand() ? z : -z);
- } else if (this.moveTime <= 0 || this.target == null) {
- x = Utils.rand(20, 100);
- z = Utils.rand(20, 100);
- if (this.y > maxY) {
- y = Utils.rand(-12, -4);
- } else {
- y = Utils.rand(-10, 10);
- }
- this.stayTime = 0;
- this.moveTime = Utils.rand(100, 200);
- this.target = this.add(Utils.rand() ? x : -x, y, Utils.rand() ? z : -z);
- }
- }
-
- @Override
- public Vector3 updateMove(int tickDiff) {
- if (this.isMovement() && !isImmobile()) {
- if (this.isKnockback()) {
- this.move(this.motionX, this.motionY, this.motionZ);
- this.updateMovement();
- return null;
- }
-
- if (this.followTarget != null && !this.followTarget.closed && this.followTarget.isAlive() && this.followTarget.canBeFollowed()) {
- double x = this.followTarget.x - this.x;
- double y = this.followTarget.y - this.y;
- double z = this.followTarget.z - this.z;
-
- double diff = Math.abs(x) + Math.abs(z);
- if (this.stayTime > 0 || this.distance(this.followTarget) <= (this.getWidth() / 2 + 0.05)) {
- this.motionX = 0;
- this.motionZ = 0;
- } else {
- this.motionX = this.getSpeed() * 0.15 * (x / diff);
- this.motionZ = this.getSpeed() * 0.15 * (z / diff);
- this.motionY = this.getSpeed() * 0.27 * (y / diff);
- }
- if (this.stayTime <= 0 || Utils.rand()) this.yaw = FastMath.toDegrees(-FastMath.atan2(x / diff, z / diff));
- }
-
- Vector3 before = this.target;
- this.checkTarget();
- if (this.target instanceof EntityCreature || before != this.target) {
- double x = this.target.x - this.x;
- double y = this.target.y - this.y;
- double z = this.target.z - this.z;
-
- double diff = Math.abs(x) + Math.abs(z);
- if (this.stayTime > 0 || this.distance(this.target) <= (this.getWidth() / 2 + 0.05) * nearbyDistanceMultiplier()) {
- this.motionX = 0;
- this.motionZ = 0;
- } else {
- this.motionX = this.getSpeed() * 0.15 * (x / diff);
- this.motionZ = this.getSpeed() * 0.15 * (z / diff);
- this.motionY = this.getSpeed() * 0.27 * (y / diff);
- }
- if (this.stayTime <= 0 || Utils.rand()) this.yaw = FastMath.toDegrees(-FastMath.atan2(x / diff, z / diff));
- }
-
- double dx = this.motionX;
- double dy = this.motionY;
- double dz = this.motionZ;
- Vector3 target = this.target;
- if (this.stayTime > 0) {
- this.stayTime -= tickDiff;
- this.move(0, dy, 0);
- } else {
- Vector2 be = new Vector2(this.x + dx, this.z + dz);
- this.move(dx, dy, dz);
- Vector2 af = new Vector2(this.x, this.z);
-
- if (be.x != af.x || be.y != af.y) {
- this.moveTime -= 90;
- }
- }
-
- if (this.isOnGround()) {
- this.motionY = Utils.rand(0.15, 0.20);
- } else {
- this.motionY = Utils.rand(-0.15, 0.15);
- }
-
- this.updateMovement();
- return target;
- }
- return null;
- }
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityHanging.java b/src/main/java/cn/nukkit/entity/EntityHanging.java
deleted file mode 100644
index 8239912ad..000000000
--- a/src/main/java/cn/nukkit/entity/EntityHanging.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package cn.nukkit.entity;
-
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.math.BlockFace;
-import cn.nukkit.nbt.tag.CompoundTag;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public abstract class EntityHanging extends Entity {
-
- protected int direction;
-
- public EntityHanging(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- protected void initEntity() {
- super.initEntity();
-
- this.setMaxHealth(1);
- this.setHealth(1);
-
- if (this.namedTag.contains("Direction")) {
- this.direction = this.namedTag.getByte("Direction");
- } else if (this.namedTag.contains("Dir")) {
- int d = this.namedTag.getByte("Dir");
- if (d == 2) {
- this.direction = 0;
- } else if (d == 0) {
- this.direction = 2;
- }
- }
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
-
- this.namedTag.putByte("Direction", this.getDirection().getHorizontalIndex());
- this.namedTag.putInt("TileX", (int) this.x);
- this.namedTag.putInt("TileY", (int) this.y);
- this.namedTag.putInt("TileZ", (int) this.z);
- }
-
- @Override
- public BlockFace getDirection() {
- return BlockFace.fromIndex(this.direction);
- }
-
- @Override
- public boolean onUpdate(int currentTick) {
- if (this.closed) {
- return false;
- }
-
- if (!this.isAlive()) {
-
- this.despawnFromAll();
- if (!this.isPlayer) {
- this.close();
- }
-
- return true;
- }
-
- if (this.lastYaw != this.yaw || this.lastX != this.x || this.lastY != this.y || this.lastZ != this.z) {
- this.despawnFromAll();
-
- this.direction = (int) (this.yaw / 90);
-
- this.lastYaw = this.yaw;
- this.lastX = this.x;
- this.lastY = this.y;
- this.lastZ = this.z;
-
- this.spawnToAll();
-
- return true;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityHuman.java b/src/main/java/cn/nukkit/entity/EntityHuman.java
deleted file mode 100644
index 32e1804cc..000000000
--- a/src/main/java/cn/nukkit/entity/EntityHuman.java
+++ /dev/null
@@ -1,366 +0,0 @@
-package cn.nukkit.entity;
-
-import cn.nukkit.Player;
-import cn.nukkit.entity.data.IntPositionEntityData;
-import cn.nukkit.entity.data.Skin;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemID;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.nbt.tag.StringTag;
-import cn.nukkit.network.protocol.AddPlayerPacket;
-import cn.nukkit.network.protocol.SetEntityLinkPacket;
-import cn.nukkit.utils.*;
-
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-/**
- * @author MagicDroidX
- * Nukkit Project
- */
-public class EntityHuman extends EntityHumanType {
-
- public static final int DATA_PLAYER_FLAG_SLEEP = 1;
- public static final int DATA_PLAYER_FLAG_DEAD = 2;
-
- public static final int DATA_PLAYER_FLAGS = 26;
- public static final int DATA_PLAYER_BUTTON_TEXT = 40;
-
- protected UUID uuid;
- protected byte[] rawUUID;
-
- protected Skin skin;
-
- @Override
- public float getWidth() {
- return 0.58f;
- }
-
- @Override
- public float getLength() {
- return 0.58f;
- }
-
- @Override
- public float getHeight() {
- return isSwimming() || isGliding() ? 0.6f : 1.8f;
- }
-
- @Override
- protected double getStepHeight() {
- return 0.6f;
- }
-
- @Override
- public float getEyeHeight() {
- return isSwimming() || isGliding() ? 0.42f : 1.62f;
- }
-
- @Override
- protected float getBaseOffset() {
- return this.getEyeHeight();
- }
-
- @Override
- public int getNetworkId() {
- return -1;
- }
-
- public EntityHuman(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- public Skin getSkin() {
- return skin;
- }
-
- public UUID getUniqueId() {
- return uuid;
- }
-
- public byte[] getRawUniqueId() {
- return rawUUID;
- }
-
- public void setSkin(Skin skin) {
- this.skin = skin;
- }
-
- @Override
- protected void initEntity() {
- this.setDataFlag(DATA_PLAYER_FLAGS, DATA_PLAYER_FLAG_SLEEP, false, false);
- this.setDataFlag(DATA_FLAGS, DATA_FLAG_GRAVITY, true, false);
- this.setDataProperty(new IntPositionEntityData(DATA_PLAYER_BED_POSITION, 0, 0, 0), false);
-
- if (!(this instanceof Player)) {
- if (this.namedTag.contains("NameTag")) {
- this.setNameTag(this.namedTag.getString("NameTag"));
- }
-
- if (this.namedTag.contains("Skin") && this.namedTag.get("Skin") instanceof CompoundTag) {
- CompoundTag skinTag = this.namedTag.getCompound("Skin");
- if (!skinTag.contains("Transparent")) {
- skinTag.putBoolean("Transparent", false);
- }
- Skin newSkin = new Skin();
- if (skinTag.contains("ModelId")) {
- newSkin.setSkinId(skinTag.getString("ModelId"));
- }
- if (skinTag.contains("PlayFabID")) {
- newSkin.setPlayFabId(skinTag.getString("PlayFabID"));
- }
- if (skinTag.contains("Data")) {
- byte[] data = skinTag.getByteArray("Data");
- if (skinTag.contains("SkinImageWidth") && skinTag.contains("SkinImageHeight")) {
- newSkin.setSkinData(new SerializedImage(skinTag.getInt("SkinImageWidth"), skinTag.getInt("SkinImageHeight"), data));
- } else {
- newSkin.setSkinData(data);
- }
- }
- if (skinTag.contains("CapeId")) {
- newSkin.setCapeId(skinTag.getString("CapeId"));
- }
- if (skinTag.contains("CapeData")) {
- byte[] data = skinTag.getByteArray("CapeData");
- if (skinTag.contains("CapeImageWidth") && skinTag.contains("CapeImageHeight")) {
- newSkin.setCapeData(new SerializedImage(skinTag.getInt("CapeImageWidth"), skinTag.getInt("CapeImageHeight"), data));
- } else {
- newSkin.setCapeData(data);
- }
- }
- if (skinTag.contains("GeometryName")) {
- newSkin.setGeometryName(skinTag.getString("GeometryName"));
- }
- if (skinTag.contains("SkinResourcePatch")) {
- newSkin.setSkinResourcePatch(new String(skinTag.getByteArray("SkinResourcePatch"), StandardCharsets.UTF_8));
- }
- if (skinTag.contains("GeometryData")) {
- newSkin.setGeometryData(new String(skinTag.getByteArray("GeometryData"), StandardCharsets.UTF_8));
- }
- if (skinTag.contains("AnimationData")) {
- newSkin.setAnimationData(new String(skinTag.getByteArray("AnimationData"), StandardCharsets.UTF_8));
- }
- if (skinTag.contains("PremiumSkin")) {
- newSkin.setPremium(skinTag.getBoolean("PremiumSkin"));
- }
- if (skinTag.contains("PersonaSkin")) {
- newSkin.setPersona(skinTag.getBoolean("PersonaSkin"));
- }
- if (skinTag.contains("CapeOnClassicSkin")) {
- newSkin.setCapeOnClassic(skinTag.getBoolean("CapeOnClassicSkin"));
- }
- if (skinTag.contains("AnimatedImageData")) {
- for (CompoundTag animationTag : skinTag.getList("AnimatedImageData", CompoundTag.class).getAll()) {
- newSkin.getAnimations().add(new SkinAnimation(new SerializedImage(animationTag.getInt("ImageWidth"), animationTag.getInt("ImageHeight"), animationTag.getByteArray("Image")), animationTag.getInt("Type"), animationTag.getFloat("Frames"), animationTag.getInt("AnimationExpression")));
- }
- }
- if (skinTag.contains("ArmSize")) {
- newSkin.setArmSize(skinTag.getString("ArmSize"));
- }
- if (skinTag.contains("SkinColor")) {
- newSkin.setSkinColor(skinTag.getString("SkinColor"));
- }
- if (skinTag.contains("PersonaPieces")) {
- ListTag pieces = skinTag.getList("PersonaPieces", CompoundTag.class);
- for (CompoundTag piece : pieces.getAll()) {
- newSkin.getPersonaPieces().add(new PersonaPiece(
- piece.getString("PieceId"),
- piece.getString("PieceType"),
- piece.getString("PackId"),
- piece.getBoolean("IsDefault"),
- piece.getString("ProductId")
- ));
- }
- }
- if (skinTag.contains("PieceTintColors")) {
- ListTag tintColors = skinTag.getList("PieceTintColors", CompoundTag.class);
- for (CompoundTag tintColor : tintColors.getAll()) {
- newSkin.getTintColors().add(new PersonaPieceTint(
- tintColor.getString("PieceType"),
- tintColor.getList("Colors", StringTag.class).getAll().stream()
- .map(stringTag -> stringTag.data).collect(Collectors.toList())
- ));
- }
- }
- if (skinTag.contains("IsTrustedSkin")) {
- newSkin.setTrusted(skinTag.getBoolean("IsTrustedSkin"));
- }
- this.setSkin(newSkin);
- }
-
- this.uuid = Utils.dataToUUID(String.valueOf(this.getId()).getBytes(StandardCharsets.UTF_8), this.skin
- .getSkinData().data, this.getNameTag().getBytes(StandardCharsets.UTF_8));
- } else {
- // HACK: Fix gravity on 1.2.11 and lower
- if (((Player) this).protocol <= 201) {
- this.setDataFlag(DATA_FLAGS, 46, true, false);
- }
- }
-
- super.initEntity();
- }
-
- @Override
- public String getName() {
- return this.getNameTag();
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
-
- if (skin != null) {
- CompoundTag skinTag = new CompoundTag()
- .putByteArray("Data", this.getSkin().getSkinData().data)
- .putInt("SkinImageWidth", this.getSkin().getSkinData().width)
- .putInt("SkinImageHeight", this.getSkin().getSkinData().height)
- .putString("ModelId", this.skin.getSkinId())
- .putString("CapeId", this.getSkin().getCapeId())
- .putByteArray("CapeData", this.getSkin().getCapeData().data)
- .putInt("CapeImageWidth", this.getSkin().getCapeData().width)
- .putInt("CapeImageHeight", this.getSkin().getCapeData().height)
- .putByteArray("SkinResourcePatch", this.getSkin().getSkinResourcePatch().getBytes(StandardCharsets.UTF_8))
- .putByteArray("GeometryData", this.skin.getGeometryData().getBytes(StandardCharsets.UTF_8))
- .putByteArray("AnimationData", this.getSkin().getAnimationData().getBytes(StandardCharsets.UTF_8))
- .putBoolean("PremiumSkin", this.getSkin().isPremium())
- .putBoolean("PersonaSkin", this.getSkin().isPersona())
- .putBoolean("CapeOnClassicSkin", this.getSkin().isCapeOnClassic())
- .putString("ArmSize", this.getSkin().getArmSize())
- .putString("SkinColor", this.getSkin().getSkinColor())
- .putBoolean("IsTrustedSkin", this.getSkin().isTrusted());
-
- List animations = this.getSkin().getAnimations();
-
- if (!animations.isEmpty()) {
- ListTag animationsTag = new ListTag<>("AnimatedImageData");
-
- for (SkinAnimation animation : animations) {
- animationsTag.add(new CompoundTag()
- .putFloat("Frames", animation.frames)
- .putInt("Type", animation.type)
- .putInt("ImageWidth", animation.image.width)
- .putInt("ImageHeight", animation.image.height)
- .putInt("AnimationExpression", animation.expression)
- .putByteArray("Image", animation.image.data));
- }
-
- skinTag.putList(animationsTag);
- }
-
- List personaPieces = this.getSkin().getPersonaPieces();
- if (!personaPieces.isEmpty()) {
- ListTag piecesTag = new ListTag<>("PersonaPieces");
- for (PersonaPiece piece : personaPieces) {
- piecesTag.add(new CompoundTag().putString("PieceId", piece.id)
- .putString("PieceType", piece.type)
- .putString("PackId", piece.packId)
- .putBoolean("IsDefault", piece.isDefault)
- .putString("ProductId", piece.productId));
- }
- }
-
- List tints = this.getSkin().getTintColors();
- if (!tints.isEmpty()) {
- ListTag tintsTag = new ListTag<>("PieceTintColors");
- for (PersonaPieceTint tint : tints) {
- ListTag colors = new ListTag<>("Colors");
- colors.setAll(tint.colors.stream().map(s -> new StringTag("", s)).collect(Collectors.toList()));
- tintsTag.add(new CompoundTag()
- .putString("PieceType", tint.pieceType)
- .putList(colors));
- }
- }
-
- if (!this.getSkin().getPlayFabId().isEmpty()) {
- skinTag.putString("PlayFabID", this.getSkin().getPlayFabId());
- }
-
- this.namedTag.putCompound("Skin", skinTag);
- }
- }
-
- @Override
- public void spawnTo(Player player) {
- if (this != player && !this.hasSpawned.containsKey(player.getLoaderId())) {
- this.hasSpawned.put(player.getLoaderId(), player);
-
- if (!this.skin.isValid()) {
- throw new IllegalStateException(this.getClass().getSimpleName() + " must have a valid skin set");
- }
-
- if (this.isPlayer) {
- this.server.updatePlayerListData(this.uuid, this.getId(), ((Player) this).getDisplayName(), this.skin, ((Player) this).getLoginChainData().getXUID(), new Player[]{player});
- } else {
- this.server.updatePlayerListData(this.uuid, this.getId(), this.getName(), this.skin, new Player[]{player});
- }
-
- AddPlayerPacket pk = new AddPlayerPacket();
- pk.uuid = this.uuid;
- pk.username = this.getName();
- pk.entityUniqueId = this.getId();
- pk.entityRuntimeId = this.getId();
- pk.x = (float) this.x;
- pk.y = (float) this.y;
- pk.z = (float) this.z;
- pk.speedX = (float) this.motionX;
- pk.speedY = (float) this.motionY;
- pk.speedZ = (float) this.motionZ;
- pk.yaw = (float) this.yaw;
- pk.pitch = (float) this.pitch;
- pk.item = this.getInventory().getItemInHand();
- pk.metadata = this.dataProperties.clone();
- player.dataPacket(pk);
-
- if (this.isPlayer) {
- this.inventory.sendArmorContents(player);
- } else {
- this.inventory.sendArmorContentsIfNotAr(player);
- }
- this.offhandInventory.sendContents(player);
-
- if (this.riding != null) {
- SetEntityLinkPacket pkk = new SetEntityLinkPacket();
- pkk.vehicleUniqueId = this.riding.getId();
- pkk.riderUniqueId = this.getId();
- pkk.type = 1;
- pkk.immediate = 1;
- player.dataPacket(pkk);
- }
-
- if (!this.isPlayer) {
- this.server.removePlayerListData(this.uuid, player);
- }
- }
- }
-
- @Override
- public void close() {
- if (!this.closed) {
- if (inventory != null && (!(this instanceof Player) || ((Player) this).loggedIn)) {
- for (Player viewer : this.inventory.getViewers()) {
- viewer.removeWindow(this.inventory);
- }
- }
-
- super.close();
- }
- }
-
- @Override
- protected void onBlock(Entity entity, boolean animate, float damage) {
- super.onBlock(entity, animate, damage);
- Item shieldOffhand = getOffhandInventory().getItem(0);
- if (shieldOffhand.getId() == ItemID.SHIELD) {
- getOffhandInventory().setItem(0, damageArmor(shieldOffhand, entity, damage, true, null));
- } else {
- Item shield = getInventory().getItemInHand();
- if (shield.getId() == ItemID.SHIELD) {
- getInventory().setItemInHand(damageArmor(shield, entity, damage, true, null));
- }
- }
- }
-}
diff --git a/src/main/java/cn/nukkit/entity/EntityHumanType.java b/src/main/java/cn/nukkit/entity/EntityHumanType.java
deleted file mode 100644
index 2ce24e316..000000000
--- a/src/main/java/cn/nukkit/entity/EntityHumanType.java
+++ /dev/null
@@ -1,260 +0,0 @@
-package cn.nukkit.entity;
-
-import cn.nukkit.block.BlockID;
-import cn.nukkit.event.entity.EntityDamageByEntityEvent;
-import cn.nukkit.event.entity.EntityDamageEvent;
-import cn.nukkit.event.entity.EntityDamageEvent.DamageCause;
-import cn.nukkit.inventory.InventoryHolder;
-import cn.nukkit.inventory.PlayerEnderChestInventory;
-import cn.nukkit.inventory.PlayerInventory;
-import cn.nukkit.inventory.PlayerOffhandInventory;
-import cn.nukkit.item.Item;
-import cn.nukkit.item.ItemSkull;
-import cn.nukkit.item.enchantment.Enchantment;
-import cn.nukkit.level.format.FullChunk;
-import cn.nukkit.math.NukkitMath;
-import cn.nukkit.nbt.NBTIO;
-import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.nbt.tag.ListTag;
-import cn.nukkit.utils.Utils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class EntityHumanType extends EntityCreature implements InventoryHolder {
-
- protected PlayerInventory inventory;
- protected PlayerEnderChestInventory enderChestInventory;
- protected PlayerOffhandInventory offhandInventory;
-
- public EntityHumanType(FullChunk chunk, CompoundTag nbt) {
- super(chunk, nbt);
- }
-
- @Override
- public PlayerInventory getInventory() {
- return inventory;
- }
-
- public PlayerEnderChestInventory getEnderChestInventory() {
- return enderChestInventory;
- }
-
- public PlayerOffhandInventory getOffhandInventory() {
- return offhandInventory;
- }
-
- @Override
- protected void initEntity() {
- this.inventory = new PlayerInventory(this);
- this.offhandInventory = new PlayerOffhandInventory(this);
-
- if (this.namedTag.contains("Inventory") && this.namedTag.get("Inventory") instanceof ListTag) {
- ListTag inventoryList = this.namedTag.getList("Inventory", CompoundTag.class);
- for (CompoundTag item : inventoryList.getAll()) {
- int slot = item.getByte("Slot");
- if (slot >= 0 && slot < 9) {
- inventoryList.remove(item);
- } else if (slot >= 100 && slot < 104) {
- this.inventory.setItem(this.inventory.getSize() + slot - 100, NBTIO.getItemHelper(item));
- } else if (slot == -106) {
- this.offhandInventory.setItem(0, NBTIO.getItemHelper(item));
- } else {
- this.inventory.setItem(slot - 9, NBTIO.getItemHelper(item));
- }
- }
- }
-
- this.enderChestInventory = new PlayerEnderChestInventory(this);
-
- if (this.namedTag.contains("EnderItems") && this.namedTag.get("EnderItems") instanceof ListTag) {
- ListTag inventoryList = this.namedTag.getList("EnderItems", CompoundTag.class);
- for (CompoundTag item : inventoryList.getAll()) {
- this.enderChestInventory.setItem(item.getByte("Slot"), NBTIO.getItemHelper(item));
- }
- }
-
- super.initEntity();
- }
-
- @Override
- public void saveNBT() {
- super.saveNBT();
-
- ListTag inventoryTag = null;
- if (this.inventory != null) {
- inventoryTag = new ListTag<>("Inventory");
- this.namedTag.putList(inventoryTag);
-
- for (int slot = 0; slot < 9; ++slot) {
- inventoryTag.add(new CompoundTag()
- .putByte("Count", 0)
- .putShort("Damage", 0)
- .putByte("Slot", slot)
- .putByte("TrueSlot", -1)
- .putShort("id", 0)
- );
- }
-
- int slotCount = 45;
- for (int slot = 9; slot < slotCount; ++slot) {
- Item item = this.inventory.getItem(slot - 9);
- inventoryTag.add(NBTIO.putItemHelper(item, slot));
- }
-
- for (int slot = 100; slot < 104; ++slot) {
- Item item = this.inventory.getItem(this.inventory.getSize() + slot - 100);
- if (item != null && item.getId() != Item.AIR) {
- inventoryTag.add(NBTIO.putItemHelper(item, slot));
- }
- }
- }
-
- if (this.offhandInventory != null) {
- Item item = this.offhandInventory.getItem(0);
- if (item.getId() != Item.AIR) {
- if (inventoryTag == null) {
- inventoryTag = new ListTag<>("Inventory");
- this.namedTag.putList(inventoryTag);
- }
- inventoryTag.add(NBTIO.putItemHelper(item, -106));
- }
- }
-
- this.namedTag.putList(new ListTag