From c5794c5351076e6f792fe266462b1b61b2207a16 Mon Sep 17 00:00:00 2001 From: Josh Roy <10731363+JRoy@users.noreply.github.com> Date: Mon, 14 Jun 2021 06:45:16 -0700 Subject: [PATCH] even MOAR progress --- ...-translation-keys-for-blocks-entitie.patch | 2 +- .../Add-more-Evoker-API.patch | 0 ...ate-HoverEvent-from-ItemStack-Entity.patch | 4 +- .../server-remapped/Add-BellRingEvent.patch | 58 ------------------- .../server-remapped/Add-more-Evoker-API.patch | 57 ------------------ patches/server/Add-BellRingEvent.patch | 28 +++++++++ ...-translation-keys-for-blocks-entitie.patch | 35 +---------- patches/server/Add-more-Evoker-API.patch | 35 +++++++++++ ...Add-zombie-targets-turtle-egg-config.patch | 8 ++- .../Buffer-joins-to-world.patch | 25 ++------ .../Fix-CraftTeam-null-check.patch | 2 +- ...rs-not-working-in-some-kick-messages.patch | 12 ++-- .../Optimize-redstone-algorithm.patch | 49 +++++----------- ...CreateEvent-needs-to-know-its-entity.patch | 23 ++++---- 14 files changed, 113 insertions(+), 225 deletions(-) rename patches/{api-unmapped => api}/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch (98%) rename patches/{api-unmapped => api}/Add-more-Evoker-API.patch (100%) rename patches/{api-unmapped => api}/Create-HoverEvent-from-ItemStack-Entity.patch (97%) delete mode 100644 patches/server-remapped/Add-BellRingEvent.patch delete mode 100644 patches/server-remapped/Add-more-Evoker-API.patch create mode 100644 patches/server/Add-BellRingEvent.patch rename patches/{server-remapped => server}/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch (74%) create mode 100644 patches/server/Add-more-Evoker-API.patch rename patches/{server-remapped => server}/Add-zombie-targets-turtle-egg-config.patch (90%) rename patches/{server-remapped => server}/Buffer-joins-to-world.patch (70%) rename patches/{server-remapped => server}/Fix-CraftTeam-null-check.patch (94%) rename patches/{server-remapped => server}/Fix-hex-colors-not-working-in-some-kick-messages.patch (87%) rename patches/{server-remapped => server}/Optimize-redstone-algorithm.patch (95%) rename patches/{server-remapped => server}/PortalCreateEvent-needs-to-know-its-entity.patch (90%) diff --git a/patches/api-unmapped/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch b/patches/api/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch similarity index 98% rename from patches/api-unmapped/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch rename to patches/api/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch index b2800e9f32..32e767fb64 100644 --- a/patches/api-unmapped/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch +++ b/patches/api/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch @@ -1,4 +1,4 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From 0000000000000000000000>>>>>>> replacement000000000000000000 Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Tue, 11 Aug 2020 19:17:46 +0200 Subject: [PATCH] Add a way to get translation keys for blocks, entities and diff --git a/patches/api-unmapped/Add-more-Evoker-API.patch b/patches/api/Add-more-Evoker-API.patch similarity index 100% rename from patches/api-unmapped/Add-more-Evoker-API.patch rename to patches/api/Add-more-Evoker-API.patch diff --git a/patches/api-unmapped/Create-HoverEvent-from-ItemStack-Entity.patch b/patches/api/Create-HoverEvent-from-ItemStack-Entity.patch similarity index 97% rename from patches/api-unmapped/Create-HoverEvent-from-ItemStack-Entity.patch rename to patches/api/Create-HoverEvent-from-ItemStack-Entity.patch index 14f854c189..52beec5c41 100644 --- a/patches/api-unmapped/Create-HoverEvent-from-ItemStack-Entity.patch +++ b/patches/api/Create-HoverEvent-from-ItemStack-Entity.patch @@ -10,8 +10,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -0,0 +0,0 @@ public interface ItemFactory { */ - @Nullable - String getI18NDisplayName(@Nullable ItemStack item); + @NotNull + ItemStack ensureServerConversions(@NotNull ItemStack item); + + /** + * Creates a {@link net.md_5.bungee.api.chat.hover.content.Content} of that ItemStack for displaying. diff --git a/patches/server-remapped/Add-BellRingEvent.patch b/patches/server-remapped/Add-BellRingEvent.patch deleted file mode 100644 index 43efc8a40e..0000000000 --- a/patches/server-remapped/Add-BellRingEvent.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Eearslya Sleiarion -Date: Sun, 23 Aug 2020 13:04:02 +0200 -Subject: [PATCH] Add BellRingEvent - -Add a new event, BellRingEvent, to trigger whenever a player rings a -village bell. Passes along the bell block and the player who rang it. - -diff --git a/src/main/java/net/minecraft/world/level/block/BellBlock.java b/src/main/java/net/minecraft/world/level/block/BellBlock.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/block/BellBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/BellBlock.java -@@ -0,0 +0,0 @@ - package net.minecraft.world.level.block; - -+import io.papermc.paper.event.block.BellRingEvent; -+ - import javax.annotation.Nullable; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; -+import net.minecraft.server.MCUtil; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.sounds.SoundSource; - import net.minecraft.stats.Stats; -@@ -0,0 +0,0 @@ public class BellBlock extends BaseEntityBlock { - boolean flag1 = !flag || this.isProperHit(state, enumdirection, movingobjectpositionblock.getLocation().y - (double) blockposition.getY()); - - if (flag1) { -- boolean flag2 = this.attemptToRing(world, blockposition, enumdirection); -+ boolean flag2 = this.handleBellRing(world, blockposition, enumdirection, entityhuman); // Paper - - if (flag2 && entityhuman != null) { - entityhuman.awardStat(Stats.BELL_RING); -@@ -0,0 +0,0 @@ public class BellBlock extends BaseEntityBlock { - } - - public boolean attemptToRing(Level world, BlockPos pos, @Nullable Direction enumdirection) { -- BlockEntity tileentity = world.getBlockEntity(pos); -+ // Paper start - add ringer param -+ return this.handleBellRing(world, pos, enumdirection, null); -+ } -+ public boolean handleBellRing(Level world, BlockPos blockposition, @Nullable Direction enumdirection, @Nullable Entity ringer) { -+ // Paper end -+ BlockEntity tileentity = world.getBlockEntity(blockposition); - - if (!world.isClientSide && tileentity instanceof BellBlockEntity) { - if (enumdirection == null) { -- enumdirection = (Direction) world.getBlockState(pos).getValue(BellBlock.FACING); -+ enumdirection = (Direction) world.getBlockState(blockposition).getValue(BellBlock.FACING); - } - -+ if (!new BellRingEvent(world.getWorld().getBlockAt(MCUtil.toLocation(world, blockposition)), ringer == null ? null : ringer.getBukkitEntity()).callEvent()) return false; // Paper - BellRingEvent - ((BellBlockEntity) tileentity).onHit(enumdirection); -- world.playSound((Player) null, pos, SoundEvents.BELL_BLOCK, SoundSource.BLOCKS, 2.0F, 1.0F); -+ world.playSound((Player) null, blockposition, SoundEvents.BELL_BLOCK, SoundSource.BLOCKS, 2.0F, 1.0F); - return true; - } else { - return false; diff --git a/patches/server-remapped/Add-more-Evoker-API.patch b/patches/server-remapped/Add-more-Evoker-API.patch deleted file mode 100644 index 358012301f..0000000000 --- a/patches/server-remapped/Add-more-Evoker-API.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: BillyGalbreath -Date: Sun, 23 Aug 2020 15:28:35 +0200 -Subject: [PATCH] Add more Evoker API - - -diff --git a/src/main/java/net/minecraft/world/entity/monster/Evoker.java b/src/main/java/net/minecraft/world/entity/monster/Evoker.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/Evoker.java -+++ b/src/main/java/net/minecraft/world/entity/monster/Evoker.java -@@ -0,0 +0,0 @@ import net.minecraft.world.phys.shapes.VoxelShape; - - public class Evoker extends SpellcasterIllager { - -- private Sheep wololoTarget; -+ private Sheep wololoTarget; public final Sheep getWololoTarget() { return this.wololoTarget; } public final void setWololoTarget(Sheep sheep) { this.wololoTarget = sheep; } // Paper - OBFHELPER - - public Evoker(EntityType type, Level world) { - super(type, world); -@@ -0,0 +0,0 @@ public class Evoker extends SpellcasterIllager { - this.goalSelector.addGoal(8, new RandomStrollGoal(this, 0.6D)); - this.goalSelector.addGoal(9, new LookAtPlayerGoal(this, Player.class, 3.0F, 1.0F)); - this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Mob.class, 8.0F)); -- this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[]{Raider.class})).canUse()); -+ this.targetSelector.addGoal(1, (new HurtByTargetGoal(this, new Class[]{Raider.class})).setAlertOthers(new Class[0])); // Paper - decompile fix - this.targetSelector.addGoal(2, (new NearestAttackableTargetGoal<>(this, Player.class, true)).setUnseenMemoryTicks(300)); - this.targetSelector.addGoal(3, (new NearestAttackableTargetGoal<>(this, AbstractVillager.class, false)).setUnseenMemoryTicks(300)); - this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, false)); -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java -@@ -0,0 +0,0 @@ - package org.bukkit.craftbukkit.entity; - -+import net.minecraft.world.entity.animal.Sheep; - import net.minecraft.world.entity.monster.SpellcasterIllager; - import org.bukkit.craftbukkit.CraftServer; - import org.bukkit.entity.EntityType; -@@ -0,0 +0,0 @@ public class CraftEvoker extends CraftSpellcaster implements Evoker { - public void setCurrentSpell(Evoker.Spell spell) { - getHandle().setIsCastingSpell(spell == null ? SpellcasterIllager.IllagerSpell.NONE : SpellcasterIllager.IllagerSpell.byId(spell.ordinal())); - } -+ -+ // Paper start -+ @Override -+ public org.bukkit.entity.Sheep getWololoTarget() { -+ Sheep sheep = getHandle().getWololoTarget(); -+ return sheep == null ? null : (org.bukkit.entity.Sheep) sheep.getBukkitEntity(); -+ } -+ -+ @Override -+ public void setWololoTarget(org.bukkit.entity.Sheep sheep) { -+ getHandle().setWololoTarget(sheep == null ? null : ((org.bukkit.craftbukkit.entity.CraftSheep) sheep).getHandle()); -+ } -+ // Paper end - } diff --git a/patches/server/Add-BellRingEvent.patch b/patches/server/Add-BellRingEvent.patch new file mode 100644 index 0000000000..9ad0b5d8c5 --- /dev/null +++ b/patches/server/Add-BellRingEvent.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Eearslya Sleiarion +Date: Sun, 23 Aug 2020 13:04:02 +0200 +Subject: [PATCH] Add BellRingEvent + +Add a new event, BellRingEvent, to trigger whenever a player rings a +village bell. Passes along the bell block and the player who rang it. + +diff --git a/src/main/java/net/minecraft/world/level/block/BellBlock.java b/src/main/java/net/minecraft/world/level/block/BellBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/BellBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/BellBlock.java +@@ -0,0 +0,0 @@ package net.minecraft.world.level.block; + import javax.annotation.Nullable; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; ++import net.minecraft.server.MCUtil; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.stats.Stats; +@@ -0,0 +0,0 @@ public class BellBlock extends BaseEntityBlock { + direction = world.getBlockState(pos).getValue(FACING); + } + ++ if (!new io.papermc.paper.event.block.BellRingEvent(world.getWorld().getBlockAt(MCUtil.toLocation(world, pos)), entity == null ? null : entity.getBukkitEntity()).callEvent()) return false; // Paper - BellRingEvent + ((BellBlockEntity)blockEntity).onHit(direction); + world.playSound((Player)null, pos, SoundEvents.BELL_BLOCK, SoundSource.BLOCKS, 2.0F, 1.0F); + world.gameEvent(entity, GameEvent.RING_BELL, pos); diff --git a/patches/server-remapped/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch b/patches/server/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch similarity index 74% rename from patches/server-remapped/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch rename to patches/server/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch index 9cce0aace1..8a01b2d174 100644 --- a/patches/server-remapped/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch +++ b/patches/server/Add-a-way-to-get-translation-keys-for-blocks-entitie.patch @@ -9,7 +9,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -0,0 +0,0 @@ public class EntityType { +@@ -0,0 +0,0 @@ public class EntityType implements EntityTypeTest { return Registry.ENTITY_TYPE.getKey(type); } @@ -17,7 +17,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static Optional> byString(String id) { return Registry.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(id)); } -@@ -0,0 +0,0 @@ public class EntityType { +@@ -0,0 +0,0 @@ public class EntityType implements EntityTypeTest { return this.category; } @@ -25,41 +25,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public String getDescriptionId() { if (this.descriptionId == null) { this.descriptionId = Util.makeDescriptionId("entity", Registry.ENTITY_TYPE.getKey(this)); -diff --git a/src/main/java/net/minecraft/world/item/Item.java b/src/main/java/net/minecraft/world/item/Item.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/item/Item.java -+++ b/src/main/java/net/minecraft/world/item/Item.java -@@ -0,0 +0,0 @@ public class Item implements ItemLike { - private final FoodProperties foodProperties; - - public static int getId(Item item) { -- return item == null ? 0 : Registry.ITEM.getId((Object) item); -+ return item == null ? 0 : Registry.ITEM.getId(item); // Paper - Fix Decompiler Issue - } - - public static Item byId(int id) { -@@ -0,0 +0,0 @@ public class Item implements ItemLike { - return Registry.ITEM.getKey(this).getPath(); - } - -+ public String getOrCreateDescriptionId() { return getOrCreateDescriptionId(); } // Paper - OBFHELPER - protected String getOrCreateDescriptionId() { - if (this.descriptionId == null) { - this.descriptionId = Util.makeDescriptionId("item", Registry.ITEM.getKey(this)); -@@ -0,0 +0,0 @@ public class Item implements ItemLike { - return this.getOrCreateDescriptionId(); - } - -+ public String getDescriptionId(ItemStack itemStack) { return getDescriptionId(itemStack); } // Paper - OBFHELPER - public String getDescriptionId(ItemStack stack) { - return this.getDescriptionId(); - } diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java @@ -0,0 +0,0 @@ public class Block extends BlockBehaviour implements ItemLike { - return !this.material.isBuildable() && !this.material.isLiquid(); + return new TranslatableComponent(this.getDescriptionId()); } + public String getOrCreateDescriptionId() { return getDescriptionId(); } // Paper - OBFHELPER diff --git a/patches/server/Add-more-Evoker-API.patch b/patches/server/Add-more-Evoker-API.patch new file mode 100644 index 0000000000..0b853fe9ad --- /dev/null +++ b/patches/server/Add-more-Evoker-API.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: BillyGalbreath +Date: Sun, 23 Aug 2020 15:28:35 +0200 +Subject: [PATCH] Add more Evoker API + + +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java +@@ -0,0 +0,0 @@ + package org.bukkit.craftbukkit.entity; + ++import net.minecraft.world.entity.animal.Sheep; + import net.minecraft.world.entity.monster.SpellcasterIllager; + import org.bukkit.craftbukkit.CraftServer; + import org.bukkit.entity.EntityType; +@@ -0,0 +0,0 @@ public class CraftEvoker extends CraftSpellcaster implements Evoker { + public void setCurrentSpell(Evoker.Spell spell) { + this.getHandle().setIsCastingSpell(spell == null ? SpellcasterIllager.IllagerSpell.NONE : SpellcasterIllager.IllagerSpell.byId(spell.ordinal())); + } ++ ++ // Paper start ++ @Override ++ public org.bukkit.entity.Sheep getWololoTarget() { ++ Sheep sheep = getHandle().getWololoTarget(); ++ return sheep == null ? null : (org.bukkit.entity.Sheep) sheep.getBukkitEntity(); ++ } ++ ++ @Override ++ public void setWololoTarget(org.bukkit.entity.Sheep sheep) { ++ getHandle().setWololoTarget(sheep == null ? null : ((org.bukkit.craftbukkit.entity.CraftSheep) sheep).getHandle()); ++ } ++ // Paper end + } diff --git a/patches/server-remapped/Add-zombie-targets-turtle-egg-config.patch b/patches/server/Add-zombie-targets-turtle-egg-config.patch similarity index 90% rename from patches/server-remapped/Add-zombie-targets-turtle-egg-config.patch rename to patches/server/Add-zombie-targets-turtle-egg-config.patch index 446da3d801..b99215963d 100644 --- a/patches/server-remapped/Add-zombie-targets-turtle-egg-config.patch +++ b/patches/server/Add-zombie-targets-turtle-egg-config.patch @@ -9,15 +9,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { - maxLightningFlashDistance = 512; // Vanilla value } } -+ + + public boolean zombiesTargetTurtleEggs = true; + private void zombiesTargetTurtleEggs() { + zombiesTargetTurtleEggs = getBoolean("zombies-target-turtle-eggs", zombiesTargetTurtleEggs); + } - } ++ + public short keepLoadedRange; + private void keepLoadedRange() { + keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 10)) * 16); diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java diff --git a/patches/server-remapped/Buffer-joins-to-world.patch b/patches/server/Buffer-joins-to-world.patch similarity index 70% rename from patches/server-remapped/Buffer-joins-to-world.patch rename to patches/server/Buffer-joins-to-world.patch index eb1de5724c..cba62468f3 100644 --- a/patches/server-remapped/Buffer-joins-to-world.patch +++ b/patches/server/Buffer-joins-to-world.patch @@ -25,14 +25,14 @@ diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.game.ClientboundDisconnectPacket; - import net.minecraft.network.protocol.game.ClientboundKeepAlivePacket; - import net.minecraft.network.protocol.game.ClientboundSetTitlesPacket; - import net.minecraft.server.MCUtil; +@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.Packet; + import net.minecraft.network.protocol.PacketFlow; + import net.minecraft.network.protocol.game.ClientboundDisconnectPacket; + import net.minecraft.network.protocol.login.ClientboundLoginDisconnectPacket; +import net.minecraft.server.MinecraftServer; import net.minecraft.server.RunningOnDifferentThreadException; - import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerGamePacketListenerImpl; + import net.minecraft.server.network.ServerLoginPacketListenerImpl; @@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler> { } // Paper end @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + private static int joinAttemptsThisTick; // Paper + private static int currTick; // Paper public void tick() { - this.p(); + this.flushQueue(); + // Paper start + if (currTick != MinecraftServer.currentTick) { + currTick = MinecraftServer.currentTick; @@ -56,16 +56,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } if (this.packetListener instanceof ServerGamePacketListenerImpl) { -diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener - return new GameProfile(uuid, profile.getName()); - } - -- static enum State { -+ public enum State { // Paper - package private -> public - - HELLO, KEY, AUTHENTICATING, NEGOTIATING, READY_TO_ACCEPT, DELAY_ACCEPT, ACCEPTED; - diff --git a/patches/server-remapped/Fix-CraftTeam-null-check.patch b/patches/server/Fix-CraftTeam-null-check.patch similarity index 94% rename from patches/server-remapped/Fix-CraftTeam-null-check.patch rename to patches/server/Fix-CraftTeam-null-check.patch index cab5cbc511..8723505200 100644 --- a/patches/server-remapped/Fix-CraftTeam-null-check.patch +++ b/patches/server/Fix-CraftTeam-null-check.patch @@ -15,5 +15,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - Validate.notNull("Entry cannot be null"); + Validate.notNull(entry, "Entry cannot be null"); // Paper - CraftScoreboard scoreboard = checkState(); + CraftScoreboard scoreboard = this.checkState(); diff --git a/patches/server-remapped/Fix-hex-colors-not-working-in-some-kick-messages.patch b/patches/server/Fix-hex-colors-not-working-in-some-kick-messages.patch similarity index 87% rename from patches/server-remapped/Fix-hex-colors-not-working-in-some-kick-messages.patch rename to patches/server/Fix-hex-colors-not-working-in-some-kick-messages.patch index 3aa59a73e2..8d9ea9e548 100644 --- a/patches/server-remapped/Fix-hex-colors-not-working-in-some-kick-messages.patch +++ b/patches/server/Fix-hex-colors-not-working-in-some-kick-messages.patch @@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java @@ -0,0 +0,0 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL - synchronized (throttleTracker) { - if (throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - throttleTracker.get(address) < connectionThrottle) { - throttleTracker.put(address, currentTime); + synchronized (ServerHandshakePacketListenerImpl.throttleTracker) { + if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) { + ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime); - TranslatableComponent chatmessage = new TranslatableComponent(com.destroystokyo.paper.PaperConfig.connectionThrottleKickMessage); // Paper - Configurable connection throttle kick message + Component chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(com.destroystokyo.paper.PaperConfig.connectionThrottleKickMessage, true)[0]; // Paper - Configurable connection throttle kick message // Paper - Fix hex colors not working in some kick messages this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); @@ -37,10 +37,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (event.callEvent()) { // If we've failed somehow, let the client know so and go no further. if (event.isFailed()) { -- chatmessage = new TranslatableComponent(event.getFailMessage()); +- TranslatableComponent chatmessage = new TranslatableComponent(event.getFailMessage()); + Component chatmessage = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(event.getFailMessage(), true)[0]; // Paper - Fix hex colors not working in some kick messages - this.getNetworkManager().send(new ClientboundLoginDisconnectPacket(chatmessage)); - this.getNetworkManager().disconnect(chatmessage); + this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); + this.connection.disconnect(chatmessage); return; diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 diff --git a/patches/server-remapped/Optimize-redstone-algorithm.patch b/patches/server/Optimize-redstone-algorithm.patch similarity index 95% rename from patches/server-remapped/Optimize-redstone-algorithm.patch rename to patches/server/Optimize-redstone-algorithm.patch index 719f60cc5f..ce1fb709cd 100644 --- a/patches/server-remapped/Optimize-redstone-algorithm.patch +++ b/patches/server/Optimize-redstone-algorithm.patch @@ -23,10 +23,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { - private void zombiesTargetTurtleEggs() { zombiesTargetTurtleEggs = getBoolean("zombies-target-turtle-eggs", zombiesTargetTurtleEggs); } -+ + + public boolean useEigencraftRedstone = false; + private void useEigencraftRedstone() { + useEigencraftRedstone = this.getBoolean("use-faster-eigencraft-redstone", false); @@ -36,7 +35,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + log("Using vanilla redstone algorithm."); + } + } - } ++ + public short keepLoadedRange; + private void keepLoadedRange() { + keepLoadedRange = (short) (getInt("keep-spawn-loaded-range", Math.min(spigotConfig.viewDistance, 10)) * 16); diff --git a/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java b/src/main/java/com/destroystokyo/paper/util/RedstoneWireTurbo.java new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 @@ -863,14 +865,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + j = getMaxCurrentStrength(upd, j); + int l = 0; + -+ wire.setCanProvidePower(false); ++ wire.shouldSignal = false; + // Unfortunately, World.isBlockIndirectlyGettingPowered is complicated, + // and I'm not ready to try to replicate even more functionality from + // elsewhere in Minecraft into this accelerator. So sadly, we must + // suffer the performance hit of this very expensive call. If there + // is consistency to what this call returns, we may be able to cache it. -+ final int k = worldIn.isBlockIndirectlyGettingPowered(upd.self); -+ wire.setCanProvidePower(true); ++ final int k = worldIn.getBestNeighborSignal(upd.self); ++ wire.shouldSignal = true; + + // The variable 'k' holds the maximum redstone power value of any adjacent blocks. + // If 'k' has the highest level of all neighbors, then the power level of this @@ -956,26 +958,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return i > strength ? i : strength; + } +} -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - } - -+ public void neighborChanged(BlockPos pos, Block blockIn, BlockPos fromPos) { neighborChanged(pos, blockIn, fromPos); } // Paper - OBFHELPER - public void neighborChanged(BlockPos sourcePos, Block sourceBlock, BlockPos neighborPos) { - if (!this.isClientSide) { - BlockState iblockdata = this.getBlockState(sourcePos); -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - return this.getSignal(pos.below(), Direction.DOWN) > 0 ? true : (this.getSignal(pos.above(), Direction.UP) > 0 ? true : (this.getSignal(pos.north(), Direction.NORTH) > 0 ? true : (this.getSignal(pos.south(), Direction.SOUTH) > 0 ? true : (this.getSignal(pos.west(), Direction.WEST) > 0 ? true : this.getSignal(pos.east(), Direction.EAST) > 0)))); - } - -+ public int isBlockIndirectlyGettingPowered(BlockPos pos) { return this.getBestNeighborSignal(pos); } // Paper - OBFHELPER - public int getBestNeighborSignal(BlockPos pos) { - int i = 0; - Direction[] aenumdirection = Level.DIRECTIONS; diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java @@ -989,11 +971,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -0,0 +0,0 @@ public class RedStoneWireBlock extends Block { - private final Map SHAPES_CACHE = Maps.newHashMap(); - private static final Vector3f[] COLORS = new Vector3f[16]; + }); + private static final float PARTICLE_DENSITY = 0.2F; private final BlockState crossState; - private boolean shouldSignal = true; -+ private boolean shouldSignal = true; public final boolean canProvidePower() { return this.shouldSignal; } public final void setCanProvidePower(boolean value) { this.shouldSignal = value; } // Paper - OBFHELPER ++ public boolean shouldSignal = true; // Paper private -> public public RedStoneWireBlock(BlockBehaviour.Properties settings) { super(settings); @@ -1031,9 +1013,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + int i = state.getValue(POWER); + int j = 0; + j = this.getPower(j, worldIn.getBlockState(pos2)); -+ this.setCanProvidePower(false); -+ int k = worldIn.isBlockIndirectlyGettingPowered(pos1); -+ this.setCanProvidePower(true); ++ this.shouldSignal = false; ++ int k = worldIn.getBestNeighborSignal(pos1); ++ this.shouldSignal = true; + + if (!worldIn.paperConfig.useEigencraftRedstone) { + // This code is totally redundant to if statements just below the loop. @@ -1123,8 +1105,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 return Math.max(i, j - 1); } -+ private int getPower(int min, BlockState iblockdata) { return Math.max(min, getPower(iblockdata)); } // Paper - Optimize redstone -+ private int getPower(BlockState iblockdata) { return this.getWireSignal(iblockdata); } // Paper - OBFHELPER ++ private int getPower(int min, BlockState iblockdata) { return Math.max(min, getWireSignal(iblockdata)); } // Paper - Optimize redstone private int getWireSignal(BlockState state) { return state.is((Block) this) ? (Integer) state.getValue(RedStoneWireBlock.POWER) : 0; } diff --git a/patches/server-remapped/PortalCreateEvent-needs-to-know-its-entity.patch b/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch similarity index 90% rename from patches/server-remapped/PortalCreateEvent-needs-to-know-its-entity.patch rename to patches/server/PortalCreateEvent-needs-to-know-its-entity.patch index 8e9b0d4d92..e6e1f4ac81 100644 --- a/patches/server-remapped/PortalCreateEvent-needs-to-know-its-entity.patch +++ b/patches/server/PortalCreateEvent-needs-to-know-its-entity.patch @@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, UseOnContext itemActionContext) { + // Paper end + if (!iblockdata1.is(iblockdata.getBlock())) { - if (inPortalDimension(world)) { + if (BaseFireBlock.inPortalDimension(world)) { - Optional optional = PortalShape.findEmptyPortalShape((LevelAccessor) world, pos, Direction.Axis.X); + Optional optional = PortalShape.findEmptyPortalShape((LevelAccessor) world, blockposition, Direction.Axis.X); @@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } - if (!state.canSurvive(world, pos)) { -- fireExtinguished(world, pos); // CraftBukkit - fuel block broke +- this.fireExtinguished(world, pos); // CraftBukkit - fuel block broke + if (!iblockdata.canSurvive(world, blockposition)) { + fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke } @@ -63,8 +63,8 @@ diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/FireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FireBlock.java -@@ -0,0 +0,0 @@ import net.minecraft.core.Vec3i; - import net.minecraft.server.MCUtil; +@@ -0,0 +0,0 @@ import net.minecraft.core.Direction; + import net.minecraft.core.Vec3i; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.item.context.UseOnContext; @@ -77,12 +77,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override - public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { - super.onPlace(state, world, pos, oldState, notify); -- world.getBlockTicks().a(pos, this, getFireTickDelay(world.random)); +- world.getBlockTicks().scheduleTick(pos, this, FireBlock.getFireTickDelay(world.random)); + // Paper start - ItemActionContext param + public void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, UseOnContext itemActionContext) { + super.onPlace(iblockdata, world, blockposition, iblockdata1, flag, itemActionContext); + // Paper end -+ world.getBlockTicks().a(blockposition, this, getFireTickDelay(world.random)); ++ world.getBlockTicks().scheduleTick(blockposition, this, getFireTickDelay(world.random)); } private static int getFireTickDelay(Random random) { @@ -132,16 +132,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated public boolean createPortal() { return this.createPortal(null); } + public boolean createPortal(UseOnContext itemActionContext) { + // Paper end - org.bukkit.World bworld = this.level.getLevel().getWorld(); + org.bukkit.World bworld = this.level.getMinecraftWorld().getWorld(); // Copy below for loop @@ -0,0 +0,0 @@ public class PortalShape { - BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)).forEach((blockposition) -> { - blocks.setBlock(blockposition, iblockdata, 18); + this.blocks.setBlock(blockposition, iblockdata, 18); }); -- -- PortalCreateEvent event = new PortalCreateEvent((java.util.List) (java.util.List) blocks.getList(), bworld, null, PortalCreateEvent.CreateReason.FIRE); + +- PortalCreateEvent event = new PortalCreateEvent((java.util.List) (java.util.List) this.blocks.getList(), bworld, null, PortalCreateEvent.CreateReason.FIRE); + PortalCreateEvent event = new PortalCreateEvent((java.util.List) (java.util.List) blocks.getList(), bworld, itemActionContext == null || itemActionContext.getPlayer() == null ? null : itemActionContext.getPlayer().getBukkitEntity(), PortalCreateEvent.CreateReason.FIRE); // Paper - pass entity param - this.level.getLevel().getServer().server.getPluginManager().callEvent(event); + this.level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); if (event.isCancelled()) {