mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-20 15:29:33 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@abc49bf Begin update to 1.20.5 PaperMC/Paper@f2c45ed do some work PaperMC/Paper@00c14f2 Move logging patches after adventure PaperMC/Paper@ef057bb work on Adventure patch PaperMC/Paper@380c4d2 Add plugin remapping patches PaperMC/Paper@7cdf804 Work PaperMC/Paper@dd6ce09 Fix reflection diff and order wrt commodore diff PaperMC/Paper@598a1cb Apply shadow removal patch PaperMC/Paper@ffccfd5 Apply timings PaperMC/Paper@eb41348 33 PaperMC/Paper@9cac5b6 Fix continueServerUpdate with 2-line subjects PaperMC/Paper@2eeed9e 41 PaperMC/Paper@d07c487 Don't use defaultToolchain method for run tasks PaperMC/Paper@f2350fe Set mercury sourceCompat PaperMC/Paper@5cfd92b Fix api compile PaperMC/Paper@862d004 work on some API stuff PaperMC/Paper@d6a3c0c fix 2 of our javadoc errors PaperMC/Paper@487555b update PaperMC/Paper@0225537 Update upstream PaperMC/Paper@906f906 Patches! PaperMC/Paper@8244815 221 PaperMC/Paper@309ebc1 253 PaperMC/Paper@1d7d7e9 301 PaperMC/Paper@9079c90 354 PaperMC/Paper@cc46148 405 PaperMC/Paper@5be858e Patches! PaperMC/Paper@2d9d0d8 Patches! PaperMC/Paper@a403a8d Patches!!!!!!! PaperMC/Paper@21afc0a Patches!!!!!!! PaperMC/Paper@1de0dc8 666 plus 1 PaperMC/Paper@4e654f2 More patch work PaperMC/Paper@e832328 Check for existing am session before running continueServerUpdate PaperMC/Paper@fc5c0da 683 PaperMC/Paper@90095cd 694 PaperMC/Paper@71ae391 more work (721) PaperMC/Paper@22227cc more more work (757) PaperMC/Paper@4d9e824 more more work (806) PaperMC/Paper@9617829 Restore original formatting for MC-252817 patch PaperMC/Paper@0518559 Update reflection rewriter to 0.0.1 release PaperMC/Paper@e0a245d Patches!!!!!!! PaperMC/Paper@1104431 955 PaperMC/Paper@1df7e21 Apply more API-implementing patches PaperMC/Paper@b733809 Drop conduit api patch (upstream implemented same api with same method signatures) PaperMC/Paper@c95db4f adventure 4.17.0-SNAPSHOT PaperMC/Paper@bb1351c some work on adventure PaperMC/Paper@1444b36 work on adventure PaperMC/Paper@ce0e78c compile fixes PaperMC/Paper@25f7c68 compile fixes PaperMC/Paper@690b1cd compile fixes PaperMC/Paper@b673721 compile fixes PaperMC/Paper@6a87d14 dataconverter PaperMC/Paper@ec9f7e3 starlight PaperMC/Paper@e9eec78 chunk system PaperMC/Paper@f6ea373 Patches PaperMC/Paper@ec4ada8 Apply and move up non-optimization patches PaperMC/Paper@c9907c6 More patches PaperMC/Paper@2debcaf More more patches, including hopper optimization patch PaperMC/Paper@6da0d8c (Almost) all patches applied PaperMC/Paper@345b5c1 Patches!!!!!!! (we are done) PaperMC/Paper@4590038 Fix properly resend patches PaperMC/Paper@457e2c8 pass more stuff PaperMC/Paper@b8da9ac item meta patch work PaperMC/Paper@ccf158a update smithing recipe copy data components API PaperMC/Paper@653f043 readd fix bee aging patch PaperMC/Paper@bab31b6 Update Enchantment damage increase API PaperMC/Paper@f4c7639 Un-jankify root user detection PaperMC/Paper@9c58056 Some more compilation fixes PaperMC/Paper@b984f66 Missing FQN in CraftPotionBrewer getter PaperMC/Paper@768befe Remove patch renaming scripts PaperMC/Paper@04a25c2 Fix WorldCreator#keepSpawnLoaded PaperMC/Paper@820f999 Fixes for cb pkg ver PaperMC/Paper@ca9001a compile fixes PaperMC/Paper@d01f6b2 Fix more compile issues PaperMC/Paper@8d3759d More more compile fixes PaperMC/Paper@ed79038 More compile fixes PaperMC/Paper@2641c02 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@68aea43 Fixup damage source change PaperMC/Paper@3062eb2 address my own comments PaperMC/Paper@e85e1ec fixup sus effect entry patches PaperMC/Paper@10e6143 fixup adventure's book meta handling PaperMC/Paper@a244281 Replace VanillaGradle use and update generated API PaperMC/Paper@31ad90b some more compile fixes PaperMC/Paper@d2ef062 generator fix PaperMC/Paper@7c6411b compile fixes PaperMC/Paper@867eb90 compile fixes PaperMC/Paper@62b96c5 compile fixes PaperMC/Paper@c5c2a5f hunk system fixes PaperMC/Paper@bcdf1f9 fixup loom pattern select event patch PaperMC/Paper@43d110e fix issue with item default attribute API PaperMC/Paper@2997fd6 plugin manager updates PaperMC/Paper@7e9da43 support patch versions in api-version PaperMC/Paper@813cfbf Fix compile issues PaperMC/Paper@478a971 Fix light setting in protochunk PaperMC/Paper@8b28f9f Fix accumulated total ticking chunks not being updated PaperMC/Paper@00dac83 Drop old decompile fix PaperMC/Paper@f6fae41 fix chat_type issue PaperMC/Paper@cc81668 fix some issues on the todo list PaperMC/Paper@44e68c3 fix some more issues PaperMC/Paper@1bc278b Update patched spigot decompiler to fix inconsistency based on processing order PaperMC/Paper@19ac9d4 remove no longer needed patches and fix tests PaperMC/Paper@e856d17 Update paper plugin check in PluginRemapper PaperMC/Paper@882ea0a fix adventure translations PaperMC/Paper@4c53ace fix exact choice recipes PaperMC/Paper@464cc81 fix custom potion mixes PaperMC/Paper@ff77f82 paperweight 1.6.0 PaperMC/Paper@6a4974b Remove shadow from build classpath PaperMC/Paper@c38f96b deprecate our ItemRarity API PaperMC/Paper@ba8512a fix javadocs for SpawnerEntry$Equipment API PaperMC/Paper@f1fc1b3 readd old UUID format patch PaperMC/Paper@5485043 Don't tell people to build the reobf jar PaperMC/Paper@2f19f0f fix enchantment order issue PaperMC/Paper@80bd015 fix adventure converters not using RegistryOps PaperMC/Paper@68e23db add back missing call to profile fill events PaperMC/Paper@9bac389 more fixes PaperMC/Paper@81f4405 add back hunk to async SavedData IO PaperMC/Paper@91b5de6 bunch of fixes and improvements PaperMC/Paper@f85d423 improve dumpitem and pgive commands PaperMC/Paper@5731f34 Restore Handle Large Packets Disconnecting Client Patch PaperMC/Paper@f037f08 Unify plugin remapping debug flags PaperMC/Paper@c82766d fix item flags PaperMC/Paper@f933c35 Update DataConverter to 1.20.6-rc1 PaperMC/Paper@55b1a87 fix PotionEffectType#getEffectAttributes PaperMC/Paper@0b1b1fe fix helmet damage reduction inconsistencies PaperMC/Paper@e2552ee Start cleaning up plugin remapping patches PaperMC/Paper@711dbd7 Bump adventure ansi serializer PaperMC/Paper@af97400 update generator PaperMC/Paper@b7e148a Move obfhelper/stack deobf diff into original patch PaperMC/Paper@a390119 Move cb version definition to gradle patch PaperMC/Paper@20af7a7 remove funny diff PaperMC/Paper@b3ea907 more ItemFlag fixes PaperMC/Paper@53d8edd properly check for experimental stuff in generator PaperMC/Paper@a771940 Revert to vanilla handling of LivingEntity#actuallyHurt (#10463) PaperMC/Paper@06cae13 Update jdk version and distribution in actions PaperMC/Paper@dd571d8 Fix bad diff in build gradle file PaperMC/Paper@d02bb81 proper migration to gamerules for keep spawn loaded distance PaperMC/Paper@aeb3f37 update paperweight to 1.6.1 PaperMC/Paper@75c22d5 Bump tiny-remapper PaperMC/Paper@8454786 Bump tiny-remapper (real) PaperMC/Paper@d99d84a Temporarily comment out adventure jd links PaperMC/Paper@83767f9 Use JetBrains runtime for run tasks PaperMC/Paper@4ad6022 improve checking handled tags in itemmeta (#9470) PaperMC/Paper@8ce62b3 Fix issue with hopppers PaperMC/Paper@7e3d5b5 bump paperweight to 1.6.2 to fix spurious build failure from scanJar OOM PaperMC/Paper@d964c15 fix last test issue PaperMC/Paper@3e90a19 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@d93c6f9 remove calls to DoNotUse methods PaperMC/Paper@f187fd6 Only scan `org.bukkit.craftbukkit.inventory` in `MetaHandledTagsTest` PaperMC/Paper@a3c4dc9 Fix the incorrect codec usage in the Style convert (#10465) PaperMC/Paper@e16263c Fix firework meta NPE PaperMC/Paper@306b203 more fixes for ItemMeta relating to components PaperMC/Paper@1a03cc9 Fix test compilation PaperMC/Paper@6e31f38 Fix book meta lacking resolved tag from older versions (Fixes #10470) PaperMC/Paper@37b3891 Fix another missing book meta tag PaperMC/Paper@c4a1cd1 Fix issue with empty lists in adventure predicates PaperMC/Paper@9d6e7e3 Don't hard fail on plugin remap error PaperMC/Paper@4491ac0 respect hard list size limits in ItemMeta PaperMC/Paper@aed7dca Fix overly strong name validation in player heads PaperMC/Paper@0f4d328 final missing validation for data components PaperMC/Paper@52ff3b7 Add itemName components (Resolves #10467) (#10471) PaperMC/Paper@ba673a3 [ci skip] Feature requests are now in GitHub Discussions (#10606) PaperMC/Paper@0f3e324 [ci skip] Fix discussion template file name (#10607) PaperMC/Paper@82a8012 [ci skip] adjust projects workflow for label changes PaperMC/Paper@61c9c07 Fix CraftMetaBlockState adding extra tags PaperMC/Paper@7f2d531 Rewrite reflection in library loader jars (#10608) PaperMC/Paper@05308fc Remap plugin libraries with namespace set to spigot (#10610) PaperMC/Paper@69a971a Reset component prototype on itemtype change PaperMC/Paper@f9397e1 Fix incorrect Commodore mapping of sweeping enchant PaperMC/Paper@8f7ac62 Validate manifest provided mapping namespace (#10612) PaperMC/Paper@fbe3c00 [ci skip] update projects workflow configuration PaperMC/Paper@44ee092 1.20.6 (#10623) PaperMC/Paper@812ccb9 fix spawnChunkRadius gamerule resetting PaperMC/Paper@25e44bc fix dumpitem command nbt format PaperMC/Paper@3fdd094 Fix sealed package check in BytecodeModifyingURLClassLoader (#10627) PaperMC/Paper@937a67a Add initial size cap to component map PaperMC/Paper@4ea67ab [ci skip] Remove trailing comma in projects action PaperMC/Paper@8c058f8 Update paperweight to 1.6.3 (#10626) PaperMC/Paper@fa6013d Fixes beds not exploding in the nether PaperMC/Paper@3e0eb4a Updated Upstream (CraftBukkit) (#10624) PaperMC/Paper@4cfd9e2 Expose canReach to mob pathfinding API (#10636) PaperMC/Paper@b8c454c Add damage check for mending (#10631) PaperMC/Paper@310b47b Update Java version references, add note on var usages PaperMC/Paper@faa7aa2 Add GameMode#isInvulnerable (#10633) PaperMC/Paper@18c201b Add EquipmentSlot#getOppositeHand (#10632) PaperMC/Paper@544ce20 Expose #hasColor to leather armor (#10638) PaperMC/Paper@59fe7cc default save-empty-scoreboard-teams to vanilla PaperMC/Paper@0db72ac Fix can_place_on conversion and size check for item containers PaperMC/Paper@156675c Fix lodestone compass target conversion PaperMC/Paper@5632210 add RegistryAccess for managing registries (#10154) PaperMC/Paper@6fcca46 Add missing step in V3818 PaperMC/Paper@7401313 fix shear drops for wolf and bogged PaperMC/Paper@7ae2c67 Keep components using single items in creative (#10664) PaperMC/Paper@b13c7db Add missing experimental field and annotations (#10653) PaperMC/Paper@9d8d38d Updated Upstream (CraftBukkit) (#10646) PaperMC/Paper@0e43d3c Added API to get player's proxy address (#10400) PaperMC/Paper@54c5ecb Add missing SpigotConfig logCommands check (#10659) PaperMC/Paper@816ea9e [ci skip] Update old particle reference in javadoc (#10652) PaperMC/Paper@716dfd8 Fix EntityLoadCrossbowEvent (#10645) PaperMC/Paper@21d91ce Prevent profile lookups when unnecessary (#10651) PaperMC/Paper@2a6a5fe Add a way to check whether the chest is blocked (#10635) PaperMC/Paper@ac3a547 Fix BlockStateMeta (#10647)
650 lines
34 KiB
Diff
650 lines
34 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Tue, 21 Sep 2021 23:54:25 +0100
|
|
Subject: [PATCH] Visibility API and Command
|
|
|
|
|
|
diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
|
index 3b08454cf7411d12bb33225df59800bd73312123..22676ec7a7ae9494b198e5e65e6be6d32e0feb85 100644
|
|
--- a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
|
+++ b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java
|
|
@@ -2,6 +2,9 @@ package me.samsuik.sakura.command;
|
|
|
|
import io.papermc.paper.command.PaperPluginsCommand;
|
|
import me.samsuik.sakura.command.subcommands.ConfigCommand;
|
|
+import me.samsuik.sakura.command.subcommands.FPSCommand;
|
|
+import me.samsuik.sakura.command.subcommands.VisualCommand;
|
|
+import me.samsuik.sakura.player.visibility.Visibility;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import org.bukkit.command.Command;
|
|
|
|
@@ -14,6 +17,10 @@ public final class SakuraCommands {
|
|
static {
|
|
COMMANDS.put("sakura", new SakuraCommand("sakura"));
|
|
COMMANDS.put("config", new ConfigCommand("config"));
|
|
+ COMMANDS.put("fps", new FPSCommand("fps"));
|
|
+ COMMANDS.put("tntvisibility", new VisualCommand(Visibility.Setting.TNT_VISIBILITY, "tnttoggle"));
|
|
+ COMMANDS.put("sandvisibility", new VisualCommand(Visibility.Setting.SAND_VISIBILITY, "sandtoggle"));
|
|
+ COMMANDS.put("minimal", new VisualCommand(Visibility.Setting.MINIMAL, "minimaltnt", "tntlag"));
|
|
}
|
|
|
|
public static void registerCommands(final MinecraftServer server) {
|
|
diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/FPSCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/FPSCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..aa5ddf696b09226a0bd3d967d2ac2b11fc2deb32
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/command/subcommands/FPSCommand.java
|
|
@@ -0,0 +1,26 @@
|
|
+package me.samsuik.sakura.command.subcommands;
|
|
+
|
|
+import me.samsuik.sakura.command.BaseSubCommand;
|
|
+import me.samsuik.sakura.player.visibility.VisibilityGUI;
|
|
+import org.bukkit.command.CommandSender;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
+
|
|
+@DefaultQualifier(NonNull.class)
|
|
+public final class FPSCommand extends BaseSubCommand {
|
|
+
|
|
+ private final VisibilityGUI VISIBILITY_GUI = new VisibilityGUI();
|
|
+
|
|
+ public FPSCommand(String name) {
|
|
+ super(name);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void execute(CommandSender sender, String[] args) {
|
|
+ if (sender instanceof Player player) {
|
|
+ VISIBILITY_GUI.showTo(player);
|
|
+ }
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/VisualCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/VisualCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..148a583279333eeb3e5db16652623082cd5e0e60
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/command/subcommands/VisualCommand.java
|
|
@@ -0,0 +1,45 @@
|
|
+package me.samsuik.sakura.command.subcommands;
|
|
+
|
|
+import me.samsuik.sakura.command.BaseSubCommand;
|
|
+import me.samsuik.sakura.configuration.GlobalConfiguration;
|
|
+import me.samsuik.sakura.player.visibility.Visibility;
|
|
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
|
+import org.bukkit.command.CommandSender;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.checkerframework.checker.nullness.qual.NonNull;
|
|
+import org.checkerframework.framework.qual.DefaultQualifier;
|
|
+
|
|
+import java.util.Arrays;
|
|
+
|
|
+@DefaultQualifier(NonNull.class)
|
|
+public final class VisualCommand extends BaseSubCommand {
|
|
+
|
|
+ private final Visibility.Setting type;
|
|
+
|
|
+ public VisualCommand(Visibility.Setting type, String... aliases) {
|
|
+ super(type.basicName());
|
|
+ this.setAliases(Arrays.asList(aliases));
|
|
+ this.type = type;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void execute(CommandSender sender, String[] args) {
|
|
+ if (!(sender instanceof Player player)) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ var visibility = player.getVisibility();
|
|
+
|
|
+ // Toggle clicked setting visibility
|
|
+ visibility.toggle(type);
|
|
+
|
|
+ // Send message to player
|
|
+ var state = visibility.isEnabled(type) ? "Enabled" : "Disabled";
|
|
+ player.sendMessage(MiniMessage.miniMessage().deserialize(GlobalConfiguration.get().fps.message,
|
|
+ Placeholder.unparsed("name", type.friendlyName()),
|
|
+ Placeholder.unparsed("state", state))
|
|
+ );
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..115addbbed36b9c10c123450a0f6400c2b8cf97d
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java
|
|
@@ -0,0 +1,119 @@
|
|
+package me.samsuik.sakura.player.visibility;
|
|
+
|
|
+import me.samsuik.sakura.configuration.GlobalConfiguration;
|
|
+import me.samsuik.sakura.player.gui.ItemIcon;
|
|
+import me.samsuik.sakura.player.gui.PlayerGUI;
|
|
+import net.kyori.adventure.text.Component;
|
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
+import net.kyori.adventure.text.format.TextColor;
|
|
+import net.kyori.adventure.text.format.TextDecoration;
|
|
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.Material;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.inventory.Inventory;
|
|
+import org.bukkit.inventory.ItemStack;
|
|
+import org.bukkit.inventory.meta.ItemMeta;
|
|
+
|
|
+import java.util.function.BiFunction;
|
|
+
|
|
+public final class VisibilityGUI extends PlayerGUI {
|
|
+
|
|
+ private static final BiFunction<Player, Holder, Inventory> CREATE_INVENTORY = (player, holder) -> {
|
|
+ Inventory inventory = Bukkit.createInventory(holder, 45, Component.text("FPS GUI"));
|
|
+
|
|
+ for (int i = 0; i < inventory.getSize(); ++i) {
|
|
+ int column = i % 9;
|
|
+ int row = (i + 1) / 9;
|
|
+
|
|
+ Material background = column > 0 && column < 8 ? (row > 0 && row < 4 || column > 1 && column < 7)
|
|
+ ? Material.matchMaterial(GlobalConfiguration.get().fps.material)
|
|
+ : Material.WHITE_STAINED_GLASS_PANE
|
|
+ : Material.BLACK_STAINED_GLASS_PANE;
|
|
+
|
|
+ ItemStack itemstack = new ItemStack(background);
|
|
+ ItemMeta meta = itemstack.getItemMeta();
|
|
+ meta.displayName(Component.space());
|
|
+ itemstack.setItemMeta(meta);
|
|
+
|
|
+ inventory.setItem(i, itemstack);
|
|
+ }
|
|
+
|
|
+ return inventory;
|
|
+ };
|
|
+
|
|
+ public VisibilityGUI() {
|
|
+ super(CREATE_INVENTORY);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ protected void register() {
|
|
+ registerFPSIcon(Visibility.Setting.TNT_VISIBILITY, Material.TNT, NamedTextColor.RED, 12);
|
|
+ registerFPSIcon(Visibility.Setting.SAND_VISIBILITY, Material.SAND, NamedTextColor.YELLOW, 14);
|
|
+ registerFPSIcon(Visibility.Setting.MINIMAL, Material.NETHER_BRICK_SLAB, NamedTextColor.GOLD, 13);
|
|
+ registerFPSIcon(Visibility.Setting.SPAWNERS, Material.SPAWNER, NamedTextColor.DARK_GRAY, 20);
|
|
+ registerFPSIcon(Visibility.Setting.FLASHING_TNT, Material.REDSTONE_LAMP, NamedTextColor.RED, 22);
|
|
+ registerFPSIcon(Visibility.Setting.EXPLOSIONS, Material.COBWEB, NamedTextColor.WHITE, 24);
|
|
+ registerFPSIcon(Visibility.Setting.PISTONS, Material.PISTON, NamedTextColor.GOLD, 30);
|
|
+ registerFPSIcon(Visibility.Setting.REDSTONE, Material.REDSTONE, NamedTextColor.DARK_RED, 31);
|
|
+ registerFPSIcon(Visibility.Setting.ENCHANTMENT_GLINT, Material.ENCHANTED_BOOK, NamedTextColor.DARK_PURPLE, 32);
|
|
+
|
|
+ registerIcon(new ItemIcon(
|
|
+ (player) -> {
|
|
+ ItemStack itemstack = new ItemStack(Material.GREEN_STAINED_GLASS_PANE);
|
|
+ Component title = Component.text("Toggle all", NamedTextColor.GREEN);
|
|
+
|
|
+ itemstack.editMeta(meta -> meta.displayName(title.decoration(TextDecoration.ITALIC, false)));
|
|
+ return itemstack;
|
|
+ },
|
|
+ (player) -> {
|
|
+ player.getVisibility().toggleAll();
|
|
+
|
|
+ // refresh icons after toggling
|
|
+ this.refresh(player);
|
|
+ },
|
|
+ 26
|
|
+ ));
|
|
+ }
|
|
+
|
|
+ private void registerFPSIcon(Visibility.Setting setting, Material material, TextColor colour, int slot) {
|
|
+ registerIcon(new ItemIcon((player) -> {
|
|
+ Visibility visibility = player.getVisibility();
|
|
+ ItemStack itemstack = new ItemStack(material);
|
|
+
|
|
+ itemstack.editMeta(meta -> {
|
|
+ // Get the current state as a string
|
|
+ String state = visibility.isEnabled(setting) ? "Enabled" : "Disabled";
|
|
+
|
|
+ // Friendly name as a component
|
|
+ Component title = Component.text(setting.friendlyName(), colour);
|
|
+
|
|
+ // Display names are italic by default
|
|
+ title = title.decoration(TextDecoration.ITALIC, false);
|
|
+
|
|
+ // Set the display name
|
|
+ meta.displayName(title.append(Component.space())
|
|
+ .append(Component.text(state, NamedTextColor.GRAY)));
|
|
+ });
|
|
+
|
|
+ return itemstack;
|
|
+ }, (player) -> {
|
|
+ Visibility visibility = player.getVisibility();
|
|
+
|
|
+ // Toggle clicked setting visibility
|
|
+ visibility.toggle(setting);
|
|
+
|
|
+ // Get the current state as a string
|
|
+ String state = visibility.isEnabled(setting) ? "Enabled" : "Disabled";
|
|
+
|
|
+ // Send message to player
|
|
+ player.sendRichMessage(GlobalConfiguration.get().fps.message,
|
|
+ Placeholder.unparsed("name", setting.friendlyName()),
|
|
+ Placeholder.unparsed("state", state)
|
|
+ );
|
|
+ },
|
|
+ slot
|
|
+ ));
|
|
+ }
|
|
+
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
|
index 1a37654aff9a9c86c9f7af10a1cf721371f0c5ec..82644b34a77dc5e5af38260b7b07b3ec9aceae33 100644
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
|
|
@@ -19,7 +19,7 @@ public class ClientboundSectionBlocksUpdatePacket implements Packet<ClientGamePa
|
|
private static final int POS_IN_SECTION_BITS = 12;
|
|
private final SectionPos sectionPos;
|
|
private final short[] positions;
|
|
- private final BlockState[] states;
|
|
+ public final BlockState[] states; // Sakura - private -> public
|
|
|
|
public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section) {
|
|
this.sectionPos = sectionPos;
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 6aacf5ff736bcbbb8582b6ae11e7dfc6ff265c08..6e6ca00b20072e65370a47d38dded747fc0eb7c9 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1803,6 +1803,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
this.profiler.pop();
|
|
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
|
|
worldserver.localConfig().expire(currentTickLong); // Sakura
|
|
+ worldserver.minimalTNT.clear(); // Sakura - visibility api
|
|
}
|
|
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
index dbe9df1e1973db133f7c8516256697ef7c968137..0bfd2005dc82b0262badfe6867835e80a6e6a1dc 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
|
@@ -1438,6 +1438,22 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
}
|
|
// Paper end - Configurable entity tracking range by Y
|
|
|
|
+ // Sakura start - visibility api
|
|
+ if (this.entity.isPrimedTNT && player.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.TNT_VISIBILITY)
|
|
+ || this.entity.isFallingBlock && player.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.SAND_VISIBILITY)) {
|
|
+ flag = false;
|
|
+ }
|
|
+
|
|
+ if (flag && (this.entity.isPrimedTNT || this.entity.isFallingBlock) && player.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.MINIMAL)) {
|
|
+ long key = entity.blockPosition().asLong();
|
|
+
|
|
+ if (level.minimalTNT.containsKey(key)) {
|
|
+ flag = level.minimalTNT.get(key) == entity.getId();
|
|
+ } else {
|
|
+ level.minimalTNT.put(key, entity.getId());
|
|
+ }
|
|
+ }
|
|
+ // Sakura end
|
|
// CraftBukkit start - respect vanish API
|
|
if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits
|
|
flag = false;
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
index 4f103f731623a8570238a6867fda1c5f83fca4e4..2835f102559edcd6e7891a83125d84f5553565da 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
|
@@ -51,6 +51,13 @@ import net.minecraft.util.Mth;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.player.PlayerVelocityEvent;
|
|
// CraftBukkit end
|
|
+// Sakura start
|
|
+import me.samsuik.sakura.player.visibility.Visibility;
|
|
+import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
|
|
+import net.minecraft.world.entity.EntityType;
|
|
+import net.minecraft.world.level.block.Block;
|
|
+import net.minecraft.world.level.block.Blocks;
|
|
+// Sakura end
|
|
|
|
public class ServerEntity {
|
|
|
|
@@ -297,6 +304,18 @@ public class ServerEntity {
|
|
this.entity.startSeenByPlayer(player);
|
|
}
|
|
|
|
+ // Sakura start - visibility api
|
|
+ protected Packet<ClientGamePacketListener> createEntityPacket(Entity entity, ServerPlayer entityplayer) {
|
|
+ if (entity.isPrimedTNT && entityplayer.visibility.isToggled(Visibility.Setting.FLASHING_TNT)) {
|
|
+ return new ClientboundAddEntityPacket(entity.getId(), entity.getUUID(),
|
|
+ entity.getX(), entity.getY(), entity.getZ(), 0, 0, EntityType.FALLING_BLOCK,
|
|
+ Block.getId(Blocks.TNT.defaultBlockState()), entity.getDeltaMovement(), entity.getYHeadRot());
|
|
+ } else {
|
|
+ return entity.getAddEntityPacket();
|
|
+ }
|
|
+ }
|
|
+ // Sakura end
|
|
+
|
|
public void sendPairingData(ServerPlayer player, Consumer<Packet<ClientGamePacketListener>> sender) {
|
|
if (this.entity.isRemoved()) {
|
|
// CraftBukkit start - Remove useless error spam, just return
|
|
@@ -305,12 +324,19 @@ public class ServerEntity {
|
|
// CraftBukkit end
|
|
}
|
|
|
|
- Packet<ClientGamePacketListener> packet = this.entity.getAddEntityPacket();
|
|
+ Packet<ClientGamePacketListener> packet = this.createEntityPacket(this.entity, player); // Sakura - visibility api
|
|
|
|
this.yHeadRotp = Mth.floor(this.entity.getYHeadRot() * 256.0F / 360.0F);
|
|
sender.accept(packet);
|
|
if (this.trackedDataValues != null) {
|
|
- sender.accept(new ClientboundSetEntityDataPacket(this.entity.getId(), this.trackedDataValues));
|
|
+ // Sakura start - visibility api
|
|
+ if (this.entity.isPrimedTNT && player.visibility.isToggled(Visibility.Setting.FLASHING_TNT)) {
|
|
+ // Could modifying this break something elsewhere?
|
|
+ trackedDataValues.removeIf((data) -> data.id() == 8);
|
|
+ }
|
|
+
|
|
+ sender.accept(new ClientboundSetEntityDataPacket(this.entity.getId(), trackedDataValues));
|
|
+ // Sakura end
|
|
}
|
|
|
|
boolean flag = this.trackDelta;
|
|
@@ -375,6 +401,32 @@ public class ServerEntity {
|
|
}
|
|
|
|
}
|
|
+
|
|
+ // Sakura start - visibility api
|
|
+ private void broadcastEntityData(List<SynchedEntityData.DataValue<?>> packedValues) {
|
|
+ Packet<?> packet0 = new ClientboundSetEntityDataPacket(this.entity.getId(), packedValues);
|
|
+ Packet<?> packet1 = null;
|
|
+
|
|
+ if (this.entity.isPrimedTNT) {
|
|
+ var copyOfDirtyItems = Lists.newArrayList(packedValues);
|
|
+ copyOfDirtyItems.removeIf((data) -> data.id() == 8);
|
|
+
|
|
+ if (!copyOfDirtyItems.isEmpty()) {
|
|
+ packet1 = new ClientboundSetEntityDataPacket(this.entity.getId(), copyOfDirtyItems);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ for (var connection : trackedPlayers) {
|
|
+ var player = connection.getPlayer();
|
|
+
|
|
+ if (!this.entity.isPrimedTNT || !player.visibility.isToggled(Visibility.Setting.FLASHING_TNT)) {
|
|
+ connection.send(packet0);
|
|
+ } else if (packet1 != null) {
|
|
+ connection.send(packet1);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Sakura end
|
|
|
|
private void sendDirtyEntityData() {
|
|
SynchedEntityData datawatcher = this.entity.getEntityData();
|
|
@@ -382,7 +434,7 @@ public class ServerEntity {
|
|
|
|
if (list != null) {
|
|
this.trackedDataValues = datawatcher.getNonDefaultValues();
|
|
- this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list));
|
|
+ this.broadcastEntityData(list); // Sakura - visibility api
|
|
}
|
|
|
|
if (this.entity instanceof LivingEntity) {
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index cffdb530be035d177ccfd13a9e560c544f3acaac..bb1b891d917ed41ce5da6c2c9f470c5f49eff34a 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1959,7 +1959,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
while (iterator.hasNext()) {
|
|
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
|
|
|
- if (entityplayer.distanceToSqr(x, y, z) < 4096.0D) {
|
|
+ if (entityplayer.distanceToSqr(x, y, z) < 4096.0D && !entityplayer.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.EXPLOSIONS)) { // Sakura - visibility api
|
|
entityplayer.connection.send(new ClientboundExplodePacket(x, y, z, power, explosion.getToBlow(), (Vec3) explosion.getHitPlayers().get(entityplayer), explosion.getBlockInteraction(), explosion.getSmallExplosionParticles(), explosion.getLargeExplosionParticles(), explosion.getExplosionSound()));
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
index 8437316888c6056060a2780652147590b6fe7443..826fca7c9e1b49b8fbedbc4d99d55b85b4faa807 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
|
@@ -277,6 +277,7 @@ public class ServerPlayer extends Player {
|
|
public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper
|
|
// Paper end - Optional per player mob spawns
|
|
public final int[] mobBackoffCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper - per player mob count backoff
|
|
+ public final me.samsuik.sakura.player.visibility.Visibility visibility = new me.samsuik.sakura.player.visibility.Visibility(); // Sakura - visiblity api
|
|
|
|
// CraftBukkit start
|
|
public CraftPlayer.TransferCookieConnection transferCookieConnection;
|
|
@@ -595,6 +596,15 @@ public class ServerPlayer extends Player {
|
|
this.respawnDimension = (ResourceKey) dataresult1.resultOrPartial(logger1::error).orElse(Level.OVERWORLD);
|
|
}
|
|
}
|
|
+ // Sakura start - visibility api
|
|
+ CompoundTag tag = nbt.getCompound("Sakura.Visuals");
|
|
+
|
|
+ for (me.samsuik.sakura.player.visibility.Visibility.Setting setting : me.samsuik.sakura.player.visibility.Visibility.Setting.values()) {
|
|
+ if (tag.getBoolean(setting.name())) {
|
|
+ visibility.toggle(setting);
|
|
+ }
|
|
+ }
|
|
+ // Sakura end - visibility api
|
|
|
|
this.spawnExtraParticlesOnFall = nbt.getBoolean("spawn_extra_particles_on_fall");
|
|
Tag nbtbase = nbt.get("raid_omen_position");
|
|
@@ -673,6 +683,13 @@ public class ServerPlayer extends Player {
|
|
});
|
|
}
|
|
this.getBukkitEntity().setExtraData(nbt); // CraftBukkit
|
|
+ // Sakura start - visibility api
|
|
+ CompoundTag tag = new CompoundTag();
|
|
+ for (me.samsuik.sakura.player.visibility.Visibility.Setting setting : me.samsuik.sakura.player.visibility.Visibility.Setting.values()) {
|
|
+ tag.putBoolean(setting.name(), visibility.isToggled(setting));
|
|
+ }
|
|
+ nbt.put("Sakura.Visuals", tag);
|
|
+ // Sakura end - visibility api
|
|
|
|
nbt.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall);
|
|
if (this.raidOmenPosition != null) {
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
index 8ac5d8ccf731100a1be690cb2ed1be82cadba8ed..9a5e0e244068d9ef424bcf2c466a2bf21f1fcaf8 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
|
@@ -42,6 +42,23 @@ import org.bukkit.craftbukkit.util.CraftLocation;
|
|
import org.bukkit.craftbukkit.util.Waitable;
|
|
import org.bukkit.event.player.PlayerKickEvent;
|
|
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
|
|
+// Sakura start
|
|
+import com.mojang.datafixers.util.Pair;
|
|
+import me.samsuik.sakura.player.visibility.Visibility.Setting;
|
|
+import net.minecraft.core.component.DataComponents;
|
|
+import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
|
+import net.minecraft.network.protocol.game.ClientboundBlockEventPacket;
|
|
+import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
|
|
+import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket;
|
|
+import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
|
+import net.minecraft.world.entity.EquipmentSlot;
|
|
+import net.minecraft.world.item.ItemStack;
|
|
+import net.minecraft.world.level.block.Blocks;
|
|
+import net.minecraft.world.level.block.DiodeBlock;
|
|
+import net.minecraft.world.level.block.RedStoneWireBlock;
|
|
+import net.minecraft.world.level.block.piston.PistonBaseBlock;
|
|
+import net.minecraft.world.level.block.piston.PistonHeadBlock;
|
|
+// Sakura end
|
|
|
|
public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener, CraftPlayer.TransferCookieConnection {
|
|
|
|
@@ -94,6 +111,65 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
protected final org.bukkit.craftbukkit.CraftServer cserver;
|
|
public boolean processedDisconnect;
|
|
|
|
+ // Sakura start - visibility api
|
|
+ private @Nullable Packet<?> recreatePacket(Packet<?> packet) {
|
|
+ me.samsuik.sakura.player.visibility.Visibility visibility = this.player.visibility;
|
|
+ if (packet instanceof ClientboundSetEquipmentPacket equipment && visibility.isToggled(Setting.ENCHANTMENT_GLINT)) {
|
|
+ java.util.List<Pair<EquipmentSlot, ItemStack>> slots = new java.util.ArrayList<>();
|
|
+
|
|
+ for (int i = 0; i < equipment.getSlots().size(); i++) {
|
|
+ Pair<EquipmentSlot, ItemStack> pair = equipment.getSlots().get(i);
|
|
+ ItemStack itemstack = pair.getSecond();
|
|
+
|
|
+ if (itemstack.isEnchanted()) {
|
|
+ ItemStack copy = itemstack.copy();
|
|
+ copy.remove(DataComponents.ENCHANTMENTS);
|
|
+ itemstack = copy;
|
|
+ }
|
|
+
|
|
+ slots.add(new Pair<>(pair.getFirst(), itemstack));
|
|
+ }
|
|
+
|
|
+ packet = new ClientboundSetEquipmentPacket(equipment.getEntity(), slots);
|
|
+ } else if (packet instanceof ClientboundBlockEntityDataPacket blockdata
|
|
+ && visibility.isToggled(Setting.SPAWNERS)
|
|
+ && this.player.level().getBlockIfLoaded(blockdata.getPos()) == Blocks.SPAWNER) {
|
|
+ packet = new ClientboundBlockUpdatePacket(blockdata.getPos(), Blocks.BLACK_STAINED_GLASS.defaultBlockState());
|
|
+ } else if (packet instanceof ClientboundBlockUpdatePacket updatePacket) {
|
|
+ if (visibility.isToggled(Setting.SPAWNERS) && updatePacket.blockState.getBlock() == Blocks.SPAWNER) {
|
|
+ packet = new ClientboundBlockUpdatePacket(updatePacket.getPos(), Blocks.BLACK_STAINED_GLASS.defaultBlockState());
|
|
+ } else if (visibility.isToggled(Setting.REDSTONE)
|
|
+ && (updatePacket.blockState.getBlock() instanceof DiodeBlock
|
|
+ || updatePacket.blockState.getBlock() instanceof RedStoneWireBlock)) {
|
|
+ return null;
|
|
+ } else if (visibility.isToggled(Setting.PISTONS)
|
|
+ && (updatePacket.blockState.getBlock() instanceof PistonBaseBlock
|
|
+ || updatePacket.blockState.getBlock() instanceof PistonHeadBlock)) {
|
|
+ return null;
|
|
+ }
|
|
+ } else if (packet instanceof ClientboundSectionBlocksUpdatePacket sectionPacket) {
|
|
+ for (net.minecraft.world.level.block.state.BlockState state : sectionPacket.states) {
|
|
+ if (visibility.isToggled(Setting.REDSTONE)
|
|
+ && (state.getBlock() instanceof DiodeBlock
|
|
+ || state.getBlock() instanceof RedStoneWireBlock)) {
|
|
+ return null;
|
|
+ } else if (visibility.isToggled(Setting.PISTONS)
|
|
+ && (state.getBlock() instanceof PistonBaseBlock
|
|
+ || state.getBlock() instanceof PistonHeadBlock)) {
|
|
+ return null;
|
|
+ }
|
|
+ }
|
|
+ } else if (packet instanceof ClientboundBlockEventPacket blockevent
|
|
+ && visibility.isToggled(Setting.PISTONS)
|
|
+ && (blockevent.getBlock() instanceof PistonBaseBlock
|
|
+ || blockevent.getBlock() instanceof PistonHeadBlock)) {
|
|
+ return null;
|
|
+ }
|
|
+
|
|
+ return packet;
|
|
+ }
|
|
+ // Sakura end - visibility api
|
|
+
|
|
public CraftPlayer getCraftPlayer() {
|
|
return (this.player == null) ? null : (CraftPlayer) this.player.getBukkitEntity();
|
|
// CraftBukkit end
|
|
@@ -300,6 +376,12 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
ClientboundSetDefaultSpawnPositionPacket packet6 = (ClientboundSetDefaultSpawnPositionPacket) packet;
|
|
this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld());
|
|
}
|
|
+ // Sakura start - visibility api
|
|
+ if (this.player.visibility.isModified()) {
|
|
+ packet = this.recreatePacket(packet);
|
|
+ if (packet == null) return;
|
|
+ }
|
|
+ // Sakura end - visibility api
|
|
// CraftBukkit end
|
|
if (packet.isTerminal()) {
|
|
this.close();
|
|
@@ -313,8 +395,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
|
CrashReport crashreport = CrashReport.forThrowable(throwable, "Sending packet");
|
|
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Packet being sent");
|
|
|
|
+ // Sakura start - this has to be effectively final as we're modifying the packet above
|
|
+ var packetFinal = packet;
|
|
crashreportsystemdetails.setDetail("Packet class", () -> {
|
|
- return packet.getClass().getCanonicalName();
|
|
+ return packetFinal.getClass().getCanonicalName();
|
|
+ // Sakura end
|
|
});
|
|
throw new ReportedException(crashreport);
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 5e9202bc7fc649764568b55d66ba0d684118c00c..9dd069659a7ec93b9f0c65edd233952548881870 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -3198,6 +3198,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
|
|
event.setCancelled(cancelled);
|
|
AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224
|
|
+ me.samsuik.sakura.player.gui.PlayerGUI.onWindowClick(event); // Sakura - visibility gui
|
|
this.cserver.getPluginManager().callEvent(event);
|
|
if (this.player.containerMenu != oldContainer) {
|
|
return;
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 2bc85351e6e52f90da5fdb29d8d042a06132d742..6872b9624be78e252df54858d8b9cb5aae93ceda 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -569,6 +569,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
|
|
public boolean updatingSectionStatus = false;
|
|
// Paper end
|
|
+ // Sakura start - visibility api and command
|
|
+ public boolean isPrimedTNT;
|
|
+ public boolean isFallingBlock;
|
|
+ // Sakura end - visibility api and command
|
|
|
|
public Entity(EntityType<?> type, Level world) {
|
|
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
index d504d10fbe45dfe3f2f3d08d2473df6cd18f6dcf..28b8efdd224e4dbb32f3eac1c9e2c512e2695dc8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
|
@@ -74,6 +74,7 @@ public class FallingBlockEntity extends Entity {
|
|
this.blockState = Blocks.SAND.defaultBlockState();
|
|
this.dropItem = true;
|
|
this.fallDamageMax = 40;
|
|
+ this.isFallingBlock = true; // Sakura
|
|
}
|
|
|
|
public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
index f1f352ec0e51f5db59254841a06c176c5a876fc9..dace8dc0c051ce9355d878154466ee3a548a3832 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -37,6 +37,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
|
public PrimedTnt(EntityType<? extends PrimedTnt> type, Level world) {
|
|
super(type, world);
|
|
this.blocksBuilding = true;
|
|
+ this.isPrimedTNT = true; // Sakura
|
|
}
|
|
|
|
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 62d39dd63e33c2781c39d3241130b32c18093fcf..52c203dcc1e0ba6b0b236412dadfb1fed2a8ea31 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -225,6 +225,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
|
|
public abstract ResourceKey<LevelStem> getTypeKey();
|
|
|
|
+ public final it.unimi.dsi.fastutil.longs.Long2IntMap minimalTNT = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api
|
|
+
|
|
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - create paper world config; Async-Anti-Xray: Pass executor
|
|
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
|
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index 5f896948d158651cd9837364759dbfbcce6b7d21..73068dfe3c721b38e7f00767f3c94dc1d2589a13 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -543,6 +543,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
this.getHandle().displayName = name == null ? this.getName() : name;
|
|
}
|
|
|
|
+ // Sakura start - visiblity api
|
|
+ @Override
|
|
+ public me.samsuik.sakura.player.visibility.Visibility getVisibility() {
|
|
+ return getHandle().visibility;
|
|
+ }
|
|
+ // Sakura end
|
|
+
|
|
// Paper start
|
|
@Override
|
|
public void playerListName(net.kyori.adventure.text.Component name) {
|