From 27c0ed55ea716e5befe3405cd77c0549fa212405 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 8 Jun 2023 10:48:28 -0700 Subject: [PATCH] add some more patches back --- ...riting-of-comments-to-server.propert.patch | 69 +++++++++++++++++++ patches/server/Fix-block-place-logic.patch | 39 +++++++++++ 2 files changed, 108 insertions(+) create mode 100644 patches/server/Allow-skipping-writing-of-comments-to-server.propert.patch create mode 100644 patches/server/Fix-block-place-logic.patch diff --git a/patches/server/Allow-skipping-writing-of-comments-to-server.propert.patch b/patches/server/Allow-skipping-writing-of-comments-to-server.propert.patch new file mode 100644 index 0000000000..e4ce42e876 --- /dev/null +++ b/patches/server/Allow-skipping-writing-of-comments-to-server.propert.patch @@ -0,0 +1,69 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Professor Bloodstone +Date: Fri, 23 Jul 2021 02:32:04 +0200 +Subject: [PATCH] Allow skipping writing of comments to server.properties + +Makes less git noise, as it won't update the date every single time + +Use -DPaper.skipServerPropertiesComments=true flag to disable writing it + +diff --git a/src/main/java/net/minecraft/server/dedicated/Settings.java b/src/main/java/net/minecraft/server/dedicated/Settings.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/dedicated/Settings.java ++++ b/src/main/java/net/minecraft/server/dedicated/Settings.java +@@ -0,0 +0,0 @@ public abstract class Settings> { + + private static final Logger LOGGER = LogUtils.getLogger(); + public final Properties properties; ++ private static final boolean skipComments = Boolean.getBoolean("Paper.skipServerPropertiesComments"); // Paper - allow skipping server.properties comments + // CraftBukkit start + private OptionSet options = null; + +@@ -0,0 +0,0 @@ public abstract class Settings> { + return; + } + // CraftBukkit end +- BufferedWriter bufferedwriter = Files.newBufferedWriter(path, StandardCharsets.UTF_8); ++ // Paper start - disable writing comments to properties file ++ java.io.OutputStream outputstream = Files.newOutputStream(path); ++ java.io.BufferedOutputStream bufferedOutputStream = !skipComments ? new java.io.BufferedOutputStream(outputstream) : new java.io.BufferedOutputStream(outputstream) { ++ private boolean isRightAfterNewline = true; // If last written char was newline ++ private boolean isComment = false; // Are we writing comment currently? ++ ++ @Override ++ public void write(@org.jetbrains.annotations.NotNull byte[] b) throws IOException { ++ this.write(b, 0, b.length); ++ } ++ ++ @Override ++ public void write(@org.jetbrains.annotations.NotNull byte[] bbuf, int off, int len) throws IOException { ++ int latest_offset = off; // The latest offset, updated when comment ends ++ for (int index = off; index < off + len; ++index ) { ++ byte c = bbuf[index]; ++ boolean isNewline = (c == '\n' || c == '\r'); ++ if (isNewline && this.isComment) { ++ // Comment has ended ++ this.isComment = false; ++ latest_offset = index+1; ++ } ++ if (c == '#' && this.isRightAfterNewline) { ++ this.isComment = true; ++ if (index != latest_offset) { ++ // We got some non-comment data earlier ++ super.write(bbuf, latest_offset, index-latest_offset); ++ } ++ } ++ this.isRightAfterNewline = isNewline; // Store for next iteration ++ ++ } ++ if (latest_offset < off+len && !this.isComment) { ++ // We have some unwritten data, that isn't part of a comment ++ super.write(bbuf, latest_offset, (off + len) - latest_offset); ++ } ++ } ++ }; ++ BufferedWriter bufferedwriter = new BufferedWriter(new java.io.OutputStreamWriter(bufferedOutputStream, java.nio.charset.StandardCharsets.UTF_8.newEncoder())); ++ // Paper end + + try { + this.properties.store(bufferedwriter, "Minecraft server properties"); diff --git a/patches/server/Fix-block-place-logic.patch b/patches/server/Fix-block-place-logic.patch new file mode 100644 index 0000000000..b30665f58c --- /dev/null +++ b/patches/server/Fix-block-place-logic.patch @@ -0,0 +1,39 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> +Date: Mon, 3 Apr 2023 18:46:49 +0200 +Subject: [PATCH] Fix block place logic + +TODO: what to do about dropped sign diff + +diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/BlockItem.java ++++ b/src/main/java/net/minecraft/world/item/BlockItem.java +@@ -0,0 +0,0 @@ public class BlockItem extends Item { + + SoundType soundeffecttype = iblockdata1.getSoundType(); + +- // world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), SoundCategory.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); ++ if (entityhuman == null) world.playSound(entityhuman, blockposition, this.getPlaceSound(iblockdata1), net.minecraft.sounds.SoundSource.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); // Paper - reintroduce this for the dispenser (i.e the shulker) + world.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.Context.of(entityhuman, iblockdata1)); + if ((entityhuman == null || !entityhuman.getAbilities().instabuild) && itemstack != ItemStack.EMPTY) { // CraftBukkit + itemstack.shrink(1); +diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/item/ItemStack.java ++++ b/src/main/java/net/minecraft/world/item/ItemStack.java +@@ -0,0 +0,0 @@ public final class ItemStack { + if (tileentity instanceof JukeboxBlockEntity) { + JukeboxBlockEntity tileentityjukebox = (JukeboxBlockEntity) tileentity; + +- // There can only be one +- ItemStack record = this.copy(); +- if (!record.isEmpty()) { +- record.setCount(1); +- } +- +- tileentityjukebox.setFirstItem(record); ++ tileentityjukebox.setFirstItem(this.copy()); // Paper - sync this with record item, jukebox has now an inventory + world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entityhuman, world.getBlockState(blockposition))); + } +