mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-20 15:29:33 +00:00
Remove Flashing TNT visibility setting
This commit is contained in:
@@ -114,10 +114,10 @@ index 0000000000000000000000000000000000000000..148a583279333eeb3e5db16652623082
|
||||
+}
|
||||
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
|
||||
index 0000000000000000000000000000000000000000..d61d47f9a473d072a160bc6b1cff8a8daf8929b6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java
|
||||
@@ -0,0 +1,119 @@
|
||||
@@ -0,0 +1,117 @@
|
||||
+package me.samsuik.sakura.player.visibility;
|
||||
+
|
||||
+import me.samsuik.sakura.configuration.GlobalConfiguration;
|
||||
@@ -172,21 +172,21 @@ index 0000000000000000000000000000000000000000..115addbbed36b9c10c123450a0f6400c
|
||||
+ 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.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) -> {
|
||||
+ 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 -> {
|
||||
+ player.getVisibility().toggleAll();
|
||||
+
|
||||
+ // refresh icons after toggling
|
||||
@@ -197,7 +197,7 @@ index 0000000000000000000000000000000000000000..115addbbed36b9c10c123450a0f6400c
|
||||
+ }
|
||||
+
|
||||
+ private void registerFPSIcon(Visibility.Setting setting, Material material, TextColor colour, int slot) {
|
||||
+ registerIcon(new ItemIcon((player) -> {
|
||||
+ registerIcon(new ItemIcon(player -> {
|
||||
+ Visibility visibility = player.getVisibility();
|
||||
+ ItemStack itemstack = new ItemStack(material);
|
||||
+
|
||||
@@ -217,7 +217,7 @@ index 0000000000000000000000000000000000000000..115addbbed36b9c10c123450a0f6400c
|
||||
+ });
|
||||
+
|
||||
+ return itemstack;
|
||||
+ }, (player) -> {
|
||||
+ }, player -> {
|
||||
+ Visibility visibility = player.getVisibility();
|
||||
+
|
||||
+ // Toggle clicked setting visibility
|
||||
@@ -231,9 +231,7 @@ index 0000000000000000000000000000000000000000..115addbbed36b9c10c123450a0f6400c
|
||||
+ Placeholder.unparsed("name", setting.friendlyName()),
|
||||
+ Placeholder.unparsed("state", state)
|
||||
+ );
|
||||
+ },
|
||||
+ slot
|
||||
+ ));
|
||||
+ }, slot));
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
@@ -289,107 +287,6 @@ index 12109446fc76a39faee6cda042ca48b3fd3809f4..bb6a2be67394b9a6904d759b7564008d
|
||||
// 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 529ab44baaf573b97cf7e89560c548642733188f..cce8f45c15b9a9acfbf9b769f7670cfd0969d62f 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -47,6 +47,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 {
|
||||
|
||||
@@ -290,6 +297,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
|
||||
@@ -298,12 +317,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;
|
||||
@@ -373,6 +399,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();
|
||||
@@ -380,7 +432,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 ed7b9d9a3856cf36b64e629a86c2e9bdac381eb3..5df1d01c52b527ff74778d8e4aa27b3b0b1e7a4b 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
|
||||
Reference in New Issue
Block a user