mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
API for updating recipes on clients
This commit is contained in:
parent
4c98f21716
commit
06b00246a2
@ -596,10 +596,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- return ichatmutablecomponent;
|
- return ichatmutablecomponent;
|
||||||
|
- } else {
|
||||||
|
- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(profile) ? Component.translatable("multiplayer.disconnect.server_full") : null;
|
||||||
+ // return chatmessage;
|
+ // return chatmessage;
|
||||||
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure
|
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent)); // Paper - Adventure
|
||||||
} else {
|
+ } else {
|
||||||
- return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(profile) ? Component.translatable("multiplayer.disconnect.server_full") : null;
|
|
||||||
+ // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null;
|
+ // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null;
|
||||||
+ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
|
+ if (this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile)) {
|
||||||
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure
|
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure
|
||||||
@ -863,10 +864,11 @@
|
|||||||
this.sendAllPlayerInfoIn = 0;
|
this.sendAllPlayerInfoIn = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,6 +952,25 @@
|
@@ -540,6 +951,25 @@
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
+
|
||||||
+ // CraftBukkit start - add a world/entity limited version
|
+ // CraftBukkit start - add a world/entity limited version
|
||||||
+ public void broadcastAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) {
|
+ public void broadcastAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) {
|
||||||
+ for (int i = 0; i < this.players.size(); ++i) {
|
+ for (int i = 0; i < this.players.size(); ++i) {
|
||||||
@ -885,10 +887,9 @@
|
|||||||
+
|
+
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
|
public void broadcastAll(Packet<?> packet, ResourceKey<Level> dimension) {
|
||||||
Iterator iterator = this.players.iterator();
|
Iterator iterator = this.players.iterator();
|
||||||
|
|
||||||
@@ -554,7 +984,7 @@
|
@@ -554,7 +984,7 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -928,7 +929,7 @@
|
|||||||
if (player.connection != null) {
|
if (player.connection != null) {
|
||||||
byte b0;
|
byte b0;
|
||||||
|
|
||||||
@@ -643,36 +1078,53 @@
|
@@ -643,35 +1078,52 @@
|
||||||
player.connection.send(new ClientboundEntityEventPacket(player, b0));
|
player.connection.send(new ClientboundEntityEventPacket(player, b0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -985,16 +986,15 @@
|
|||||||
+ public void broadcast(@Nullable net.minecraft.world.entity.player.Player player, double x, double y, double z, double distance, ResourceKey<Level> worldKey, Packet<?> packet) {
|
+ public void broadcast(@Nullable net.minecraft.world.entity.player.Player player, double x, double y, double z, double distance, ResourceKey<Level> worldKey, Packet<?> packet) {
|
||||||
for (int i = 0; i < this.players.size(); ++i) {
|
for (int i = 0; i < this.players.size(); ++i) {
|
||||||
ServerPlayer entityplayer = (ServerPlayer) this.players.get(i);
|
ServerPlayer entityplayer = (ServerPlayer) this.players.get(i);
|
||||||
|
+
|
||||||
+ // CraftBukkit start - Test if player receiving packet can see the source of the packet
|
+ // CraftBukkit start - Test if player receiving packet can see the source of the packet
|
||||||
+ if (player != null && !entityplayer.getBukkitEntity().canSee(player.getBukkitEntity())) {
|
+ if (player != null && !entityplayer.getBukkitEntity().canSee(player.getBukkitEntity())) {
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
|
if (entityplayer != player && entityplayer.level().dimension() == worldKey) {
|
||||||
double d4 = x - entityplayer.getX();
|
double d4 = x - entityplayer.getX();
|
||||||
double d5 = y - entityplayer.getY();
|
|
||||||
@@ -687,10 +1139,12 @@
|
@@ -687,10 +1139,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1202,11 +1202,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
advancementdataplayer.setPlayer(player);
|
advancementdataplayer.setPlayer(player);
|
||||||
@@ -932,15 +1449,28 @@
|
@@ -932,15 +1449,39 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadResources() {
|
public void reloadResources() {
|
||||||
- Iterator iterator = this.advancements.values().iterator();
|
- Iterator iterator = this.advancements.values().iterator();
|
||||||
|
+ // Paper start - API for updating recipes on clients
|
||||||
|
+ this.reloadAdvancementData();
|
||||||
|
+ this.reloadTagData();
|
||||||
|
+ this.reloadRecipes();
|
||||||
|
+ }
|
||||||
|
+ public void reloadAdvancementData() {
|
||||||
|
+ // Paper end - API for updating recipes on clients
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ /*Iterator iterator = this.advancements.values().iterator();
|
+ /*Iterator iterator = this.advancements.values().iterator();
|
||||||
|
|
||||||
@ -1223,9 +1230,13 @@
|
|||||||
}
|
}
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
|
+ // Paper start - API for updating recipes on clients
|
||||||
|
+ }
|
||||||
|
+ public void reloadTagData() {
|
||||||
this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries)));
|
this.broadcastAll(new ClientboundUpdateTagsPacket(TagNetworkSerialization.serializeTagsToNetwork(this.registries)));
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ this.reloadRecipes();
|
+ // this.reloadRecipes(); // Paper - do not reload recipes just because tag data was reloaded
|
||||||
|
+ // Paper end - API for updating recipes on clients
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public void reloadRecipes() {
|
+ public void reloadRecipes() {
|
||||||
|
@ -1190,6 +1190,18 @@ public final class CraftServer implements Server {
|
|||||||
ReloadCommand.reload(this.console);
|
ReloadCommand.reload(this.console);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Paper start - API for updating recipes on clients
|
||||||
|
@Override
|
||||||
|
public void updateResources() {
|
||||||
|
this.playerList.reloadResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateRecipes() {
|
||||||
|
this.playerList.reloadRecipes();
|
||||||
|
}
|
||||||
|
// Paper end - API for updating recipes on clients
|
||||||
|
|
||||||
private void loadIcon() {
|
private void loadIcon() {
|
||||||
this.icon = new CraftIconCache(null);
|
this.icon = new CraftIconCache(null);
|
||||||
try {
|
try {
|
||||||
@ -1569,6 +1581,13 @@ public final class CraftServer implements Server {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addRecipe(Recipe recipe) {
|
public boolean addRecipe(Recipe recipe) {
|
||||||
|
// Paper start - API for updating recipes on clients
|
||||||
|
return this.addRecipe(recipe, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addRecipe(Recipe recipe, boolean resendRecipes) {
|
||||||
|
// Paper end - API for updating recipes on clients
|
||||||
CraftRecipe toAdd;
|
CraftRecipe toAdd;
|
||||||
if (recipe instanceof CraftRecipe) {
|
if (recipe instanceof CraftRecipe) {
|
||||||
toAdd = (CraftRecipe) recipe;
|
toAdd = (CraftRecipe) recipe;
|
||||||
@ -1600,6 +1619,11 @@ public final class CraftServer implements Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
toAdd.addToCraftingManager();
|
toAdd.addToCraftingManager();
|
||||||
|
// Paper start - API for updating recipes on clients
|
||||||
|
if (true || resendRecipes) { // Always needs to be resent now... TODO
|
||||||
|
this.playerList.reloadRecipes();
|
||||||
|
}
|
||||||
|
// Paper end - API for updating recipes on clients
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1780,9 +1804,23 @@ public final class CraftServer implements Server {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeRecipe(NamespacedKey recipeKey) {
|
public boolean removeRecipe(NamespacedKey recipeKey) {
|
||||||
|
// Paper start - API for updating recipes on clients
|
||||||
|
return this.removeRecipe(recipeKey, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeRecipe(NamespacedKey recipeKey, boolean resendRecipes) {
|
||||||
|
// Paper end - API for updating recipes on clients
|
||||||
Preconditions.checkArgument(recipeKey != null, "recipeKey == null");
|
Preconditions.checkArgument(recipeKey != null, "recipeKey == null");
|
||||||
|
|
||||||
return this.getServer().getRecipeManager().removeRecipe(CraftRecipe.toMinecraft(recipeKey));
|
// Paper start - resend recipes on successful removal
|
||||||
|
final ResourceKey<net.minecraft.world.item.crafting.Recipe<?>> minecraftKey = CraftRecipe.toMinecraft(recipeKey);
|
||||||
|
final boolean removed = this.getServer().getRecipeManager().removeRecipe(minecraftKey);
|
||||||
|
if (removed/* && resendRecipes*/) { // TODO Always need to resend them rn - deprecate this method?
|
||||||
|
this.playerList.reloadRecipes();
|
||||||
|
}
|
||||||
|
return removed;
|
||||||
|
// Paper end - resend recipes on successful removal
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user