diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index ae61b1deca..56c26ef278 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -3,7 +3,7 @@ name: Dev Build on: push: branches: [dev, '1.12'] - paths: + paths: - .github/workflows/** - etc/checkstyle.xml - src/** @@ -20,83 +20,83 @@ jobs: name: Dev Build (Java ${{ matrix.java }}) steps: - - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1 - - name: Set up JDK - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: ${{ matrix.java }} + - uses: actions/checkout@v3 + - uses: gradle/wrapper-validation-action@v1 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: ${{ matrix.java }} - - name: Cache gradle - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/jdks - ~/.gradle/native - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'gradle/libs.versions.toml') }} - restore-keys: | - ${{ runner.os }}-gradle- + - name: Cache gradle + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/jdks + ~/.gradle/native + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'gradle/libs.versions.toml') }} + restore-keys: | + ${{ runner.os }}-gradle- - - name: Gradle Build and Deploy - run: BUILD_EXTRAS=true ./gradlew assemble publish --no-daemon --stacktrace - env: - ORG_GRADLE_PROJECT_glowstoneUsername: ${{ secrets.MAVEN_USERNAME }} - ORG_GRADLE_PROJECT_glowstonePassword: ${{ secrets.MAVEN_PASSWORD }} + - name: Gradle Build and Deploy + run: BUILD_EXTRAS=true ./gradlew assemble publish --no-daemon --stacktrace + env: + ORG_GRADLE_PROJECT_glowstoneUsername: ${{ secrets.MAVEN_USERNAME }} + ORG_GRADLE_PROJECT_glowstonePassword: ${{ secrets.MAVEN_PASSWORD }} - - name: Get Minecraft version - id: version - run: | - minecraft_version=$(./gradlew -q printMinecraftVersion) - echo "::set-output name=minecraft_version::$minecraft_version" + - name: Get Minecraft version + id: version + run: | + minecraft_version=$(./gradlew -q printMinecraftVersion) + echo "::set-output name=minecraft_version::$minecraft_version" - - name: Cleanup Gradle Cache - # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. - # Restoring these files from a GitHub Actions cache might cause problems for future builds. - run: | - rm -f ~/.gradle/caches/modules-2/modules-2.lock - rm -f ~/.gradle/caches/modules-2/gc.properties + - name: Cleanup Gradle Cache + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties - - name: Push Javadocs to Pages - uses: dmnemec/copy_file_to_another_repo_action@v1.1.1 - env: - API_TOKEN_GITHUB: ${{ secrets.GH_TOKEN }} - with: - source_file: 'build/docs/javadoc/.' - destination_repo: 'GlowstoneMC/glowstonemc.github.io' - destination_folder: content/jd/glowstone/${{ steps.version.outputs.minecraft_version }}/ - user_email: 'mastercoms@tuta.io' - user_name: 'mastercoms' - commit_message: Update Javadocs for Glowstone commit ${{ github.sha }} + - name: Push Javadocs to Pages + uses: dmnemec/copy_file_to_another_repo_action@v1.1.1 + env: + API_TOKEN_GITHUB: ${{ secrets.GH_TOKEN }} + with: + source_file: 'build/docs/javadoc/.' + destination_repo: 'GlowstoneMC/glowstonemc.github.io' + destination_folder: content/jd/glowstone/${{ steps.version.outputs.minecraft_version }}/ + user_email: 'mastercoms@tuta.io' + user_name: 'mastercoms' + commit_message: Update Javadocs for Glowstone commit ${{ github.sha }} - - name: GitHub Artifact - uses: actions/upload-artifact@v3 - with: - name: glowstone - path: build/libs/glowstone.jar + - name: GitHub Artifact + uses: actions/upload-artifact@v3 + with: + name: glowstone + path: build/libs/glowstone.jar - - name: Setup SSH - if: ${{ github.ref == 'refs/heads/1.12' }} - run: | - mkdir -p ~/.ssh - cat << EOF > ~/.ssh/config - Host * - ControlMaster auto - ControlPath ~/.ssh/-%r@%h:%p - ControlPersist 120 - EOF - echo $SSH_KNOWN_HOSTS >> ~/.ssh/known_hosts - sudo apt-get install sshpass - env: - SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }} + - name: Setup SSH + if: ${{ github.ref == 'refs/heads/1.12' }} + run: | + mkdir -p ~/.ssh + cat << EOF > ~/.ssh/config + Host * + ControlMaster auto + ControlPath ~/.ssh/-%r@%h:%p + ControlPersist 120 + EOF + echo $SSH_KNOWN_HOSTS >> ~/.ssh/known_hosts + sudo apt-get install sshpass + env: + SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }} - - name: Deploy to Test Server - if: ${{ github.ref == 'refs/heads/1.12' }} - run: | - sshpass -e scp target/glowstone.jar glowstone@$SSH_ADDRESS: - sshpass -e ssh glowstone@$SSH_ADDRESS sudo systemctl restart glowstone - env: - SSH_ADDRESS: ${{ secrets.SSH_ADDRESS }} - SSHPASS: ${{ secrets.SSH_PASSWORD }} + - name: Deploy to Test Server + if: ${{ github.ref == 'refs/heads/1.12' }} + run: | + sshpass -e scp target/glowstone.jar glowstone@$SSH_ADDRESS: + sshpass -e ssh glowstone@$SSH_ADDRESS sudo systemctl restart glowstone + env: + SSH_ADDRESS: ${{ secrets.SSH_ADDRESS }} + SSHPASS: ${{ secrets.SSH_PASSWORD }} diff --git a/build.gradle.kts b/build.gradle.kts index 4c62902187..467eff1818 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,6 +8,7 @@ plugins { checkstyle jacoco kotlin("jvm") version "1.7.0" + application id("io.freefair.lombok") version "6.5.0-rc1" id("com.github.johnrengelman.shadow") version "7.1.2" @@ -53,6 +54,13 @@ dependencies { compileOnly(libs.jetbrains.annotations) } + +application { + mainClass.set("net.glowstone.GlowServer") +} + + + group = "net.glowstone" version = "2022.6.1-SNAPSHOT" description = "A fast, customizable and compatible open source Minecraft server." @@ -127,6 +135,7 @@ kotlin { tasks.withType { options.encoding = Charsets.UTF_8.name() options.release.set(javaVersion) + options.isWarnings = false; } tasks.withType { @@ -208,8 +217,8 @@ tasks.jar { tasks.shadowJar { val prefix = "org.bukkit.craftbukkit.libs" listOf( - "jline", - "it.unimi", + "jline", + "it.unimi", ).forEach { pattern -> relocate(pattern, "$prefix.$pattern") } diff --git a/gradle.properties b/gradle.properties index d688a63e6e..d852712c49 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,6 @@ group = net.glowstone -mcVersion = 1.19 +mcVersion = 1.19.3 +org.gradle.warning.mode=none org.gradle.caching=true org.gradle.parallel=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 279705bbd6..6bae085cab 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -api = "1.19-R0.1-SNAPSHOT" +api = "1.19.3-R0.1-SNAPSHOT" redstone-transformer = "1.1.0-SNAPSHOT" linkstone = "1.0.0-SNAPSHOT" @@ -7,7 +7,7 @@ checkstyle = "8.44" jansi = "1.18" jline = "2.14.6" fastutil = "1.0" -flow = "1.2.10-SNAPSHOT" +flow = "1.2.11-SNAPSHOT" fastuuid = "0.1" brigadier = "1.0.17" gluegen = "2.3.2" diff --git a/settings.gradle.kts b/settings.gradle.kts index e67cbfc1e9..31a7094593 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -3,5 +3,4 @@ */ rootProject.name = "glowstone" -enableFeaturePreview("VERSION_CATALOGS") enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") diff --git a/src/main/java/net/glowstone/EventFactory.java b/src/main/java/net/glowstone/EventFactory.java index f695d5ea6f..cd842f272b 100644 --- a/src/main/java/net/glowstone/EventFactory.java +++ b/src/main/java/net/glowstone/EventFactory.java @@ -196,7 +196,7 @@ public PlayerJoinEvent onPlayerJoin(Player player) { } public PlayerKickEvent onPlayerKick(Player player, String reason) { - return callEvent(new PlayerKickEvent(player, reason, null)); + return callEvent(new PlayerKickEvent(player, reason, "")); } public PlayerQuitEvent onPlayerQuit(Player player) { diff --git a/src/main/java/net/glowstone/GlowOfflinePlayer.java b/src/main/java/net/glowstone/GlowOfflinePlayer.java index 4d158bc3ed..c9d809b8db 100644 --- a/src/main/java/net/glowstone/GlowOfflinePlayer.java +++ b/src/main/java/net/glowstone/GlowOfflinePlayer.java @@ -1,5 +1,6 @@ package net.glowstone; +import com.destroystokyo.paper.profile.PlayerProfile; import lombok.Getter; import net.glowstone.entity.meta.profile.GlowPlayerProfile; import net.glowstone.entity.meta.profile.ProfileCache; @@ -15,7 +16,6 @@ import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; -import org.bukkit.profile.PlayerProfile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/src/main/java/net/glowstone/GlowServer.java b/src/main/java/net/glowstone/GlowServer.java index 079c70afa8..637ff02efa 100644 --- a/src/main/java/net/glowstone/GlowServer.java +++ b/src/main/java/net/glowstone/GlowServer.java @@ -106,6 +106,8 @@ import net.glowstone.linkstone.runtime.FieldSet; import net.glowstone.linkstone.runtime.LinkstoneRuntimeData; import net.glowstone.linkstone.runtime.inithook.ClassInitHook; +import net.glowstone.linkstone.runtime.FieldSet; +import net.glowstone.linkstone.runtime.LinkstoneRuntimeData; import net.glowstone.map.GlowMapView; import net.glowstone.net.GameServer; import net.glowstone.net.GlowSession; @@ -140,6 +142,8 @@ import net.glowstone.util.linkstone.LinkstoneClassInitObserver; import net.glowstone.util.linkstone.LinkstonePluginLoader; import net.glowstone.util.linkstone.LinkstonePluginScanner; +import net.glowstone.util.linkstone.LinkstoneClassInitObserver; +import net.glowstone.util.linkstone.LinkstonePluginScanner; import net.glowstone.util.loot.LootingManager; import net.glowstone.util.mojangson.Mojangson; import net.glowstone.util.mojangson.ex.MojangsonParseException; @@ -161,6 +165,7 @@ import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.OfflinePlayer; +import org.bukkit.Registry; import org.bukkit.Server; import org.bukkit.StructureType; import org.bukkit.Tag; @@ -216,6 +221,7 @@ import org.bukkit.plugin.messaging.StandardMessenger; import org.bukkit.potion.PotionBrewer; import org.bukkit.profile.PlayerProfile; +import org.bukkit.scoreboard.Criteria; import org.bukkit.structure.StructureManager; import org.bukkit.util.CachedServerIcon; import org.bukkit.util.permissions.DefaultPermissions; @@ -282,11 +288,11 @@ public class GlowServer implements Server { /** * The game version supported by the server. */ - public static final String GAME_VERSION = NoInline.of("1.19"); + public static final String GAME_VERSION = NoInline.of("1.19.3"); /** * The protocol version supported by the server. */ - public static final int PROTOCOL_VERSION = NoInline.of(759); + public static final int PROTOCOL_VERSION = NoInline.of(761); /** * The data version supported by the server. */ @@ -868,7 +874,7 @@ public void start() { String seedString = config.getString(Key.LEVEL_SEED); WorldType type = WorldType.getByName(getWorldType()); if (type == null) { - type = WorldType.NORMAL; + type = WorldType.FLAT; } long seed = new Random().nextLong(); @@ -1611,6 +1617,11 @@ public LootTable getLootTable(@NotNull NamespacedKey tableKey) { return null; } + @Override + public @org.jetbrains.annotations.Nullable Registry getRegistry(@NotNull Class tClass) { + return null; + } + /** * Registers an advancement to the advancement registry. * @@ -1972,6 +1983,11 @@ public GlowScoreboardManager getScoreboardManager() { return scoreboardManager; } + @Override + public @NotNull Criteria getScoreboardCriteria(@NotNull String name) { + return null; + } + @Override @Deprecated public UnsafeValues getUnsafe() { @@ -2517,6 +2533,11 @@ public List getWorlds() { return (List) worlds.getWorlds(); } + @Override + public boolean isTickingWorlds() { + return false; + } + /** * Gets the default ChunkGenerator for the given environment and type. * @@ -2685,6 +2706,11 @@ public Merchant createMerchant(String title) { return null; } + @Override + public int getMaxChainedNeighborUpdates() { + return 0; + } + @Override public GlowServerIcon getServerIcon() { return defaultIcon; @@ -2748,6 +2774,16 @@ public void setSpawnRadius(int value) { spawnRadius = value; } + @Override + public boolean shouldSendChatPreviews() { + return false; + } + + @Override + public boolean isEnforcingSecureProfiles() { + return false; + } + @Override public boolean getHideOnlinePlayers() { return false; diff --git a/src/main/java/net/glowstone/GlowWorld.java b/src/main/java/net/glowstone/GlowWorld.java index 0dae48922b..a4bb8c3794 100644 --- a/src/main/java/net/glowstone/GlowWorld.java +++ b/src/main/java/net/glowstone/GlowWorld.java @@ -100,6 +100,7 @@ import org.bukkit.generator.BiomeProvider; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; +import org.bukkit.generator.structure.Structure; import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.metadata.MetadataStore; @@ -110,6 +111,7 @@ import org.bukkit.plugin.messaging.StandardMessenger; import org.bukkit.util.Consumer; import org.bukkit.util.RayTraceResult; +import org.bukkit.util.StructureSearchResult; import org.bukkit.util.Vector; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -1135,7 +1137,7 @@ private void prepareSpawn() { @Override public void setDifficulty(Difficulty difficulty) { this.difficulty = difficulty; - ServerDifficultyMessage message = new ServerDifficultyMessage(difficulty); + ServerDifficultyMessage message = new ServerDifficultyMessage(difficulty, false); for (GlowPlayer player : getRawPlayers()) { player.getSession().send(message); } @@ -1555,6 +1557,11 @@ public boolean lineOfSightExists(@NotNull Location from, @NotNull Location to) { return false; } + @Override + public boolean hasCollisionsIn(org.bukkit.util.@NotNull BoundingBox boundingBox) { + return false; + } + //////////////////////////////////////////////////////////////////////////// // Chunk loading and unloading @@ -2398,11 +2405,21 @@ public void playSound(@NotNull Entity entity, @NotNull Sound sound, float volume } + @Override + public void playSound(@NotNull Entity entity, @NotNull String sound, float volume, float pitch) { + + } + @Override public void playSound(@NotNull Entity entity, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { } + @Override + public void playSound(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) { + + } + @Override public Spigot spigot() { return spigot; @@ -2740,6 +2757,16 @@ public void spawnParticle(@NotNull Particle particle, double v, double v1, d return null; } + @Override + public @Nullable StructureSearchResult locateNearestStructure(@NotNull Location origin, org.bukkit.generator.structure.@NotNull StructureType structureType, int radius, boolean findUnexplored) { + return null; + } + + @Override + public @Nullable StructureSearchResult locateNearestStructure(@NotNull Location origin, @NotNull Structure structure, int radius, boolean findUnexplored) { + return null; + } + @Override public @Nullable Location locateNearestBiome(@NotNull Location location, @NotNull Biome biome, int i) { // TODO: 1.16 diff --git a/src/main/java/net/glowstone/GlowWorldBorder.java b/src/main/java/net/glowstone/GlowWorldBorder.java index 0145d92592..12fc07ad70 100644 --- a/src/main/java/net/glowstone/GlowWorldBorder.java +++ b/src/main/java/net/glowstone/GlowWorldBorder.java @@ -8,6 +8,9 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.WorldBorder; +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.TimeUnit; public class GlowWorldBorder implements WorldBorder { @@ -131,6 +134,11 @@ public void setSize(double size, long seconds) { broadcast(createMessage()); // TODO 1.19 packet } + @Override + public void setSize(double newSize, @NotNull TimeUnit unit, long time) { + + } + @Override public void setCenter(Location location) { center = location.clone(); @@ -162,6 +170,16 @@ public boolean isInside(Location location) { && location.getX() >= min.getX() && location.getZ() >= min.getZ(); } + @Override + public double getMaxSize() { + return 0; + } + + @Override + public double getMaxCenterCoordinate() { + return 0; + } + private void broadcast(WorldBorderMessage message) { world.getPlayers().forEach(player -> ((GlowPlayer) player).getSession().send(message)); } diff --git a/src/main/java/net/glowstone/advancement/GlowAdvancement.java b/src/main/java/net/glowstone/advancement/GlowAdvancement.java index e29d24410c..e29d07a9e4 100644 --- a/src/main/java/net/glowstone/advancement/GlowAdvancement.java +++ b/src/main/java/net/glowstone/advancement/GlowAdvancement.java @@ -5,6 +5,7 @@ import io.netty.buffer.ByteBuf; import io.papermc.paper.advancement.AdvancementDisplay; import lombok.Data; +import net.kyori.adventure.text.Component; import org.bukkit.NamespacedKey; import org.bukkit.advancement.Advancement; import org.jetbrains.annotations.NotNull; @@ -114,4 +115,9 @@ public ByteBuf encode(ByteBuf buf) throws IOException { public @Nullable AdvancementDisplay getDisplay() { return display; } + + @Override + public @NotNull Component displayName() { + return null; + } } diff --git a/src/main/java/net/glowstone/advancement/GlowAdvancementDisplay.java b/src/main/java/net/glowstone/advancement/GlowAdvancementDisplay.java index 75f89b1abb..0c0f980d5f 100644 --- a/src/main/java/net/glowstone/advancement/GlowAdvancementDisplay.java +++ b/src/main/java/net/glowstone/advancement/GlowAdvancementDisplay.java @@ -116,4 +116,9 @@ public boolean isHidden() { public @Nullable NamespacedKey backgroundPath() { return background; } + + @Override + public @NotNull Component displayName() { + return null; + } } diff --git a/src/main/java/net/glowstone/block/GlowBlock.java b/src/main/java/net/glowstone/block/GlowBlock.java index f2c5a721a3..42f5ba31fb 100644 --- a/src/main/java/net/glowstone/block/GlowBlock.java +++ b/src/main/java/net/glowstone/block/GlowBlock.java @@ -579,12 +579,32 @@ public boolean breakNaturally(boolean triggerEffect) { return false; } + @Override + public boolean breakNaturally(boolean triggerEffect, boolean dropExperience) { + return true; + } + @Override public boolean breakNaturally(@NotNull ItemStack tool, boolean triggerEffect) { // TODO: triggerEffect return breakNaturally(tool); } + @Override + public boolean breakNaturally(@NotNull ItemStack tool, boolean triggerEffect, boolean dropExperience) { + return false; + } + + @Override + public void tick() { + + } + + @Override + public void randomTick() { + + } + @Override public boolean applyBoneMeal(@NotNull BlockFace blockFace) { return false; diff --git a/src/main/java/net/glowstone/block/GlowBlockState.java b/src/main/java/net/glowstone/block/GlowBlockState.java index 304257209c..e1c6e6bd85 100644 --- a/src/main/java/net/glowstone/block/GlowBlockState.java +++ b/src/main/java/net/glowstone/block/GlowBlockState.java @@ -12,12 +12,17 @@ import org.bukkit.block.BlockState; import org.bukkit.block.TileState; import org.bukkit.block.data.BlockData; +import org.bukkit.entity.Entity; +import org.bukkit.inventory.ItemStack; import org.bukkit.material.MaterialData; import org.bukkit.metadata.MetadataValue; import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.plugin.Plugin; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; +import java.util.Collection; import java.util.List; /** @@ -110,6 +115,21 @@ public boolean isCollidable() { return false; } + @Override + public @Unmodifiable @NotNull Collection getDrops() { + return null; + } + + @Override + public @Unmodifiable @NotNull Collection getDrops(@Nullable ItemStack tool) { + return null; + } + + @Override + public @Unmodifiable @NotNull Collection getDrops(@NotNull ItemStack tool, @Nullable Entity entity) { + return null; + } + //////////////////////////////////////////////////////////////////////////// // Update diff --git a/src/main/java/net/glowstone/block/entity/state/GlowDispenser.java b/src/main/java/net/glowstone/block/entity/state/GlowDispenser.java index 7cb60619e7..c704f4a09e 100644 --- a/src/main/java/net/glowstone/block/entity/state/GlowDispenser.java +++ b/src/main/java/net/glowstone/block/entity/state/GlowDispenser.java @@ -33,7 +33,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.projectiles.BlockProjectileSource; +import org.bukkit.util.Consumer; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.concurrent.ThreadLocalRandom; @@ -204,4 +207,9 @@ public T launchProjectile(Class projectile, return null; } + @Override + public @NotNull T launchProjectile(@NotNull Class projectile, @Nullable Vector velocity, @Nullable Consumer function) { + return null; + } + } diff --git a/src/main/java/net/glowstone/block/entity/state/GlowSkull.java b/src/main/java/net/glowstone/block/entity/state/GlowSkull.java index 3e707727a3..d5d1605d4e 100644 --- a/src/main/java/net/glowstone/block/entity/state/GlowSkull.java +++ b/src/main/java/net/glowstone/block/entity/state/GlowSkull.java @@ -10,6 +10,7 @@ import net.glowstone.entity.meta.profile.GlowPlayerProfile; import net.glowstone.util.Position; import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; import org.bukkit.OfflinePlayer; import org.bukkit.SkullType; import org.bukkit.block.BlockFace; @@ -106,6 +107,16 @@ public void setOwnerProfile(org.bukkit.profile.@Nullable PlayerProfile profile) owner = (GlowPlayerProfile) profile; } + @Override + public @Nullable NamespacedKey getNoteBlockSound() { + return null; + } + + @Override + public void setNoteBlockSound(@Nullable NamespacedKey noteBlockSound) { + + } + public void setOwner(org.bukkit.profile.@Nullable PlayerProfile profile) { this.owner = (GlowPlayerProfile) profile; } diff --git a/src/main/java/net/glowstone/block/itemtype/ItemItemFrame.java b/src/main/java/net/glowstone/block/itemtype/ItemItemFrame.java index 15689f3065..d869163d37 100644 --- a/src/main/java/net/glowstone/block/itemtype/ItemItemFrame.java +++ b/src/main/java/net/glowstone/block/itemtype/ItemItemFrame.java @@ -22,7 +22,7 @@ public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, face); if (EventFactory.getInstance() - .callEvent(new HangingPlaceEvent(entity, player, target, face)) + .callEvent(new HangingPlaceEvent(entity, player, target, face, hand)) .isCancelled()) { return; } diff --git a/src/main/java/net/glowstone/chunk/ChunkManager.java b/src/main/java/net/glowstone/chunk/ChunkManager.java index 09caf5ebe2..6b06b1f20f 100644 --- a/src/main/java/net/glowstone/chunk/ChunkManager.java +++ b/src/main/java/net/glowstone/chunk/ChunkManager.java @@ -315,13 +315,31 @@ private void generateChunk(GlowChunk chunk, int x, int z) { if (glowChunkData != null) { int[][] extSections = glowChunkData.getSections(); + DimensionType dimensionType = DimensionTypes.getByEnvironmentId(world.getEnvironment().getId()); + int numSections = dimensionType.getLogicalHeight() / GlowChunk.SEC_DEPTH; + ChunkSection[] sections = new ChunkSection[numSections]; if (extSections != null) { - ChunkSection[] sections = new ChunkSection[extSections.length]; - for (int i = 0; i < extSections.length; ++i) { - if (extSections[i] != null) { - sections[i] = ChunkSection.fromStateArray(extSections[i]); + if (DimensionTypes.OVERWORLD.equals(dimensionType)) { + for (int i = 0; i < 4; i++) { + sections[i] = ChunkSection.initNewEmptySection(); + } + for (int i = 0; i < extSections.length; i++) { + if (extSections[i] != null) { + sections[i+4] = ChunkSection.fromStateArray(extSections[i]); + } } } + else { + for (int i = 0; i < extSections.length; ++i) { + if (extSections[i] != null) { + sections[i] = ChunkSection.fromStateArray(extSections[i]); + } + else { + sections[i] = ChunkSection.initNewEmptySection(); + } + } + } + chunk.initializeSections(sections); chunk.setBiomes(biomes.biomes); chunk.automaticHeightMap(); diff --git a/src/main/java/net/glowstone/chunk/ChunkSection.java b/src/main/java/net/glowstone/chunk/ChunkSection.java index bd57f8e462..eaeb53845e 100644 --- a/src/main/java/net/glowstone/chunk/ChunkSection.java +++ b/src/main/java/net/glowstone/chunk/ChunkSection.java @@ -1,6 +1,7 @@ package net.glowstone.chunk; import com.flowpowered.network.util.ByteBufUtils; +import com.google.common.primitives.Longs; import io.netty.buffer.ByteBuf; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; @@ -51,6 +52,7 @@ public final class ChunkSection { */ @Nullable private IntList palette; + private VariableValueArray data; /** * The sky light array. This array is always set, even in dimensions without skylight. @@ -176,6 +178,12 @@ public static ChunkSection fromStateArray(int[] types) { return new ChunkSection(types); } + public static ChunkSection initNewEmptySection() { + ChunkSection result = new ChunkSection(); + result.count = 0; + return result; + } + /** * Loads the contents of this chunk section from the given type array, initializing the * palette. @@ -290,6 +298,7 @@ public BlockData getBlockData(int x, int y, int z) { */ public int getType(int x, int y, int z) { int value = data.get(index(x, y, z)); + if (palette != null) { value = palette.getInt(value); } @@ -435,33 +444,42 @@ public boolean isEmpty() { */ public void writeToBuf(ByteBuf buf, boolean skylight) throws IllegalStateException { if (this.isEmpty()) { - throw new IllegalStateException("Can't write empty sections"); + buf.writeShort(0); + buf.writeByte(0); + ByteBufUtils.writeVarInt(buf, 0); + ByteBufUtils.writeVarInt(buf, 0); } - - buf.writeByte(data.getBitsPerValue()); // Bit per value -> varies - if (palette != null) { - ByteBufUtils.writeVarInt(buf, palette.size()); // Palette size - // Foreach loops can't be used due to autoboxing - IntListIterator itr = palette.iterator(); - while (itr.hasNext()) { - ByteBufUtils.writeVarInt(buf, itr.nextInt()); // The palette entry + else { + buf.writeShort(count); + buf.writeByte(data.getBitsPerValue()); // Bit per value -> varies + if (palette != null) { + ByteBufUtils.writeVarInt(buf, palette.size()); // Palette size + // Foreach loops can't be used due to autoboxing + IntListIterator itr = palette.iterator(); + while (itr.hasNext()) { + ByteBufUtils.writeVarInt(buf, itr.nextInt()); // The palette entry + } + } + long[] backing = data.getBacking(); + ByteBufUtils.writeVarInt(buf, backing.length); + buf.ensureWritable((backing.length << 3) + blockLight.byteSize() + (skylight ? skyLight + .byteSize() : 0)); + for (long value : backing) { + buf.writeLong(value); } - } - long[] backing = data.getBacking(); - ByteBufUtils.writeVarInt(buf, backing.length); - buf.ensureWritable((backing.length << 3) + blockLight.byteSize() + (skylight ? skyLight - .byteSize() : 0)); - for (long value : backing) { - buf.writeLong(value); } + // Biome palette, hardcoded for now + buf.writeByte(0); + ByteBufUtils.writeVarInt(buf, 0); + ByteBufUtils.writeVarInt(buf, 0); // Palette - ByteBufUtils.writeVarInt(buf, 1); // Palette length - ByteBufUtils.writeVarInt(buf, 0); // Palette data (AIR) + //ByteBufUtils.writeVarInt(buf, 0); // Palette length + //ByteBufUtils.writeVarInt(buf, 0); // Palette data (AIR) // Section data (4096 indices of 4-bit, 64 bit longs -> 256 empty longs) - ByteBufUtils.writeVarInt(buf, 256); // Data size - buf.writeBytes(new byte[2048]); // 256 longs is 2048 bytes + //ByteBufUtils.writeVarInt(buf, 256); // Data size + //buf.writeBytes(new byte[2048]); // 256 longs is 2048 bytes // buf.writeByte(data.getBitsPerValue()); // Bit per value -> varies diff --git a/src/main/java/net/glowstone/chunk/DimensionTypes.java b/src/main/java/net/glowstone/chunk/DimensionTypes.java index 2ed2ddd2fd..3e05933c50 100644 --- a/src/main/java/net/glowstone/chunk/DimensionTypes.java +++ b/src/main/java/net/glowstone/chunk/DimensionTypes.java @@ -28,4 +28,58 @@ public class DimensionTypes { false ); + public static final DimensionType NETHER = new DimensionType( + true, + false, + 15, + 0, + false, + 0.1f, + OptionalLong.of(18000L), + Optional.of(NamespacedKey.minecraft("infiniburn_nether")), + true, + false, + false, + NamespacedKey.minecraft("the_nether"), + 0, + 256, + 256, + 8.0D, + true, + true + ); + + public static final DimensionType THE_END = new DimensionType( + false, + true, + 15, + 0, + false, + 0.0f, + OptionalLong.of(600L), + Optional.of(NamespacedKey.minecraft("infiniburn_end")), + false, + false, + false, + NamespacedKey.minecraft("the_end"), + 0, + 256, + 256, + 1.0D, + false, + false + ); + + public static DimensionType getByEnvironmentId(int id) { + switch (id) { + case 0: + return OVERWORLD; + case -1: + return NETHER; + case 1: + return THE_END; + default: + throw new IllegalStateException("Dimension id " + id + " does not match a dimension type"); + } + } } diff --git a/src/main/java/net/glowstone/chunk/GlowChunk.java b/src/main/java/net/glowstone/chunk/GlowChunk.java index ce5d49c9f9..f89cfec695 100644 --- a/src/main/java/net/glowstone/chunk/GlowChunk.java +++ b/src/main/java/net/glowstone/chunk/GlowChunk.java @@ -27,6 +27,7 @@ import org.bukkit.Difficulty; import org.bukkit.Material; import org.bukkit.World.Environment; +import org.bukkit.block.Biome; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; @@ -264,6 +265,11 @@ public boolean contains(@NotNull BlockData block) { return false; } + @Override + public boolean contains(@NotNull Biome biome) { + return false; + } + @Override public @NotNull GlowChunkSnapshot getChunkSnapshot() { return getChunkSnapshot(true, false, false); @@ -355,7 +361,7 @@ public void initializeSections(ChunkSection[] initSections) { new Throwable()); return; } - if (initSections.length != SEC_COUNT) { + if (initSections.length != 16 && initSections.length != 24) { GlowServer.logger.log(Level.WARNING, "Got an unexpected section length - wanted " + SEC_COUNT + ", but length was " + initSections.length, @@ -363,11 +369,11 @@ public void initializeSections(ChunkSection[] initSections) { } //GlowServer.logger.log(Level.INFO, "Initializing chunk ({0},{1})", new Object[]{x, z}); - sections = new ChunkSection[SEC_COUNT]; + sections = new ChunkSection[initSections.length]; biomes = new byte[WIDTH * HEIGHT]; heightMap = new byte[WIDTH * HEIGHT]; - for (int y = 0; y < SEC_COUNT && y < initSections.length; y++) { + for (int y = 0; y < initSections.length; y++) { if (initSections[y] != null) { initializeSection(y, initSections[y]); } @@ -521,6 +527,11 @@ public BlockEntity createEntity(int cx, int cy, int cz, Material type) { * @return The ChunkSection, or null if it is empty. */ private ChunkSection getSection(int y) { + DimensionType dimensionType = DimensionTypes.getByEnvironmentId(this.getWorld().getEnvironment().getId()); + if (dimensionType.equals(DimensionTypes.OVERWORLD)) { + //Offset y by 64 since our 0th section is at y = -64 + y+=64; + } int idx = y >> 4; if (y < 0 || y >= DEPTH || !load() || idx >= sections.length) { return null; @@ -563,7 +574,7 @@ public BlockData getBlockData(int x, int z, int y) { @Deprecated public int getType(int x, int z, int y) { ChunkSection section = getSection(y); - return section == null ? 0 : section.getType(x, y, z) >> 4; + return section == null ? 0 : section.getType(x, y, z); } /** @@ -957,7 +968,9 @@ public ChunkDataMessage toMessage(boolean skylight, boolean entireChunk, if (sections != null) { // get the list of sections for (int i = 0; i < sections.length; ++i) { - sections[i].writeToBuf(buf, skylight); + if (sections[i] != null) { + sections[i].writeToBuf(buf, skylight); + } } } @@ -978,7 +991,19 @@ public ChunkDataMessage toMessage(boolean skylight, boolean entireChunk, } CompoundTag heightMap = new CompoundTag(); - heightMap.putByteArray("MOTION_BLOCKING", this.heightMap); + long actualHeightMap[] = new long[37]; + for (int i = 0; i < 37; i++) { + long mappedLong = 0; + for (int j = 0; j < 7; j++) { + if ((i * 7) + j < 256){ + mappedLong = mappedLong << 9; + mappedLong += this.heightMap[(i * 7) + j]; + } + } + actualHeightMap[i] = mappedLong << 1; + } + + heightMap.putLongArray("MOTION_BLOCKING", actualHeightMap); BitSet skyLightMask = new BitSet(); diff --git a/src/main/java/net/glowstone/chunk/GlowChunkSnapshot.java b/src/main/java/net/glowstone/chunk/GlowChunkSnapshot.java index 3dc44915c4..4bc47a8fcd 100644 --- a/src/main/java/net/glowstone/chunk/GlowChunkSnapshot.java +++ b/src/main/java/net/glowstone/chunk/GlowChunkSnapshot.java @@ -118,6 +118,11 @@ public boolean contains(@NotNull BlockData blockData) { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public boolean contains(@NotNull Biome biome) { + return false; + } + public int getBlockTypeId(int x, int y, int z) { ChunkSection section = getSection(y); return section == null ? 0 : section.getType(x, y, z) >> 4; diff --git a/src/main/java/net/glowstone/constants/ItemIds.java b/src/main/java/net/glowstone/constants/ItemIds.java index 4c8e60f15e..14ee5b3009 100644 --- a/src/main/java/net/glowstone/constants/ItemIds.java +++ b/src/main/java/net/glowstone/constants/ItemIds.java @@ -32,6 +32,7 @@ public final class ItemIds { static { // blocks + both(-1, "cave_air"); both(0, "air"); both(1, "stone"); both(2, "grass"); @@ -551,9 +552,8 @@ public static Material getBlock(String name) { if (!blocks.containsKey(name)) { return null; } - return Material.getMaterial(name); + return Material.matchMaterial(name); } - /** * Verify that a given material is a valid item. All non-blocks are valid items, but some blocks * cannot be represented as items. diff --git a/src/main/java/net/glowstone/entity/GlowCreature.java b/src/main/java/net/glowstone/entity/GlowCreature.java index 076ae9e77c..c6ccaf3ded 100644 --- a/src/main/java/net/glowstone/entity/GlowCreature.java +++ b/src/main/java/net/glowstone/entity/GlowCreature.java @@ -8,11 +8,15 @@ import net.glowstone.net.message.play.entity.EntityMetadataMessage; import net.glowstone.net.message.play.entity.SpawnEntityMessage; import net.glowstone.util.Position; +import net.kyori.adventure.util.TriState; import org.bukkit.Location; import org.bukkit.entity.Creature; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; import org.bukkit.loot.LootTable; +import org.bukkit.util.Consumer; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -97,4 +101,19 @@ public long getSeed() { public void setSeed(long seed) { } + + @Override + public @NotNull TriState getFrictionState() { + return TriState.NOT_SET; + } + + @Override + public void setFrictionState(@NotNull TriState state) { + + } + + @Override + public @NotNull T launchProjectile(@NotNull Class projectile, @Nullable Vector velocity, @Nullable Consumer function) { + return null; + } } diff --git a/src/main/java/net/glowstone/entity/GlowEntity.java b/src/main/java/net/glowstone/entity/GlowEntity.java index fc40bbedab..514095b562 100644 --- a/src/main/java/net/glowstone/entity/GlowEntity.java +++ b/src/main/java/net/glowstone/entity/GlowEntity.java @@ -39,6 +39,7 @@ import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.Block; @@ -1812,6 +1813,51 @@ public PersistentDataContainer getPersistentDataContainer() { throw new UnsupportedOperationException("Not implemented yet."); } + @Override + public boolean teleport(@NotNull Location location, @NotNull TeleportCause cause, boolean ignorePassengers, boolean dismount) { + return teleport(location, cause, ignorePassengers); + } + + @Override + public @NotNull Sound getSwimSound() { + return Sound.ENTITY_GENERIC_SWIM; + } + + @Override + public @NotNull Sound getSwimSplashSound() { + return Sound.ENTITY_GENERIC_SPLASH; + } + + @Override + public @NotNull Sound getSwimHighSpeedSplashSound() { + return Sound.ENTITY_GENERIC_SPLASH; + } + + @Override + public boolean isSneaking() { + return false; + } + + @Override + public void setSneaking(boolean sneak) { + + } + + @Override + public boolean isUnderWater() { + return false; + } + + @Override + public boolean collidesAt(@NotNull Location location) { + return false; + } + + @Override + public boolean wouldCollideUsing(org.bukkit.util.@NotNull BoundingBox boundingBox) { + return false; + } + /** * The metadata store class for entities. */ diff --git a/src/main/java/net/glowstone/entity/GlowHumanEntity.java b/src/main/java/net/glowstone/entity/GlowHumanEntity.java index 48cf99343b..e2fdb6ba90 100644 --- a/src/main/java/net/glowstone/entity/GlowHumanEntity.java +++ b/src/main/java/net/glowstone/entity/GlowHumanEntity.java @@ -23,19 +23,24 @@ import net.glowstone.util.Position; import net.glowstone.util.UuidUtils; import net.glowstone.util.nbt.CompoundTag; +import org.bukkit.FluidCollisionMode; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.Sound; +import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.InventoryView.Property; @@ -47,6 +52,7 @@ import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.Plugin; +import org.bukkit.util.RayTraceResult; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -823,4 +829,74 @@ public void setStarvationRate(int ticks) { public void setLastDeathLocation(@Nullable Location location) { } + + @Override + public @Nullable BlockFace getTargetBlockFace(int maxDistance, @NotNull FluidCollisionMode fluidMode) { + return null; + } + + @Override + public @Nullable RayTraceResult rayTraceEntities(int maxDistance, boolean ignoreBlocks) { + return null; + } + + @Override + public void setArrowsInBody(int count, boolean fireEvent) { + + } + + @Override + public @NotNull Sound getFallDamageSound(int fallHeight) { + return null; + } + + @Override + public @NotNull Sound getFallDamageSoundSmall() { + return null; + } + + @Override + public @NotNull Sound getFallDamageSoundBig() { + return null; + } + + @Override + public @NotNull Sound getDrinkingSound(@NotNull ItemStack itemStack) { + return Sound.ENTITY_GENERIC_DRINK; + } + + @Override + public @NotNull Sound getEatingSound(@NotNull ItemStack itemStack) { + return Sound.ENTITY_GENERIC_EAT; + } + + @Override + public boolean canBreatheUnderwater() { + return false; + } + + @Override + public void knockback(double strength, double directionX, double directionZ) { + + } + + @Override + public void broadcastSlotBreak(@NotNull EquipmentSlot slot) { + + } + + @Override + public void broadcastSlotBreak(@NotNull EquipmentSlot slot, @NotNull Collection players) { + + } + + @Override + public @NotNull ItemStack damageItemStack(@NotNull ItemStack stack, int amount) { + return null; + } + + @Override + public void damageItemStack(@NotNull EquipmentSlot slot, int amount) { + + } } diff --git a/src/main/java/net/glowstone/entity/GlowLivingEntity.java b/src/main/java/net/glowstone/entity/GlowLivingEntity.java index f054b9105d..ebdc54be94 100644 --- a/src/main/java/net/glowstone/entity/GlowLivingEntity.java +++ b/src/main/java/net/glowstone/entity/GlowLivingEntity.java @@ -111,6 +111,85 @@ * @author Graham Edgecombe. */ public abstract class GlowLivingEntity extends GlowEntity implements LivingEntity { + @Override + public float getBodyYaw() { + return 0; + } + + @Override + public void setBodyYaw(float bodyYaw) { + + } + + @Override + public @Nullable BlockFace getTargetBlockFace(int maxDistance, @NotNull FluidCollisionMode fluidMode) { + return null; + } + + @Override + public @Nullable RayTraceResult rayTraceEntities(int maxDistance, boolean ignoreBlocks) { + return null; + } + + @Override + public void setArrowsInBody(int count, boolean fireEvent) { + + } + + @Override + public @NotNull Sound getFallDamageSound(int fallHeight) { + return Sound.ENTITY_GENERIC_BIG_FALL; + } + + @Override + public @NotNull Sound getFallDamageSoundSmall() { + return Sound.ENTITY_GENERIC_SMALL_FALL; + } + + @Override + public @NotNull Sound getFallDamageSoundBig() { + return Sound.ENTITY_GENERIC_BIG_FALL; + } + + @Override + public @NotNull Sound getDrinkingSound(@NotNull ItemStack itemStack) { + return Sound.ENTITY_GENERIC_DRINK; + } + + @Override + public @NotNull Sound getEatingSound(@NotNull ItemStack itemStack) { + return Sound.ENTITY_GENERIC_EAT; + } + + @Override + public boolean canBreatheUnderwater() { + return false; + } + + @Override + public void knockback(double strength, double directionX, double directionZ) { + + } + + @Override + public void broadcastSlotBreak(@NotNull EquipmentSlot slot) { + + } + + @Override + public void broadcastSlotBreak(@NotNull EquipmentSlot slot, @NotNull Collection players) { + + } + + @Override + public @NotNull ItemStack damageItemStack(@NotNull ItemStack stack, int amount) { + return null; + } + + @Override + public void damageItemStack(@NotNull EquipmentSlot slot, int amount) { + + } /** * The entity's AI task manager. @@ -654,7 +733,7 @@ public boolean getCanPickupItems() { * * @return the hurt sound if available */ - protected Sound getHurtSound() { + public Sound getHurtSound() { return null; } @@ -663,7 +742,7 @@ protected Sound getHurtSound() { * * @return the death sound if available */ - protected Sound getDeathSound() { + public Sound getDeathSound() { return null; } @@ -672,7 +751,7 @@ protected Sound getDeathSound() { * * @return the ambient sound if available */ - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return null; } diff --git a/src/main/java/net/glowstone/entity/GlowPlayer.java b/src/main/java/net/glowstone/entity/GlowPlayer.java index 27f9d4561a..af44949014 100644 --- a/src/main/java/net/glowstone/entity/GlowPlayer.java +++ b/src/main/java/net/glowstone/entity/GlowPlayer.java @@ -7,9 +7,12 @@ import com.flowpowered.network.Message; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.Unpooled; +import io.papermc.paper.entity.LookAnchor; +import io.papermc.paper.entity.RelativeTeleportFlag; import lombok.Getter; import lombok.Setter; import net.glowstone.EventFactory; @@ -101,8 +104,10 @@ import net.glowstone.util.mojangson.Mojangson; import net.glowstone.util.nbt.CompoundTag; import net.glowstone.util.nbt.ListTag; +import net.glowstone.util.nbt.StringTag; import net.glowstone.util.nbt.TagType; import net.kyori.adventure.text.Component; +import net.kyori.adventure.util.TriState; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.chat.ComponentSerializer; @@ -133,6 +138,7 @@ import org.bukkit.advancement.AdvancementProgress; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; import org.bukkit.boss.BossBar; import org.bukkit.configuration.serialization.DelegateDeserialization; @@ -142,6 +148,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; +import org.bukkit.entity.FishHook; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -189,6 +196,7 @@ import org.bukkit.scoreboard.Scoreboard; import org.bukkit.util.BlockVector; import org.bukkit.util.BoundingBox; +import org.bukkit.util.Consumer; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import org.json.simple.JSONObject; @@ -598,7 +606,6 @@ public GlowPlayer(GlowSession session, GlowPlayerProfile profile, PlayerReader r invMonitor = new InventoryMonitor(getOpenInventory()); server.getPlayerStatisticIoService().readStatistics(this); recipeMonitor = new PlayerRecipeMonitor(this); - updateBossBars(); } @@ -799,21 +806,29 @@ public void join(GlowSession session, PlayerReader reader) { List chatList = new ArrayList<>(); { - CompoundTag system = new CompoundTag(); - system.putCompound("chat", new CompoundTag()); + CompoundTag chat = new CompoundTag(); + chat.putString("translation_key", ""); + chat.putCompound("style", new CompoundTag()); + chat.putList("parameters", TagType.STRING, Lists.newArrayList("sender", "target", "content"), (StringTag::new)); CompoundTag narration = new CompoundTag(); - narration.putString("priority", "system"); - system.putCompound("narration", narration); + narration.putString("translation_key", ""); + narration.putList("parameters", TagType.STRING, Lists.newArrayList("sender", "target", "content"), (StringTag::new)); + + CompoundTag element = new CompoundTag(); + element.putCompound("chat", chat); + element.putCompound("narration", narration); + + CompoundTag parent = new CompoundTag(); parent.putString("name", "minecraft:system"); parent.putInt("id", 0); - parent.putCompound("element", system); + parent.putCompound("element", element); chatList.add(parent); } - + /* { CompoundTag gameInfo = new CompoundTag(); gameInfo.putCompound("overlay", new CompoundTag()); @@ -826,11 +841,13 @@ public void join(GlowSession session, PlayerReader reader) { chatList.add(parent); } + */ + CompoundTag chatRegistry = new CompoundTag(); chatRegistry.putString("type", "minecraft:chat_type"); chatRegistry.putCompoundList("value", chatList); - registryCodecs.putCompound("minecraft:chat_typee", chatRegistry); + registryCodecs.putCompound("minecraft:chat_type", chatRegistry); } session.send(new JoinGameMessage( @@ -852,6 +869,9 @@ public void join(GlowSession session, PlayerReader reader) { world.getWorldType() == WorldType.FLAT, null )); + joinTime = System.currentTimeMillis(); + // Add player to list of online players + getServer().setPlayerOnline(this, true); // send server brand and supported plugin channels Message pluginMessage = PluginMessage.fromString("minecraft:brand", server.getName()); @@ -859,52 +879,46 @@ public void join(GlowSession session, PlayerReader reader) { session.send(pluginMessage); } sendSupportedChannels(); - joinTime = System.currentTimeMillis(); - // Add player to list of online players - getServer().setPlayerOnline(this, true); + getServer().sendPlayerAbilities(this); + // send held item + getSession().send(new HeldItemMessage(getInventory().getHeldItemSlot())); + //TODO: Update recipes and tags + //TODO: Send OP perm level + //TODO: Send commands + session.send(recipeMonitor.createInitMessage()); + // send initial location + session.send(new PositionRotationMessage(location)); + //TODO: Set center chunk + //TODO: Update light + streamBlocks(); // stream the initial set of blocks + session.send(world.getWorldBorder().createMessage()); + setCompassTarget(world.getSpawnLocation()); + //Tell client they can now load in + session.send(new PositionRotationMessage(location)); // save data back out saveData(); - streamBlocks(); // stream the initial set of blocks + //Send client all current world info + session.send(new EntityVelocityMessage(getEntityId(), velocity)); sendWeather(); sendRainDensity(); sendSkyDarkness(); - getServer().sendPlayerAbilities(this); - - // send initial location - session.send(new PositionRotationMessage(location)); - - // send initial velocity - session.send(new EntityVelocityMessage(getEntityId(), velocity)); - - // send initial health sendHealth(); - - // send gamemode defaults setGameModeDefaults(); - - // send held item - getSession().send(new HeldItemMessage(getInventory().getHeldItemSlot())); - - // send xp bar sendExperience(); - - session.send(world.getWorldBorder().createMessage()); sendTime(); - setCompassTarget(world.getSpawnLocation()); // set our compass target - - scoreboard = server.getScoreboardManager().getMainScoreboard(); - scoreboard.subscribe(this); - + // set our compass target invMonitor = new InventoryMonitor(getOpenInventory()); updateInventory(); // send inventory contents - session.send(recipeMonitor.createInitMessage()); - if (!server.getResourcePackUrl().isEmpty()) { - setResourcePack(server.getResourcePackUrl(), server.getResourcePackHash()); - } + //scoreboard = server.getScoreboardManager().getMainScoreboard(); + //scoreboard.subscribe(this); + +// if (!server.getResourcePackUrl().isEmpty()) { +// setResourcePack(server.getResourcePackUrl(), server.getResourcePackHash()); +// } } @Override @@ -1386,16 +1400,20 @@ private void spawnPlayerAt(Location location) { // spawn into world session.send(new RespawnMessage( - world.getName(), + NamespacedKey.fromString("minecraft:overworld"), + world.getKey(), world.getSeedHash(), getGameMode().getValue(), -1, false, world.getWorldType() == WorldType.FLAT, - oldWorld.getEnvironment() != world.getEnvironment() + oldWorld.getEnvironment() != world.getEnvironment(), + oldWorld.getKey(), + location )); - setRawLocation(location, false); // take us to spawn position + // take us to spawn position + setRawLocation(location, false); session.send(new PositionRotationMessage(location)); teleportedTo = location.clone(); setCompassTarget(world.getSpawnLocation()); // set our compass target @@ -1604,6 +1622,61 @@ public void setRotation(float yaw, float pitch) { } + @Override + public boolean teleport(@NotNull Location location, @NotNull TeleportCause cause, boolean ignorePassengers, boolean dismount, @NotNull RelativeTeleportFlag @NotNull ... teleportFlags) { + return false; + } + + @Override + public void lookAt(double x, double y, double z, @NotNull LookAnchor playerAnchor) { + + } + + @Override + public void lookAt(@NotNull Entity entity, @NotNull LookAnchor playerAnchor, @NotNull LookAnchor entityAnchor) { + + } + + @Override + public void showElderGuardian(boolean silent) { + + } + + @Override + public int getWardenWarningCooldown() { + return 0; + } + + @Override + public void setWardenWarningCooldown(int cooldown) { + + } + + @Override + public int getWardenTimeSinceLastWarning() { + return 0; + } + + @Override + public void setWardenTimeSinceLastWarning(int time) { + + } + + @Override + public int getWardenWarningLevel() { + return 0; + } + + @Override + public void setWardenWarningLevel(int warningLevel) { + + } + + @Override + public void increaseWardenWarningLevel() { + + } + /** * Set this player's client settings. * @@ -1982,6 +2055,16 @@ public void setAllowFlight(boolean flight) { getServer().sendPlayerAbilities(this); } + @Override + public void setFlyingFallDamage(@NotNull TriState flyingFallDamage) { + + } + + @Override + public @NotNull TriState hasFlyingFallDamage() { + return null; + } + @Override public void setFlying(boolean value) { flying = value && canFly; @@ -2269,6 +2352,11 @@ public void setStarvationRate(int i) { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public @org.jetbrains.annotations.Nullable Firework fireworkBoost(@NotNull ItemStack fireworkItemStack) { + return null; + } + private boolean shouldCalculateExhaustion() { return getGameMode() == GameMode.SURVIVAL | getGameMode() == GameMode.ADVENTURE; } @@ -2993,6 +3081,16 @@ public void sendOpLevel(byte b) { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public void addAdditionalChatCompletions(@NotNull Collection completions) { + + } + + @Override + public void removeAdditionalChatCompletions(@NotNull Collection completions) { + + } + @Override public @NotNull Set getTrackedPlayers() { throw new UnsupportedOperationException("Not supported yet."); @@ -3093,11 +3191,21 @@ public void playSound(@NotNull Entity entity, @NotNull Sound sound, float volume } + @Override + public void playSound(@NotNull Entity entity, @NotNull String sound, float volume, float pitch) { + + } + @Override public void playSound(@NotNull Entity entity, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) { } + @Override + public void playSound(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) { + + } + @Override public void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch) { @@ -3122,6 +3230,11 @@ public void stopSound(String sound, SoundCategory category) { session.send(new StopSoundMessage(category, sound)); } + @Override + public void stopSound(@NotNull SoundCategory category) { + + } + @Override public void stopAllSounds() { @@ -3189,6 +3302,11 @@ public void sendBlockChange(@NotNull Location loc, @NotNull BlockData blockData) sendBlockChange(loc, MaterialUtil.getId(blockData)); } + @Override + public void sendBlockChanges(@NotNull Collection blocks, boolean suppressLightUpdates) { + + } + private void sendBlockChange(@NotNull Location loc, int type) { sendBlockChange(new BlockChangeMessage(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), type)); } @@ -3216,6 +3334,11 @@ public void sendBlockDamage(@NotNull Location location, float v) { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public void sendBlockDamage(@NotNull Location loc, float progress, int destroyerIdentity) { + + } + @Override public void sendMultiBlockChange(@NotNull Map blockChanges, boolean suppressLightUpdates) { @@ -3226,6 +3349,11 @@ public void sendEquipmentChange(@NotNull LivingEntity entity, @NotNull Equipment } + @Override + public void sendEquipmentChange(@NotNull LivingEntity entity, @NotNull Map equipmentChanges) { + + } + @Override public void sendSignChange(@NotNull Location location, @org.jetbrains.annotations.Nullable List list) @@ -3314,6 +3442,11 @@ public void sendMap(MapView map) { mapCanvas.toSection())); } + @Override + public void showWinScreen() { + + } + @Override public void setPlayerListHeaderFooter(@Nullable String header, @Nullable String footer) { @@ -3696,6 +3829,11 @@ public boolean isDeeplySleeping() { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public @org.jetbrains.annotations.Nullable FishHook getFishHook() { + return null; + } + @Override public MainHand getMainHand() { return metadata.getByte(MetadataIndex.PLAYER_MAIN_HAND) == 0 ? MainHand.LEFT @@ -3711,6 +3849,16 @@ public boolean setWindowProperty(Property prop, int value) { return true; } + @Override + public int getEnchantmentSeed() { + return 0; + } + + @Override + public void setEnchantmentSeed(int seed) { + + } + @Override public void openInventory(InventoryView view) { session.send(new CloseWindowMessage(invMonitor.getId())); @@ -3924,7 +4072,7 @@ public void showPlayer(Player player) { } hiddenEntities.remove(player.getUniqueId()); - session.send(new UserListItemMessage(UserListItemMessage.Action.ADD_PLAYER, ((GlowPlayer) + session.send(new UserListItemMessage(Lists.newArrayList(UserListItemMessage.Action.ADD_PLAYER), ((GlowPlayer) player) .getUserListEntry())); } @@ -4319,4 +4467,33 @@ public int getOpenWindowId() { } return invMonitor.getId(); } + + @Override + public @NotNull TriState getFrictionState() { + return null; + } + + @Override + public void setFrictionState(@NotNull TriState state) { + + } + + @Override + public @NotNull T launchProjectile(@NotNull Class projectile, @org.jetbrains.annotations.Nullable Vector velocity, @org.jetbrains.annotations.Nullable Consumer function) { + return null; + } + + @Override + public boolean hasSeenWinScreen() { + return false; + } + + @Override + public void setHasSeenWinScreen(boolean hasSeenWinScreen) { + + } + + public void savePlayerData() { + world.getStorage().getPlayerDataService().writeData(this); + } } diff --git a/src/main/java/net/glowstone/entity/meta/profile/GlowPlayerProfile.java b/src/main/java/net/glowstone/entity/meta/profile/GlowPlayerProfile.java index a207cab2e7..adbf28af16 100644 --- a/src/main/java/net/glowstone/entity/meta/profile/GlowPlayerProfile.java +++ b/src/main/java/net/glowstone/entity/meta/profile/GlowPlayerProfile.java @@ -351,7 +351,7 @@ public boolean isComplete() { } @Override - public @NotNull CompletableFuture update() { + public @NotNull CompletableFuture update() { return null; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowBlaze.java b/src/main/java/net/glowstone/entity/monster/GlowBlaze.java index 5334fa2f8f..7da84839c6 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowBlaze.java +++ b/src/main/java/net/glowstone/entity/monster/GlowBlaze.java @@ -22,17 +22,17 @@ public void setOnFire(boolean onFire) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_BLAZE_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_BLAZE_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_BLAZE_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowCaveSpider.java b/src/main/java/net/glowstone/entity/monster/GlowCaveSpider.java index 9a21bcc335..222401fcf3 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowCaveSpider.java +++ b/src/main/java/net/glowstone/entity/monster/GlowCaveSpider.java @@ -13,17 +13,17 @@ public GlowCaveSpider(Location loc) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_SPIDER_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SPIDER_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_SPIDER_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowCreeper.java b/src/main/java/net/glowstone/entity/monster/GlowCreeper.java index 58913e9367..9e9aa5a4b2 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowCreeper.java +++ b/src/main/java/net/glowstone/entity/monster/GlowCreeper.java @@ -66,12 +66,12 @@ public void ignite() { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_CREEPER_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_CREEPER_HURT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowElderGuardian.java b/src/main/java/net/glowstone/entity/monster/GlowElderGuardian.java index 44d20912eb..a17a149219 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowElderGuardian.java +++ b/src/main/java/net/glowstone/entity/monster/GlowElderGuardian.java @@ -13,17 +13,17 @@ public GlowElderGuardian(Location loc) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_ELDER_GUARDIAN_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_ELDER_GUARDIAN_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_ELDER_GUARDIAN_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowEnderman.java b/src/main/java/net/glowstone/entity/monster/GlowEnderman.java index acea9c5596..efa44b8c89 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowEnderman.java +++ b/src/main/java/net/glowstone/entity/monster/GlowEnderman.java @@ -69,17 +69,17 @@ public void setHasBeenStaredAt(boolean hasBeenStaredAt) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_ENDERMAN_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_ENDERMAN_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_ENDERMAN_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowEndermite.java b/src/main/java/net/glowstone/entity/monster/GlowEndermite.java index e07e5e2866..6ec3c63feb 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowEndermite.java +++ b/src/main/java/net/glowstone/entity/monster/GlowEndermite.java @@ -23,17 +23,27 @@ public void setPlayerSpawned(boolean playerSpawned) { } @Override - protected Sound getDeathSound() { + public void setLifetimeTicks(int ticks) { + + } + + @Override + public int getLifetimeTicks() { + return 0; + } + + @Override + public Sound getDeathSound() { return Sound.ENTITY_ENDERMITE_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_ENDERMITE_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_ENDERMITE_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowEvoker.java b/src/main/java/net/glowstone/entity/monster/GlowEvoker.java index af661e6e6d..6161cb644c 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowEvoker.java +++ b/src/main/java/net/glowstone/entity/monster/GlowEvoker.java @@ -80,12 +80,12 @@ public void setCurrentSpell(Evoker.Spell spell) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_EVOKER_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_EVOKER_HURT; } @@ -96,7 +96,7 @@ public void damage(double amount, Entity source, @NotNull EntityDamageEvent.Dama } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_EVOKER_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowGhast.java b/src/main/java/net/glowstone/entity/monster/GlowGhast.java index 48b8058002..debb8eaa04 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowGhast.java +++ b/src/main/java/net/glowstone/entity/monster/GlowGhast.java @@ -20,17 +20,17 @@ public GlowGhast(Location loc) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_GHAST_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_GHAST_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_GHAST_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowGiant.java b/src/main/java/net/glowstone/entity/monster/GlowGiant.java index f84b129f07..d4264a9a5c 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowGiant.java +++ b/src/main/java/net/glowstone/entity/monster/GlowGiant.java @@ -13,7 +13,7 @@ public GlowGiant(Location loc) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_PLAYER_HURT; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowGuardian.java b/src/main/java/net/glowstone/entity/monster/GlowGuardian.java index 7ba061c919..7fb936c964 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowGuardian.java +++ b/src/main/java/net/glowstone/entity/monster/GlowGuardian.java @@ -49,17 +49,17 @@ public void setElder(boolean elder) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_GUARDIAN_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_GUARDIAN_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_GUARDIAN_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowIronGolem.java b/src/main/java/net/glowstone/entity/monster/GlowIronGolem.java index e08b625ee5..e1a8667f86 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowIronGolem.java +++ b/src/main/java/net/glowstone/entity/monster/GlowIronGolem.java @@ -29,12 +29,12 @@ public void setPlayerCreated(boolean playerCreated) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_IRON_GOLEM_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_IRON_GOLEM_HURT; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowMagmaCube.java b/src/main/java/net/glowstone/entity/monster/GlowMagmaCube.java index f667d2ae45..f44d95fc5e 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowMagmaCube.java +++ b/src/main/java/net/glowstone/entity/monster/GlowMagmaCube.java @@ -12,12 +12,12 @@ public GlowMagmaCube(Location loc) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_MAGMA_CUBE_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_MAGMA_CUBE_HURT; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowMonster.java b/src/main/java/net/glowstone/entity/monster/GlowMonster.java index 77225c77e6..d593981e18 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowMonster.java +++ b/src/main/java/net/glowstone/entity/monster/GlowMonster.java @@ -2,6 +2,7 @@ import net.glowstone.entity.GlowCreature; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.Monster; diff --git a/src/main/java/net/glowstone/entity/monster/GlowPigZombie.java b/src/main/java/net/glowstone/entity/monster/GlowPigZombie.java index 8983766395..8bfa9d2982 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowPigZombie.java +++ b/src/main/java/net/glowstone/entity/monster/GlowPigZombie.java @@ -39,17 +39,17 @@ public void setAngry(boolean angry) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_ZOMBIFIED_PIGLIN_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_ZOMBIFIED_PIGLIN_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_ZOMBIFIED_PIGLIN_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowRaider.java b/src/main/java/net/glowstone/entity/monster/GlowRaider.java index 1b668c2be3..cf33421243 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowRaider.java +++ b/src/main/java/net/glowstone/entity/monster/GlowRaider.java @@ -3,9 +3,11 @@ import lombok.Getter; import lombok.Setter; import org.bukkit.Location; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.EntityType; import org.bukkit.entity.Raider; +import org.jetbrains.annotations.NotNull; /** * A mob that can raid villages. @@ -34,4 +36,9 @@ public boolean isCelebrating() { public void setCelebrating(boolean celebrating) { } + + @Override + public @NotNull Sound getCelebrationSound() { + return Sound.ENTITY_PILLAGER_CELEBRATE; + } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowShulker.java b/src/main/java/net/glowstone/entity/monster/GlowShulker.java index 1894035951..db538e6468 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowShulker.java +++ b/src/main/java/net/glowstone/entity/monster/GlowShulker.java @@ -78,12 +78,12 @@ public void setAttachment(Location attachment) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SHULKER_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { if (getShieldHeight() == 0) { return Sound.ENTITY_SHULKER_HURT_CLOSED; } @@ -91,7 +91,7 @@ protected Sound getHurtSound() { } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_SHULKER_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowSilverfish.java b/src/main/java/net/glowstone/entity/monster/GlowSilverfish.java index f67054b841..1f49e6e859 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowSilverfish.java +++ b/src/main/java/net/glowstone/entity/monster/GlowSilverfish.java @@ -13,17 +13,17 @@ public GlowSilverfish(Location loc) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SILVERFISH_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_SILVERFISH_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_SILVERFISH_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowSkeleton.java b/src/main/java/net/glowstone/entity/monster/GlowSkeleton.java index a9a7c2dc09..4afa1f66e1 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowSkeleton.java +++ b/src/main/java/net/glowstone/entity/monster/GlowSkeleton.java @@ -33,17 +33,17 @@ public void setSkeletonType(SkeletonType type) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SKELETON_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_SKELETON_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_SKELETON_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowSlime.java b/src/main/java/net/glowstone/entity/monster/GlowSlime.java index 879dc13d1a..9e265a8062 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowSlime.java +++ b/src/main/java/net/glowstone/entity/monster/GlowSlime.java @@ -51,12 +51,12 @@ public void setWander(boolean canWander) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_SLIME_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SLIME_DEATH; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowSnowman.java b/src/main/java/net/glowstone/entity/monster/GlowSnowman.java index b5fc911a8e..ea5a096c6e 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowSnowman.java +++ b/src/main/java/net/glowstone/entity/monster/GlowSnowman.java @@ -25,17 +25,17 @@ public void setDerp(boolean derp) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SNOW_GOLEM_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_SNOW_GOLEM_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_SNOW_GOLEM_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowSpider.java b/src/main/java/net/glowstone/entity/monster/GlowSpider.java index 55f5bcba48..8cf2264302 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowSpider.java +++ b/src/main/java/net/glowstone/entity/monster/GlowSpider.java @@ -22,17 +22,17 @@ public void setClimbing(boolean climbing) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_SPIDER_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SPIDER_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_SPIDER_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowStray.java b/src/main/java/net/glowstone/entity/monster/GlowStray.java index b93ca719e9..60a9a88538 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowStray.java +++ b/src/main/java/net/glowstone/entity/monster/GlowStray.java @@ -12,17 +12,17 @@ public GlowStray(Location loc) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_STRAY_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_STRAY_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_STRAY_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowVex.java b/src/main/java/net/glowstone/entity/monster/GlowVex.java index d004afcb40..47fb539643 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowVex.java +++ b/src/main/java/net/glowstone/entity/monster/GlowVex.java @@ -45,17 +45,17 @@ public void pulse() { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_VEX_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_VEX_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_VEX_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowVindicator.java b/src/main/java/net/glowstone/entity/monster/GlowVindicator.java index dc45b36f34..87f689c6b1 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowVindicator.java +++ b/src/main/java/net/glowstone/entity/monster/GlowVindicator.java @@ -23,17 +23,17 @@ public void setJohnny(boolean johnny) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_VINDICATOR_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_VINDICATOR_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_VINDICATOR_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowWitch.java b/src/main/java/net/glowstone/entity/monster/GlowWitch.java index 26f981a526..1f604697b0 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowWitch.java +++ b/src/main/java/net/glowstone/entity/monster/GlowWitch.java @@ -34,17 +34,17 @@ public void setAggressive(boolean aggressive) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_WITCH_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_WITCH_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_WITCH_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowWither.java b/src/main/java/net/glowstone/entity/monster/GlowWither.java index 9b298d913a..6805706993 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowWither.java +++ b/src/main/java/net/glowstone/entity/monster/GlowWither.java @@ -124,17 +124,17 @@ public void pulse() { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_WITHER_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_WITHER_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_WITHER_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowWitherSkeleton.java b/src/main/java/net/glowstone/entity/monster/GlowWitherSkeleton.java index 50f9175cd5..64f4ff4cdf 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowWitherSkeleton.java +++ b/src/main/java/net/glowstone/entity/monster/GlowWitherSkeleton.java @@ -13,17 +13,17 @@ public GlowWitherSkeleton(Location loc) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_WITHER_SKELETON_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_WITHER_SKELETON_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_WITHER_SKELETON_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/monster/GlowZombie.java b/src/main/java/net/glowstone/entity/monster/GlowZombie.java index cae85e65a0..3a37972d97 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowZombie.java +++ b/src/main/java/net/glowstone/entity/monster/GlowZombie.java @@ -166,17 +166,17 @@ protected float getSoundPitch() { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_ZOMBIE_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_ZOMBIE_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_ZOMBIE_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/monster/GlowZombieVillager.java b/src/main/java/net/glowstone/entity/monster/GlowZombieVillager.java index 44093c0e24..e4eac17fab 100644 --- a/src/main/java/net/glowstone/entity/monster/GlowZombieVillager.java +++ b/src/main/java/net/glowstone/entity/monster/GlowZombieVillager.java @@ -71,17 +71,17 @@ public void setVillagerType(@NotNull Villager.Type type) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_ZOMBIE_VILLAGER_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_ZOMBIE_VILLAGER_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_ZOMBIE_VILLAGER_AMBIENT; } @@ -111,4 +111,9 @@ public void setConversionPlayer(@Nullable OfflinePlayer offlinePlayer) { conversionPlayerId = offlinePlayer.getUniqueId(); } } + + @Override + public void setConversionTime(int time, boolean broadcastEntityEvent) { + + } } diff --git a/src/main/java/net/glowstone/entity/monster/complex/GlowEnderDragon.java b/src/main/java/net/glowstone/entity/monster/complex/GlowEnderDragon.java index 70147bda24..a47a1cbb4b 100644 --- a/src/main/java/net/glowstone/entity/monster/complex/GlowEnderDragon.java +++ b/src/main/java/net/glowstone/entity/monster/complex/GlowEnderDragon.java @@ -85,12 +85,12 @@ public Set getParts() { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_ENDER_DRAGON_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_ENDER_DRAGON_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/objects/GlowArmorStand.java b/src/main/java/net/glowstone/entity/objects/GlowArmorStand.java index 9641db34d2..1b429dbc05 100644 --- a/src/main/java/net/glowstone/entity/objects/GlowArmorStand.java +++ b/src/main/java/net/glowstone/entity/objects/GlowArmorStand.java @@ -1,6 +1,7 @@ package net.glowstone.entity.objects; import com.flowpowered.network.Message; +import io.papermc.paper.math.Rotations; import net.glowstone.EventFactory; import net.glowstone.entity.GlowLivingEntity; import net.glowstone.entity.GlowPlayer; @@ -17,6 +18,7 @@ import net.glowstone.net.message.play.player.InteractEntityMessage; import net.glowstone.net.message.play.player.InteractEntityMessage.Action; import net.glowstone.util.InventoryUtil; +import net.kyori.adventure.util.TriState; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -37,8 +39,11 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.Criterias; import org.bukkit.scoreboard.Objective; +import org.bukkit.util.Consumer; import org.bukkit.util.EulerAngle; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Arrays; import java.util.Collections; @@ -610,6 +615,66 @@ public boolean isSlotDisabled(EquipmentSlot equipmentSlot) { throw new UnsupportedOperationException("Not implemented yet."); } + @Override + public @NotNull Rotations getBodyRotations() { + return null; + } + + @Override + public void setBodyRotations(@NotNull Rotations rotations) { + + } + + @Override + public @NotNull Rotations getLeftArmRotations() { + return null; + } + + @Override + public void setLeftArmRotations(@NotNull Rotations rotations) { + + } + + @Override + public @NotNull Rotations getRightArmRotations() { + return null; + } + + @Override + public void setRightArmRotations(@NotNull Rotations rotations) { + + } + + @Override + public @NotNull Rotations getLeftLegRotations() { + return null; + } + + @Override + public void setLeftLegRotations(@NotNull Rotations rotations) { + + } + + @Override + public @NotNull Rotations getRightLegRotations() { + return null; + } + + @Override + public void setRightLegRotations(@NotNull Rotations rotations) { + + } + + @Override + public @NotNull Rotations getHeadRotations() { + return null; + } + + @Override + public void setHeadRotations(@NotNull Rotations rotations) { + + } + @Override public void addEquipmentLock(@NotNull EquipmentSlot equipmentSlot, @NotNull LockType lockType) { // TODO: 1.16 @@ -634,4 +699,19 @@ public boolean hasEquipmentLock(@NotNull EquipmentSlot equipmentSlot, public EntityEquipment getEquipment() { return this.equipment; } + + @Override + public @NotNull TriState getFrictionState() { + return null; + } + + @Override + public void setFrictionState(@NotNull TriState state) { + + } + + @Override + public @NotNull T launchProjectile(@NotNull Class projectile, @Nullable Vector velocity, @Nullable Consumer function) { + return null; + } } diff --git a/src/main/java/net/glowstone/entity/objects/GlowBoat.java b/src/main/java/net/glowstone/entity/objects/GlowBoat.java index 63356413fb..d5df9f6af0 100644 --- a/src/main/java/net/glowstone/entity/objects/GlowBoat.java +++ b/src/main/java/net/glowstone/entity/objects/GlowBoat.java @@ -163,6 +163,16 @@ public void setWoodType(TreeSpecies treeSpecies) { metadata.set(MetadataIndex.BOAT_TYPE, this.woodType.ordinal()); } + @Override + public @NotNull Type getBoatType() { + return null; + } + + @Override + public void setBoatType(@NotNull Type type) { + + } + @Override public double getMaxSpeed() { return 0.4; @@ -203,6 +213,11 @@ public void setWorkOnLand(boolean workOnLand) { this.workOnLand = workOnLand; } + @Override + public @NotNull Status getStatus() { + return null; + } + @Override public @NotNull Material getBoatMaterial() { switch (this.woodType) { diff --git a/src/main/java/net/glowstone/entity/objects/GlowItem.java b/src/main/java/net/glowstone/entity/objects/GlowItem.java index 2cdb1eaf82..62179f1d16 100644 --- a/src/main/java/net/glowstone/entity/objects/GlowItem.java +++ b/src/main/java/net/glowstone/entity/objects/GlowItem.java @@ -14,6 +14,7 @@ import net.glowstone.net.message.play.entity.SpawnEntityMessage; import net.glowstone.util.InventoryUtil; import net.glowstone.util.TickUtil; +import net.kyori.adventure.util.TriState; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -256,4 +257,14 @@ public boolean canPlayerPickup() { public boolean willAge() { return willAge; } + + @Override + public @NotNull TriState getFrictionState() { + return TriState.NOT_SET; + } + + @Override + public void setFrictionState(@NotNull TriState state) { + + } } diff --git a/src/main/java/net/glowstone/entity/objects/GlowMinecart.java b/src/main/java/net/glowstone/entity/objects/GlowMinecart.java index b44944264b..8abc49bbfb 100644 --- a/src/main/java/net/glowstone/entity/objects/GlowMinecart.java +++ b/src/main/java/net/glowstone/entity/objects/GlowMinecart.java @@ -320,6 +320,16 @@ public static class Explosive extends GlowMinecart implements ExplosiveMinecart public Explosive(Location location) { super(location, MinecartType.TNT); } + + @Override + public void setFuseTicks(int fuseTicks) { + + } + + @Override + public int getFuseTicks() { + return 0; + } } public static class Hopper extends GlowMinecart implements HopperMinecart { @@ -424,6 +434,16 @@ public long getSeed() { public void setSeed(long seed) { } + + @Override + public int getPickupCooldown() { + return 0; + } + + @Override + public void setPickupCooldown(int cooldown) { + + } } public static class Spawner extends GlowMinecart implements SpawnerMinecart { diff --git a/src/main/java/net/glowstone/entity/passive/GlowBat.java b/src/main/java/net/glowstone/entity/passive/GlowBat.java index 1b6256587d..ceace63159 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowBat.java +++ b/src/main/java/net/glowstone/entity/passive/GlowBat.java @@ -8,11 +8,17 @@ import net.glowstone.net.message.play.entity.EntityMetadataMessage; import net.glowstone.net.message.play.entity.SpawnEntityMessage; import net.glowstone.util.Position; +import net.kyori.adventure.util.TriState; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Bat; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.util.Consumer; +import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.LinkedList; import java.util.List; @@ -48,23 +54,33 @@ public void setAwake(boolean isAwake) { metadata.setBit(MetadataIndex.BAT_FLAGS, MetadataIndex.BatFlags.IS_HANGING, !isAwake); } + @Override + public @Nullable Location getTargetLocation() { + return null; + } + + @Override + public void setTargetLocation(@Nullable Location location) { + + } + @Override public EntityType getType() { return EntityType.BAT; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_BAT_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_BAT_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_BAT_AMBIENT; } @@ -77,4 +93,19 @@ public LivingEntity getTarget() { public void setTarget(LivingEntity target) { throw new UnsupportedOperationException("Not implemented yet."); } + + @Override + public @NotNull TriState getFrictionState() { + return null; + } + + @Override + public void setFrictionState(@NotNull TriState state) { + + } + + @Override + public @NotNull T launchProjectile(@NotNull Class projectile, @Nullable Vector velocity, @Nullable Consumer function) { + return null; + } } diff --git a/src/main/java/net/glowstone/entity/passive/GlowChicken.java b/src/main/java/net/glowstone/entity/passive/GlowChicken.java index aa8bf71ede..e5cbfcb741 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowChicken.java +++ b/src/main/java/net/glowstone/entity/passive/GlowChicken.java @@ -57,17 +57,17 @@ public void pulse() { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_CHICKEN_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_CHICKEN_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_CHICKEN_AMBIENT; } @@ -75,4 +75,9 @@ protected Sound getAmbientSound() { public Set getBreedingFoods() { return BREEDING_FOODS; } + + @Override + public void setIsChickenJockey(boolean isChickenJockey) { + + } } diff --git a/src/main/java/net/glowstone/entity/passive/GlowCow.java b/src/main/java/net/glowstone/entity/passive/GlowCow.java index 52ba74bd1d..af761d6316 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowCow.java +++ b/src/main/java/net/glowstone/entity/passive/GlowCow.java @@ -60,17 +60,17 @@ public boolean entityInteract(GlowPlayer player, InteractEntityMessage message) } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_COW_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_COW_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_COW_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowDonkey.java b/src/main/java/net/glowstone/entity/passive/GlowDonkey.java index f762975947..f988828f27 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowDonkey.java +++ b/src/main/java/net/glowstone/entity/passive/GlowDonkey.java @@ -13,17 +13,17 @@ public GlowDonkey(Location location) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_DONKEY_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_DONKEY_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_DONKEY_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowFirework.java b/src/main/java/net/glowstone/entity/passive/GlowFirework.java index d63ee637d4..28cf7fa4c1 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowFirework.java +++ b/src/main/java/net/glowstone/entity/passive/GlowFirework.java @@ -119,6 +119,36 @@ public void setFireworkMeta(FireworkMeta fireworkMeta) { this.lifeTime = calculateLifeTime(fireworkMeta.getPower()); } + @Override + public boolean setAttachedTo(@Nullable LivingEntity entity) { + return false; + } + + @Override + public @Nullable LivingEntity getAttachedTo() { + return null; + } + + @Override + public boolean setLife(int ticks) { + return false; + } + + @Override + public int getLife() { + return 0; + } + + @Override + public boolean setMaxLife(int ticks) { + return false; + } + + @Override + public int getMaxLife() { + return 0; + } + /** * Get the underlying firework item. * @@ -158,6 +188,11 @@ public void detonate() { setTicksLived(lifeTime); } + @Override + public boolean isDetonated() { + return false; + } + @Override public @NotNull ItemStack getItem() { return null; @@ -301,4 +336,39 @@ public boolean doesBounce() { public void setBounce(boolean doesBounce) { // deprecated, does not do anything } + + @Override + public boolean hasLeftShooter() { + return false; + } + + @Override + public void setHasLeftShooter(boolean leftShooter) { + + } + + @Override + public boolean hasBeenShot() { + return false; + } + + @Override + public void setHasBeenShot(boolean beenShot) { + + } + + @Override + public boolean canHitEntity(@NotNull Entity entity) { + return false; + } + + @Override + public void hitEntity(@NotNull Entity entity) { + + } + + @Override + public void hitEntity(@NotNull Entity entity, @NotNull Vector vector) { + + } } diff --git a/src/main/java/net/glowstone/entity/passive/GlowFishingHook.java b/src/main/java/net/glowstone/entity/passive/GlowFishingHook.java index 599016ee77..efe3ad1fb1 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowFishingHook.java +++ b/src/main/java/net/glowstone/entity/passive/GlowFishingHook.java @@ -140,6 +140,26 @@ public void setShooter(ProjectileSource shooter) { } } + @Override + public boolean hasLeftShooter() { + return false; + } + + @Override + public void setHasLeftShooter(boolean leftShooter) { + + } + + @Override + public boolean hasBeenShot() { + return false; + } + + @Override + public void setHasBeenShot(boolean beenShot) { + + } + private int calculateLifeTime() { // Waiting time is 5-45 seconds int lifeTime = ThreadLocalRandom.current().nextInt(MINIMUM_BASE_WAIT, MAXIMUM_WAIT + 1); diff --git a/src/main/java/net/glowstone/entity/passive/GlowHorse.java b/src/main/java/net/glowstone/entity/passive/GlowHorse.java index 2a4d1ce869..8a97465cda 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowHorse.java +++ b/src/main/java/net/glowstone/entity/passive/GlowHorse.java @@ -128,17 +128,17 @@ private int getHorseArmorData() { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_HORSE_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_HORSE_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_HORSE_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowLlama.java b/src/main/java/net/glowstone/entity/passive/GlowLlama.java index 3155a02ee0..164f10ba26 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowLlama.java +++ b/src/main/java/net/glowstone/entity/passive/GlowLlama.java @@ -11,6 +11,8 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Llama; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.Map; import java.util.Set; @@ -65,17 +67,47 @@ public void setStrength(int strength) { } @Override - protected Sound getDeathSound() { + public boolean inCaravan() { + return false; + } + + @Override + public void joinCaravan(@NotNull Llama llama) { + + } + + @Override + public void leaveCaravan() { + + } + + @Override + public @Nullable Llama getCaravanHead() { + return null; + } + + @Override + public boolean hasCaravanTail() { + return false; + } + + @Override + public @Nullable Llama getCaravanTail() { + return null; + } + + @Override + public Sound getDeathSound() { return Sound.ENTITY_LLAMA_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_LLAMA_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_LLAMA_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowMooshroom.java b/src/main/java/net/glowstone/entity/passive/GlowMooshroom.java index 907ae16492..7fb8048512 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowMooshroom.java +++ b/src/main/java/net/glowstone/entity/passive/GlowMooshroom.java @@ -9,6 +9,8 @@ import org.bukkit.Sound; import org.bukkit.entity.EntityType; import org.bukkit.entity.MushroomCow; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.Nullable; import java.util.Set; @@ -25,17 +27,17 @@ public GlowMooshroom(Location location) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_COW_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_COW_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_COW_AMBIENT; } @@ -43,4 +45,24 @@ protected Sound getAmbientSound() { public Set getBreedingFoods() { return BREEDING_FOODS; } + + @Override + public int getStewEffectDuration() { + return 0; + } + + @Override + public void setStewEffectDuration(int duration) { + + } + + @Override + public @Nullable PotionEffectType getStewEffectType() { + return null; + } + + @Override + public void setStewEffect(@Nullable PotionEffectType type) { + + } } diff --git a/src/main/java/net/glowstone/entity/passive/GlowMule.java b/src/main/java/net/glowstone/entity/passive/GlowMule.java index 717d476c49..17eaff9043 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowMule.java +++ b/src/main/java/net/glowstone/entity/passive/GlowMule.java @@ -18,17 +18,17 @@ public boolean canBreed() { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_MULE_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_MULE_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_MULE_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowOcelot.java b/src/main/java/net/glowstone/entity/passive/GlowOcelot.java index 3b67792659..eb550c83ce 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowOcelot.java +++ b/src/main/java/net/glowstone/entity/passive/GlowOcelot.java @@ -56,17 +56,17 @@ public void setOwner(AnimalTamer animalTamer) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_CAT_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_CAT_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_CAT_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowParrot.java b/src/main/java/net/glowstone/entity/passive/GlowParrot.java index bf7067a730..330179b978 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowParrot.java +++ b/src/main/java/net/glowstone/entity/passive/GlowParrot.java @@ -58,6 +58,11 @@ public void setVariant(Variant variant) { metadata.set(MetadataIndex.PARROT_VARIANT, variant.ordinal()); } + @Override + public boolean isDancing() { + return false; + } + public LivingEntity getImitatedEntity() { return null; } @@ -142,17 +147,17 @@ && fireEntityTameEvent(player)) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_PARROT_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_PARROT_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_PARROT_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowPig.java b/src/main/java/net/glowstone/entity/passive/GlowPig.java index 9429826249..32bf982b06 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowPig.java +++ b/src/main/java/net/glowstone/entity/passive/GlowPig.java @@ -80,17 +80,17 @@ public boolean entityInteract(GlowPlayer player, InteractEntityMessage message) } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_PIG_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_PIG_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_PIG_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowPolarBear.java b/src/main/java/net/glowstone/entity/passive/GlowPolarBear.java index 9682292534..83f4d29387 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowPolarBear.java +++ b/src/main/java/net/glowstone/entity/passive/GlowPolarBear.java @@ -23,17 +23,17 @@ public void setStanding(boolean standing) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_POLAR_BEAR_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_POLAR_BEAR_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_POLAR_BEAR_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/passive/GlowRabbit.java b/src/main/java/net/glowstone/entity/passive/GlowRabbit.java index d5c589b3e0..8268304bb2 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowRabbit.java +++ b/src/main/java/net/glowstone/entity/passive/GlowRabbit.java @@ -57,17 +57,27 @@ public void setRabbitType(Type type) { } @Override - protected Sound getHurtSound() { + public void setMoreCarrotTicks(int ticks) { + + } + + @Override + public int getMoreCarrotTicks() { + return 0; + } + + @Override + public Sound getHurtSound() { return Sound.ENTITY_RABBIT_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_RABBIT_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_RABBIT_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowSheep.java b/src/main/java/net/glowstone/entity/passive/GlowSheep.java index 1c160453b2..06be129657 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowSheep.java +++ b/src/main/java/net/glowstone/entity/passive/GlowSheep.java @@ -211,17 +211,17 @@ public void pulse() { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_SHEEP_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SHEEP_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_SHEEP_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowSkeletonHorse.java b/src/main/java/net/glowstone/entity/passive/GlowSkeletonHorse.java index d552b9c621..e20e5e0e60 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowSkeletonHorse.java +++ b/src/main/java/net/glowstone/entity/passive/GlowSkeletonHorse.java @@ -12,17 +12,17 @@ public GlowSkeletonHorse(Location location) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_SKELETON_HORSE_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SKELETON_HORSE_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_SKELETON_HORSE_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowSquid.java b/src/main/java/net/glowstone/entity/passive/GlowSquid.java index 41393892ae..421bcf185e 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowSquid.java +++ b/src/main/java/net/glowstone/entity/passive/GlowSquid.java @@ -14,17 +14,17 @@ public GlowSquid(Location location) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_SQUID_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_SQUID_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_SQUID_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/passive/GlowVillager.java b/src/main/java/net/glowstone/entity/passive/GlowVillager.java index a9a5fd3440..41a2aa0444 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowVillager.java +++ b/src/main/java/net/glowstone/entity/passive/GlowVillager.java @@ -172,6 +172,16 @@ public void setVillagerExperience(int i) { throw new UnsupportedOperationException(); } + @Override + public boolean increaseLevel(int amount) { + return false; + } + + @Override + public boolean addTrades(int amount) { + return false; + } + @Override public int getRestocksToday() { throw new UnsupportedOperationException(); @@ -339,17 +349,17 @@ private void sendRecipes(GlowMerchantInventory inventory, GlowPlayer player) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_VILLAGER_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_VILLAGER_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_VILLAGER_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowWolf.java b/src/main/java/net/glowstone/entity/passive/GlowWolf.java index 6412442372..7dc68b154f 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowWolf.java +++ b/src/main/java/net/glowstone/entity/passive/GlowWolf.java @@ -73,6 +73,16 @@ public void setCollarColor(DyeColor color) { metadata.set(MetadataIndex.WOLF_COLOR, color.getDyeData()); } + @Override + public boolean isWet() { + return false; + } + + @Override + public float getTailAngle() { + return 0; + } + @Override public void setInterested(boolean interested) { @@ -166,17 +176,17 @@ public void setHealth(double health) { } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_WOLF_HURT; } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_WOLF_DEATH; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_WOLF_AMBIENT; } diff --git a/src/main/java/net/glowstone/entity/passive/GlowZombieHorse.java b/src/main/java/net/glowstone/entity/passive/GlowZombieHorse.java index 3624f8b4eb..0838f0173a 100644 --- a/src/main/java/net/glowstone/entity/passive/GlowZombieHorse.java +++ b/src/main/java/net/glowstone/entity/passive/GlowZombieHorse.java @@ -12,17 +12,17 @@ public GlowZombieHorse(Location location) { } @Override - protected Sound getDeathSound() { + public Sound getDeathSound() { return Sound.ENTITY_ZOMBIE_HORSE_DEATH; } @Override - protected Sound getHurtSound() { + public Sound getHurtSound() { return Sound.ENTITY_ZOMBIE_HORSE_HURT; } @Override - protected Sound getAmbientSound() { + public Sound getAmbientSound() { return Sound.ENTITY_ZOMBIE_HORSE_AMBIENT; } } diff --git a/src/main/java/net/glowstone/entity/projectile/GlowArrow.java b/src/main/java/net/glowstone/entity/projectile/GlowArrow.java index 8173b1e8d8..5bd25f29a3 100644 --- a/src/main/java/net/glowstone/entity/projectile/GlowArrow.java +++ b/src/main/java/net/glowstone/entity/projectile/GlowArrow.java @@ -9,6 +9,7 @@ import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.entity.Arrow; import org.bukkit.entity.Entity; @@ -195,6 +196,26 @@ public void setShotFromCrossbow(boolean b) { return new ItemStack(Material.ARROW); } + @Override + public void setLifetimeTicks(int ticks) { + + } + + @Override + public int getLifetimeTicks() { + return 0; + } + + @Override + public @NotNull Sound getHitSound() { + return Sound.ENTITY_ARROW_HIT; + } + + @Override + public void setHitSound(@NotNull Sound sound) { + + } + @Override public void setNoPhysics(boolean noPhysics) { diff --git a/src/main/java/net/glowstone/entity/projectile/GlowLingeringPotion.java b/src/main/java/net/glowstone/entity/projectile/GlowLingeringPotion.java index 6f56165822..7237296184 100644 --- a/src/main/java/net/glowstone/entity/projectile/GlowLingeringPotion.java +++ b/src/main/java/net/glowstone/entity/projectile/GlowLingeringPotion.java @@ -43,4 +43,9 @@ private void createEffectCloud() { } remove(); } + + @Override + public void splash() { + + } } diff --git a/src/main/java/net/glowstone/entity/projectile/GlowProjectile.java b/src/main/java/net/glowstone/entity/projectile/GlowProjectile.java index 4509a879f4..36fa7559d7 100644 --- a/src/main/java/net/glowstone/entity/projectile/GlowProjectile.java +++ b/src/main/java/net/glowstone/entity/projectile/GlowProjectile.java @@ -18,6 +18,7 @@ import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; +import org.jetbrains.annotations.NotNull; import java.util.Arrays; import java.util.List; @@ -28,6 +29,25 @@ * with other entities. */ public abstract class GlowProjectile extends GlowEntity implements Projectile { + @Override + public boolean hasLeftShooter() { + return false; + } + + @Override + public void setHasLeftShooter(boolean leftShooter) { + + } + + @Override + public boolean hasBeenShot() { + return true; + } + + @Override + public void setHasBeenShot(boolean beenShot) { + + } @Getter @Setter @@ -121,4 +141,19 @@ public boolean doesBounce() { public void setBounce(boolean doesBounce) { // deprecated, does not do anything } + + @Override + public void hitEntity(@NotNull Entity entity, @NotNull Vector vector) { + //TODO: implement + } + + @Override + public boolean canHitEntity(@NotNull Entity entity) { + return false; + } + + @Override + public void hitEntity(@NotNull Entity entity) { + + } } diff --git a/src/main/java/net/glowstone/entity/projectile/GlowSplashPotion.java b/src/main/java/net/glowstone/entity/projectile/GlowSplashPotion.java index c75cb32eee..24f9e0b8da 100644 --- a/src/main/java/net/glowstone/entity/projectile/GlowSplashPotion.java +++ b/src/main/java/net/glowstone/entity/projectile/GlowSplashPotion.java @@ -102,4 +102,9 @@ public Collection getEffects() { public void setPotionMeta(@NotNull PotionMeta meta) { } + + @Override + public void splash() { + + } } diff --git a/src/main/java/net/glowstone/inventory/GlowMetaSkull.java b/src/main/java/net/glowstone/inventory/GlowMetaSkull.java index 6a517f9968..397d9f05fd 100644 --- a/src/main/java/net/glowstone/inventory/GlowMetaSkull.java +++ b/src/main/java/net/glowstone/inventory/GlowMetaSkull.java @@ -4,10 +4,12 @@ import net.glowstone.GlowOfflinePlayer; import net.glowstone.GlowServer; import net.glowstone.ServerProvider; +import net.glowstone.block.data.BlockDataManager; import net.glowstone.entity.GlowPlayer; import net.glowstone.entity.meta.profile.GlowPlayerProfile; import net.glowstone.util.nbt.CompoundTag; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.OfflinePlayer; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; @@ -176,6 +178,16 @@ public void setOwnerProfile(org.bukkit.profile.@Nullable PlayerProfile profile) owner.set((GlowPlayerProfile) profile); } + @Override + public void setNoteBlockSound(@Nullable NamespacedKey noteBlockSound) { + + } + + @Override + public @Nullable NamespacedKey getNoteBlockSound() { + return NamespacedKey.fromString("minecraft:guitar"); + } + private boolean setOwningPlayerInternal(OfflinePlayer owningPlayer) { if (owningPlayer instanceof GlowOfflinePlayer) { GlowOfflinePlayer impl = (GlowOfflinePlayer) owningPlayer; diff --git a/src/main/java/net/glowstone/io/nbt/NbtSerialization.java b/src/main/java/net/glowstone/io/nbt/NbtSerialization.java index 62a0b26cbf..cf27878513 100644 --- a/src/main/java/net/glowstone/io/nbt/NbtSerialization.java +++ b/src/main/java/net/glowstone/io/nbt/NbtSerialization.java @@ -90,7 +90,7 @@ public static CompoundTag writeItem(ItemStack stack, int slot) { public static BlockData readBlockData(CompoundTag tag) { NamespacedKey key = namespacedKeyFromString(tag.getString("Name")); - Material type = Material.getMaterial(key.toString()); + Material type = Material.matchMaterial(key.toString()); Optional properties = tag.tryGetCompound("Properties"); return Bukkit.getServer().createBlockData(type); } @@ -112,6 +112,9 @@ public static CompoundTag writeBlockData(BlockData blockData) { */ public static ItemStack[] readInventory(List tagList, int start, int size) { ItemStack[] items = new ItemStack[size]; + Arrays.setAll(items, (index) -> { + return new ItemStack(Material.AIR); + }); for (CompoundTag tag : tagList) { tag.readByte("Slot", slot -> { if (slot >= start && slot < start + size) { diff --git a/src/main/java/net/glowstone/net/GlowBufUtils.java b/src/main/java/net/glowstone/net/GlowBufUtils.java index 1bd8e53077..3eff500075 100644 --- a/src/main/java/net/glowstone/net/GlowBufUtils.java +++ b/src/main/java/net/glowstone/net/GlowBufUtils.java @@ -125,7 +125,7 @@ public static void writeMetadata(ByteBuf buf, List entries) throws IOExce int type = index.getType().getId(); int id = index.getIndex(); - System.out.println("Metadata: " + id + " " + type); + //System.out.println("Metadata: " + id + " " + type); buf.writeByte(id); ByteBufUtils.writeVarInt(buf, type); @@ -139,7 +139,6 @@ public static void writeMetadata(ByteBuf buf, List entries) throws IOExce continue; } } - writeValue(buf, value, index.getType()); } @@ -446,7 +445,7 @@ public static void writeBitSet(ByteBuf buf, BitSet bitSet) { @SneakyThrows public static NamespacedKey readNamespacedKey(ByteBuf buf) { String raw = ByteBufUtils.readUTF8(buf); - return NamespacedKey.fromString(ByteBufUtils.readUTF8(buf)); + return NamespacedKey.fromString(raw); } @SneakyThrows diff --git a/src/main/java/net/glowstone/net/GlowSession.java b/src/main/java/net/glowstone/net/GlowSession.java index 0e414c26a3..977fe07f62 100644 --- a/src/main/java/net/glowstone/net/GlowSession.java +++ b/src/main/java/net/glowstone/net/GlowSession.java @@ -6,6 +6,7 @@ import com.flowpowered.network.MessageHandler; import com.flowpowered.network.protocol.AbstractProtocol; import com.flowpowered.network.session.BasicSession; +import com.google.common.collect.Lists; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; @@ -293,12 +294,12 @@ public void setPlayer(GlowPlayerProfile profile) { + UuidUtils.toString(player.getUniqueId())); // message and user list - String message = EventFactory.getInstance().onPlayerJoin(player).getJoinMessage(); + String message = EventFactory.getInstance().onPlayerJoin(player).joinMessage().examinableName(); if (message != null && !message.isEmpty()) { server.broadcastMessage(message); } - Message addMessage = new UserListItemMessage(Action.ADD_PLAYER, player.getUserListEntry()); + Message addMessage = new UserListItemMessage(Lists.newArrayList(Action.ADD_PLAYER), player.getUserListEntry()); List entries = new ArrayList<>(); for (GlowPlayer other : server.getRawOnlinePlayers()) { if (other != player && other.canSee(player)) { @@ -308,7 +309,7 @@ public void setPlayer(GlowPlayerProfile profile) { entries.add(other.getUserListEntry()); } } - send(new UserListItemMessage(Action.ADD_PLAYER, entries)); + send(new UserListItemMessage(Lists.newArrayList(Action.ADD_PLAYER), entries)); send(server.createAdvancementsMessage(false, Collections.emptyList(), player)); } @@ -320,8 +321,8 @@ public ChannelFuture sendWithFuture(Message message) { } // Useful for debugging packet sends // TODO: config option? - // Throwable trace = new Throwable(); - // return super.sendWithFuture(message).addListener(f -> GlowServer.logger.log(Level.INFO, "Message sent: " + message.toString() + " to " + this, trace)); + //Throwable trace = new Throwable(); + //return super.sendWithFuture(message).addListener(f -> GlowServer.logger.log(Level.INFO, "Message sent: " + message.toString() + " to " + this, trace)); return super.sendWithFuture(message); } @@ -491,7 +492,7 @@ private void finalizeLogin(GlowPlayerProfile profile) { } // send login response - send(new LoginSuccessMessage(profile.getId(), profile.getName())); + send(new LoginSuccessMessage(profile.getId(), profile.getName(), new ArrayList())); setProtocol(protocolProvider.play); } diff --git a/src/main/java/net/glowstone/net/codec/play/game/ClientSettingsCodec.java b/src/main/java/net/glowstone/net/codec/play/game/ClientSettingsCodec.java index ed4ea3206c..1e5b309e0c 100644 --- a/src/main/java/net/glowstone/net/codec/play/game/ClientSettingsCodec.java +++ b/src/main/java/net/glowstone/net/codec/play/game/ClientSettingsCodec.java @@ -17,7 +17,9 @@ public ClientSettingsMessage decode(ByteBuf buf) throws IOException { boolean colors = buf.readBoolean(); int skinFlags = buf.readUnsignedByte(); int hand = ByteBufUtils.readVarInt(buf); - return new ClientSettingsMessage(locale, viewDistance, chatFlags, colors, skinFlags, hand); + boolean textFiltering = buf.readBoolean(); + boolean serverListing = buf.readBoolean(); + return new ClientSettingsMessage(locale, viewDistance, chatFlags, colors, skinFlags, hand, textFiltering, serverListing); } @Override @@ -28,6 +30,8 @@ public ByteBuf encode(ByteBuf buf, ClientSettingsMessage message) throws IOExcep buf.writeBoolean(message.isChatColors()); buf.writeByte(message.getSkinFlags()); ByteBufUtils.writeVarInt(buf, message.getHand()); + buf.writeBoolean(message.isTextFilteringEnabled()); + buf.writeBoolean(message.isServerListingEnables()); return buf; } } diff --git a/src/main/java/net/glowstone/net/codec/play/game/PluginMessageCodec.java b/src/main/java/net/glowstone/net/codec/play/game/PluginMessageCodec.java index a684e0c4ef..3fa6455b1a 100644 --- a/src/main/java/net/glowstone/net/codec/play/game/PluginMessageCodec.java +++ b/src/main/java/net/glowstone/net/codec/play/game/PluginMessageCodec.java @@ -4,6 +4,7 @@ import com.flowpowered.network.util.ByteBufUtils; import io.netty.buffer.ByteBuf; import net.glowstone.net.message.play.game.PluginMessage; +import net.glowstone.net.message.play.game.PluginMessage; import java.io.IOException; diff --git a/src/main/java/net/glowstone/net/codec/play/game/RespawnCodec.java b/src/main/java/net/glowstone/net/codec/play/game/RespawnCodec.java index 83b6bd394d..386e212fa0 100644 --- a/src/main/java/net/glowstone/net/codec/play/game/RespawnCodec.java +++ b/src/main/java/net/glowstone/net/codec/play/game/RespawnCodec.java @@ -2,9 +2,13 @@ import com.flowpowered.network.Codec; import io.netty.buffer.ByteBuf; +import net.glowstone.net.GlowBufUtils; import net.glowstone.net.message.play.game.RespawnMessage; +import net.glowstone.util.Position; import net.glowstone.util.nbt.CompoundTag; +import org.bukkit.Location; +import javax.naming.OperationNotSupportedException; import java.io.IOException; import static com.flowpowered.network.util.ByteBufUtils.readUTF8; @@ -16,6 +20,8 @@ public final class RespawnCodec implements Codec { @Override public RespawnMessage decode(ByteBuf buf) throws IOException { + throw new RuntimeException("Decoding RespawnMessages Unsupported"); + /** CompoundTag dimension = readCompound(buf); String world = readUTF8(buf); byte[] seedHash = new byte[8]; @@ -26,20 +32,25 @@ public RespawnMessage decode(ByteBuf buf) throws IOException { boolean flat = buf.readBoolean(); boolean copyMetadata = buf.readBoolean(); return new RespawnMessage(world, seedHash, mode, previousMode, debug, flat, copyMetadata); + **/ } @Override public ByteBuf encode(ByteBuf buf, RespawnMessage message) throws IOException { - // TODO: Encode dimension data (1.15+) - CompoundTag dimension = new CompoundTag(); - writeCompound(buf, dimension); - writeUTF8(buf, message.getWorld()); + GlowBufUtils.writeNamespacedKey(buf, message.getDimName()); + GlowBufUtils.writeNamespacedKey(buf, message.getDimType()); buf.writeBytes(message.getSeedHash(), 0, 8); - buf.writeByte(message.getMode()); - buf.writeByte(message.getPreviousMode()); + buf.writeByte(message.getGamemode()); + buf.writeByte(message.getPreviousGamemode()); buf.writeBoolean(message.isDebug()); buf.writeBoolean(message.isFlat()); buf.writeBoolean(message.isCopyMetadata()); + boolean writeDeathInfo = message.getDeathDimName() != null; + buf.writeBoolean(writeDeathInfo); + if (writeDeathInfo) { + GlowBufUtils.writeNamespacedKey(buf, message.getDimType()); + GlowBufUtils.writeBlockPosition(buf, message.getDeathPosition().toVector()); + } return buf; } } diff --git a/src/main/java/net/glowstone/net/codec/play/game/StateChangeCodec.java b/src/main/java/net/glowstone/net/codec/play/game/StateChangeCodec.java index e11b6ccb65..f808842a52 100644 --- a/src/main/java/net/glowstone/net/codec/play/game/StateChangeCodec.java +++ b/src/main/java/net/glowstone/net/codec/play/game/StateChangeCodec.java @@ -10,7 +10,7 @@ public final class StateChangeCodec implements Codec { @Override public StateChangeMessage decode(ByteBuf buffer) throws IOException { - int reason = buffer.readByte(); + int reason = buffer.readUnsignedByte(); float value = buffer.readFloat(); return new StateChangeMessage(reason, value); diff --git a/src/main/java/net/glowstone/net/codec/play/game/UserListItemCodec.java b/src/main/java/net/glowstone/net/codec/play/game/UserListItemCodec.java index 8c239e9783..35b2959e2e 100644 --- a/src/main/java/net/glowstone/net/codec/play/game/UserListItemCodec.java +++ b/src/main/java/net/glowstone/net/codec/play/game/UserListItemCodec.java @@ -11,6 +11,8 @@ import net.glowstone.net.message.play.game.UserListItemMessage.Entry; import java.io.IOException; +import java.util.BitSet; +import java.util.Collections; import java.util.List; public final class UserListItemCodec implements Codec { @@ -22,72 +24,64 @@ public UserListItemMessage decode(ByteBuf buf) throws IOException { @Override public ByteBuf encode(ByteBuf buf, UserListItemMessage message) throws IOException { - Action action = message.getAction(); + List actions = message.getActions(); + //Sort list so actions are added to the buf in the correct order + Collections.sort(actions); List entries = message.getEntries(); - ByteBufUtils.writeVarInt(buf, message.getAction().ordinal()); + BitSet actionBitSet = new BitSet(6); + for (Action a : actions) { + actionBitSet.set(a.getBitFieldIndex(), true); + } + byte arr[] = actionBitSet.toByteArray(); + buf.writeByte(arr[0]); ByteBufUtils.writeVarInt(buf, entries.size()); for (Entry entry : entries) { GlowBufUtils.writeUuid(buf, entry.uuid); - // todo: implement the rest of the actions - switch (action) { - case ADD_PLAYER: - // this code is somewhat saddening - ByteBufUtils.writeUTF8(buf, entry.profile.getName()); - ByteBufUtils.writeVarInt(buf, entry.profile.getProperties().size()); - for (ProfileProperty property : entry.profile.getProperties()) { - ByteBufUtils.writeUTF8(buf, property.getName()); - ByteBufUtils.writeUTF8(buf, property.getValue()); - buf.writeBoolean(property.isSigned()); - if (property.isSigned()) { - ByteBufUtils.writeUTF8(buf, property.getSignature()); + for (Action a : actions) { + switch (a) { + case ADD_PLAYER: + // this code is somewhat saddening + ByteBufUtils.writeUTF8(buf, entry.profile.getName()); + ByteBufUtils.writeVarInt(buf, entry.profile.getProperties().size()); + for (ProfileProperty property : entry.profile.getProperties()) { + ByteBufUtils.writeUTF8(buf, property.getName()); + ByteBufUtils.writeUTF8(buf, property.getValue()); + buf.writeBoolean(property.isSigned()); + if (property.isSigned()) { + ByteBufUtils.writeUTF8(buf, property.getSignature()); + } } - } - ByteBufUtils.writeVarInt(buf, entry.gameMode); - ByteBufUtils.writeVarInt(buf, entry.ping); - if (entry.displayName != null) { - buf.writeBoolean(true); - GlowBufUtils.writeChat(buf, entry.displayName); - } else { - buf.writeBoolean(false); - } - if (entry.publicKey != null && entry.signature != null) { - buf.writeBoolean(true); - buf.writeLong(entry.timestamp); - ByteBufUtils.writeVarInt(buf, entry.publicKey.length); - buf.writeBytes(entry.publicKey); - ByteBufUtils.writeVarInt(buf, entry.signature.length); - buf.writeBytes(entry.signature); - } else { - buf.writeBoolean(false); - } - break; + break; - case UPDATE_GAMEMODE: - ByteBufUtils.writeVarInt(buf, entry.gameMode); - break; + case UPDATE_GAMEMODE: + ByteBufUtils.writeVarInt(buf, entry.gameMode); + break; - case UPDATE_LATENCY: - ByteBufUtils.writeVarInt(buf, entry.ping); - break; + case UPDATE_LATENCY: + ByteBufUtils.writeVarInt(buf, entry.ping); + break; - case UPDATE_DISPLAY_NAME: - if (entry.displayName != null) { - buf.writeBoolean(true); - GlowBufUtils.writeChat(buf, entry.displayName); - } else { - buf.writeBoolean(false); - } - break; + case UPDATE_DISPLAY_NAME: + if (entry.displayName != null) { + buf.writeBoolean(true); + GlowBufUtils.writeChat(buf, entry.displayName); + } else { + buf.writeBoolean(false); + } + break; - case REMOVE_PLAYER: - // nothing - break; + case REMOVE_PLAYER: + // nothing + break; - default: - throw new UnsupportedOperationException("not yet implemented: " + action); + default: + throw new UnsupportedOperationException("not yet implemented: " + a); + } } + // todo: implement the rest of the actions + } return buf; } diff --git a/src/main/java/net/glowstone/net/codec/play/inv/HeldItemCodec.java b/src/main/java/net/glowstone/net/codec/play/inv/HeldItemCodec.java index fb07b7b407..235d9f1bcc 100644 --- a/src/main/java/net/glowstone/net/codec/play/inv/HeldItemCodec.java +++ b/src/main/java/net/glowstone/net/codec/play/inv/HeldItemCodec.java @@ -10,7 +10,7 @@ public final class HeldItemCodec implements Codec { @Override public HeldItemMessage decode(ByteBuf buf) throws IOException { - int slot = buf.readShort(); + int slot = buf.readByte(); return new HeldItemMessage(slot); } diff --git a/src/main/java/net/glowstone/net/codec/play/player/BlockPlacementCodec.java b/src/main/java/net/glowstone/net/codec/play/player/BlockPlacementCodec.java index ae2eade36d..6e40438bf2 100644 --- a/src/main/java/net/glowstone/net/codec/play/player/BlockPlacementCodec.java +++ b/src/main/java/net/glowstone/net/codec/play/player/BlockPlacementCodec.java @@ -13,24 +13,29 @@ public final class BlockPlacementCodec implements Codec { @Override public BlockPlacementMessage decode(ByteBuf buf) throws IOException { - BlockVector pos = GlowBufUtils.readBlockPosition(buf); - int direction = buf.readByte(); int hand = ByteBufUtils.readVarInt(buf); + BlockVector pos = GlowBufUtils.readBlockPosition(buf); + int face = ByteBufUtils.readVarInt(buf); + float cursorX = buf.readFloat(); float cursorY = buf.readFloat(); float cursorZ = buf.readFloat(); - return new BlockPlacementMessage(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), - direction, hand, cursorX, cursorY, cursorZ); + boolean isInsideBlock = buf.readBoolean(); + int sequence = ByteBufUtils.readVarInt(buf); + return new BlockPlacementMessage(hand, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), face, cursorX, cursorY, cursorZ, isInsideBlock, sequence); } @Override public ByteBuf encode(ByteBuf buf, BlockPlacementMessage message) throws IOException { - GlowBufUtils.writeBlockPosition(buf, message.getX(), message.getY(), message.getZ()); - buf.writeByte(message.getDirection()); ByteBufUtils.writeVarInt(buf, message.getHand()); + GlowBufUtils.writeBlockPosition(buf, message.getX(), message.getY(), message.getZ()); + ByteBufUtils.writeVarInt(buf, message.getFace()); + buf.writeFloat(message.getCursorX()); buf.writeFloat(message.getCursorY()); buf.writeFloat(message.getCursorZ()); + buf.writeBoolean(message.isInsideBlock()); + ByteBufUtils.writeVarInt(buf, message.getSequence()); return buf; } } diff --git a/src/main/java/net/glowstone/net/codec/play/player/PlayerSessionCodec.java b/src/main/java/net/glowstone/net/codec/play/player/PlayerSessionCodec.java new file mode 100644 index 0000000000..fd0337b2a8 --- /dev/null +++ b/src/main/java/net/glowstone/net/codec/play/player/PlayerSessionCodec.java @@ -0,0 +1,29 @@ +package net.glowstone.net.codec.play.player; + +import com.flowpowered.network.Codec; +import com.flowpowered.network.util.ByteBufUtils; +import io.netty.buffer.ByteBuf; +import net.glowstone.net.GlowBufUtils; +import net.glowstone.net.message.play.player.PlayerSessionMessage; + +import java.io.IOException; +import java.util.UUID; + +public final class PlayerSessionCodec implements Codec { + @Override + public PlayerSessionMessage decode(ByteBuf byteBuf) throws IOException { + UUID uuid = GlowBufUtils.readUuid(byteBuf); + long expires = byteBuf.readLong(); + int pubKeyLen = ByteBufUtils.readVarInt(byteBuf); + ByteBuf pubKey = byteBuf.readBytes(pubKeyLen); + + int pubKeySigLen = ByteBufUtils.readVarInt(byteBuf); + ByteBuf pubKeySig = byteBuf.readBytes(pubKeySigLen); + return new PlayerSessionMessage(uuid, expires, pubKey, pubKeySig); + } + + @Override + public ByteBuf encode(ByteBuf byteBuf, PlayerSessionMessage playerSessionMessage) throws IOException { + throw new RuntimeException("Can't encode PlayerSessionMessage"); + } +} diff --git a/src/main/java/net/glowstone/net/codec/play/player/ServerDifficultyCodec.java b/src/main/java/net/glowstone/net/codec/play/player/ServerDifficultyCodec.java index 4fe8504875..e52c6cb0c7 100644 --- a/src/main/java/net/glowstone/net/codec/play/player/ServerDifficultyCodec.java +++ b/src/main/java/net/glowstone/net/codec/play/player/ServerDifficultyCodec.java @@ -12,7 +12,8 @@ public final class ServerDifficultyCodec implements Codec { + @Override + public void handle(GlowSession glowSession, PlayerSessionMessage playerSessionMessage) { + //TODO: Handle + } +} diff --git a/src/main/java/net/glowstone/net/message/login/EncryptionKeyResponseCodec.java b/src/main/java/net/glowstone/net/message/login/EncryptionKeyResponseCodec.java index 2e121e7ee5..a9f67ac488 100644 --- a/src/main/java/net/glowstone/net/message/login/EncryptionKeyResponseCodec.java +++ b/src/main/java/net/glowstone/net/message/login/EncryptionKeyResponseCodec.java @@ -12,21 +12,10 @@ public final class EncryptionKeyResponseCodec implements Codec { @Override public LoginStartMessage decode(ByteBuf buffer) throws IOException { String input = ByteBufUtils.readUTF8(buffer); - boolean hasSigData = buffer.readBoolean(); - long timestamp = 0; - byte[] publicKey = null; - byte[] signature = null; - if (hasSigData) { - timestamp = buffer.readLong(); - publicKey = new byte[ByteBufUtils.readVarInt(buffer)]; - buffer.readBytes(publicKey); - signature = new byte[ByteBufUtils.readVarInt(buffer)]; - buffer.readBytes(signature); + boolean hasUuid = buffer.readBoolean(); + UUID uuid = null; + if (hasUuid) { + ByteBuf uuidBuf = buffer.readBytes(16); + uuid = new UUID(uuidBuf.readLong(), uuidBuf.readLong()); } - return new LoginStartMessage(URLEncoder.encode(input, StandardCharsets.UTF_8.toString()), - timestamp, publicKey, signature); + return new LoginStartMessage(input, hasUuid, uuid); } @Override public ByteBuf encode(ByteBuf buf, LoginStartMessage message) throws IOException { ByteBufUtils.writeUTF8(buf, message.getUsername()); + buf.writeBoolean(message.isHasUuid()); + if (message.isHasUuid()) { + UUID uuid = message.getUuid(); + ByteBuffer bb = ByteBuffer.wrap(new byte[16]); + bb.putLong(uuid.getMostSignificantBits()); + bb.putLong(uuid.getLeastSignificantBits()); + buf.writeBytes(bb); + } return buf; } } diff --git a/src/main/java/net/glowstone/net/message/login/LoginStartMessage.java b/src/main/java/net/glowstone/net/message/login/LoginStartMessage.java index 8c81c97392..8521f40486 100644 --- a/src/main/java/net/glowstone/net/message/login/LoginStartMessage.java +++ b/src/main/java/net/glowstone/net/message/login/LoginStartMessage.java @@ -3,13 +3,14 @@ import com.flowpowered.network.AsyncableMessage; import lombok.Data; +import java.util.UUID; + @Data public final class LoginStartMessage implements AsyncableMessage { private final String username; - private final long timestamp; - private final byte[] publicKey; - private final byte[] signature; + private final boolean hasUuid; + private final UUID uuid; @Override public boolean isAsync() { diff --git a/src/main/java/net/glowstone/net/message/login/LoginSuccessCodec.java b/src/main/java/net/glowstone/net/message/login/LoginSuccessCodec.java index 19de52aedd..d5454f2de4 100644 --- a/src/main/java/net/glowstone/net/message/login/LoginSuccessCodec.java +++ b/src/main/java/net/glowstone/net/message/login/LoginSuccessCodec.java @@ -3,10 +3,12 @@ import com.flowpowered.network.Codec; import com.flowpowered.network.util.ByteBufUtils; import io.netty.buffer.ByteBuf; +import io.netty.handler.codec.DecoderException; import net.glowstone.net.GlowBufUtils; import net.glowstone.net.message.login.LoginSuccessMessage; import java.io.IOException; +import java.util.ArrayList; import java.util.UUID; public final class LoginSuccessCodec implements Codec { @@ -15,8 +17,12 @@ public final class LoginSuccessCodec implements Codec { public LoginSuccessMessage decode(ByteBuf buffer) throws IOException { UUID uuid = GlowBufUtils.readUuid(buffer); String username = ByteBufUtils.readUTF8(buffer); + int numProps = ByteBufUtils.readVarInt(buffer); + if (numProps > 0) { + throw new DecoderException("Can't decode LoginSuccessMessage with props"); + } - return new LoginSuccessMessage(uuid, username); + return new LoginSuccessMessage(uuid, username, new ArrayList<>()); } @Override diff --git a/src/main/java/net/glowstone/net/message/login/LoginSuccessMessage.java b/src/main/java/net/glowstone/net/message/login/LoginSuccessMessage.java index 5507be4a9f..070d12b4a0 100644 --- a/src/main/java/net/glowstone/net/message/login/LoginSuccessMessage.java +++ b/src/main/java/net/glowstone/net/message/login/LoginSuccessMessage.java @@ -3,6 +3,7 @@ import com.flowpowered.network.Message; import lombok.Data; +import java.util.ArrayList; import java.util.UUID; @Data @@ -10,5 +11,14 @@ public final class LoginSuccessMessage implements Message { private final UUID uuid; private final String username; + private final ArrayList properties; + + @Data + public class LoginSuccessProperties { + private final String name; + private final String value; + private final boolean isSigned; + private final String signature; + } } diff --git a/src/main/java/net/glowstone/net/message/play/game/ClientSettingsMessage.java b/src/main/java/net/glowstone/net/message/play/game/ClientSettingsMessage.java index e9f93d4cb0..5f380ac9bd 100644 --- a/src/main/java/net/glowstone/net/message/play/game/ClientSettingsMessage.java +++ b/src/main/java/net/glowstone/net/message/play/game/ClientSettingsMessage.java @@ -12,5 +12,7 @@ public final class ClientSettingsMessage implements Message { private final boolean chatColors; private final int skinFlags; private final int hand; + private final boolean textFilteringEnabled; + private final boolean serverListingEnables; } diff --git a/src/main/java/net/glowstone/net/message/play/game/RespawnMessage.java b/src/main/java/net/glowstone/net/message/play/game/RespawnMessage.java index 8e631310f7..d81aaaaba4 100644 --- a/src/main/java/net/glowstone/net/message/play/game/RespawnMessage.java +++ b/src/main/java/net/glowstone/net/message/play/game/RespawnMessage.java @@ -1,18 +1,25 @@ package net.glowstone.net.message.play.game; import com.flowpowered.network.Message; +import io.papermc.paper.math.Position; import lombok.Data; +import org.bukkit.Location; +import org.bukkit.NamespacedKey; +import org.bukkit.util.Vector; @Data public final class RespawnMessage implements Message { // TODO: Dimension (NBT compound) - private final String world; + private final NamespacedKey dimType; + private final NamespacedKey dimName; private final byte[] seedHash; - private final int mode; - private final int previousMode; + private final int gamemode; + private final int previousGamemode; private final boolean debug; private final boolean flat; private final boolean copyMetadata; + private final NamespacedKey deathDimName; + private final Location deathPosition; } diff --git a/src/main/java/net/glowstone/net/message/play/game/UserListItemMessage.java b/src/main/java/net/glowstone/net/message/play/game/UserListItemMessage.java index 9d9631fe2b..6cf3232524 100644 --- a/src/main/java/net/glowstone/net/message/play/game/UserListItemMessage.java +++ b/src/main/java/net/glowstone/net/message/play/game/UserListItemMessage.java @@ -1,6 +1,7 @@ package net.glowstone.net.message.play.game; import com.flowpowered.network.Message; +import com.google.common.collect.Lists; import lombok.AllArgsConstructor; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -17,30 +18,28 @@ @Data public final class UserListItemMessage implements Message { - private final Action action; + private final List actions; private final List entries; /** * Creates an instance. * - * @param action the action code: 0 = add player; 1 = update gamemode; 2 = update latency; - * 3 = update display name; 4 = remove player + * @param actions List of actions in this message * @param entries the players to add, update or remove */ - public UserListItemMessage(Action action, List entries) { - this.action = action; + public UserListItemMessage(List actions, List entries) { + this.actions = actions; this.entries = entries; for (Entry entry : entries) { - if (entry.action != action) { - throw new IllegalArgumentException( - "Entries must be " + action + ", not " + entry.action); + if (!entry.actions.equals(actions)) { + throw new IllegalArgumentException("Entries do not match"); } } } - public UserListItemMessage(Action action, Entry entry) { - this(action, Arrays.asList(entry)); + public UserListItemMessage(List actions, Entry entry) { + this(actions, Arrays.asList(entry)); } // add @@ -62,61 +61,72 @@ public static Entry add(GlowPlayerProfile profile, int gameMode, int ping, TextMessage displayName) { // TODO: measure ping return new Entry(profile.getId(), profile, gameMode, ping, displayName, - Action.ADD_PLAYER); + Lists.newArrayList(Action.ADD_PLAYER)); } public static UserListItemMessage addOne(GlowPlayerProfile profile) { - return new UserListItemMessage(Action.ADD_PLAYER, add(profile)); + return new UserListItemMessage(Lists.newArrayList(Action.ADD_PLAYER), add(profile)); } // gamemode public static Entry gameMode(UUID uuid, int gameMode) { - return new Entry(uuid, null, gameMode, 0, null, Action.UPDATE_GAMEMODE); + return new Entry(uuid, null, gameMode, 0, null, Lists.newArrayList(Action.UPDATE_GAMEMODE)); } public static UserListItemMessage gameModeOne(UUID uuid, int gameMode) { - return new UserListItemMessage(Action.UPDATE_GAMEMODE, gameMode(uuid, gameMode)); + return new UserListItemMessage(Lists.newArrayList(Action.UPDATE_GAMEMODE), gameMode(uuid, gameMode)); } // latency public static Entry latency(UUID uuid, int ping) { - return new Entry(uuid, null, 0, ping, null, Action.UPDATE_LATENCY); + return new Entry(uuid, null, 0, ping, null, Lists.newArrayList(Action.UPDATE_LATENCY)); } public static UserListItemMessage latencyOne(UUID uuid, int ping) { - return new UserListItemMessage(Action.UPDATE_LATENCY, latency(uuid, ping)); + return new UserListItemMessage(Lists.newArrayList(Action.UPDATE_LATENCY), latency(uuid, ping)); } // display name public static Entry displayName(UUID uuid, TextMessage displayName) { - return new Entry(uuid, null, 0, 0, displayName, Action.UPDATE_DISPLAY_NAME); + return new Entry(uuid, null, 0, 0, displayName, Lists.newArrayList(Action.UPDATE_DISPLAY_NAME)); } public static UserListItemMessage displayNameOne(UUID uuid, TextMessage displayName) { - return new UserListItemMessage(Action.UPDATE_DISPLAY_NAME, displayName(uuid, displayName)); + return new UserListItemMessage(Lists.newArrayList(Action.UPDATE_DISPLAY_NAME), displayName(uuid, displayName)); } // remove public static Entry remove(UUID uuid) { - return new Entry(uuid, null, 0, 0, null, Action.REMOVE_PLAYER); + return new Entry(uuid, null, 0, 0, null, Lists.newArrayList(Action.REMOVE_PLAYER)); } public static UserListItemMessage removeOne(UUID uuid) { - return new UserListItemMessage(Action.REMOVE_PLAYER, remove(uuid)); + return new UserListItemMessage(Lists.newArrayList(Action.REMOVE_PLAYER), remove(uuid)); } // inner classes + /** + * The actions that can be performed in a user list update + * The bitFieldIndex field is the index of the action fla + */ public enum Action { - ADD_PLAYER, - UPDATE_GAMEMODE, - UPDATE_LATENCY, - UPDATE_DISPLAY_NAME, - REMOVE_PLAYER + ADD_PLAYER(0), + UPDATE_GAMEMODE(2), + REMOVE_PLAYER(3), + UPDATE_LATENCY(4), + UPDATE_DISPLAY_NAME(5); + private int bitFieldIndex; + private Action(int bitIndex) { + this.bitFieldIndex = bitIndex; + } + public int getBitFieldIndex() { + return bitFieldIndex; + } } @Data @@ -128,13 +138,13 @@ public static final class Entry { public final int gameMode; public final int ping; public final TextMessage displayName; - private final Action action; + private final List actions; public final long timestamp; public final byte[] publicKey; public final byte[] signature; - public Entry(UUID uuid, GlowPlayerProfile profile, int gameMode, int ping, TextMessage displayName, Action action) { - this(uuid, profile, gameMode, ping, displayName, action, 0, null, null); + public Entry(UUID uuid, GlowPlayerProfile profile, int gameMode, int ping, TextMessage displayName, List actions) { + this(uuid, profile, gameMode, ping, displayName, actions, 0, null, null); } } } diff --git a/src/main/java/net/glowstone/net/message/play/player/BlockPlacementMessage.java b/src/main/java/net/glowstone/net/message/play/player/BlockPlacementMessage.java index c3d84d3e33..af04512466 100644 --- a/src/main/java/net/glowstone/net/message/play/player/BlockPlacementMessage.java +++ b/src/main/java/net/glowstone/net/message/play/player/BlockPlacementMessage.java @@ -7,14 +7,16 @@ @Data public final class BlockPlacementMessage implements Message { + private final int hand; private final int x; private final int y; private final int z; - private final int direction; - private final int hand; + private final int face; private final float cursorX; private final float cursorY; private final float cursorZ; + private final boolean isInsideBlock; + private final int sequence; public EquipmentSlot getHandSlot() { return hand == 1 ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND; diff --git a/src/main/java/net/glowstone/net/message/play/player/PlayerSessionMessage.java b/src/main/java/net/glowstone/net/message/play/player/PlayerSessionMessage.java new file mode 100644 index 0000000000..3e9572f798 --- /dev/null +++ b/src/main/java/net/glowstone/net/message/play/player/PlayerSessionMessage.java @@ -0,0 +1,15 @@ +package net.glowstone.net.message.play.player; + +import com.flowpowered.network.Message; +import io.netty.buffer.ByteBuf; +import lombok.Data; + +import java.util.UUID; + +@Data +public final class PlayerSessionMessage implements Message { + private final UUID sessionId; + private final long expiresAt; + private final ByteBuf pubKey; + private final ByteBuf keySig; +} diff --git a/src/main/java/net/glowstone/net/message/play/player/ServerDifficultyMessage.java b/src/main/java/net/glowstone/net/message/play/player/ServerDifficultyMessage.java index 4b2f73df09..6af3c014c8 100644 --- a/src/main/java/net/glowstone/net/message/play/player/ServerDifficultyMessage.java +++ b/src/main/java/net/glowstone/net/message/play/player/ServerDifficultyMessage.java @@ -8,5 +8,6 @@ public final class ServerDifficultyMessage implements Message { private final Difficulty difficulty; + private final boolean locked; } diff --git a/src/main/java/net/glowstone/net/protocol/PlayProtocol.java b/src/main/java/net/glowstone/net/protocol/PlayProtocol.java index ac6d6b6902..67225b28a2 100644 --- a/src/main/java/net/glowstone/net/protocol/PlayProtocol.java +++ b/src/main/java/net/glowstone/net/protocol/PlayProtocol.java @@ -46,6 +46,7 @@ import net.glowstone.net.codec.play.player.PlayerLookCodec; import net.glowstone.net.codec.play.player.PlayerPositionCodec; import net.glowstone.net.codec.play.player.PlayerPositionLookCodec; +import net.glowstone.net.codec.play.player.PlayerSessionCodec; import net.glowstone.net.codec.play.player.PlayerSwingArmCodec; import net.glowstone.net.codec.play.player.PlayerUpdateCodec; import net.glowstone.net.codec.play.player.ResourcePackSendCodec; @@ -86,6 +87,7 @@ import net.glowstone.net.handler.play.player.InteractEntityHandler; import net.glowstone.net.handler.play.player.PlayerAbilitiesHandler; import net.glowstone.net.handler.play.player.PlayerActionHandler; +import net.glowstone.net.handler.play.player.PlayerSessionHandler; import net.glowstone.net.handler.play.player.PlayerSwingArmHandler; import net.glowstone.net.handler.play.player.PlayerUpdateHandler; import net.glowstone.net.handler.play.player.ResourcePackStatusHandler; @@ -141,6 +143,7 @@ import net.glowstone.net.message.play.player.PlayerLookMessage; import net.glowstone.net.message.play.player.PlayerPositionLookMessage; import net.glowstone.net.message.play.player.PlayerPositionMessage; +import net.glowstone.net.message.play.player.PlayerSessionMessage; import net.glowstone.net.message.play.player.PlayerSwingArmMessage; import net.glowstone.net.message.play.player.PlayerUpdateMessage; import net.glowstone.net.message.play.player.ResourcePackSendMessage; @@ -170,10 +173,11 @@ public PlayProtocol() { TeleportConfirmHandler.class); // TODO 0x01 : Query Block NBT // Note: 0x02 (Set Difficulty) is unused in multiplayer - // TODO 0x03 Chat Command - inbound(0x04, IncomingChatMessage.class, IncomingChatCodec.class, + // TODO 0x03 Message Acknowledge + // TODO 0x04 Chat Command + // TODO 0x05 Update Chat Message Handling to relfect Protocol changes + inbound(0x05, IncomingChatMessage.class, IncomingChatCodec.class, IncomingChatHandler.class); - // TODO 0x05 Chat Preview inbound(0x06, ClientStatusMessage.class, ClientStatusCodec.class, ClientStatusHandler.class); inbound(0x07, ClientSettingsMessage.class, ClientSettingsCodec.class, @@ -181,11 +185,14 @@ public PlayProtocol() { inbound(0x08, TabCompleteMessage.class, TabCompleteCodec.class, TabCompleteHandler.class); inbound(0x09, ClickWindowButtonMessage.class, ClickWindowButtonCodec.class, ClickWindowButtonHandler.class); + //TODO 0x0A : Update WindowClickMessage inbound(0x0A, WindowClickMessage.class, WindowClickCodec.class, WindowClickHandler.class); inbound(0x0B, CloseWindowMessage.class, CloseWindowCodec.class, CloseWindowHandler.class); inbound(0x0C, PluginMessage.class, PluginMessageCodec.class, PluginMessageHandler.class); + //TODO 0x0D : Update EditBookMessage inbound(0x0D, EditBookMessage.class, EditBookCodec.class, EditBookHandler.class); // TODO 0x0E : Query Entity NBT + // TODO 0x0F : Add shifting flag to InteractEntityMessage inbound(0x0F, InteractEntityMessage.class, InteractEntityCodec.class, InteractEntityHandler.class); // TODO 0x10 : Generate Structure (Jigsaw Block stuff: https://wiki.vg/Protocol#Generate_Structure) @@ -193,6 +200,7 @@ public PlayProtocol() { // Note: 0x12 (Lock Difficulty) is unused in multiplayer inbound(0x13, PlayerPositionMessage.class, PlayerPositionCodec.class, PlayerUpdateHandler.class); + inbound(0x14, PlayerPositionLookMessage.class, PlayerPositionLookCodec.class, PlayerUpdateHandler.class); inbound(0x15, PlayerLookMessage.class, PlayerLookCodec.class, PlayerUpdateHandler.class); @@ -203,39 +211,44 @@ public PlayProtocol() { // TODO 0x19 : Pick Item (see https://wiki.vg/Protocol#Pick_Item) inbound(0x1A, CraftRecipeRequestMessage.class, CraftRecipeRequestCodec.class, CraftRecipeRequestHandler.class); + // TODO 0x1B Update PlayerAbilitiesMessage inbound(0x1B, PlayerAbilitiesMessage.class, PlayerAbilitiesCodec.class, PlayerAbilitiesHandler.class); + // TODO 0x1C Update DiggingMessage inbound(0x1C, DiggingMessage.class, DiggingCodec.class, DiggingHandler.class); inbound(0x1D, PlayerActionMessage.class, PlayerActionCodec.class, PlayerActionHandler.class); inbound(0x1E, SteerVehicleMessage.class, SteerVehicleCodec.class, SteerVehicleHandler.class); // TODO 0x1F : Pong - inbound(0x20, RecipeBookStateMessage.class, RecipeBookStateCodec.class, + inbound(0x20, PlayerSessionMessage.class, PlayerSessionCodec.class, PlayerSessionHandler.class); + inbound(0x21, RecipeBookStateMessage.class, RecipeBookStateCodec.class, RecipeBookStateHandler.class); - inbound(0x21, DisplayedRecipeMessage.class, DisplayedRecipeCodec.class, DisplayedRecipeHandler.class); - inbound(0x22, NameItemMessage.class, NameItemCodec.class, NameItemHandler.class); - inbound(0x23, ResourcePackStatusMessage.class, ResourcePackStatusCodec.class, + inbound(0x22, DisplayedRecipeMessage.class, DisplayedRecipeCodec.class, DisplayedRecipeHandler.class); + inbound(0x23, NameItemMessage.class, NameItemCodec.class, NameItemHandler.class); + inbound(0x24, ResourcePackStatusMessage.class, ResourcePackStatusCodec.class, ResourcePackStatusHandler.class); - inbound(0x24, AdvancementTabMessage.class, AdvancementTabCodec.class, + inbound(0x25, AdvancementTabMessage.class, AdvancementTabCodec.class, AdvancementTabHandler.class); - // TODO 0x25 : Select Trade (when a player selects a specific trade in a villager GUI) - inbound(0x26, BeaconEffectMessage.class, BeaconEffectCodec.class, + // TODO 0x26 : Select Trade (when a player selects a specific trade in a villager GUI) + // TODO 0x27 : Update BeaconEffectMessage + inbound(0x27, BeaconEffectMessage.class, BeaconEffectCodec.class, BeaconEffectHandler.class); - inbound(0x27, HeldItemMessage.class, HeldItemCodec.class, HeldItemHandler.class); - // TODO 0x28 : Update Command Block - // TODO 0x29 : Update Command Block Minecart - inbound(0x2A, CreativeItemMessage.class, CreativeItemCodec.class, + inbound(0x28, HeldItemMessage.class, HeldItemCodec.class, HeldItemHandler.class); + // TODO 0x29 : Update Command Block + // TODO 0x2A : Update Command Block Minecart + inbound(0x2B, CreativeItemMessage.class, CreativeItemCodec.class, CreativeItemHandler.class); - // TODO 0x2B : Update Jigsaw Block - // TODO 0x2C : Update Structure Block (difference with 0x29) - inbound(0x2D, UpdateSignMessage.class, UpdateSignCodec.class, UpdateSignHandler.class); - inbound(0x2E, PlayerSwingArmMessage.class, PlayerSwingArmCodec.class, + // TODO 0x2C : Update Jigsaw Block + // TODO 0x2D : Update Structure Block (difference with 0x29) + inbound(0x2E, UpdateSignMessage.class, UpdateSignCodec.class, UpdateSignHandler.class); + inbound(0x2F, PlayerSwingArmMessage.class, PlayerSwingArmCodec.class, PlayerSwingArmHandler.class); - inbound(0x2F, SpectateMessage.class, SpectateCodec.class, SpectateHandler.class); - inbound(0x30, BlockPlacementMessage.class, BlockPlacementCodec.class, + inbound(0x30, SpectateMessage.class, SpectateCodec.class, SpectateHandler.class); + inbound(0x31, BlockPlacementMessage.class, BlockPlacementCodec.class, BlockPlacementHandler.class); - inbound(0x31, UseItemMessage.class, UseItemCodec.class, UseItemHandler.class); + // TODO 0x32 : Add sequence field to UseItemMessage + inbound(0x32, UseItemMessage.class, UseItemCodec.class, UseItemHandler.class); outbound(0x00, SpawnEntityMessage.class, SpawnEntityCodec.class); outbound(0x01, SpawnXpOrbMessage.class, SpawnXpOrbCodec.class); @@ -249,99 +262,104 @@ public PlayProtocol() { outbound(0x09, BlockChangeMessage.class, BlockChangeCodec.class); outbound(0x0A, BossBarMessage.class, BossBarCodec.class); outbound(0x0B, ServerDifficultyMessage.class, ServerDifficultyCodec.class); - // TODO 0x0C : Chat preview - // TODO 0x0D : Clear Titles - outbound(0x0E, TabCompleteResponseMessage.class, TabCompleteResponseCodec.class); - outbound(0x0F, DeclareCommandsMessage.class, DeclareCommandsCodec.class); - outbound(0x10, CloseWindowMessage.class, CloseWindowCodec.class); - outbound(0x11, SetWindowContentsMessage.class, SetWindowContentsCodec.class); - outbound(0x12, WindowPropertyMessage.class, WindowPropertyCodec.class); - outbound(0x13, SetWindowSlotMessage.class, SetWindowSlotCodec.class); - outbound(0x14, SetCooldownMessage.class, SetCooldownCodec.class); + // TODO 0x0C : Clear Titles + outbound(0x0D, TabCompleteResponseMessage.class, TabCompleteResponseCodec.class); + outbound(0x0E, DeclareCommandsMessage.class, DeclareCommandsCodec.class); + outbound(0x0F, CloseWindowMessage.class, CloseWindowCodec.class); + outbound(0x10, SetWindowContentsMessage.class, SetWindowContentsCodec.class); + outbound(0x11, WindowPropertyMessage.class, WindowPropertyCodec.class); + outbound(0x12, SetWindowSlotMessage.class, SetWindowSlotCodec.class); + outbound(0x13, SetCooldownMessage.class, SetCooldownCodec.class); + //TODO 0x14 : Add ChatSuggestionsMessage outbound(0x15, PluginMessage.class, PluginMessageCodec.class); - outbound(0x16, NamedSoundEffectMessage.class, NamedSoundEffectCodec.class); + //TODO 0x16 : Add DeleteMessageMessage + //outbound(0x16, NamedSoundEffectMessage.class, NamedSoundEffectCodec.class); outbound(0x17, KickMessage.class, KickCodec.class); - outbound(0x18, EntityStatusMessage.class, EntityStatusCodec.class); - outbound(0x19, ExplosionMessage.class, ExplosionCodec.class); - outbound(0x1A, UnloadChunkMessage.class, UnloadChunkCodec.class); - outbound(0x1B, StateChangeMessage.class, StateChangeCodec.class); - // TODO 0x1C : Open Horse Window (opens the horse window, all other inventories use 0x2D) - outbound(0x1D, WorldBorderMessage.class, WorldBorderCodec.class); - outbound(0x1E, PingMessage.class, PingCodec.class); - outbound(0x1F, ChunkDataMessage.class, ChunkDataCodec.class); - outbound(0x20, PlayEffectMessage.class, PlayEffectCodec.class); - outbound(0x21, PlayParticleMessage.class, PlayParticleCodec.class); - outbound(0x22, ChunkLightDataMessage.class, ChunkLightDataCodec.class); - outbound(0x23, JoinGameMessage.class, JoinGameCodec.class); - outbound(0x24, MapDataMessage.class, MapDataCodec.class); - // TODO 0x25 : Trade List (the list of trades a villager is offering) - outbound(0x26, RelativeEntityPositionMessage.class, RelativeEntityPositionCodec.class); - outbound(0x27, RelativeEntityPositionRotationMessage.class, + //TODO 0x18 Add DisguisedChatMessageMessage + outbound(0x19, EntityStatusMessage.class, EntityStatusCodec.class); + outbound(0x1A, ExplosionMessage.class, ExplosionCodec.class); + outbound(0x1B, UnloadChunkMessage.class, UnloadChunkCodec.class); + outbound(0x1C, StateChangeMessage.class, StateChangeCodec.class); + // TODO 0x1D : Open Horse Window (opens the horse window, all other inventories use 0x2D) + outbound(0x1E, WorldBorderMessage.class, WorldBorderCodec.class); + outbound(0x1F, PingMessage.class, PingCodec.class); + outbound(0x20, ChunkDataMessage.class, ChunkDataCodec.class); + outbound(0x21, PlayEffectMessage.class, PlayEffectCodec.class); + outbound(0x22, PlayParticleMessage.class, PlayParticleCodec.class); + outbound(0x23, ChunkLightDataMessage.class, ChunkLightDataCodec.class); + outbound(0x24, JoinGameMessage.class, JoinGameCodec.class); + outbound(0x25, MapDataMessage.class, MapDataCodec.class); + // TODO 0x26 : Trade List (the list of trades a villager is offering) + outbound(0x27, RelativeEntityPositionMessage.class, RelativeEntityPositionCodec.class); + outbound(0x28, RelativeEntityPositionRotationMessage.class, RelativeEntityPositionRotationCodec.class); - outbound(0x28, EntityRotationMessage.class, EntityRotationCodec.class); - outbound(0x29, VehicleMoveMessage.class, VehicleMoveCodec.class); - // TODO 0x2A : Open Book (this replaces the old plugin channel. tells the client to open the book they have in hand) - outbound(0x2B, OpenWindowMessage.class, OpenWindowCodec.class); - outbound(0x2C, SignEditorMessage.class, SignEditorCodec.class); - // TODO 0x2D Ping (it's different to 0x1E PingMessage) - outbound(0x2E, CraftRecipeResponseMessage.class, CraftRecipeResponseCodec.class); - outbound(0x2F, PlayerAbilitiesMessage.class, PlayerAbilitiesCodec.class); - // TODO 0x30 Player Chat Message - // TODO 0x31 End Combat Event - // TODO 0x32 Enter Combat Event - // TODO 0x33 Death Combat Event - outbound(0x34, UserListItemMessage.class, UserListItemCodec.class); - // TODO 0x35 : Face Player (rotates the client to face a location or entity) - outbound(0x36, PositionRotationMessage.class, PositionRotationCodec.class); - outbound(0x37, UnlockRecipesMessage.class, UnlockRecipesCodec.class); - outbound(0x38, DestroyEntitiesMessage.class, DestroyEntitiesCodec.class); - outbound(0x39, EntityRemoveEffectMessage.class, EntityRemoveEffectCodec.class); - outbound(0x3A, ResourcePackSendMessage.class, ResourcePackSendCodec.class); - outbound(0x3B, RespawnMessage.class, RespawnCodec.class); - outbound(0x3C, EntityHeadRotationMessage.class, EntityHeadRotationCodec.class); - outbound(0x3D, MultiBlockChangeMessage.class, MultiBlockChangeCodec.class); - // TODO 0x3E : Select Advancement Tab (tells the client to switch tabs) - // TODO 0x3F : Server Data - // TODO 0x40 : Action Bar - // TODO 0x41 : World Border Center - // TODO 0x42 : World Border Lerp Size - // TODO 0x43 : World Border Size - // TODO 0x44 : World Border Warning Delay - // TODO 0x45 : World Border Warning Reach - outbound(0x46, CameraMessage.class, CameraCodec.class); - outbound(0x47, HeldItemMessage.class, HeldItemCodec.class); - // TODO 0x48 : "Update View Position" (use unclear, see https://wiki.vg/Protocol#Update_View_Position) - // TODO 0x49 : Update View Distance (unused in Vanilla, but could be used when changing view distance via plugins) - outbound(0x4A, SpawnPositionMessage.class, SpawnPositionCodec.class); + outbound(0x29, EntityRotationMessage.class, EntityRotationCodec.class); + outbound(0x2A, VehicleMoveMessage.class, VehicleMoveCodec.class); + // TODO 0x2B : Open Book (this replaces the old plugin channel. tells the client to open the book they have in hand) + outbound(0x2C, OpenWindowMessage.class, OpenWindowCodec.class); + outbound(0x2D, SignEditorMessage.class, SignEditorCodec.class); + // TODO 0x2E Ping (it's different to 0x1E PingMessage) + outbound(0x2F, CraftRecipeResponseMessage.class, CraftRecipeResponseCodec.class); + outbound(0x30, PlayerAbilitiesMessage.class, PlayerAbilitiesCodec.class); + // TODO 0x31 Player Chat Message + // TODO 0x32 End Combat Event + // TODO 0x33 Enter Combat Event + // TODO 0x34 Death Combat Event + // TODO 0x35 Player Info Remove + // TODO 0x36 Double check spec + outbound(0x36, UserListItemMessage.class, UserListItemCodec.class); + // TODO 0x37 : Face Player (rotates the client to face a location or entity) + outbound(0x38, PositionRotationMessage.class, PositionRotationCodec.class); + outbound(0x39, UnlockRecipesMessage.class, UnlockRecipesCodec.class); + outbound(0x3A, DestroyEntitiesMessage.class, DestroyEntitiesCodec.class); + outbound(0x3B, EntityRemoveEffectMessage.class, EntityRemoveEffectCodec.class); + outbound(0x3C, ResourcePackSendMessage.class, ResourcePackSendCodec.class); + outbound(0x3D, RespawnMessage.class, RespawnCodec.class); + outbound(0x3E, EntityHeadRotationMessage.class, EntityHeadRotationCodec.class); + outbound(0x3F, MultiBlockChangeMessage.class, MultiBlockChangeCodec.class); + // TODO 0x40 : Select Advancement Tab (tells the client to switch tabs) + // TODO 0x41 : Server Data + // TODO 0x42 : Action Bar + // TODO 0x43 : World Border Center + // TODO 0x44 : World Border Lerp Size + // TODO 0x45 : World Border Size + // TODO 0x46 : World Border Warning Delay + // TODO 0x47 : World Border Warning Reach + outbound(0x48, CameraMessage.class, CameraCodec.class); + outbound(0x49, HeldItemMessage.class, HeldItemCodec.class); + // TODO 0x4A Set Center Chunk + // TODO 0x4B Set Render Distance // TODO 0x4B : Set Display Chat Preview - outbound(0x4C, ScoreboardDisplayMessage.class, ScoreboardDisplayCodec.class); - outbound(0x4D, EntityMetadataMessage.class, EntityMetadataCodec.class); - outbound(0x4E, AttachEntityMessage.class, AttachEntityCodec.class); - outbound(0x4F, EntityVelocityMessage.class, EntityVelocityCodec.class); - outbound(0x50, EntityEquipmentMessage.class, EntityEquipmentCodec.class); - outbound(0x51, ExperienceMessage.class, ExperienceCodec.class); - outbound(0x52, HealthMessage.class, HealthCodec.class); - outbound(0x53, ScoreboardObjectiveMessage.class, ScoreboardObjectiveCodec.class); - outbound(0x54, SetPassengerMessage.class, SetPassengerCodec.class); - outbound(0x55, ScoreboardTeamMessage.class, ScoreboardTeamCodec.class); - outbound(0x56, ScoreboardScoreMessage.class, ScoreboardScoreCodec.class); - // TODO 0x57 : Update Simulation Distance - // TODO 0x58 : Set Title SubTitle - outbound(0x59, TimeMessage.class, TimeCodec.class); - // TODO 0x5A : Set Title Text outbound(0x5A, TitleMessage.class, TitleCodec.class); - // TODO 0x5B : Set Title Times - // TODO 0x5C : Entity Sound Effect - outbound(0x5D, SoundEffectMessage.class, SoundEffectCodec.class); - outbound(0x5E, StopSoundMessage.class, StopSoundCodec.class); - outbound(0x5F, ChatMessage.class, ChatCodec.class); - outbound(0x60, UserListHeaderFooterMessage.class, UserListHeaderFooterCodec.class); - // TODO 0x61 : NBT Query Response (response to Query Block/Entity NBT packets) - outbound(0x62, CollectItemMessage.class, CollectItemCodec.class); - outbound(0x63, EntityTeleportMessage.class, EntityTeleportCodec.class); - outbound(0x64, AdvancementsMessage.class, AdvancementsCodec.class); - outbound(0x65, EntityPropertyMessage.class, EntityPropertyCodec.class); - outbound(0x66, EntityEffectMessage.class, EntityEffectCodec.class); - // TODO 0x67 : Declare Recipes - // TODO 0x68 : Tags + outbound(0x4C, SpawnPositionMessage.class, SpawnPositionCodec.class); + outbound(0x4D, ScoreboardDisplayMessage.class, ScoreboardDisplayCodec.class); + outbound(0x4E, EntityMetadataMessage.class, EntityMetadataCodec.class); + outbound(0x4F, AttachEntityMessage.class, AttachEntityCodec.class); + outbound(0x50, EntityVelocityMessage.class, EntityVelocityCodec.class); + outbound(0x51, EntityEquipmentMessage.class, EntityEquipmentCodec.class); + outbound(0x52, ExperienceMessage.class, ExperienceCodec.class); + outbound(0x53, HealthMessage.class, HealthCodec.class); + outbound(0x54, ScoreboardObjectiveMessage.class, ScoreboardObjectiveCodec.class); + outbound(0x55, SetPassengerMessage.class, SetPassengerCodec.class); + outbound(0x56, ScoreboardTeamMessage.class, ScoreboardTeamCodec.class); + outbound(0x57, ScoreboardScoreMessage.class, ScoreboardScoreCodec.class); + // TODO 0x58 : Update Simulation Distance + // TODO 0x59 : Set Title SubTitle + outbound(0x5A, TimeMessage.class, TimeCodec.class); + // TODO 0x5B : Set Title Text outbound(0x5A, TitleMessage.class, TitleCodec.class); + // TODO 0x5C : Set Title Times + // TODO 0x5D : Entity Sound Effect + outbound(0x5E, SoundEffectMessage.class, SoundEffectCodec.class); + outbound(0x5F, StopSoundMessage.class, StopSoundCodec.class); + outbound(0x60, ChatMessage.class, ChatCodec.class); + outbound(0x61, UserListHeaderFooterMessage.class, UserListHeaderFooterCodec.class); + // TODO 0x62 : NBT Query Response (response to Query Block/Entity NBT packets) + outbound(0x63, CollectItemMessage.class, CollectItemCodec.class); + outbound(0x64, EntityTeleportMessage.class, EntityTeleportCodec.class); + outbound(0x65, AdvancementsMessage.class, AdvancementsCodec.class); + outbound(0x66, EntityPropertyMessage.class, EntityPropertyCodec.class); + // TODO 0x67 : Feature flags + outbound(0x68, EntityEffectMessage.class, EntityEffectCodec.class); + // TODO 0x69 : Update recipes + // TODO 0x6A : Update Tags } } diff --git a/src/main/java/net/glowstone/scoreboard/GlowObjective.java b/src/main/java/net/glowstone/scoreboard/GlowObjective.java index d8d46547f1..f30ceb24b3 100644 --- a/src/main/java/net/glowstone/scoreboard/GlowObjective.java +++ b/src/main/java/net/glowstone/scoreboard/GlowObjective.java @@ -6,6 +6,7 @@ import net.kyori.adventure.text.Component; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Entity; +import org.bukkit.scoreboard.Criteria; import org.bukkit.scoreboard.Criterias; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; @@ -98,6 +99,11 @@ public String getCriteria() throws IllegalStateException { return criteria; } + @Override + public @NotNull Criteria getTrackedCriteria() throws IllegalStateException { + return null; + } + @Override public String getDisplayName() throws IllegalStateException { checkValid(); diff --git a/src/main/java/net/glowstone/scoreboard/GlowScoreboard.java b/src/main/java/net/glowstone/scoreboard/GlowScoreboard.java index aaeeb0457c..48f6ad6654 100644 --- a/src/main/java/net/glowstone/scoreboard/GlowScoreboard.java +++ b/src/main/java/net/glowstone/scoreboard/GlowScoreboard.java @@ -13,6 +13,7 @@ import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Entity; +import org.bukkit.scoreboard.Criteria; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.Objective; import org.bukkit.scoreboard.RenderType; @@ -253,6 +254,16 @@ public Objective registerNewObjective(String name, String criteria) throw new UnsupportedOperationException("Adventure API is not yet supported."); } + @Override + public @NotNull Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @Nullable Component displayName) throws IllegalArgumentException { + return null; + } + + @Override + public @NotNull Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @Nullable Component displayName, @NotNull RenderType renderType) throws IllegalArgumentException { + return null; + } + @Override public Objective registerNewObjective(String name, String criteria, String displayName) throws IllegalArgumentException { @@ -269,6 +280,16 @@ public Objective registerNewObjective(String name, String criteria, return objective; } + @Override + public @NotNull Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName) throws IllegalArgumentException { + return null; + } + + @Override + public @NotNull Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName, @NotNull RenderType renderType) throws IllegalArgumentException { + return null; + } + @Override public Objective getObjective(String name) throws IllegalArgumentException { return objectives.get(name); @@ -285,6 +306,11 @@ public Set getObjectivesByCriteria(String criteria) throws IllegalArg return ImmutableSet.copyOf(getForCriteria(criteria)); } + @Override + public @NotNull Set getObjectivesByCriteria(@NotNull Criteria criteria) throws IllegalArgumentException { + return null; + } + @Override public Set getObjectives() { return ImmutableSet.copyOf(objectives.values()); diff --git a/src/main/java/net/glowstone/util/GlowUnsafeValues.java b/src/main/java/net/glowstone/util/GlowUnsafeValues.java index 3663cc9869..757f317375 100644 --- a/src/main/java/net/glowstone/util/GlowUnsafeValues.java +++ b/src/main/java/net/glowstone/util/GlowUnsafeValues.java @@ -3,6 +3,7 @@ import com.google.common.collect.Multimap; import io.papermc.paper.inventory.ItemRarity; import net.glowstone.GlowServer; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.flattener.ComponentFlattener; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; @@ -11,6 +12,7 @@ import org.bukkit.Keyed; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.RegionAccessor; import org.bukkit.Registry; import org.bukkit.Statistic; import org.bukkit.UnsafeValues; @@ -21,6 +23,7 @@ import org.bukkit.attribute.AttributeModifier; import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.inventory.CreativeCategory; @@ -31,6 +34,7 @@ import org.bukkit.util.StringUtil; import org.jetbrains.annotations.NotNull; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; @@ -94,6 +98,11 @@ public LegacyComponentSerializer legacyComponentSerializer() { return LegacyComponentSerializer.builder().build(); } + @Override + public Component resolveWithContext(Component component, CommandSender context, Entity scoreboardSubject, boolean bypassPermissions) throws IOException { + return null; + } + @Override public void reportTimings() { throw new UnsupportedOperationException(); @@ -341,4 +350,14 @@ public boolean hasDefaultEntityAttributes(@NotNull NamespacedKey entityKey) { public boolean isCollidable(@NotNull Material material) { return false; } + + @Override + public @NotNull NamespacedKey getBiomeKey(RegionAccessor accessor, int x, int y, int z) { + return null; + } + + @Override + public void setBiomeKey(RegionAccessor accessor, int x, int y, int z, NamespacedKey biomeKey) { + + } } diff --git a/src/main/java/net/glowstone/util/config/WorldConfig.java b/src/main/java/net/glowstone/util/config/WorldConfig.java index 451c835aaf..c86cd0f4f9 100644 --- a/src/main/java/net/glowstone/util/config/WorldConfig.java +++ b/src/main/java/net/glowstone/util/config/WorldConfig.java @@ -197,7 +197,7 @@ private void report(File file, InvalidConfigurationException e) { */ public enum Key { // World - SEA_LEVEL("general.sea_level", 64), + SEA_LEVEL("general.sea_level", 52), // Overworld generator OVERWORLD_COORDINATE_SCALE("overworld.coordinate-scale", 684.412), OVERWORLD_HEIGHT_SCALE("overworld.height.scale", 684.412), diff --git a/src/test/java/net/glowstone/testutils/ServerShim.java b/src/test/java/net/glowstone/testutils/ServerShim.java index 6eec7afa54..5a1ccfe854 100644 --- a/src/test/java/net/glowstone/testutils/ServerShim.java +++ b/src/test/java/net/glowstone/testutils/ServerShim.java @@ -130,7 +130,7 @@ public String getBukkitVersion() { @Override public @NotNull String getMinecraftVersion() { - return "1.19"; + return "1.19.3"; } @Override