some more stuffs
This commit is contained in:
parent
1eba407610
commit
47c5d82017
47 changed files with 375 additions and 265 deletions
48
patches/server/0617-Add-ElderGuardianAppearanceEvent.patch
Normal file
48
patches/server/0617-Add-ElderGuardianAppearanceEvent.patch
Normal file
|
@ -0,0 +1,48 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Fri, 19 Mar 2021 23:39:09 -0400
|
||||
Subject: [PATCH] Add ElderGuardianAppearanceEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/effect/MobEffectUtil.java b/src/main/java/net/minecraft/world/effect/MobEffectUtil.java
|
||||
index 4c46a843c5c7e6f735f6b5f0f3c034524a0cf1e1..2baba1ccc1acd50693e05d565784d11df27bba93 100644
|
||||
--- a/src/main/java/net/minecraft/world/effect/MobEffectUtil.java
|
||||
+++ b/src/main/java/net/minecraft/world/effect/MobEffectUtil.java
|
||||
@@ -54,10 +54,23 @@ public final class MobEffectUtil {
|
||||
}
|
||||
|
||||
public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel worldserver, @Nullable Entity entity, Vec3 vec3d, double d0, MobEffectInstance mobeffect, int i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) {
|
||||
+ // Paper start
|
||||
+ return addEffectToPlayersAround(worldserver, entity, vec3d, d0, mobeffect, i, cause, null);
|
||||
+ }
|
||||
+
|
||||
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel worldserver, @Nullable Entity entity, Vec3 vec3d, double d0, MobEffectInstance mobeffect, int i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, @Nullable java.util.function.Predicate<ServerPlayer> playerPredicate) {
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
MobEffect mobeffectlist = mobeffect.getEffect();
|
||||
List<ServerPlayer> list = worldserver.getPlayers((entityplayer) -> {
|
||||
- return entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(mobeffectlist).endsWithin(i - 1));
|
||||
+ // Paper start
|
||||
+ boolean condition = entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(mobeffectlist).endsWithin(i - 1));
|
||||
+ if (condition) {
|
||||
+ return playerPredicate == null || playerPredicate.test(entityplayer); // Only test the player AFTER it is true
|
||||
+ } else {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper ned
|
||||
});
|
||||
|
||||
list.forEach((entityplayer) -> {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/ElderGuardian.java b/src/main/java/net/minecraft/world/entity/monster/ElderGuardian.java
|
||||
index 4e4b68904151d0d851b13f14f89c1c305e95fd5a..8f481e11815d7162dd62a2b850b3d2af6d904519 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/ElderGuardian.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/ElderGuardian.java
|
||||
@@ -67,7 +67,7 @@ public class ElderGuardian extends Guardian {
|
||||
super.customServerAiStep();
|
||||
if ((this.tickCount + this.getId()) % 1200 == 0) {
|
||||
MobEffectInstance mobeffect = new MobEffectInstance(MobEffects.DIG_SLOWDOWN, 6000, 2);
|
||||
- List<ServerPlayer> list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level(), this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
+ List<ServerPlayer> list = MobEffectUtil.addEffectToPlayersAround((ServerLevel) this.level(), this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent(getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper
|
||||
|
||||
list.forEach((entityplayer) -> {
|
||||
entityplayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F));
|
87
patches/server/0618-Fix-dangerous-end-portal-logic.patch
Normal file
87
patches/server/0618-Fix-dangerous-end-portal-logic.patch
Normal file
|
@ -0,0 +1,87 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <spottedleaf@users.noreply.github.com>
|
||||
Date: Fri, 4 Jun 2021 17:06:52 -0400
|
||||
Subject: [PATCH] Fix dangerous end portal logic
|
||||
|
||||
End portals could teleport entities during move calls. Stupid
|
||||
logic given the caller will never expect that kind of thing,
|
||||
and will result in all kinds of dupes.
|
||||
|
||||
Move the tick logic into the post tick, where portaling was
|
||||
designed to happen in the first place.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 1f92d5dbaad1fb2bdfedb6c2044aa99a61388b21..223af8b0b40f11496a0639f220f8e6605be8da2a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -431,6 +431,37 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ // Paper start - make end portalling safe
|
||||
+ public BlockPos portalBlock;
|
||||
+ public ServerLevel portalWorld;
|
||||
+ public void tickEndPortal() {
|
||||
+ BlockPos pos = this.portalBlock;
|
||||
+ ServerLevel world = this.portalWorld;
|
||||
+ this.portalBlock = null;
|
||||
+ this.portalWorld = null;
|
||||
+
|
||||
+ if (pos == null || world == null || world != this.level) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (this.isPassenger() || this.isVehicle() || !this.canChangeDimensions() || this.isRemoved() || !this.valid || !this.isAlive()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ ResourceKey<Level> resourcekey = world.getTypeKey() == LevelStem.END ? Level.OVERWORLD : Level.END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
|
||||
+ ServerLevel worldserver = world.getServer().getLevel(resourcekey);
|
||||
+
|
||||
+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(this.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
+ event.callEvent();
|
||||
+
|
||||
+ if (this instanceof ServerPlayer) {
|
||||
+ ((ServerPlayer)this).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
|
||||
+ return;
|
||||
+ }
|
||||
+ this.teleportTo(worldserver, null);
|
||||
+ }
|
||||
+ // Paper end - make end portalling safe
|
||||
+
|
||||
public Entity(EntityType<?> type, Level world) {
|
||||
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
|
||||
this.passengers = ImmutableList.of();
|
||||
@@ -2765,6 +2796,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
this.processPortalCooldown();
|
||||
+ this.tickEndPortal(); // Paper - make end portalling safe
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
index 45b427f314da778cc13da9ad6e4e1316790bf1b1..41d7cff39fc37955877668337689b4b26cd8c7cf 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
||||
@@ -53,16 +53,10 @@ public class EndPortalBlock extends BaseEntityBlock {
|
||||
// return; // CraftBukkit - always fire event in case plugins wish to change it
|
||||
}
|
||||
|
||||
- // CraftBukkit start - Entity in portal
|
||||
- EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
- world.getCraftServer().getPluginManager().callEvent(event);
|
||||
-
|
||||
- if (entity instanceof ServerPlayer) {
|
||||
- ((ServerPlayer) entity).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
|
||||
- return;
|
||||
- }
|
||||
- // CraftBukkit end
|
||||
- entity.changeDimension(worldserver);
|
||||
+ // Paper start - move all of this logic into portal tick
|
||||
+ entity.portalWorld = ((ServerLevel)world);
|
||||
+ entity.portalBlock = pos.immutable();
|
||||
+ // Paper end - move all of this logic into portal tick
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 12 Sep 2018 21:47:01 -0400
|
||||
Subject: [PATCH] Optimize Biome Mob Lookups for Mob Spawning
|
||||
|
||||
Uses an EnumMap as well as a Set paired List for O(1) contains calls.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java b/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java
|
||||
index 4f4ef3349f512cc6e1588eb58de5b2558c0bd8b9..9e2f7fc64b284efd6388be35f250642c47e7603b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/biome/MobSpawnSettings.java
|
||||
@@ -61,11 +61,43 @@ public class MobSpawnSettings {
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
- private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> spawners = Stream.of(MobCategory.values()).collect(ImmutableMap.toImmutableMap((mobCategory) -> {
|
||||
+ // Paper start - keep track of data in a pair set to give O(1) contains calls - we have to hook removals incase plugins mess with it
|
||||
+ public static class MobList extends java.util.ArrayList<MobSpawnSettings.SpawnerData> {
|
||||
+ java.util.Set<MobSpawnSettings.SpawnerData> biomes = new java.util.HashSet<>();
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean contains(Object o) {
|
||||
+ return biomes.contains(o);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean add(MobSpawnSettings.SpawnerData BiomeSettingsMobs) {
|
||||
+ biomes.add(BiomeSettingsMobs);
|
||||
+ return super.add(BiomeSettingsMobs);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public MobSpawnSettings.SpawnerData remove(int index) {
|
||||
+ MobSpawnSettings.SpawnerData removed = super.remove(index);
|
||||
+ if (removed != null) {
|
||||
+ biomes.remove(removed);
|
||||
+ }
|
||||
+ return removed;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void clear() {
|
||||
+ biomes.clear();
|
||||
+ super.clear();
|
||||
+ }
|
||||
+ }
|
||||
+ // use toImmutableEnumMap collector
|
||||
+ private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> spawners = (Map) Stream.of(MobCategory.values()).collect(Maps.toImmutableEnumMap((mobCategory) -> {
|
||||
return mobCategory;
|
||||
}, (mobCategory) -> {
|
||||
- return Lists.newArrayList();
|
||||
+ return new MobList(); // Use MobList instead of ArrayList
|
||||
}));
|
||||
+ // Paper end
|
||||
private final Map<EntityType<?>, MobSpawnSettings.MobSpawnCost> mobSpawnCosts = Maps.newLinkedHashMap();
|
||||
private float creatureGenerationProbability = 0.1F;
|
||||
|
55
patches/server/0620-Make-item-validations-configurable.patch
Normal file
55
patches/server/0620-Make-item-validations-configurable.patch
Normal file
|
@ -0,0 +1,55 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 4 Jun 2021 12:12:35 -0700
|
||||
Subject: [PATCH] Make item validations configurable
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
||||
index e8413ad360e9b6c4eef13edf9dd0095e7e64bce2..a5d7fae348b0b262a0a8a5e8e76f1bc75ca52a16 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
|
||||
@@ -88,11 +88,11 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
super(tag);
|
||||
|
||||
if (tag.contains(BOOK_TITLE.NBT)) {
|
||||
- this.title = limit( tag.getString(BOOK_TITLE.NBT), 8192 ); // Spigot
|
||||
+ this.title = limit( tag.getString(BOOK_TITLE.NBT), io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.book.title); // Spigot // Paper - make configurable
|
||||
}
|
||||
|
||||
if (tag.contains(BOOK_AUTHOR.NBT)) {
|
||||
- this.author = limit( tag.getString(BOOK_AUTHOR.NBT), 8192 ); // Spigot
|
||||
+ this.author = limit( tag.getString(BOOK_AUTHOR.NBT), io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.book.author ); // Spigot // Paper - make configurable
|
||||
}
|
||||
|
||||
if (tag.contains(RESOLVED.NBT)) {
|
||||
@@ -120,7 +120,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
} else {
|
||||
page = this.validatePage(page);
|
||||
}
|
||||
- this.pages.add( limit( page, 16384 ) ); // Spigot
|
||||
+ this.pages.add( limit( page, io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.book.page ) ); // Spigot // Paper - make configurable
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index ad202473abbe4b302b825d9dd9dd75402190e824..9fc74007bd887ab71dea9dcfdc1e3017036d0bfc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -360,7 +360,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
CompoundTag display = tag.getCompound(DISPLAY.NBT);
|
||||
|
||||
if (display.contains(NAME.NBT)) {
|
||||
- this.displayName = limit( display.getString(NAME.NBT), 8192 ); // Spigot
|
||||
+ this.displayName = limit( display.getString(NAME.NBT), io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.displayName ); // Spigot // Paper - make configurable
|
||||
}
|
||||
|
||||
if (display.contains(LOCNAME.NBT)) {
|
||||
@@ -371,7 +371,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
ListTag list = display.getList(LORE.NBT, CraftMagicNumbers.NBT.TAG_STRING);
|
||||
this.lore = new ArrayList<String>(list.size());
|
||||
for (int index = 0; index < list.size(); index++) {
|
||||
- String line = limit( list.getString(index), 8192 ); // Spigot
|
||||
+ String line = limit( list.getString(index), io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.loreLine ); // Spigot // Paper - make configurable
|
||||
this.lore.add(line);
|
||||
}
|
||||
}
|
74
patches/server/0621-Line-Of-Sight-Changes.patch
Normal file
74
patches/server/0621-Line-Of-Sight-Changes.patch
Normal file
|
@ -0,0 +1,74 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: TwoLeggedCat <80929284+TwoLeggedCat@users.noreply.github.com>
|
||||
Date: Sat, 29 May 2021 14:33:25 -0500
|
||||
Subject: [PATCH] Line Of Sight Changes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 4ad927541de2f5af9121d17b4f8b359049ee2000..3a669f8e0cd072fcbd5e5ed4b55abb0f73c009e7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3555,7 +3555,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
Vec3 vec3d = new Vec3(this.getX(), this.getEyeY(), this.getZ());
|
||||
Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ());
|
||||
|
||||
- return vec3d1.distanceTo(vec3d) > 128.0D ? false : this.level().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS;
|
||||
+ // Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists
|
||||
+ return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS;
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
index 5bd5a059c5beeade313f74ba3c1fc63825bd286b..d7c9b421eb636c0642b73263f46f824b95c1614e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java
|
||||
@@ -996,5 +996,16 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
||||
public org.bukkit.NamespacedKey getKey() {
|
||||
return org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.getHandle().getLevel().dimension().location());
|
||||
}
|
||||
+
|
||||
+ public boolean lineOfSightExists(Location from, Location to) {
|
||||
+ Preconditions.checkArgument(from != null, "from parameter in lineOfSightExists cannot be null");
|
||||
+ Preconditions.checkArgument(to != null, "to parameter in lineOfSightExists cannot be null");
|
||||
+ if (from.getWorld() != to.getWorld()) return false;
|
||||
+ net.minecraft.world.phys.Vec3 vec3d = new net.minecraft.world.phys.Vec3(from.getX(), from.getY(), from.getZ());
|
||||
+ net.minecraft.world.phys.Vec3 vec3d1 = new net.minecraft.world.phys.Vec3(to.getX(), to.getY(), to.getZ());
|
||||
+ if (vec3d1.distanceToSqr(vec3d) > 128D * 128D) return false; //Return early if the distance is greater than 128 blocks
|
||||
+
|
||||
+ return this.getHandle().clip(new net.minecraft.world.level.ClipContext(vec3d, vec3d1, net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, null)).getType() == net.minecraft.world.phys.HitResult.Type.MISS;
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index b38d72e921c4705cae72eb65113b36c87e4250fd..61292952681727bcd651064619bff1b41c560d75 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -29,6 +29,9 @@ import net.minecraft.world.entity.projectile.ThrownEgg;
|
||||
import net.minecraft.world.entity.projectile.ThrownEnderpearl;
|
||||
import net.minecraft.world.entity.projectile.ThrownExperienceBottle;
|
||||
import net.minecraft.world.entity.projectile.ThrownTrident;
|
||||
+import net.minecraft.world.level.ClipContext;
|
||||
+import net.minecraft.world.phys.HitResult;
|
||||
+import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -576,6 +579,18 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
return this.getHandle().hasLineOfSight(((CraftEntity) other).getHandle());
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean hasLineOfSight(Location loc) {
|
||||
+ if (this.getHandle().level() != ((CraftWorld) loc.getWorld()).getHandle()) return false;
|
||||
+ Vec3 vec3d = new Vec3(this.getHandle().getX(), this.getHandle().getEyeY(), this.getHandle().getZ());
|
||||
+ Vec3 vec3d1 = new Vec3(loc.getX(), loc.getY(), loc.getZ());
|
||||
+ if (vec3d1.distanceToSqr(vec3d) > 128D * 128D) return false; //Return early if the distance is greater than 128 blocks
|
||||
+
|
||||
+ return this.getHandle().level().clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this.getHandle())).getType() == HitResult.Type.MISS;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean getRemoveWhenFarAway() {
|
||||
return this.getHandle() instanceof Mob && !((Mob) this.getHandle()).isPersistenceRequired();
|
25
patches/server/0622-add-per-world-spawn-limits.patch
Normal file
25
patches/server/0622-add-per-world-spawn-limits.patch
Normal file
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: chase <chasewhip20@gmail.com>
|
||||
Date: Wed, 2 Dec 2020 22:43:39 -0800
|
||||
Subject: [PATCH] add per world spawn limits
|
||||
|
||||
Taken from #2982. Credit to Chasewhip8
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 44d59c9f5053cd6affddf7a51e37ed4b7bd43b08..26468a3788c157241ded0ef7c4c704f801ef53a0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -213,6 +213,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
this.biomeProvider = biomeProvider;
|
||||
|
||||
this.environment = env;
|
||||
+ // Paper start - per world spawn limits
|
||||
+ for (SpawnCategory spawnCategory : SpawnCategory.values()) {
|
||||
+ if (CraftSpawnCategory.isValidForLimits(spawnCategory)) {
|
||||
+ setSpawnLimit(spawnCategory, this.world.paperConfig().entities.spawning.spawnLimits.getInt(CraftSpawnCategory.toNMS(spawnCategory)));
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
155
patches/server/0623-Fix-potions-splash-events.patch
Normal file
155
patches/server/0623-Fix-potions-splash-events.patch
Normal file
|
@ -0,0 +1,155 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 20 May 2021 20:40:53 -0700
|
||||
Subject: [PATCH] Fix potions splash events
|
||||
|
||||
Fix PotionSplashEvent for water splash potions
|
||||
Fixes SPIGOT-6221: https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6221
|
||||
Fix splash events cancellation that still show particles/sound
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||
index 8b245d69f2d7935bb52e3ddff0757afa95c8e329..bc8cc9ced3fd32ff916c42e8ae95a95414dd1f25 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java
|
||||
@@ -104,56 +104,77 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
||||
Potion potionregistry = PotionUtils.getPotion(itemstack);
|
||||
List<MobEffectInstance> list = PotionUtils.getMobEffects(itemstack);
|
||||
boolean flag = potionregistry == Potions.WATER && list.isEmpty();
|
||||
+ boolean showParticles = true; // Paper
|
||||
|
||||
if (flag) {
|
||||
- this.applyWater();
|
||||
+ showParticles = this.applyWater(); // Paper
|
||||
} else if (true || !list.isEmpty()) { // CraftBukkit - Call event even if no effects to apply
|
||||
if (this.isLingering()) {
|
||||
- this.makeAreaOfEffectCloud(itemstack, potionregistry);
|
||||
+ showParticles = this.makeAreaOfEffectCloud(itemstack, potionregistry); // Paper
|
||||
} else {
|
||||
- this.applySplash(list, hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null);
|
||||
+ showParticles = this.applySplash(list, hitResult.getType() == HitResult.Type.ENTITY ? ((EntityHitResult) hitResult).getEntity() : null); // Paper
|
||||
}
|
||||
}
|
||||
|
||||
+ if (showParticles) { // Paper
|
||||
int i = potionregistry.hasInstantEffects() ? 2007 : 2002;
|
||||
|
||||
this.level().levelEvent(i, this.blockPosition(), PotionUtils.getColor(itemstack));
|
||||
+ } // Paper
|
||||
this.discard();
|
||||
}
|
||||
}
|
||||
|
||||
- private void applyWater() {
|
||||
+ private static final Predicate<net.minecraft.world.entity.LivingEntity> APPLY_WATER_GET_ENTITIES_PREDICATE = ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE.or(Axolotl.class::isInstance); // Paper
|
||||
+ private boolean applyWater() { // Paper
|
||||
AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
|
||||
- List<net.minecraft.world.entity.LivingEntity> list = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE);
|
||||
+ // Paper start
|
||||
+ List<net.minecraft.world.entity.LivingEntity> list = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb, ThrownPotion.APPLY_WATER_GET_ENTITIES_PREDICATE);
|
||||
+ Map<LivingEntity, Double> affected = new HashMap<>();
|
||||
+ java.util.Set<LivingEntity> rehydrate = new java.util.HashSet<>();
|
||||
+ java.util.Set<LivingEntity> extinguish = new java.util.HashSet<>();
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
net.minecraft.world.entity.LivingEntity entityliving = (net.minecraft.world.entity.LivingEntity) iterator.next();
|
||||
+ if (entityliving instanceof Axolotl axolotl) {
|
||||
+ rehydrate.add(((org.bukkit.entity.Axolotl) axolotl.getBukkitEntity()));
|
||||
+ }
|
||||
double d0 = this.distanceToSqr((Entity) entityliving);
|
||||
|
||||
if (d0 < 16.0D) {
|
||||
if (entityliving.isSensitiveToWater()) {
|
||||
- entityliving.hurt(this.damageSources().indirectMagic(this, this.getOwner()), 1.0F);
|
||||
+ affected.put(entityliving.getBukkitLivingEntity(), 1.0);
|
||||
}
|
||||
|
||||
if (entityliving.isOnFire() && entityliving.isAlive()) {
|
||||
- entityliving.extinguishFire();
|
||||
+ extinguish.add(entityliving.getBukkitLivingEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- List<Axolotl> list1 = this.level().getEntitiesOfClass(Axolotl.class, axisalignedbb);
|
||||
- Iterator iterator1 = list1.iterator();
|
||||
-
|
||||
- while (iterator1.hasNext()) {
|
||||
- Axolotl axolotl = (Axolotl) iterator1.next();
|
||||
-
|
||||
- axolotl.rehydrate();
|
||||
+ io.papermc.paper.event.entity.WaterBottleSplashEvent event = new io.papermc.paper.event.entity.WaterBottleSplashEvent(
|
||||
+ (org.bukkit.entity.ThrownPotion) this.getBukkitEntity(), affected, rehydrate, extinguish
|
||||
+ );
|
||||
+ if (event.callEvent()) {
|
||||
+ for (LivingEntity affectedEntity : event.getToDamage()) {
|
||||
+ ((CraftLivingEntity) affectedEntity).getHandle().hurt(this.damageSources().indirectMagic(this, this.getOwner()), 1.0F);
|
||||
+ }
|
||||
+ for (LivingEntity toExtinguish : event.getToExtinguish()) {
|
||||
+ ((CraftLivingEntity) toExtinguish).getHandle().extinguishFire();
|
||||
+ }
|
||||
+ for (LivingEntity toRehydrate : event.getToRehydrate()) {
|
||||
+ if (((CraftLivingEntity) toRehydrate).getHandle() instanceof Axolotl axolotl) {
|
||||
+ axolotl.rehydrate();
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
+ return !event.isCancelled(); // Paper
|
||||
|
||||
}
|
||||
|
||||
- private void applySplash(List<MobEffectInstance> statusEffects, @Nullable Entity entity) {
|
||||
+ private boolean applySplash(List<MobEffectInstance> statusEffects, @Nullable Entity entity) { // Paper
|
||||
AABB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
|
||||
List<net.minecraft.world.entity.LivingEntity> list1 = this.level().getEntitiesOfClass(net.minecraft.world.entity.LivingEntity.class, axisalignedbb);
|
||||
Map<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>(); // CraftBukkit
|
||||
@@ -171,6 +192,7 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
||||
if (d0 < 16.0D) {
|
||||
double d1;
|
||||
|
||||
+ // Paper - diff on change, used when calling the splash event for water splash potions
|
||||
if (entityliving == entity) {
|
||||
d1 = 1.0D;
|
||||
} else {
|
||||
@@ -226,10 +248,11 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
||||
}
|
||||
}
|
||||
}
|
||||
+ return !event.isCancelled(); // Paper
|
||||
|
||||
}
|
||||
|
||||
- private void makeAreaOfEffectCloud(ItemStack stack, Potion potion) {
|
||||
+ private boolean makeAreaOfEffectCloud(ItemStack stack, Potion potion) { // Paper
|
||||
AreaEffectCloud entityareaeffectcloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
|
||||
Entity entity = this.getOwner();
|
||||
|
||||
@@ -244,10 +267,12 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
||||
entityareaeffectcloud.setPotion(potion);
|
||||
Iterator iterator = PotionUtils.getCustomEffects(stack).iterator();
|
||||
|
||||
+ boolean noEffects = potion.getEffects().isEmpty(); // Paper
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
|
||||
|
||||
entityareaeffectcloud.addEffect(new MobEffectInstance(mobeffect));
|
||||
+ noEffects = false; // Paper
|
||||
}
|
||||
|
||||
CompoundTag nbttagcompound = stack.getTag();
|
||||
@@ -258,12 +283,13 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie
|
||||
|
||||
// CraftBukkit start
|
||||
org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, entityareaeffectcloud);
|
||||
- if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) {
|
||||
+ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved() || (noEffects && entityareaeffectcloud.effects.isEmpty() && entityareaeffectcloud.getPotion().getEffects().isEmpty()))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling
|
||||
this.level().addFreshEntity(entityareaeffectcloud);
|
||||
} else {
|
||||
entityareaeffectcloud.discard();
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ return !event.isCancelled(); // Paper
|
||||
}
|
||||
|
||||
public boolean isLingering() {
|
56
patches/server/0624-Add-more-LimitedRegion-API.patch
Normal file
56
patches/server/0624-Add-more-LimitedRegion-API.patch
Normal file
|
@ -0,0 +1,56 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dfsek <dfsek@protonmail.com>
|
||||
Date: Sat, 19 Jun 2021 20:15:59 -0700
|
||||
Subject: [PATCH] Add more LimitedRegion API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java b/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java
|
||||
index 10fb28aabf8c9f764cdd614edbeec4523f8ab431..0ea1586bab74983fca19dcc5415fbc7a044fe186 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CraftLimitedRegion.java
|
||||
@@ -251,4 +251,45 @@ public class CraftLimitedRegion extends CraftRegionAccessor implements LimitedRe
|
||||
public void addEntityToWorld(net.minecraft.world.entity.Entity entity, CreatureSpawnEvent.SpawnReason reason) {
|
||||
this.entities.add(entity);
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setBlockState(int x, int y, int z, BlockState state) {
|
||||
+ BlockPos pos = new BlockPos(x, y, z);
|
||||
+ if (!state.getBlockData().matches(getHandle().getBlockState(pos).createCraftBlockData())) {
|
||||
+ throw new IllegalArgumentException("BlockData does not match! Expected " + state.getBlockData().getAsString(false) + ", got " + getHandle().getBlockState(pos).createCraftBlockData().getAsString(false));
|
||||
+ }
|
||||
+ getHandle().getBlockEntity(pos).load(((org.bukkit.craftbukkit.block.CraftBlockEntityState<?>) state).getSnapshotNBT());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void scheduleBlockUpdate(int x, int y, int z) {
|
||||
+ BlockPos position = new BlockPos(x, y, z);
|
||||
+ getHandle().scheduleTick(position, getHandle().getBlockState(position).getBlock(), 0);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void scheduleFluidUpdate(int x, int y, int z) {
|
||||
+ BlockPos position = new BlockPos(x, y, z);
|
||||
+ getHandle().scheduleTick(position, getHandle().getFluidState(position).getType(), 0);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public World getWorld() {
|
||||
+ // reading/writing the returned Minecraft world causes a deadlock.
|
||||
+ // By implementing this, and covering it in warnings, we're assuming people won't be stupid, and
|
||||
+ // if they are stupid, they'll figure it out pretty fast.
|
||||
+ return getHandle().getMinecraftWorld().getWorld();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getCenterChunkX() {
|
||||
+ return centerChunkX;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getCenterChunkZ() {
|
||||
+ return centerChunkZ;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 20 Jun 2021 21:55:59 -0700
|
||||
Subject: [PATCH] Fix PlayerDropItemEvent using wrong item
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 75fef72efe7e85bf494bce6184b6814487f2c900..c89538fe76c37ca1790c837a8eec1d1bd418eefd 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2252,7 +2252,7 @@ public class ServerPlayer extends Player {
|
||||
|
||||
if (retainOwnership) {
|
||||
if (!itemstack1.isEmpty()) {
|
||||
- this.awardStat(Stats.ITEM_DROPPED.get(itemstack1.getItem()), stack.getCount());
|
||||
+ this.awardStat(Stats.ITEM_DROPPED.get(itemstack1.getItem()), itemstack1.getCount()); // Paper
|
||||
}
|
||||
|
||||
this.awardStat(Stats.DROP);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index b3634a1d92182c746948862fc64b2e47d11320ba..8f604924b47ed4027f4212007530b6d0c39f73a9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -724,6 +724,11 @@ public abstract class Player extends LivingEntity {
|
||||
}
|
||||
|
||||
double d0 = this.getEyeY() - 0.30000001192092896D;
|
||||
+ // Paper start
|
||||
+ ItemStack tmp = itemstack.copy();
|
||||
+ itemstack.setCount(0);
|
||||
+ itemstack = tmp;
|
||||
+ // Paper end
|
||||
ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), d0, this.getZ(), itemstack);
|
||||
|
||||
entityitem.setPickUpDelay(40);
|
1247
patches/server/0626-Missing-Entity-Behavior-API.patch
Normal file
1247
patches/server/0626-Missing-Entity-Behavior-API.patch
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Tue, 22 Jun 2021 19:58:53 +0100
|
||||
Subject: [PATCH] Ensure disconnect for book edit is called on main
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 9140806ac0bcf36bb76d666c160e183534b314a0..1006ad14ee4bf9e175ee3c2e1c1f09bde792a339 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1202,7 +1202,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// Paper end
|
||||
// CraftBukkit start
|
||||
if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
|
||||
- this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
|
||||
+ server.scheduleOnMain(() -> this.disconnect("Book edited too quickly!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause // Paper - Also ensure this is called on main
|
||||
return;
|
||||
}
|
||||
this.lastBookTick = MinecraftServer.currentTick;
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Mon, 28 Jun 2021 18:16:52 -0700
|
||||
Subject: [PATCH] Fix return value of Block#applyBoneMeal always being false
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index 30fc626f51437e254993edd9b14337fa60ba313c..e7e5c9fa734072e9ae15eb5f6d75c7740ba3ba44 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -585,7 +585,7 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
}
|
||||
|
||||
- return result == InteractionResult.SUCCESS && (event == null || !event.isCancelled());
|
||||
+ return result == InteractionResult.CONSUME && (event == null || !event.isCancelled()); // Paper - CONSUME is returned on success server-side (see BoneMealItem.applyBoneMeal and InteractionResult.sidedSuccess(boolean))
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,53 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Mon, 8 Jul 2019 00:13:36 -0700
|
||||
Subject: [PATCH] Use getChunkIfLoadedImmediately in places
|
||||
|
||||
This prevents us from hitting chunk loads for chunks at or less-than
|
||||
ticket level 33 (yes getChunkIfLoaded will actually perform a chunk
|
||||
load in that case).
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index ff7b9b47c9c29949cc4ee8da162b77ef17909bdb..fa58ec5466edd5ce6a1887b73f628fb6c7272d88 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -228,7 +228,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
|
||||
@Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
||||
- return this.chunkSource.getChunk(x, z, false);
|
||||
+ return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 3da3de6a442c3b398a96fff26cd0d81a8130fc01..02e8627fc9312e865f3a1f71cc9ecba712a098a2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -200,6 +200,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
return (CraftServer) Bukkit.getServer();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean hasChunk(int chunkX, int chunkZ) {
|
||||
+ return this.getChunkIfLoaded(chunkX, chunkZ) != null;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public abstract ResourceKey<LevelStem> getTypeKey();
|
||||
|
||||
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) { // Paper
|
||||
diff --git a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
index e9ead1e49f9043430e316c36ade83b70cf850e47..f2d10d58617644a589ecec3e17358c1277795e5d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/gameevent/GameEventDispatcher.java
|
||||
@@ -56,7 +56,7 @@ public class GameEventDispatcher {
|
||||
|
||||
for (int l1 = j; l1 <= i1; ++l1) {
|
||||
for (int i2 = l; i2 <= k1; ++i2) {
|
||||
- LevelChunk chunk = this.level.getChunkSource().getChunkNow(l1, i2);
|
||||
+ LevelChunk chunk = (LevelChunk) this.level.getChunkIfLoadedImmediately(l1, i2); // Paper
|
||||
|
||||
if (chunk != null) {
|
||||
for (int j2 = k; j2 <= j1; ++j2) {
|
|
@ -0,0 +1,120 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 9 Jul 2021 13:50:48 -0700
|
||||
Subject: [PATCH] Fix commands from signs not firing command events
|
||||
|
||||
This patch changes sign command logic so that `run_command` click events:
|
||||
- are logged to the console
|
||||
- fire PlayerCommandPreprocessEvent
|
||||
- work with double-slash commands like `//wand`
|
||||
- sends failure messages to the player who clicked the sign
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/commands/DelegatingCommandSource.java b/src/main/java/io/papermc/paper/commands/DelegatingCommandSource.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..01a2bc1feec808790bb93618ce46adb9bea5a9c8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/commands/DelegatingCommandSource.java
|
||||
@@ -0,0 +1,42 @@
|
||||
+package io.papermc.paper.commands;
|
||||
+
|
||||
+import net.minecraft.commands.CommandSource;
|
||||
+import net.minecraft.commands.CommandSourceStack;
|
||||
+import net.minecraft.network.chat.Component;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+public class DelegatingCommandSource implements CommandSource {
|
||||
+
|
||||
+ private final CommandSource delegate;
|
||||
+
|
||||
+ public DelegatingCommandSource(CommandSource delegate) {
|
||||
+ this.delegate = delegate;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void sendSystemMessage(Component message) {
|
||||
+ delegate.sendSystemMessage(message);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean acceptsSuccess() {
|
||||
+ return delegate.acceptsSuccess();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean acceptsFailure() {
|
||||
+ return delegate.acceptsFailure();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldInformAdmins() {
|
||||
+ return delegate.shouldInformAdmins();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public CommandSender getBukkitSender(CommandSourceStack wrapper) {
|
||||
+ return delegate.getBukkitSender(wrapper);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
index 41c863a104d53b6c6feb4576d5b62cead229efec..dab2adffbe5ac586b61371ea9234a1056fd36a51 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
@@ -271,7 +271,17 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
||||
ClickEvent chatclickable = chatmodifier.getClickEvent();
|
||||
|
||||
if (chatclickable != null && chatclickable.getAction() == ClickEvent.Action.RUN_COMMAND) {
|
||||
- player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(player, world, pos), chatclickable.getValue());
|
||||
+ // Paper start
|
||||
+ String command = chatclickable.getValue().startsWith("/") ? chatclickable.getValue() : "/" + chatclickable.getValue();
|
||||
+ if (org.spigotmc.SpigotConfig.logCommands) {
|
||||
+ LOGGER.info("{} issued server command: {}", player.getScoreboardName(), command);
|
||||
+ }
|
||||
+ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent((org.bukkit.entity.Player) player.getBukkitEntity(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(player.getServer()), (org.bukkit.block.Sign) io.papermc.paper.util.MCUtil.toBukkitBlock(this.level, this.worldPosition).getState());
|
||||
+ if (!event.callEvent()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage());
|
||||
+ // Paper end
|
||||
flag1 = true;
|
||||
}
|
||||
}
|
||||
@@ -308,8 +318,23 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
||||
String s = player == null ? "Sign" : player.getName().getString();
|
||||
Object object = player == null ? Component.literal("Sign") : player.getDisplayName();
|
||||
|
||||
+ // Paper start - send messages back to the player
|
||||
+ CommandSource commandSource = this.level.paperConfig().misc.showSignClickCommandFailureMsgsToPlayer ? new io.papermc.paper.commands.DelegatingCommandSource(this) {
|
||||
+ @Override
|
||||
+ public void sendSystemMessage(Component message) {
|
||||
+ if (player != null) {
|
||||
+ player.sendSystemMessage(message);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean acceptsFailure() {
|
||||
+ return true;
|
||||
+ }
|
||||
+ } : this;
|
||||
+ // Paper end
|
||||
// CraftBukkit - this
|
||||
- return new CommandSourceStack(this, Vec3.atCenterOf(pos), Vec2.ZERO, (ServerLevel) world, 2, s, (Component) object, world.getServer(), player);
|
||||
+ return new CommandSourceStack(commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, (ServerLevel) world, 2, s, (Component) object, world.getServer(), player); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java
|
||||
index d113e54a30db16e2ad955170df6030d15de530d6..26f3a2799e687731d883e7733591f6934479e88d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/command/BukkitCommandWrapper.java
|
||||
@@ -61,7 +61,7 @@ public class BukkitCommandWrapper implements com.mojang.brigadier.Command<Comman
|
||||
CommandSender sender = context.getSource().getBukkitSender();
|
||||
|
||||
try {
|
||||
- return this.server.dispatchCommand(sender, context.getInput()) ? 1 : 0;
|
||||
+ return this.server.dispatchCommand(sender, context.getRange().get(context.getInput())) ? 1 : 0; // Paper - actually use the StringRange from context
|
||||
} catch (CommandException ex) {
|
||||
sender.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||
this.server.getLogger().log(Level.SEVERE, null, ex);
|
19
patches/server/0631-Adds-PlayerArmSwingEvent.patch
Normal file
19
patches/server/0631-Adds-PlayerArmSwingEvent.patch
Normal file
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 12 Mar 2021 19:22:21 -0800
|
||||
Subject: [PATCH] Adds PlayerArmSwingEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 1006ad14ee4bf9e175ee3c2e1c1f09bde792a339..1a7f3833b4be83d19e2fc54df78eac84557b5a70 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2484,7 +2484,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
|
||||
// Arm swing animation
|
||||
- PlayerAnimationEvent event = new PlayerAnimationEvent(this.getCraftPlayer(), (packet.getHand() == InteractionHand.MAIN_HAND) ? PlayerAnimationType.ARM_SWING : PlayerAnimationType.OFF_ARM_SWING);
|
||||
+ io.papermc.paper.event.player.PlayerArmSwingEvent event = new io.papermc.paper.event.player.PlayerArmSwingEvent(this.getCraftPlayer(), packet.getHand() == InteractionHand.MAIN_HAND ? org.bukkit.inventory.EquipmentSlot.HAND : org.bukkit.inventory.EquipmentSlot.OFF_HAND); // Paper
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) return;
|
|
@ -0,0 +1,85 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 7 Jul 2021 16:19:41 -0700
|
||||
Subject: [PATCH] Fixes kick event leave message not being sent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index c89538fe76c37ca1790c837a8eec1d1bd418eefd..1901bea8474e9af9d68b79bd9bd3abf319461f81 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -270,7 +270,6 @@ public class ServerPlayer extends Player {
|
||||
public boolean sentListPacket = false;
|
||||
public boolean supressTrackerForLogin = false; // Paper
|
||||
public Integer clientViewDistance;
|
||||
- public String kickLeaveMessage = null; // SPIGOT-3034: Forward leave message to PlayerQuitEvent
|
||||
// CraftBukkit end
|
||||
public boolean isRealPlayer; // Paper
|
||||
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleHashSet; // Paper
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 1a7f3833b4be83d19e2fc54df78eac84557b5a70..a5e113b571910cc26bfbcff4b7a792f86ecb1192 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -514,7 +514,6 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
// Do not kick the player
|
||||
return;
|
||||
}
|
||||
- this.player.kickLeaveMessage = event.getLeaveMessage(); // CraftBukkit - SPIGOT-3034: Forward leave message to PlayerQuitEvent
|
||||
// Send the possibly modified leave message
|
||||
final Component ichatbasecomponent = PaperAdventure.asVanilla(event.reason()); // Paper - Adventure
|
||||
// CraftBukkit end
|
||||
@@ -523,7 +522,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
this.connection.send(new ClientboundDisconnectPacket(ichatbasecomponent), PacketSendListener.thenRun(() -> {
|
||||
this.connection.disconnect(ichatbasecomponent);
|
||||
}));
|
||||
- this.onDisconnect(ichatbasecomponent); // CraftBukkit - fire quit instantly
|
||||
+ this.onDisconnect(ichatbasecomponent, event.leaveMessage()); // CraftBukkit - fire quit instantly // Paper - use kick event leave message
|
||||
this.connection.setReadOnly();
|
||||
MinecraftServer minecraftserver = this.server;
|
||||
Connection networkmanager = this.connection;
|
||||
@@ -1976,6 +1975,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
@Override
|
||||
public void onDisconnect(Component reason) {
|
||||
+ // Paper start
|
||||
+ this.onDisconnect(reason, null);
|
||||
+ }
|
||||
+ public void onDisconnect(Component reason, @Nullable net.kyori.adventure.text.Component quitMessage) {
|
||||
+ // Paper end
|
||||
// CraftBukkit start - Rarely it would send a disconnect line twice
|
||||
if (this.processedDisconnect) {
|
||||
return;
|
||||
@@ -1993,7 +1997,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
|
||||
this.player.disconnect();
|
||||
// Paper start - Adventure
|
||||
- net.kyori.adventure.text.Component quitMessage = this.server.getPlayerList().remove(this.player);
|
||||
+ quitMessage = quitMessage == null ? this.server.getPlayerList().remove(this.player) : this.server.getPlayerList().remove(this.player, quitMessage); // Paper - pass in quitMessage to fix kick message not being used
|
||||
if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) {
|
||||
this.server.getPlayerList().broadcastSystemMessage(PaperAdventure.asVanilla(quitMessage), false);
|
||||
// Paper end
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 75bb6a8fa53734b8b6548a9f203e0ff574ae08dc..7e764cf21d18a2887f7c8d424245508c2966c179 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -564,6 +564,11 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer) { // CraftBukkit - return string // Paper - return Component
|
||||
+ // Paper start
|
||||
+ return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : PaperAdventure.asAdventure(entityplayer.getDisplayName())));
|
||||
+ }
|
||||
+ public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) {
|
||||
+ // Paper end
|
||||
ServerLevel worldserver = entityplayer.serverLevel();
|
||||
|
||||
entityplayer.awardStat(Stats.LEAVE_GAME);
|
||||
@@ -574,7 +579,7 @@ public abstract class PlayerList {
|
||||
entityplayer.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper
|
||||
}
|
||||
|
||||
- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : PaperAdventure.asAdventure(entityplayer.getDisplayName())), entityplayer.quitReason); // Paper - Adventure & quit reason
|
||||
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(entityplayer.getBukkitEntity(), leaveMessage, entityplayer.quitReason); // Paper - Adventure & quit reason
|
||||
this.cserver.getPluginManager().callEvent(playerQuitEvent);
|
||||
entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 2 Dec 2020 21:03:02 -0800
|
||||
Subject: [PATCH] Add config for mobs immune to default effects
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 3a669f8e0cd072fcbd5e5ed4b55abb0f73c009e7..38b0bde34420734c50fe23aa169af82a7de4e1c2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1164,7 +1164,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
if (this.getMobType() == MobType.UNDEAD) {
|
||||
MobEffect mobeffectlist = effect.getEffect();
|
||||
|
||||
- if (mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) {
|
||||
+ if ((mobeffectlist == MobEffects.REGENERATION || mobeffectlist == MobEffects.POISON) && this.level.paperConfig().entities.mobEffects.undeadImmuneToCertainEffects) { // Paper
|
||||
return false;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
index 9adff51029781795c2cdf479a89111b3a1f102c0..3d3567e09ddf0982dfa6b2279019168a6f4abaaa 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java
|
||||
@@ -605,7 +605,7 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effect) {
|
||||
- return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
|
||||
+ return effect.getEffect() == MobEffects.WITHER && this.level.paperConfig().entities.mobEffects.immuneToWitherEffect.wither ? false : super.canBeAffected(effect); // Paper
|
||||
}
|
||||
|
||||
private class WitherDoNothingGoal extends Goal {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Spider.java b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
index b9acef460ff7e8bc9e24997771beeba6bea1f28a..dd7c7fb6ed3086b1439499df806cdb84ce7d6eb2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Spider.java
|
||||
@@ -133,7 +133,7 @@ public class Spider extends Monster {
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effect) {
|
||||
- return effect.getEffect() == MobEffects.POISON ? false : super.canBeAffected(effect);
|
||||
+ return effect.getEffect() == MobEffects.POISON && this.level.paperConfig().entities.mobEffects.spidersImmuneToPoisonEffect ? false : super.canBeAffected(effect); // Paper
|
||||
}
|
||||
|
||||
public boolean isClimbing() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
|
||||
index ea6233cb3ca30864e54d553a5d1071ea9147a868..6449213d717271bcc516e393a78dfe1e5c762d68 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/WitherSkeleton.java
|
||||
@@ -123,6 +123,6 @@ public class WitherSkeleton extends AbstractSkeleton {
|
||||
|
||||
@Override
|
||||
public boolean canBeAffected(MobEffectInstance effect) {
|
||||
- return effect.getEffect() == MobEffects.WITHER ? false : super.canBeAffected(effect);
|
||||
+ return effect.getEffect() == MobEffects.WITHER && this.level.paperConfig().entities.mobEffects.immuneToWitherEffect.witherSkeleton ? false : super.canBeAffected(effect); // Paper
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: sulu5890 <sulu@sulu.me>
|
||||
Date: Sun, 11 Jul 2021 19:34:03 -0500
|
||||
Subject: [PATCH] Fix incorrect message for outdated client
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
index 8393c1a2d15d5ad255c9808b0d0edd6aeb447893..63cf71940f6480c593a43bd39900c50676367404 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
@@ -82,7 +82,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
if (packet.getProtocolVersion() != SharedConstants.getCurrentVersion().getProtocolVersion()) {
|
||||
Component ichatmutablecomponent; // Paper - Fix hex colors not working in some kick messages
|
||||
|
||||
- if (packet.getProtocolVersion() < 754) {
|
||||
+ if (packet.getProtocolVersion() < SharedConstants.getCurrentVersion().getProtocolVersion()) { // Paper - Fix incorrect message for outdated clients
|
||||
ichatmutablecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedClientMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
||||
} else {
|
||||
ichatmutablecomponent = org.bukkit.craftbukkit.util.CraftChatMessage.fromString( java.text.MessageFormat.format( org.spigotmc.SpigotConfig.outdatedServerMessage.replaceAll("'", "''"), SharedConstants.getCurrentVersion().getName() ) , true )[0]; // Spigot // Paper - Fix hex colors not working in some kick messages
|
|
@ -0,0 +1,33 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Phoenix616 <max@themoep.de>
|
||||
Date: Sun, 20 Jun 2021 16:35:42 +0100
|
||||
Subject: [PATCH] Don't apply cramming damage to players
|
||||
|
||||
It does not make a lot of sense to damage players if they get crammed,
|
||||
especially as the usecase of teleporting lots of players to the same
|
||||
location isn't too uncommon and killing all those players isn't
|
||||
really what one would expect to happen.
|
||||
|
||||
For those who really want it a config option is provided.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 1901bea8474e9af9d68b79bd9bd3abf319461f81..369b4b5fc1df238870081efece42e897318da67d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -100,6 +100,7 @@ import net.minecraft.util.Mth;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.Unit;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
+import net.minecraft.world.damagesource.DamageSources;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
@@ -1430,7 +1431,7 @@ public class ServerPlayer extends Player {
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerableTo(DamageSource damageSource) {
|
||||
- return super.isInvulnerableTo(damageSource) || this.isChangingDimension();
|
||||
+ return super.isInvulnerableTo(damageSource) || this.isChangingDimension() || !level.paperConfig().collisions.allowPlayerCrammingDamage && damageSource == damageSources().cramming(); // Paper - disable player cramming
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,134 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Phoenix616 <max@themoep.de>
|
||||
Date: Mon, 28 Jun 2021 22:38:29 +0100
|
||||
Subject: [PATCH] Rate options and timings for sensors and behaviors
|
||||
|
||||
This adds config options to specify the tick rate for sensors
|
||||
and behaviors of different entity types as well as timings
|
||||
for those in order to be able to have some metrics as to which
|
||||
ones might need tweaking.
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
index 59affb62cb487d60e8c3e32decf89d6cb7d22f8d..4d861f9a58f8ea238471af22f387854d855b1801 100644
|
||||
--- a/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
|
||||
@@ -115,6 +115,14 @@ public final class MinecraftTimings {
|
||||
return Timings.ofSafe("Minecraft", "## tickEntity - " + entityType + " - " + type, tickEntityTimer);
|
||||
}
|
||||
|
||||
+ public static Timing getBehaviorTimings(String type) {
|
||||
+ return Timings.ofSafe("## Behavior - " + type);
|
||||
+ }
|
||||
+
|
||||
+ public static Timing getSensorTimings(String type, int rate) {
|
||||
+ return Timings.ofSafe("## Sensor - " + type + " (Default rate: " + rate + ")");
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Get a named timer for the specified tile entity type to track type specific timings.
|
||||
* @param entity
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java
|
||||
index 4ea437253539e3ee533ca9da77a337cbf4d1e807..57ef7fbba3028c28231abf7b7ae78aa019323536 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java
|
||||
@@ -13,6 +13,10 @@ public abstract class Behavior<E extends LivingEntity> implements BehaviorContro
|
||||
private long endTimestamp;
|
||||
private final int minDuration;
|
||||
private final int maxDuration;
|
||||
+ // Paper start - configurable behavior tick rate and timings
|
||||
+ private final String configKey;
|
||||
+ private final co.aikar.timings.Timing timing;
|
||||
+ // Paper end
|
||||
|
||||
public Behavior(Map<MemoryModuleType<?>, MemoryStatus> requiredMemoryState) {
|
||||
this(requiredMemoryState, 60);
|
||||
@@ -26,6 +30,15 @@ public abstract class Behavior<E extends LivingEntity> implements BehaviorContro
|
||||
this.minDuration = minRunTime;
|
||||
this.maxDuration = maxRunTime;
|
||||
this.entryCondition = requiredMemoryState;
|
||||
+ // Paper start - configurable behavior tick rate and timings
|
||||
+ String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName());
|
||||
+ int lastSeparator = key.lastIndexOf('.');
|
||||
+ if (lastSeparator != -1) {
|
||||
+ key = key.substring(lastSeparator + 1);
|
||||
+ }
|
||||
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ this.timing = co.aikar.timings.MinecraftTimings.getBehaviorTimings(configKey);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,11 +48,19 @@ public abstract class Behavior<E extends LivingEntity> implements BehaviorContro
|
||||
|
||||
@Override
|
||||
public final boolean tryStart(ServerLevel world, E entity, long time) {
|
||||
+ // Paper start - behavior tick rate
|
||||
+ int tickRate = java.util.Objects.requireNonNullElse(world.paperConfig().tickRates.behavior.get(entity.getType(), this.configKey), -1);
|
||||
+ if (tickRate > -1 && time < this.endTimestamp + tickRate) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (this.hasRequiredMemories(entity) && this.checkExtraStartConditions(world, entity)) {
|
||||
this.status = Behavior.Status.RUNNING;
|
||||
int i = this.minDuration + world.getRandom().nextInt(this.maxDuration + 1 - this.minDuration);
|
||||
this.endTimestamp = time + (long)i;
|
||||
+ this.timing.startTiming(); // Paper - behavior timings
|
||||
this.start(world, entity, time);
|
||||
+ this.timing.stopTiming(); // Paper - behavior timings
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -51,11 +72,13 @@ public abstract class Behavior<E extends LivingEntity> implements BehaviorContro
|
||||
|
||||
@Override
|
||||
public final void tickOrStop(ServerLevel world, E entity, long time) {
|
||||
+ this.timing.startTiming(); // Paper - behavior timings
|
||||
if (!this.timedOut(time) && this.canStillUse(world, entity, time)) {
|
||||
this.tick(world, entity, time);
|
||||
} else {
|
||||
this.doStop(world, entity, time);
|
||||
}
|
||||
+ this.timing.stopTiming(); // Paper - behavior timings
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
||||
index 7970eebbd6935402223e6bba962bb8ba7d861dfd..fcdb9bde8e1605e30dde3e580491522d4b62cdc0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
|
||||
@@ -19,8 +19,21 @@ public abstract class Sensor<E extends LivingEntity> {
|
||||
private static final TargetingConditions ATTACK_TARGET_CONDITIONS_IGNORE_INVISIBILITY_AND_LINE_OF_SIGHT = TargetingConditions.forCombat().range(16.0D).ignoreLineOfSight().ignoreInvisibilityTesting();
|
||||
private final int scanRate;
|
||||
private long timeToTick;
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ private final String configKey;
|
||||
+ private final co.aikar.timings.Timing timing;
|
||||
+ // Paper end
|
||||
|
||||
public Sensor(int senseInterval) {
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ String key = io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(this.getClass().getName());
|
||||
+ int lastSeparator = key.lastIndexOf('.');
|
||||
+ if (lastSeparator != -1) {
|
||||
+ key = key.substring(lastSeparator + 1);
|
||||
+ }
|
||||
+ this.configKey = key.toLowerCase(java.util.Locale.ROOT);
|
||||
+ this.timing = co.aikar.timings.MinecraftTimings.getSensorTimings(configKey, senseInterval);
|
||||
+ // Paper end
|
||||
this.scanRate = senseInterval;
|
||||
this.timeToTick = (long)RANDOM.nextInt(senseInterval);
|
||||
}
|
||||
@@ -31,8 +44,12 @@ public abstract class Sensor<E extends LivingEntity> {
|
||||
|
||||
public final void tick(ServerLevel world, E entity) {
|
||||
if (--this.timeToTick <= 0L) {
|
||||
- this.timeToTick = (long)this.scanRate;
|
||||
+ // Paper start - configurable sensor tick rate and timings
|
||||
+ this.timeToTick = java.util.Objects.requireNonNullElse(world.paperConfig().tickRates.sensor.get(entity.getType(), this.configKey), this.scanRate);
|
||||
+ this.timing.startTiming();
|
||||
+ // Paper end
|
||||
this.doTick(world, entity);
|
||||
+ this.timing.stopTiming(); // Paper - sensor timings
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Tue, 20 Jul 2021 21:25:35 -0700
|
||||
Subject: [PATCH] Add a bunch of missing forceDrop toggles
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java b/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
index ac0cfdef53ec82665acf362235842de4f17bfdd1..05c1e8c9f013547d4fcdbbd299329166a8ece1b0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
|
||||
@@ -87,7 +87,9 @@ public class WorkAtComposter extends WorkAtPoi {
|
||||
simpleContainer.removeItemType(Items.WHEAT, m);
|
||||
ItemStack itemStack = simpleContainer.addItem(new ItemStack(Items.BREAD, l));
|
||||
if (!itemStack.isEmpty()) {
|
||||
+ entity.forceDrops = true; // Paper
|
||||
entity.spawnAtLocation(itemStack, 0.5F);
|
||||
+ entity.forceDrops = false; // Paper
|
||||
}
|
||||
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Panda.java b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||||
index 7f4ff9658b0eca2034333810fd2b199a3d186e72..a0933b8467bf81333dc103055e73bb75069dcb36 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
|
||||
@@ -528,7 +528,9 @@ public class Panda extends Animal {
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide() && this.random.nextInt(700) == 0 && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ this.forceDrops = true; // Paper
|
||||
this.spawnAtLocation((ItemLike) Items.SLIME_BALL);
|
||||
+ this.forceDrops = false; // Paper
|
||||
}
|
||||
|
||||
}
|
||||
@@ -652,7 +654,9 @@ public class Panda extends Animal {
|
||||
ItemStack itemstack1 = this.getItemBySlot(EquipmentSlot.MAINHAND);
|
||||
|
||||
if (!itemstack1.isEmpty() && !player.getAbilities().instabuild) {
|
||||
+ this.forceDrops = true; // Paper
|
||||
this.spawnAtLocation(itemstack1);
|
||||
+ this.forceDrops = false; // Paper
|
||||
}
|
||||
|
||||
this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemstack.getItem(), 1));
|
||||
@@ -929,7 +933,9 @@ public class Panda extends Animal {
|
||||
ItemStack itemstack = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND);
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
+ Panda.this.forceDrops = true; // Paper
|
||||
Panda.this.spawnAtLocation(itemstack);
|
||||
+ Panda.this.forceDrops = false; // Paper
|
||||
Panda.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
|
||||
int i = Panda.this.isLazy() ? Panda.this.random.nextInt(50) + 10 : Panda.this.random.nextInt(150) + 10;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
index 2c012e8d314e8b785300de3f810f95c7452b7348..7ef04ef7995b093eef022b397cda8c27c8faede0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
@@ -322,7 +322,9 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
|
||||
@Override
|
||||
protected void finishConversion(ServerLevel world) {
|
||||
PiglinAi.cancelAdmiring(this);
|
||||
+ this.forceDrops = true; // Paper
|
||||
this.inventory.removeAllItems().forEach(this::spawnAtLocation);
|
||||
+ this.forceDrops = false; // Paper
|
||||
super.finishConversion(world);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
index 7611481c7e469a3b9eb4d00f4816adb7b190127e..092cdb889564903102dccfe7bf2e320a1eba5efe 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
@@ -270,7 +270,9 @@ public class PiglinAi {
|
||||
|
||||
private static void holdInOffhand(Piglin piglin, ItemStack stack) {
|
||||
if (PiglinAi.isHoldingItemInOffHand(piglin)) {
|
||||
+ piglin.forceDrops = true; // Paper
|
||||
piglin.spawnAtLocation(piglin.getItemInHand(InteractionHand.OFF_HAND));
|
||||
+ piglin.forceDrops = false; // Paper
|
||||
}
|
||||
|
||||
piglin.holdInOffHand(stack);
|
||||
@@ -330,7 +332,9 @@ public class PiglinAi {
|
||||
|
||||
protected static void cancelAdmiring(Piglin piglin) {
|
||||
if (PiglinAi.isAdmiringItem(piglin) && !piglin.getOffhandItem().isEmpty()) {
|
||||
+ piglin.forceDrops = true; // Paper
|
||||
piglin.spawnAtLocation(piglin.getOffhandItem());
|
||||
+ piglin.forceDrops = false; // Paper
|
||||
piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||
index 06d4c1787b1ee4976e6ed1773d3ff7130aebc2d0..9948085f51659f9b896622251739343d658dd0b2 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
||||
@@ -250,7 +250,9 @@ public abstract class Raider extends PatrollingMonster {
|
||||
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
|
||||
|
||||
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
|
||||
+ this.forceDrops = true; // Paper
|
||||
this.spawnAtLocation(itemstack1);
|
||||
+ this.forceDrops = false; // Paper
|
||||
}
|
||||
|
||||
this.onItemPickup(item);
|
39
patches/server/0638-Stinger-API.patch
Normal file
39
patches/server/0638-Stinger-API.patch
Normal file
|
@ -0,0 +1,39 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Tue, 22 Jun 2021 23:15:44 -0400
|
||||
Subject: [PATCH] Stinger API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 61292952681727bcd651064619bff1b41c560d75..1973a8ed75f9bacebebfa74dd2d06bf7d840ea4a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -340,7 +340,28 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
// Paper end
|
||||
}
|
||||
+ // Paper Start - Bee Stinger API
|
||||
+ @Override
|
||||
+ public int getBeeStingerCooldown() {
|
||||
+ return getHandle().removeStingerTime;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setBeeStingerCooldown(int ticks) {
|
||||
+ getHandle().removeStingerTime = ticks;
|
||||
+ }
|
||||
|
||||
+ @Override
|
||||
+ public int getBeeStingersInBody() {
|
||||
+ return getHandle().getStingerCount();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setBeeStingersInBody(int count) {
|
||||
+ Preconditions.checkArgument(count >= 0, "New bee stinger amount must be >= 0");
|
||||
+ getHandle().setStingerCount(count);
|
||||
+ }
|
||||
+ // Paper End - Bee Stinger API
|
||||
@Override
|
||||
public void damage(double amount) {
|
||||
this.damage(amount, null);
|
|
@ -0,0 +1,31 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 1 Aug 2021 09:49:06 +0100
|
||||
Subject: [PATCH] Fix incosistency issue with empty map items in CB
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
index 75b110c6fb685390306fe3b8504aeea9bd6deedd..d3c29e6bf8b3c2dd628809177dac50220a7de415 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/MapItem.java
|
||||
@@ -73,7 +73,7 @@ public class MapItem extends ComplexItem {
|
||||
public static Integer getMapId(ItemStack stack) {
|
||||
CompoundTag nbttagcompound = stack.getTag();
|
||||
|
||||
- return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : -1; // CraftBukkit - make new maps for no tag
|
||||
+ return nbttagcompound != null && nbttagcompound.contains("map", 99) ? nbttagcompound.getInt("map") : null; // CraftBukkit - make new maps for no tag // Paper - don't return invalid ID
|
||||
}
|
||||
|
||||
public static int createNewSavedData(Level world, int x, int z, int scale, boolean showIcons, boolean unlimitedTracking, ResourceKey<Level> dimension) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
|
||||
index 70b365afc40f11d4da3aea2b5d6b2467f517deac..a74ea06e3a190916527ab2c85d13f1e34c08d50a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaMap.java
|
||||
@@ -133,6 +133,7 @@ class CraftMetaMap extends CraftMetaItem implements MapMeta {
|
||||
|
||||
@Override
|
||||
public int getMapId() {
|
||||
+ Preconditions.checkState(this.hasMapView(), "Item does not have map associated - check hasMapView() first!"); // Paper - more friendly message
|
||||
return this.mapId;
|
||||
}
|
||||
|
118
patches/server/0640-Add-System.out-err-catcher.patch
Normal file
118
patches/server/0640-Add-System.out-err-catcher.patch
Normal file
|
@ -0,0 +1,118 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: underscore11code <minecrafter11mrt@gmail.com>
|
||||
Date: Fri, 23 Jul 2021 23:01:42 -0700
|
||||
Subject: [PATCH] Add System.out/err catcher
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/SysoutCatcher.java b/src/main/java/io/papermc/paper/logging/SysoutCatcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a8e813ca89b033f061e695288b3383bdcf128531
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/SysoutCatcher.java
|
||||
@@ -0,0 +1,94 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.plugin.java.JavaPlugin;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.io.OutputStream;
|
||||
+import java.io.PrintStream;
|
||||
+import java.util.Objects;
|
||||
+import java.util.concurrent.ConcurrentHashMap;
|
||||
+import java.util.concurrent.ConcurrentMap;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+import java.util.logging.Level;
|
||||
+
|
||||
+public final class SysoutCatcher {
|
||||
+ private static final boolean SUPPRESS_NAGS = Boolean.getBoolean("io.papermc.paper.suppress.sout.nags");
|
||||
+ // Nanoseconds between nag at most; if interval is caught first, this is reset.
|
||||
+ // <= 0 for disabling.
|
||||
+ private static final long NAG_TIMEOUT = TimeUnit.MILLISECONDS.toNanos(
|
||||
+ Long.getLong("io.papermc.paper.sout.nags.timeout", TimeUnit.MINUTES.toMillis(5L)));
|
||||
+ // Count since last nag; if timeout is first, this is reset.
|
||||
+ // <= 0 for disabling.
|
||||
+ private static final long NAG_INTERVAL = Long.getLong("io.papermc.paper.sout.nags.interval", 200L);
|
||||
+
|
||||
+ // We don't particularly care about how correct this is at any given moment; let's do it on a best attempt basis.
|
||||
+ // The records are also pretty small, so let's just go for a size of 64 to start...
|
||||
+ //
|
||||
+ // Content: Plugin name => nag object
|
||||
+ // Why plugin name?: This doesn't store a reference to the plugin; keeps the reload ability.
|
||||
+ // Why not clean on reload?: Effort.
|
||||
+ private final ConcurrentMap<String, PluginNag> nagRecords = new ConcurrentHashMap<>(64);
|
||||
+
|
||||
+ public SysoutCatcher() {
|
||||
+ System.setOut(new WrappedOutStream(System.out, Level.INFO, "[STDOUT] "));
|
||||
+ System.setErr(new WrappedOutStream(System.err, Level.SEVERE, "[STDERR] "));
|
||||
+ }
|
||||
+
|
||||
+ private final class WrappedOutStream extends PrintStream {
|
||||
+ private static final StackWalker STACK_WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
|
||||
+ private final Level level;
|
||||
+ private final String prefix;
|
||||
+
|
||||
+ public WrappedOutStream(@NotNull final OutputStream out, final Level level, final String prefix) {
|
||||
+ super(out);
|
||||
+ this.level = level;
|
||||
+ this.prefix = prefix;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void println(@Nullable final String line) {
|
||||
+ final Class<?> clazz = STACK_WALKER.getCallerClass();
|
||||
+ try {
|
||||
+ final JavaPlugin plugin = JavaPlugin.getProvidingPlugin(clazz);
|
||||
+
|
||||
+ // Instead of just printing the message, send it to the plugin's logger
|
||||
+ plugin.getLogger().log(this.level, this.prefix + line);
|
||||
+
|
||||
+ if (SysoutCatcher.SUPPRESS_NAGS) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (SysoutCatcher.NAG_INTERVAL > 0 || SysoutCatcher.NAG_TIMEOUT > 0) {
|
||||
+ final PluginNag nagRecord = SysoutCatcher.this.nagRecords.computeIfAbsent(plugin.getName(), k -> new PluginNag());
|
||||
+ final boolean hasTimePassed = SysoutCatcher.NAG_TIMEOUT > 0
|
||||
+ && (nagRecord.lastNagTimestamp == Long.MIN_VALUE
|
||||
+ || nagRecord.lastNagTimestamp + SysoutCatcher.NAG_TIMEOUT <= System.nanoTime());
|
||||
+ final boolean hasMessagesPassed = SysoutCatcher.NAG_INTERVAL > 0
|
||||
+ && (nagRecord.messagesSinceNag == Long.MIN_VALUE
|
||||
+ || ++nagRecord.messagesSinceNag >= SysoutCatcher.NAG_INTERVAL);
|
||||
+ if (!hasMessagesPassed && !hasTimePassed) {
|
||||
+ return;
|
||||
+ }
|
||||
+ nagRecord.lastNagTimestamp = System.nanoTime();
|
||||
+ nagRecord.messagesSinceNag = 0;
|
||||
+ }
|
||||
+ Bukkit.getLogger().warning(
|
||||
+ String.format("Nag author(s): '%s' of '%s' about their usage of System.out/err.print. "
|
||||
+ + "Please use your plugin's logger instead (JavaPlugin#getLogger).",
|
||||
+ plugin.getPluginMeta().getAuthors(),
|
||||
+ plugin.getPluginMeta().getDisplayName())
|
||||
+ );
|
||||
+ } catch (final IllegalArgumentException | IllegalStateException e) {
|
||||
+ // If anything happens, the calling class doesn't exist, there is no JavaPlugin that "owns" the calling class, etc
|
||||
+ // Just print out normally, with some added information
|
||||
+ Bukkit.getLogger().log(this.level, String.format("%s[%s] %s", this.prefix, clazz.getName(), line));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static class PluginNag {
|
||||
+ private long lastNagTimestamp = Long.MIN_VALUE;
|
||||
+ private long messagesSinceNag = Long.MIN_VALUE;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index b8f5f17b9759d82e39d2e619ce58704f7d74d3c1..3e8266fce7fec1185620125874d8349dd180b727 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -300,6 +300,7 @@ public final class CraftServer implements Server {
|
||||
public int reloadCount;
|
||||
private final io.papermc.paper.datapack.PaperDatapackManager datapackManager; // Paper
|
||||
public static Exception excessiveVelEx; // Paper - Velocity warnings
|
||||
+ private final io.papermc.paper.logging.SysoutCatcher sysoutCatcher = new io.papermc.paper.logging.SysoutCatcher(); // Paper
|
||||
|
||||
static {
|
||||
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
|
24
patches/server/0641-Fix-test-not-bootstrapping.patch
Normal file
24
patches/server/0641-Fix-test-not-bootstrapping.patch
Normal file
|
@ -0,0 +1,24 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Mon, 2 Aug 2021 08:52:21 +0200
|
||||
Subject: [PATCH] Fix test not bootstrapping
|
||||
|
||||
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
|
||||
diff --git a/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java b/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
|
||||
index 439bf35c251ab5dc0d27923e62789a496618de82..5d3b8ba99d0fe966b7329540d61825aa266c7e64 100644
|
||||
--- a/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
|
||||
+++ b/src/test/java/org/bukkit/enchantments/EnchantmentTargetTest.java
|
||||
@@ -5,10 +5,11 @@ import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentCategory;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
-public class EnchantmentTargetTest {
|
||||
+public class EnchantmentTargetTest extends AbstractTestingBase { // Paper
|
||||
|
||||
@Test
|
||||
public void test() {
|
|
@ -0,0 +1,246 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: SirYwell <hannesgreule@outlook.de>
|
||||
Date: Sat, 10 Jul 2021 11:12:30 +0200
|
||||
Subject: [PATCH] Rewrite LogEvents to contain the source jars in stack traces
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/DelegateLogEvent.java b/src/main/java/io/papermc/paper/logging/DelegateLogEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6ffd1befe64c6c3036c22e05ed1c44808d64bd28
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/DelegateLogEvent.java
|
||||
@@ -0,0 +1,130 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.apache.logging.log4j.Level;
|
||||
+import org.apache.logging.log4j.Marker;
|
||||
+import org.apache.logging.log4j.ThreadContext;
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.impl.ThrowableProxy;
|
||||
+import org.apache.logging.log4j.core.time.Instant;
|
||||
+import org.apache.logging.log4j.message.Message;
|
||||
+import org.apache.logging.log4j.util.ReadOnlyStringMap;
|
||||
+
|
||||
+import java.util.Map;
|
||||
+
|
||||
+public class DelegateLogEvent implements LogEvent {
|
||||
+ private final LogEvent original;
|
||||
+
|
||||
+ protected DelegateLogEvent(LogEvent original) {
|
||||
+ this.original = original;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public LogEvent toImmutable() {
|
||||
+ return this.original.toImmutable();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Map<String, String> getContextMap() {
|
||||
+ return this.original.getContextMap();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ReadOnlyStringMap getContextData() {
|
||||
+ return this.original.getContextData();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ThreadContext.ContextStack getContextStack() {
|
||||
+ return this.original.getContextStack();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getLoggerFqcn() {
|
||||
+ return this.original.getLoggerFqcn();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Level getLevel() {
|
||||
+ return this.original.getLevel();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getLoggerName() {
|
||||
+ return this.original.getLoggerName();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Marker getMarker() {
|
||||
+ return this.original.getMarker();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Message getMessage() {
|
||||
+ return this.original.getMessage();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getTimeMillis() {
|
||||
+ return this.original.getTimeMillis();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Instant getInstant() {
|
||||
+ return this.original.getInstant();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public StackTraceElement getSource() {
|
||||
+ return this.original.getSource();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getThreadName() {
|
||||
+ return this.original.getThreadName();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getThreadId() {
|
||||
+ return this.original.getThreadId();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getThreadPriority() {
|
||||
+ return this.original.getThreadPriority();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Throwable getThrown() {
|
||||
+ return this.original.getThrown();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ThrowableProxy getThrownProxy() {
|
||||
+ return this.original.getThrownProxy();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isEndOfBatch() {
|
||||
+ return this.original.isEndOfBatch();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isIncludeLocation() {
|
||||
+ return this.original.isIncludeLocation();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setEndOfBatch(boolean endOfBatch) {
|
||||
+ this.original.setEndOfBatch(endOfBatch);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setIncludeLocation(boolean locationRequired) {
|
||||
+ this.original.setIncludeLocation(locationRequired);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getNanoTime() {
|
||||
+ return this.original.getNanoTime();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/ExtraClassInfoLogEvent.java b/src/main/java/io/papermc/paper/logging/ExtraClassInfoLogEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..558427c65b4051923f73d15d85ee519be005060a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/ExtraClassInfoLogEvent.java
|
||||
@@ -0,0 +1,48 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.impl.ExtendedClassInfo;
|
||||
+import org.apache.logging.log4j.core.impl.ExtendedStackTraceElement;
|
||||
+import org.apache.logging.log4j.core.impl.ThrowableProxy;
|
||||
+
|
||||
+public class ExtraClassInfoLogEvent extends DelegateLogEvent {
|
||||
+
|
||||
+ private boolean fixed;
|
||||
+
|
||||
+ public ExtraClassInfoLogEvent(LogEvent original) {
|
||||
+ super(original);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ThrowableProxy getThrownProxy() {
|
||||
+ if (fixed) {
|
||||
+ return super.getThrownProxy();
|
||||
+ }
|
||||
+ rewriteStackTrace(super.getThrownProxy());
|
||||
+ fixed = true;
|
||||
+ return super.getThrownProxy();
|
||||
+ }
|
||||
+
|
||||
+ private void rewriteStackTrace(ThrowableProxy throwable) {
|
||||
+ ExtendedStackTraceElement[] stackTrace = throwable.getExtendedStackTrace();
|
||||
+ for (int i = 0; i < stackTrace.length; i++) {
|
||||
+ ExtendedClassInfo classInfo = stackTrace[i].getExtraClassInfo();
|
||||
+ if (classInfo.getLocation().equals("?")) {
|
||||
+ StackTraceElement element = stackTrace[i].getStackTraceElement();
|
||||
+ String classLoaderName = element.getClassLoaderName();
|
||||
+ if (classLoaderName != null) {
|
||||
+ stackTrace[i] = new ExtendedStackTraceElement(element,
|
||||
+ new ExtendedClassInfo(classInfo.getExact(), classLoaderName, "?"));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (throwable.getCauseProxy() != null) {
|
||||
+ rewriteStackTrace(throwable.getCauseProxy());
|
||||
+ }
|
||||
+ if (throwable.getSuppressedProxies() != null) {
|
||||
+ for (ThrowableProxy proxy : throwable.getSuppressedProxies()) {
|
||||
+ rewriteStackTrace(proxy);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/logging/ExtraClassInfoRewritePolicy.java b/src/main/java/io/papermc/paper/logging/ExtraClassInfoRewritePolicy.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..34734bb969a1a74c7a4f9c17d40ebf007ad5d701
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/logging/ExtraClassInfoRewritePolicy.java
|
||||
@@ -0,0 +1,29 @@
|
||||
+package io.papermc.paper.logging;
|
||||
+
|
||||
+import org.apache.logging.log4j.core.Core;
|
||||
+import org.apache.logging.log4j.core.LogEvent;
|
||||
+import org.apache.logging.log4j.core.appender.rewrite.RewritePolicy;
|
||||
+import org.apache.logging.log4j.core.config.plugins.Plugin;
|
||||
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+@Plugin(
|
||||
+ name = "ExtraClassInfoRewritePolicy",
|
||||
+ category = Core.CATEGORY_NAME,
|
||||
+ elementType = "rewritePolicy",
|
||||
+ printObject = true
|
||||
+)
|
||||
+public final class ExtraClassInfoRewritePolicy implements RewritePolicy {
|
||||
+ @Override
|
||||
+ public LogEvent rewrite(LogEvent source) {
|
||||
+ if (source.getThrown() != null) {
|
||||
+ return new ExtraClassInfoLogEvent(source);
|
||||
+ }
|
||||
+ return source;
|
||||
+ }
|
||||
+
|
||||
+ @PluginFactory
|
||||
+ public static @NotNull ExtraClassInfoRewritePolicy createPolicy() {
|
||||
+ return new ExtraClassInfoRewritePolicy();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml
|
||||
index 2e421eaac80cf251b32e0bb504dd54a73edf4986..74ccc67e3c12dc5182602fb691ef3ddeb5b53280 100644
|
||||
--- a/src/main/resources/log4j2.xml
|
||||
+++ b/src/main/resources/log4j2.xml
|
||||
@@ -34,6 +34,10 @@
|
||||
</Async>
|
||||
<Rewrite name="rewrite">
|
||||
<StacktraceDeobfuscatingRewritePolicy />
|
||||
+ <AppenderRef ref="rewrite2"/>
|
||||
+ </Rewrite>
|
||||
+ <Rewrite name="rewrite2">
|
||||
+ <ExtraClassInfoRewritePolicy />
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="TerminalConsole" level="info"/>
|
||||
<AppenderRef ref="ServerGuiConsole" level="info"/>
|
70
patches/server/0643-Improve-boat-collision-performance.patch
Normal file
70
patches/server/0643-Improve-boat-collision-performance.patch
Normal file
|
@ -0,0 +1,70 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Mon, 2 Aug 2021 10:10:40 +0200
|
||||
Subject: [PATCH] Improve boat collision performance
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
||||
index 7354711e194ab58b11b68f447c1fc795fe611a65..5579dad0ba8f2e4ce43883e7d36059c2a2bd1b83 100644
|
||||
--- a/src/main/java/net/minecraft/Util.java
|
||||
+++ b/src/main/java/net/minecraft/Util.java
|
||||
@@ -113,6 +113,7 @@ public class Util {
|
||||
}).findFirst().orElseThrow(() -> {
|
||||
return new IllegalStateException("No jar file system provider found");
|
||||
});
|
||||
+ public static final double COLLISION_EPSILON = 1.0E-7; // Paper
|
||||
private static Consumer<String> thePauser = (message) -> {
|
||||
};
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 38b0bde34420734c50fe23aa169af82a7de4e1c2..3017e7a6c2685e4ab82a425025c363133209222d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1383,7 +1383,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
if (!source.is(DamageTypeTags.IS_PROJECTILE)) {
|
||||
Entity entity = source.getDirectEntity();
|
||||
|
||||
- if (entity instanceof LivingEntity) {
|
||||
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper
|
||||
LivingEntity entityliving = (LivingEntity) entity;
|
||||
|
||||
this.blockUsingShield(entityliving);
|
||||
@@ -1488,11 +1488,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
if (entity1 != null && !source.is(DamageTypeTags.IS_EXPLOSION)) {
|
||||
- double d0 = entity1.getX() - this.getX();
|
||||
+ final boolean far = entity1.distanceToSqr(this) > (200.0 * 200.0); // Paper
|
||||
+ double d0 = far ? (Math.random() - Math.random()) : entity1.getX() - this.getX(); // Paper
|
||||
|
||||
double d1;
|
||||
|
||||
- for (d1 = entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) {
|
||||
+ for (d1 = far ? Math.random() - Math.random() : entity1.getZ() - this.getZ(); d0 * d0 + d1 * d1 < 1.0E-4D; d1 = (Math.random() - Math.random()) * 0.01D) { // Paper
|
||||
d0 = (Math.random() - Math.random()) * 0.01D;
|
||||
}
|
||||
|
||||
@@ -2220,7 +2221,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
||||
Entity entity = damagesource.getDirectEntity();
|
||||
|
||||
- if (entity instanceof LivingEntity) {
|
||||
+ if (entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper
|
||||
this.blockUsingShield((LivingEntity) entity);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
index 9fd8c9b82ee6a2cf94a90d0acb42637a2fde7ad5..fab73940378f0635c2b5634f6c91a589bdd80031 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||
@@ -709,8 +709,8 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
||||
this.invFriction = 0.05F;
|
||||
if (this.oldStatus == Boat.Status.IN_AIR && this.status != Boat.Status.IN_AIR && this.status != Boat.Status.ON_LAND) {
|
||||
this.waterLevel = this.getY(1.0D);
|
||||
- this.setPos(this.getX(), (double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D, this.getZ());
|
||||
- this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D));
|
||||
+ this.move(MoverType.SELF, new Vec3(0.0, ((double) (this.getWaterLevelAbove() - this.getBbHeight()) + 0.101D) - this.getY(), 0.0)); // Paper
|
||||
+ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0D, 0.0D, 1.0D)); // Paper
|
||||
this.lastYd = 0.0D;
|
||||
this.status = Boat.Status.IN_WATER;
|
||||
} else {
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Noah van der Aa <ndvdaa@gmail.com>
|
||||
Date: Sat, 24 Jul 2021 16:54:11 +0200
|
||||
Subject: [PATCH] Prevent AFK kick while watching end credits.
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index a5e113b571910cc26bfbcff4b7a792f86ecb1192..8342fa795a4813ca5a4292c4933f01f8b4a5a4f3 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -431,7 +431,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
--this.dropSpamTickCount;
|
||||
}
|
||||
|
||||
- if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L) {
|
||||
+ if (this.player.getLastActionTime() > 0L && this.server.getPlayerIdleTimeout() > 0 && Util.getMillis() - this.player.getLastActionTime() > (long) this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits.
|
||||
this.player.resetLastActionTime(); // CraftBukkit - SPIGOT-854
|
||||
this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
|
||||
}
|
189
patches/server/0645-Add-PlayerSetSpawnEvent.patch
Normal file
189
patches/server/0645-Add-PlayerSetSpawnEvent.patch
Normal file
|
@ -0,0 +1,189 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 19 May 2021 18:59:10 -0700
|
||||
Subject: [PATCH] Add PlayerSetSpawnEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java b/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java
|
||||
index a2d0699e8427b2262a2396495111125eccafbb66..c29340eb3e4044f6c342146bcd1ddbed6b9a5969 100644
|
||||
--- a/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java
|
||||
+++ b/src/main/java/net/minecraft/server/commands/SetSpawnCommand.java
|
||||
@@ -38,11 +38,23 @@ public class SetSpawnCommand {
|
||||
ResourceKey<Level> resourcekey = source.getLevel().dimension();
|
||||
Iterator iterator = targets.iterator();
|
||||
|
||||
+ final Collection<ServerPlayer> actualTargets = new java.util.ArrayList<>(); // Paper
|
||||
while (iterator.hasNext()) {
|
||||
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
|
||||
|
||||
- entityplayer.setRespawnPosition(resourcekey, pos, angle, true, false, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.COMMAND); // CraftBukkit
|
||||
+ // Paper start - PlayerSetSpawnEvent
|
||||
+ if (entityplayer.setRespawnPosition(resourcekey, pos, angle, true, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.COMMAND)) {
|
||||
+ actualTargets.add(entityplayer);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
+ // Paper start
|
||||
+ if (actualTargets.isEmpty()) {
|
||||
+ return 0;
|
||||
+ } else {
|
||||
+ targets = actualTargets;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
String s = resourcekey.location().toString();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 369b4b5fc1df238870081efece42e897318da67d..096a8c7c6559bf252d8dbba09a33e97fd8a0b4af 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1307,7 +1307,7 @@ public class ServerPlayer extends Player {
|
||||
} else if (this.bedBlocked(blockposition, enumdirection)) {
|
||||
return Either.left(Player.BedSleepingProblem.OBSTRUCTED);
|
||||
} else {
|
||||
- this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true, PlayerSpawnChangeEvent.Cause.BED); // CraftBukkit
|
||||
+ this.setRespawnPosition(this.level().dimension(), blockposition, this.getYRot(), false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED); // Paper - PlayerSetSpawnEvent
|
||||
if (this.level().isDay()) {
|
||||
return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW);
|
||||
} else {
|
||||
@@ -2154,44 +2154,50 @@ public class ServerPlayer extends Player {
|
||||
return this.respawnForced;
|
||||
}
|
||||
|
||||
+ @Deprecated // Paper
|
||||
public void setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage) {
|
||||
- // CraftBukkit start
|
||||
- this.setRespawnPosition(dimension, pos, angle, forced, sendMessage, PlayerSpawnChangeEvent.Cause.UNKNOWN);
|
||||
- }
|
||||
-
|
||||
- public void setRespawnPosition(ResourceKey<Level> resourcekey, @Nullable BlockPos blockposition, float f, boolean flag, boolean flag1, PlayerSpawnChangeEvent.Cause cause) {
|
||||
- ServerLevel newWorld = this.server.getLevel(resourcekey);
|
||||
- Location newSpawn = (blockposition != null) ? CraftLocation.toBukkit(blockposition, newWorld.getWorld(), f, 0) : null;
|
||||
-
|
||||
- PlayerSpawnChangeEvent event = new PlayerSpawnChangeEvent(this.getBukkitEntity(), newSpawn, flag, cause);
|
||||
- Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
- if (event.isCancelled()) {
|
||||
- return;
|
||||
- }
|
||||
- newSpawn = event.getNewSpawn();
|
||||
- flag = event.isForced();
|
||||
-
|
||||
- if (newSpawn != null) {
|
||||
- resourcekey = ((CraftWorld) newSpawn.getWorld()).getHandle().dimension();
|
||||
- blockposition = BlockPos.containing(newSpawn.getX(), newSpawn.getY(), newSpawn.getZ());
|
||||
- f = newSpawn.getYaw();
|
||||
- } else {
|
||||
- resourcekey = Level.OVERWORLD;
|
||||
- blockposition = null;
|
||||
- f = 0.0F;
|
||||
+ // Paper start
|
||||
+ this.setRespawnPosition(dimension, pos, angle, forced, sendMessage, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+ @Deprecated
|
||||
+ public boolean setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage, PlayerSpawnChangeEvent.Cause cause) {
|
||||
+ return this.setRespawnPosition(dimension, pos, angle, forced, sendMessage, cause == PlayerSpawnChangeEvent.Cause.RESET ?
|
||||
+ com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN : com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.valueOf(cause.name()));
|
||||
+ }
|
||||
+ public boolean setRespawnPosition(ResourceKey<Level> dimension, @Nullable BlockPos pos, float angle, boolean forced, boolean sendMessage, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause cause) {
|
||||
+ Location spawnLoc = null;
|
||||
+ boolean willNotify = false;
|
||||
+ if (pos != null) {
|
||||
+ boolean flag2 = pos.equals(this.respawnPosition) && dimension.equals(this.respawnDimension);
|
||||
+ spawnLoc = io.papermc.paper.util.MCUtil.toLocation(this.getServer().getLevel(dimension), pos);
|
||||
+ spawnLoc.setYaw(angle);
|
||||
+ willNotify = sendMessage && !flag2;
|
||||
+ }
|
||||
+
|
||||
+ PlayerSpawnChangeEvent dumbEvent = new PlayerSpawnChangeEvent(this.getBukkitEntity(), spawnLoc, forced,
|
||||
+ cause == com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN ? PlayerSpawnChangeEvent.Cause.RESET : PlayerSpawnChangeEvent.Cause.valueOf(cause.name()));
|
||||
+ dumbEvent.callEvent();
|
||||
+
|
||||
+ com.destroystokyo.paper.event.player.PlayerSetSpawnEvent event = new com.destroystokyo.paper.event.player.PlayerSetSpawnEvent(this.getBukkitEntity(), cause, dumbEvent.getNewSpawn(), dumbEvent.isForced(), willNotify, willNotify ? net.kyori.adventure.text.Component.translatable("block.minecraft.set_spawn") : null);
|
||||
+ event.setCancelled(dumbEvent.isCancelled());
|
||||
+ if (!event.callEvent()) {
|
||||
+ return false;
|
||||
}
|
||||
- // CraftBukkit end
|
||||
- if (blockposition != null) {
|
||||
- boolean flag2 = blockposition.equals(this.respawnPosition) && resourcekey.equals(this.respawnDimension);
|
||||
+ if (event.getLocation() != null) {
|
||||
+ dimension = event.getLocation().getWorld() != null ? ((CraftWorld) event.getLocation().getWorld()).getHandle().dimension() : dimension;
|
||||
+ pos = io.papermc.paper.util.MCUtil.toBlockPosition(event.getLocation());
|
||||
+ angle = event.getLocation().getYaw();
|
||||
+ forced = event.isForced();
|
||||
+ // Paper end
|
||||
|
||||
- if (flag1 && !flag2) {
|
||||
- this.sendSystemMessage(Component.translatable("block.minecraft.set_spawn"));
|
||||
+ if (event.willNotifyPlayer() && event.getNotification() != null) { // Paper
|
||||
+ this.sendSystemMessage(PaperAdventure.asVanilla(event.getNotification())); // Paper
|
||||
}
|
||||
|
||||
- this.respawnPosition = blockposition;
|
||||
- this.respawnDimension = resourcekey;
|
||||
- this.respawnAngle = f;
|
||||
- this.respawnForced = flag;
|
||||
+ this.respawnPosition = pos;
|
||||
+ this.respawnDimension = dimension;
|
||||
+ this.respawnAngle = angle;
|
||||
+ this.respawnForced = forced;
|
||||
} else {
|
||||
this.respawnPosition = null;
|
||||
this.respawnDimension = Level.OVERWORLD;
|
||||
@@ -2199,6 +2205,7 @@ public class ServerPlayer extends Player {
|
||||
this.respawnForced = false;
|
||||
}
|
||||
|
||||
+ return true; // Paper
|
||||
}
|
||||
|
||||
public void trackChunk(ChunkPos chunkPos, Packet<?> chunkDataPacket) {
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 7e764cf21d18a2887f7c8d424245508c2966c179..cbc8d79b22568d2233614c8fcd592b4f4e2c8d51 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -860,7 +860,7 @@ public abstract class PlayerList {
|
||||
location = CraftLocation.toBukkit(vec3d, worldserver1.getWorld(), f1, 0.0F);
|
||||
} else if (blockposition != null) {
|
||||
entityplayer1.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F));
|
||||
- entityplayer1.setRespawnPosition(null, null, 0f, false, false, PlayerSpawnChangeEvent.Cause.RESET); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed
|
||||
+ entityplayer1.setRespawnPosition(null, null, 0f, false, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed // Paper - PlayerSetSpawnEvent
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
||||
index 1a27b7faa22e6b3dc5fce329ed06425de56c4315..b9903c29bdea8d1e3b6fce0e97be6bd9493cfdf4 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java
|
||||
@@ -80,9 +80,14 @@ public class RespawnAnchorBlock extends Block {
|
||||
ServerPlayer entityplayer = (ServerPlayer) player;
|
||||
|
||||
if (entityplayer.getRespawnDimension() != world.dimension() || !pos.equals(entityplayer.getRespawnPosition())) {
|
||||
- entityplayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.RESPAWN_ANCHOR); // CraftBukkit
|
||||
+ if (entityplayer.setRespawnPosition(world.dimension(), pos, 0.0F, false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - PlayerSetSpawnEvent
|
||||
world.playSound((Player) null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F);
|
||||
return InteractionResult.SUCCESS;
|
||||
+ // Paper start - handle failed set spawn
|
||||
+ } else {
|
||||
+ return InteractionResult.FAIL;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 1b206a58cb9bc92e8b9a6ac1919bff95f341ede9..d9ec6b1d52c54ae3c05b3e895c88751039a2fe1c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1302,9 +1302,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@Override
|
||||
public void setBedSpawnLocation(Location location, boolean override) {
|
||||
if (location == null) {
|
||||
- this.getHandle().setRespawnPosition(null, null, 0.0F, override, false, PlayerSpawnChangeEvent.Cause.PLUGIN);
|
||||
+ this.getHandle().setRespawnPosition(null, null, 0.0F, override, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLUGIN); // Paper - PlayerSetSpawnEvent
|
||||
} else {
|
||||
- this.getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().dimension(), CraftLocation.toBlockPosition(location), location.getYaw(), override, false, PlayerSpawnChangeEvent.Cause.PLUGIN);
|
||||
+ this.getHandle().setRespawnPosition(((CraftWorld) location.getWorld()).getHandle().dimension(), CraftLocation.toBlockPosition(location), location.getYaw(), override, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLUGIN); // Paper - PlayerSetSpawnEvent
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 7 Jul 2021 16:30:17 -0700
|
||||
Subject: [PATCH] Make hoppers respect inventory max stack size
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index 73e505630e8a702e0c46e042c478a9c9c246856c..6907e647ef4d3f5c9c46edb4cf0905844dd1cea9 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -436,15 +436,17 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
// Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
|
||||
+ ItemStack leftover = ItemStack.EMPTY; // Paper
|
||||
if (!stack.isEmpty() && stack.getCount() > to.getMaxStackSize()) {
|
||||
+ leftover = stack; // Paper
|
||||
stack = stack.split(to.getMaxStackSize());
|
||||
}
|
||||
// Spigot end
|
||||
to.setItem(slot, stack);
|
||||
- stack = ItemStack.EMPTY;
|
||||
+ stack = leftover; // Paper
|
||||
flag = true;
|
||||
} else if (HopperBlockEntity.canMergeItems(itemstack1, stack)) {
|
||||
- int j = stack.getMaxStackSize() - itemstack1.getCount();
|
||||
+ int j = Math.min(stack.getMaxStackSize(), to.getMaxStackSize()) - itemstack1.getCount(); // Paper
|
||||
int k = Math.min(stack.getCount(), j);
|
||||
|
||||
stack.shrink(k);
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Sun, 8 Aug 2021 00:52:54 -0400
|
||||
Subject: [PATCH] Optimize entity tracker passenger checks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 3f3c7ced3a43e2b0eb451930c09188e3706a1bee..3a7a0e24e1c12ae044a455ee4f85216508e97d21 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -76,7 +76,7 @@ public class ServerEntity {
|
||||
this.trackedPlayers = trackedPlayers;
|
||||
// CraftBukkit end
|
||||
this.ap = Vec3.ZERO;
|
||||
- this.lastPassengers = Collections.emptyList();
|
||||
+ this.lastPassengers = com.google.common.collect.ImmutableList.of(); // Paper - optimize passenger checks
|
||||
this.level = worldserver;
|
||||
this.broadcast = consumer;
|
||||
this.entity = entity;
|
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Wed, 2 Dec 2020 03:07:58 -0800
|
||||
Subject: [PATCH] Config option for Piglins guarding chests
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
index 092cdb889564903102dccfe7bf2e320a1eba5efe..c8e6893a7d2be08d6b0d111aa6e58e72f3376edc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
|
||||
@@ -477,6 +477,7 @@ public class PiglinAi {
|
||||
}
|
||||
|
||||
public static void angerNearbyPiglins(Player player, boolean blockOpen) {
|
||||
+ if (!player.level().paperConfig().entities.behavior.piglinsGuardChests) return; // Paper
|
||||
List<Piglin> list = player.level().getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0D));
|
||||
|
||||
list.stream().filter(PiglinAi::isIdle).filter((entitypiglin) -> {
|
65
patches/server/0649-Added-EntityDamageItemEvent.patch
Normal file
65
patches/server/0649-Added-EntityDamageItemEvent.patch
Normal file
|
@ -0,0 +1,65 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Tue, 22 Dec 2020 13:52:48 -0800
|
||||
Subject: [PATCH] Added EntityDamageItemEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index 12c0e0096153d1c7166829d6f7417d54d364df67..99be49b179b46ed1a9c3b3784dcd91f2fcc34ca9 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -591,7 +591,7 @@ public final class ItemStack {
|
||||
return this.getItem().getMaxDamage();
|
||||
}
|
||||
|
||||
- public boolean hurt(int amount, RandomSource random, @Nullable ServerPlayer player) {
|
||||
+ public boolean hurt(int amount, RandomSource random, @Nullable LivingEntity player) { // Paper - allow any living entity instead of only ServerPlayers
|
||||
if (!this.isDamageableItem()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -609,8 +609,8 @@ public final class ItemStack {
|
||||
|
||||
amount -= k;
|
||||
// CraftBukkit start
|
||||
- if (player != null) {
|
||||
- PlayerItemDamageEvent event = new PlayerItemDamageEvent(player.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount);
|
||||
+ if (player instanceof ServerPlayer serverPlayer) { // Paper
|
||||
+ PlayerItemDamageEvent event = new PlayerItemDamageEvent(serverPlayer.getBukkitEntity(), CraftItemStack.asCraftMirror(this), amount); // Paper
|
||||
event.getPlayer().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (amount != event.getDamage() || event.isCancelled()) {
|
||||
@@ -621,6 +621,14 @@ public final class ItemStack {
|
||||
}
|
||||
|
||||
amount = event.getDamage();
|
||||
+ // Paper start - EntityDamageItemEvent
|
||||
+ } else if (player != null) {
|
||||
+ io.papermc.paper.event.entity.EntityDamageItemEvent event = new io.papermc.paper.event.entity.EntityDamageItemEvent(player.getBukkitLivingEntity(), CraftItemStack.asCraftMirror(this), amount);
|
||||
+ if (!event.callEvent()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ amount = event.getDamage();
|
||||
+ // Paper end
|
||||
}
|
||||
// CraftBukkit end
|
||||
if (amount <= 0) {
|
||||
@@ -628,8 +636,8 @@ public final class ItemStack {
|
||||
}
|
||||
}
|
||||
|
||||
- if (player != null && amount != 0) {
|
||||
- CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(player, this, this.getDamageValue() + amount);
|
||||
+ if (player instanceof ServerPlayer serverPlayer && amount != 0) { // Paper
|
||||
+ CriteriaTriggers.ITEM_DURABILITY_CHANGED.trigger(serverPlayer, this, this.getDamageValue() + amount); // Paper
|
||||
}
|
||||
|
||||
j = this.getDamageValue() + amount;
|
||||
@@ -641,7 +649,7 @@ public final class ItemStack {
|
||||
public <T extends LivingEntity> void hurtAndBreak(int amount, T entity, Consumer<T> breakCallback) {
|
||||
if (!entity.level().isClientSide && (!(entity instanceof net.minecraft.world.entity.player.Player) || !((net.minecraft.world.entity.player.Player) entity).getAbilities().instabuild)) {
|
||||
if (this.isDamageableItem()) {
|
||||
- if (this.hurt(amount, entity.getRandom(), entity instanceof ServerPlayer ? (ServerPlayer) entity : null)) {
|
||||
+ if (this.hurt(amount, entity.getRandom(), entity /*instanceof ServerPlayer ? (ServerPlayer) entity : null*/)) { // Paper - pass LivingEntity for EntityItemDamageEvent
|
||||
breakCallback.accept(entity);
|
||||
Item item = this.getItem();
|
||||
// CraftBukkit start - Check for item breaking
|
|
@ -0,0 +1,52 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Andrew Steinborn <git@steinborn.me>
|
||||
Date: Mon, 9 Aug 2021 00:38:37 -0400
|
||||
Subject: [PATCH] Optimize indirect passenger iteration
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 223af8b0b40f11496a0639f220f8e6605be8da2a..6b6fbcc69c834e2bb48ddd9dfbb18e93d536f40b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -3809,26 +3809,41 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
private Stream<Entity> getIndirectPassengersStream() {
|
||||
+ if (this.passengers.isEmpty()) { return Stream.of(); } // Paper
|
||||
return this.passengers.stream().flatMap(Entity::getSelfAndPassengers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Entity> getSelfAndPassengers() {
|
||||
+ if (this.passengers.isEmpty()) { return Stream.of(this); } // Paper
|
||||
return Stream.concat(Stream.of(this), this.getIndirectPassengersStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Entity> getPassengersAndSelf() {
|
||||
+ if (this.passengers.isEmpty()) { return Stream.of(this); } // Paper
|
||||
return Stream.concat(this.passengers.stream().flatMap(Entity::getPassengersAndSelf), Stream.of(this));
|
||||
}
|
||||
|
||||
public Iterable<Entity> getIndirectPassengers() {
|
||||
+ // Paper start - rewrite this method
|
||||
+ if (this.passengers.isEmpty()) { return ImmutableList.of(); }
|
||||
+ ImmutableList.Builder<Entity> indirectPassengers = ImmutableList.builder();
|
||||
+ for (Entity passenger : this.passengers) {
|
||||
+ indirectPassengers.add(passenger);
|
||||
+ indirectPassengers.addAll(passenger.getIndirectPassengers());
|
||||
+ }
|
||||
+ return indirectPassengers.build();
|
||||
+ }
|
||||
+ private Iterable<Entity> getIndirectPassengers_old() {
|
||||
+ // Paper end
|
||||
return () -> {
|
||||
return this.getIndirectPassengersStream().iterator();
|
||||
};
|
||||
}
|
||||
|
||||
public boolean hasExactlyOnePlayerPassenger() {
|
||||
+ if (this.passengers.isEmpty()) { return false; } // Paper
|
||||
return this.getIndirectPassengersStream().filter((entity) -> {
|
||||
return entity instanceof Player;
|
||||
}).count() == 1L;
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Warrior <50800980+Warriorrrr@users.noreply.github.com>
|
||||
Date: Fri, 13 Aug 2021 01:14:38 +0200
|
||||
Subject: [PATCH] Configurable item frame map cursor update interval
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 3a7a0e24e1c12ae044a455ee4f85216508e97d21..c41f06c82d2db758d8a91317ef21eb2f5eb76a49 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -114,7 +114,7 @@ public class ServerEntity {
|
||||
if (true || this.tickCount % 10 == 0) { // CraftBukkit - Moved below, should always enter this block
|
||||
ItemStack itemstack = entityitemframe.getItem();
|
||||
|
||||
- if (this.tickCount % 10 == 0 && itemstack.getItem() instanceof MapItem) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks
|
||||
+ if (this.level.paperConfig().maps.itemFrameCursorUpdateInterval > 0 && this.tickCount % this.level.paperConfig().maps.itemFrameCursorUpdateInterval == 0 && itemstack.getItem() instanceof MapItem) { // CraftBukkit - Moved this.tickCounter % 10 logic here so item frames do not enter the other blocks // Paper - Make item frame map cursor update interval configurable
|
||||
Integer integer = MapItem.getMapId(itemstack);
|
||||
MapItemSavedData worldmap = MapItem.getSavedData(integer, this.level);
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 3 Jan 2021 21:25:31 -0800
|
||||
Subject: [PATCH] Make EntityUnleashEvent cancellable
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 1887b9cd309556eeacac2a5e5cd922560101fa72..b6e48531a2a1316eef786e0476574eb1c3c29a9e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -1543,7 +1543,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||
if (flag1 && this.isLeashed()) {
|
||||
// Paper start - drop leash variable
|
||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.UNKNOWN, true);
|
||||
- this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ if (!event.callEvent()) { return flag1; }
|
||||
this.dropLeash(true, event.isDropLeash());
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/PathfinderMob.java b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
index a4dfe40d30a5abf5d614d0921b3b23023fdbc4b1..610bc67af915c8ff40a6c8a0d8e022e7db8614d8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/PathfinderMob.java
|
||||
@@ -51,7 +51,7 @@ public abstract class PathfinderMob extends Mob {
|
||||
if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper
|
||||
// Paper start - drop leash variable
|
||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||
- this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ if (!event.callEvent()) { return; }
|
||||
this.dropLeash(true, event.isDropLeash());
|
||||
// Paper end
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public abstract class PathfinderMob extends Mob {
|
||||
if (f > entity.level().paperConfig().misc.maxLeashDistance) { // Paper
|
||||
// Paper start - drop leash variable
|
||||
EntityUnleashEvent event = new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE, true);
|
||||
- this.level().getCraftServer().getPluginManager().callEvent(event); // CraftBukkit
|
||||
+ if (!event.callEvent()) { return; }
|
||||
this.dropLeash(true, event.isDropLeash());
|
||||
// Paper end
|
||||
this.goalSelector.disableControlFlag(Goal.Flag.MOVE);
|
20
patches/server/0653-Clear-bucket-NBT-after-dispense.patch
Normal file
20
patches/server/0653-Clear-bucket-NBT-after-dispense.patch
Normal file
|
@ -0,0 +1,20 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 13 Aug 2021 15:00:06 -0700
|
||||
Subject: [PATCH] Clear bucket NBT after dispense
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
index cec6ee5d31f2a86a61fd142035af853fa512e211..f651d866355557d10d4bb8730e0aceac483d3ba7 100644
|
||||
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
|
||||
@@ -650,8 +650,7 @@ public interface DispenseItemBehavior {
|
||||
Item item = Items.BUCKET;
|
||||
stack.shrink(1);
|
||||
if (stack.isEmpty()) {
|
||||
- stack.setItem(Items.BUCKET);
|
||||
- stack.setCount(1);
|
||||
+ stack = new ItemStack(item); // Paper - clear tag
|
||||
} else if (((DispenserBlockEntity) pointer.getEntity()).addItem(new ItemStack(item)) < 0) {
|
||||
this.defaultDispenseItemBehavior.dispense(pointer, new ItemStack(item));
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sat, 21 Aug 2021 12:13:53 -0700
|
||||
Subject: [PATCH] Change EnderEye target without changing other things
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java b/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
index ee6bbe96503e9205349e9a5c411dc60dd952ec9e..e48706e2fefc39fcce3c65f629153fdcd677044c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
@@ -70,6 +70,11 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
|
||||
}
|
||||
|
||||
public void signalTo(BlockPos pos) {
|
||||
+ // Paper start
|
||||
+ this.signalTo(pos, true);
|
||||
+ }
|
||||
+ public void signalTo(BlockPos pos, boolean update) {
|
||||
+ // Paper end
|
||||
double d0 = (double) pos.getX();
|
||||
int i = pos.getY();
|
||||
double d1 = (double) pos.getZ();
|
||||
@@ -87,8 +92,10 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
|
||||
this.tz = d1;
|
||||
}
|
||||
|
||||
+ if (update) { // Paper
|
||||
this.life = 0;
|
||||
this.surviveAfterDeath = this.random.nextInt(5) > 0;
|
||||
+ } // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
|
||||
index e45c1bfb1b8e0cd8f7b9ab5b655d33dd4da1b151..e3688e941d9b63b5319faf9370b8f75e0e5828ae 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderSignal.java
|
||||
@@ -38,8 +38,15 @@ public class CraftEnderSignal extends CraftEntity implements EnderSignal {
|
||||
|
||||
@Override
|
||||
public void setTargetLocation(Location location) {
|
||||
+ // Paper start
|
||||
+ this.setTargetLocation(location, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setTargetLocation(Location location, boolean update) {
|
||||
+ // Paper end
|
||||
Preconditions.checkArgument(getWorld().equals(location.getWorld()), "Cannot target EnderSignal across worlds");
|
||||
- this.getHandle().signalTo(CraftLocation.toBlockPosition(location));
|
||||
+ this.getHandle().signalTo(CraftLocation.toBlockPosition(location), update); // Paper
|
||||
}
|
||||
|
||||
@Override
|
86
patches/server/0655-Add-BlockBreakBlockEvent.patch
Normal file
86
patches/server/0655-Add-BlockBreakBlockEvent.patch
Normal file
|
@ -0,0 +1,86 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 3 Jan 2021 17:58:11 -0800
|
||||
Subject: [PATCH] Add BlockBreakBlockEvent
|
||||
|
||||
|
||||
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 36b196c8834c4eb873bfca0b12f1fc2b421ea071..9522e646529f3d849471931b4b3c0d133e7fcfc5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
@@ -319,6 +319,23 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
}
|
||||
|
||||
}
|
||||
+ // Paper start
|
||||
+ public static boolean dropResources(BlockState state, LevelAccessor world, BlockPos pos, @Nullable BlockEntity blockEntity, BlockPos source) {
|
||||
+ if (world instanceof ServerLevel) {
|
||||
+ List<org.bukkit.inventory.ItemStack> items = com.google.common.collect.Lists.newArrayList();
|
||||
+ for (net.minecraft.world.item.ItemStack drop : net.minecraft.world.level.block.Block.getDrops(state, world.getMinecraftWorld(), pos, blockEntity)) {
|
||||
+ items.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(drop));
|
||||
+ }
|
||||
+ io.papermc.paper.event.block.BlockBreakBlockEvent event = new io.papermc.paper.event.block.BlockBreakBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.block.CraftBlock.at(world, source), items);
|
||||
+ event.callEvent();
|
||||
+ for (var drop : event.getDrops()) {
|
||||
+ popResource(world.getMinecraftWorld(), pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop));
|
||||
+ }
|
||||
+ state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY, true);
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) {
|
||||
if (world instanceof ServerLevel) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
index 9abae63e06c1dde9b8434d32bac8798808428d10..9b3d253c4224410719bf778a4688fce13c12069d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
@@ -401,7 +401,7 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
iblockdata1 = world.getBlockState(blockposition3);
|
||||
BlockEntity tileentity = iblockdata1.hasBlockEntity() ? world.getBlockEntity(blockposition3) : null;
|
||||
|
||||
- dropResources(iblockdata1, world, blockposition3, tileentity);
|
||||
+ dropResources(iblockdata1, world, blockposition3, tileentity, pos); // Paper
|
||||
world.setBlock(blockposition3, Blocks.AIR.defaultBlockState(), 18);
|
||||
world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition3, GameEvent.Context.of(iblockdata1));
|
||||
if (!iblockdata1.is(BlockTags.FIRE)) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
index fbf699e777d45db3dcf1606d34f509ca1a5bbb7a..37fcbca0c56b7707a0c9f5d3ae874aff7268f6fc 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
@@ -292,7 +292,7 @@ public abstract class FlowingFluid extends Fluid {
|
||||
((LiquidBlockContainer) state.getBlock()).placeLiquid(world, pos, state, fluidState);
|
||||
} else {
|
||||
if (!state.isAir()) {
|
||||
- this.beforeDestroyingBlock(world, pos, state);
|
||||
+ this.beforeDestroyingBlock(world, pos, state, pos.relative(direction.getOpposite())); // Paper
|
||||
}
|
||||
|
||||
world.setBlock(pos, fluidState.createLegacyBlock(), 3);
|
||||
@@ -300,6 +300,7 @@ public abstract class FlowingFluid extends Fluid {
|
||||
|
||||
}
|
||||
|
||||
+ protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state, BlockPos source) { beforeDestroyingBlock(world, pos, state); } // Paper - add source parameter
|
||||
protected abstract void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state);
|
||||
|
||||
private static short getCacheKey(BlockPos from, BlockPos to) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
index 1897c0012800d5ba9d2fc386f3e2bf57c9d878bb..82e85fbbd45244d02df90fa00c9046e7f51275a2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
@@ -64,6 +64,13 @@ public abstract class WaterFluid extends FlowingFluid {
|
||||
return world.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state, BlockPos source) {
|
||||
+ BlockEntity tileentity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
||||
+ Block.dropResources(state, world, pos, tileentity, source);
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
|
@ -0,0 +1,147 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 26 Sep 2021 12:57:28 -0700
|
||||
Subject: [PATCH] Option to prevent NBT copy in smithing recipes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
index 2b3718f9fc68c286e8abdde4a960e19b97302531..7819a914bbbe4f0e2a4407e4c99b14732d4d89c5 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
@@ -25,8 +25,15 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
||||
final Ingredient base;
|
||||
final Ingredient addition;
|
||||
final ItemStack result;
|
||||
+ final boolean copyNBT; // Paper
|
||||
|
||||
public SmithingTransformRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition, ItemStack result) {
|
||||
+ // Paper start
|
||||
+ this(id, template, base, addition, result, true);
|
||||
+ }
|
||||
+ public SmithingTransformRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition, ItemStack result, boolean copyNBT) {
|
||||
+ this.copyNBT = copyNBT;
|
||||
+ // Paper end
|
||||
this.id = id;
|
||||
this.template = template;
|
||||
this.base = base;
|
||||
@@ -42,11 +49,13 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
||||
@Override
|
||||
public ItemStack assemble(Container inventory, RegistryAccess registryManager) {
|
||||
ItemStack itemstack = this.result.copy();
|
||||
+ if (this.copyNBT) { // Paper - copy nbt conditionally
|
||||
CompoundTag nbttagcompound = inventory.getItem(1).getTag();
|
||||
|
||||
if (nbttagcompound != null) {
|
||||
itemstack.setTag(nbttagcompound.copy());
|
||||
}
|
||||
+ } // Paper
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
@@ -91,7 +100,7 @@ public class SmithingTransformRecipe implements SmithingRecipe {
|
||||
public Recipe toBukkitRecipe() {
|
||||
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
|
||||
- CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
|
||||
+ CraftSmithingTransformRecipe recipe = new CraftSmithingTransformRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNBT); // Paper
|
||||
|
||||
return recipe;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
index c28b0d7a97e8463f7fe15bbf0f3485f2559efd4a..5b0cee067b5c69d2d4c51b8c8d2489744b843043 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
@@ -31,8 +31,15 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
||||
final Ingredient template;
|
||||
final Ingredient base;
|
||||
final Ingredient addition;
|
||||
+ final boolean copyNbt; // Paper
|
||||
|
||||
public SmithingTrimRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition) {
|
||||
+ // Paper start
|
||||
+ this(id, template, base, addition, true);
|
||||
+ }
|
||||
+ public SmithingTrimRecipe(ResourceLocation id, Ingredient template, Ingredient base, Ingredient addition, boolean copyNbt) {
|
||||
+ this.copyNbt = copyNbt;
|
||||
+ // Paper end
|
||||
this.id = id;
|
||||
this.template = template;
|
||||
this.base = base;
|
||||
@@ -59,7 +66,7 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
- ItemStack itemstack1 = itemstack.copy();
|
||||
+ ItemStack itemstack1 = this.copyNbt ? itemstack.copy() : new ItemStack(itemstack.getItem(), itemstack.getCount()); // Paper
|
||||
|
||||
itemstack1.setCount(1);
|
||||
ArmorTrim armortrim = new ArmorTrim((Holder) optional.get(), (Holder) optional1.get());
|
||||
@@ -124,7 +131,7 @@ public class SmithingTrimRecipe implements SmithingRecipe {
|
||||
// CraftBukkit start
|
||||
@Override
|
||||
public Recipe toBukkitRecipe() {
|
||||
- return new CraftSmithingTrimRecipe(CraftNamespacedKey.fromMinecraft(this.id), CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
|
||||
+ return new CraftSmithingTrimRecipe(CraftNamespacedKey.fromMinecraft(this.id), CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNbt); // Paper
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
|
||||
index 872baa62d5c893141af88727f5f93911cebf8cdc..248d742b173d7b5fae655e656cd87146e2a483c1 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTransformRecipe.java
|
||||
@@ -11,12 +11,17 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem
|
||||
public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition) {
|
||||
super(key, result, template, base, addition);
|
||||
}
|
||||
+ // Paper start
|
||||
+ public CraftSmithingTransformRecipe(NamespacedKey key, ItemStack result, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) {
|
||||
+ super(key, result, template, base, addition, copyNbt);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static CraftSmithingTransformRecipe fromBukkitRecipe(SmithingTransformRecipe recipe) {
|
||||
if (recipe instanceof CraftSmithingTransformRecipe) {
|
||||
return (CraftSmithingTransformRecipe) recipe;
|
||||
}
|
||||
- CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition());
|
||||
+ CraftSmithingTransformRecipe ret = new CraftSmithingTransformRecipe(recipe.getKey(), recipe.getResult(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyNbt()); // Paper
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -24,6 +29,6 @@ public class CraftSmithingTransformRecipe extends SmithingTransformRecipe implem
|
||||
public void addToCraftingManager() {
|
||||
ItemStack result = this.getResult();
|
||||
|
||||
- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTransformRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)));
|
||||
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTransformRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyNbt())); // Paper
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
|
||||
index 6ef43f58d8fb6bbe9e2a58fc0bb62fb0c935d7f9..610e6fa88e5d835027ba19d1bd3ff31cc42d2687 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingTrimRecipe.java
|
||||
@@ -11,17 +11,22 @@ public class CraftSmithingTrimRecipe extends SmithingTrimRecipe implements Craft
|
||||
public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition) {
|
||||
super(key, template, base, addition);
|
||||
}
|
||||
+ // Paper start
|
||||
+ public CraftSmithingTrimRecipe(NamespacedKey key, RecipeChoice template, RecipeChoice base, RecipeChoice addition, boolean copyNbt) {
|
||||
+ super(key, template, base, addition, copyNbt);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static CraftSmithingTrimRecipe fromBukkitRecipe(SmithingTrimRecipe recipe) {
|
||||
if (recipe instanceof CraftSmithingTrimRecipe) {
|
||||
return (CraftSmithingTrimRecipe) recipe;
|
||||
}
|
||||
- CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition());
|
||||
+ CraftSmithingTrimRecipe ret = new CraftSmithingTrimRecipe(recipe.getKey(), recipe.getTemplate(), recipe.getBase(), recipe.getAddition(), recipe.willCopyNbt()); // Paper
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToCraftingManager() {
|
||||
- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTrimRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true)));
|
||||
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.SmithingTrimRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getTemplate(), true), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), this.willCopyNbt())); // Paper
|
||||
}
|
||||
}
|
100
patches/server/0657-More-CommandBlock-API.patch
Normal file
100
patches/server/0657-More-CommandBlock-API.patch
Normal file
|
@ -0,0 +1,100 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 23 Sep 2021 10:40:09 -0700
|
||||
Subject: [PATCH] More CommandBlock API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0b42306f17bf8850a13a51067c2d19e7583187e5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
|
||||
@@ -0,0 +1,33 @@
|
||||
+package io.papermc.paper.commands;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import io.papermc.paper.command.CommandBlockHolder;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.minecraft.world.level.BaseCommandBlock;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public interface PaperCommandBlockHolder extends CommandBlockHolder {
|
||||
+
|
||||
+ BaseCommandBlock getCommandBlockHandle();
|
||||
+
|
||||
+ @Override
|
||||
+ default @NotNull Component lastOutput() {
|
||||
+ return PaperAdventure.asAdventure(getCommandBlockHandle().getLastOutput());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default void lastOutput(@Nullable Component lastOutput) {
|
||||
+ getCommandBlockHandle().setLastOutput(PaperAdventure.asVanilla(lastOutput));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default int getSuccessCount() {
|
||||
+ return getCommandBlockHandle().getSuccessCount();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default void setSuccessCount(int successCount) {
|
||||
+ getCommandBlockHandle().setSuccessCount(successCount);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
index c4ea6760f489e6171f9e6e170160b932597f842f..245a9b062a0033a39fd42f3ff94350192570aec4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
-public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock {
|
||||
+public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock, io.papermc.paper.commands.PaperCommandBlockHolder {
|
||||
|
||||
public CraftCommandBlock(World world, CommandBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
@@ -41,5 +41,10 @@ public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity>
|
||||
public void name(net.kyori.adventure.text.Component name) {
|
||||
getSnapshot().getCommandBlock().setName(name == null ? net.minecraft.network.chat.Component.literal("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name));
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
|
||||
+ return getSnapshot().getCommandBlock();
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
index f9863e138994f6c7a7975a852f106faa96d52315..b709a1d909c189f60d0c3aa97b4b96623e7c1db0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
@@ -14,7 +14,7 @@ import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
-public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart {
|
||||
+public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart, io.papermc.paper.commands.PaperCommandBlockHolder {
|
||||
private final PermissibleBase perm = new PermissibleBase(this);
|
||||
|
||||
public CraftMinecartCommand(CraftServer server, MinecartCommandBlock entity) {
|
||||
@@ -70,6 +70,17 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca
|
||||
public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component name() {
|
||||
return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getHandle().getCommandBlock().getName());
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
|
||||
+ return getHandle().getCommandBlock();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lastOutput(net.kyori.adventure.text.Component lastOutput) {
|
||||
+ io.papermc.paper.commands.PaperCommandBlockHolder.super.lastOutput(lastOutput);
|
||||
+ getCommandBlockHandle().onUpdated();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
106
patches/server/0658-Add-missing-team-sidebar-display-slots.patch
Normal file
106
patches/server/0658-Add-missing-team-sidebar-display-slots.patch
Normal file
|
@ -0,0 +1,106 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 1 Oct 2021 08:04:39 -0700
|
||||
Subject: [PATCH] Add missing team sidebar display slots
|
||||
|
||||
== AT ==
|
||||
public org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations
|
||||
public org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations toBukkitSlot(I)Lorg/bukkit/scoreboard/DisplaySlot;
|
||||
public org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations fromBukkitSlot(Lorg/bukkit/scoreboard/DisplaySlot;)I
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
|
||||
index e2d3fe9af7d3bd82bee519b20e141cd58f68bbd6..944a4fee237730c0d89567aaa6ddf268467aa0e0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
|
||||
@@ -7,36 +7,23 @@ import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.RenderType;
|
||||
|
||||
public final class CraftScoreboardTranslations {
|
||||
- static final int MAX_DISPLAY_SLOT = 19;
|
||||
+ static final int MAX_DISPLAY_SLOT = Scoreboard.getDisplaySlotNames().length; // Paper
|
||||
+ @Deprecated // Paper
|
||||
static final ImmutableBiMap<DisplaySlot, String> SLOTS = ImmutableBiMap.<DisplaySlot, String>builder()
|
||||
.put(DisplaySlot.BELOW_NAME, "belowName")
|
||||
.put(DisplaySlot.PLAYER_LIST, "list")
|
||||
.put(DisplaySlot.SIDEBAR, "sidebar")
|
||||
- .put(DisplaySlot.SIDEBAR_BLACK, "sidebar.team.black")
|
||||
- .put(DisplaySlot.SIDEBAR_DARK_BLUE, "sidebar.team.dark_blue")
|
||||
- .put(DisplaySlot.SIDEBAR_DARK_GREEN, "sidebar.team.dark_green")
|
||||
- .put(DisplaySlot.SIDEBAR_DARK_AQUA, "sidebar.team.dark_aqua")
|
||||
- .put(DisplaySlot.SIDEBAR_DARK_RED, "sidebar.team.dark_red")
|
||||
- .put(DisplaySlot.SIDEBAR_DARK_PURPLE, "sidebar.team.dark_purple")
|
||||
- .put(DisplaySlot.SIDEBAR_GOLD, "sidebar.team.gold")
|
||||
- .put(DisplaySlot.SIDEBAR_GRAY, "sidebar.team.gray")
|
||||
- .put(DisplaySlot.SIDEBAR_DARK_GRAY, "sidebar.team.dark_gray")
|
||||
- .put(DisplaySlot.SIDEBAR_BLUE, "sidebar.team.blue")
|
||||
- .put(DisplaySlot.SIDEBAR_GREEN, "sidebar.team.green")
|
||||
- .put(DisplaySlot.SIDEBAR_AQUA, "sidebar.team.aqua")
|
||||
- .put(DisplaySlot.SIDEBAR_RED, "sidebar.team.red")
|
||||
- .put(DisplaySlot.SIDEBAR_LIGHT_PURPLE, "sidebar.team.light_purple")
|
||||
- .put(DisplaySlot.SIDEBAR_YELLOW, "sidebar.team.yellow")
|
||||
- .put(DisplaySlot.SIDEBAR_WHITE, "sidebar.team.white")
|
||||
.buildOrThrow();
|
||||
|
||||
private CraftScoreboardTranslations() {}
|
||||
|
||||
public static DisplaySlot toBukkitSlot(int i) {
|
||||
+ if (true) return org.bukkit.scoreboard.DisplaySlot.NAMES.value(Scoreboard.getDisplaySlotName(i)); // Paper
|
||||
return CraftScoreboardTranslations.SLOTS.inverse().get(Scoreboard.getDisplaySlotName(i));
|
||||
}
|
||||
|
||||
public static int fromBukkitSlot(DisplaySlot slot) {
|
||||
+ if (true) return Scoreboard.getDisplaySlotByName(slot.getId()); // Paper
|
||||
return Scoreboard.getDisplaySlotByName(CraftScoreboardTranslations.SLOTS.get(slot));
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
||||
index fe5d3b60ad740b7f1cce040f9c8d96ac51245ef6..43ffc4180b1ef2d2000991ad58b0706141470d08 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
|
||||
@@ -251,6 +251,14 @@ public class Commodore
|
||||
desc = getOriginalOrRewrite( desc );
|
||||
}
|
||||
// Paper end
|
||||
+ // Paper start - DisplaySlot
|
||||
+ if (owner.equals("org/bukkit/scoreboard/DisplaySlot")) {
|
||||
+ if (name.startsWith("SIDEBAR_") && !name.startsWith("SIDEBAR_TEAM_")) {
|
||||
+ super.visitFieldInsn(opcode, owner, name.replace("SIDEBAR_", "SIDEBAR_TEAM_"), desc);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - DisplaySlot
|
||||
|
||||
if ( owner.equals( "org/bukkit/block/Biome" ) )
|
||||
{
|
||||
diff --git a/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..bb41a2f2c0a5e3b4cb3fe1b584e0ceb7a7116afb
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java
|
||||
@@ -0,0 +1,26 @@
|
||||
+package io.papermc.paper.scoreboard;
|
||||
+
|
||||
+import net.minecraft.world.scores.Scoreboard;
|
||||
+import org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations;
|
||||
+import org.bukkit.scoreboard.DisplaySlot;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+import static org.junit.Assert.assertNotEquals;
|
||||
+import static org.junit.Assert.assertNotNull;
|
||||
+
|
||||
+public class DisplaySlotTest {
|
||||
+
|
||||
+ @Test
|
||||
+ public void testBukkitToMinecraftDisplaySlots() {
|
||||
+ for (DisplaySlot value : DisplaySlot.values()) {
|
||||
+ assertNotEquals(-1, CraftScoreboardTranslations.fromBukkitSlot(value));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testMinecraftToBukkitDisplaySlots() {
|
||||
+ for (String name : Scoreboard.getDisplaySlotNames()) {
|
||||
+ assertNotNull(CraftScoreboardTranslations.toBukkitSlot(Scoreboard.getDisplaySlotByName(name)));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
45
patches/server/0659-Add-back-EntityPortalExitEvent.patch
Normal file
45
patches/server/0659-Add-back-EntityPortalExitEvent.patch
Normal file
|
@ -0,0 +1,45 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 16 May 2021 09:39:46 -0700
|
||||
Subject: [PATCH] Add back EntityPortalExitEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 6b6fbcc69c834e2bb48ddd9dfbb18e93d536f40b..cd57b071a7cfd6ace4457dddc82367735e64e952 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -3256,6 +3256,23 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
} else {
|
||||
// CraftBukkit start
|
||||
worldserver = shapedetectorshape.world;
|
||||
+ // Paper start - Call EntityPortalExitEvent
|
||||
+ CraftEntity bukkitEntity = this.getBukkitEntity();
|
||||
+ Vec3 position = shapedetectorshape.pos;
|
||||
+ float yaw = shapedetectorshape.yRot;
|
||||
+ float pitch = bukkitEntity.getLocation().getPitch(); // Keep entity pitch as per moveTo line below
|
||||
+ Vec3 velocity = shapedetectorshape.speed;
|
||||
+ org.bukkit.event.entity.EntityPortalExitEvent event = new org.bukkit.event.entity.EntityPortalExitEvent(bukkitEntity,
|
||||
+ bukkitEntity.getLocation(), new Location(worldserver.getWorld(), position.x, position.y, position.z, yaw, pitch),
|
||||
+ bukkitEntity.getVelocity(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(shapedetectorshape.speed));
|
||||
+ if (event.callEvent() && event.getTo() != null && this.isAlive()) {
|
||||
+ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
|
||||
+ position = new Vec3(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||
+ yaw = event.getTo().getYaw();
|
||||
+ pitch = event.getTo().getPitch();
|
||||
+ velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter());
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (worldserver == this.level) {
|
||||
// SPIGOT-6782: Just move the entity if a plugin changed the world to the one the entity is already in
|
||||
this.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, shapedetectorshape.xRot);
|
||||
@@ -3275,8 +3292,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
|
||||
if (entity != null) {
|
||||
entity.restoreFrom(this);
|
||||
- entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
|
||||
- entity.setDeltaMovement(shapedetectorshape.speed);
|
||||
+ entity.moveTo(position.x, position.y, position.z, yaw, pitch); // Paper - use EntityPortalExitEvent values
|
||||
+ entity.setDeltaMovement(velocity); // Paper - use EntityPortalExitEvent values
|
||||
worldserver.addDuringTeleport(entity);
|
||||
if (worldserver.getTypeKey() == LevelStem.END) { // CraftBukkit
|
||||
ServerLevel.makeObsidianPlatform(worldserver, this); // CraftBukkit
|
|
@ -0,0 +1,60 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jakub Zacek <dawon@dawon.eu>
|
||||
Date: Mon, 4 Oct 2021 10:16:44 +0200
|
||||
Subject: [PATCH] Add methods to find targets for lightning strikes
|
||||
|
||||
== AT ==
|
||||
public net.minecraft.server.level.ServerLevel findLightningRod(Lnet/minecraft/core/BlockPos;)Ljava/util/Optional;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index fa58ec5466edd5ce6a1887b73f628fb6c7272d88..ebce1f6331ab31b7dea1d4f46ff278c4907cdbea 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -744,6 +744,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
|
||||
protected BlockPos findLightningTargetAround(BlockPos pos) {
|
||||
+ // Paper start
|
||||
+ return this.findLightningTargetAround(pos, false);
|
||||
+ }
|
||||
+ public BlockPos findLightningTargetAround(BlockPos pos, boolean returnNullWhenNoTarget) {
|
||||
+ // Paper end
|
||||
BlockPos blockposition1 = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
|
||||
Optional<BlockPos> optional = this.findLightningRod(blockposition1);
|
||||
|
||||
@@ -758,6 +763,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
if (!list.isEmpty()) {
|
||||
return ((LivingEntity) list.get(this.random.nextInt(list.size()))).blockPosition();
|
||||
} else {
|
||||
+ if (returnNullWhenNoTarget) return null; // Paper
|
||||
if (blockposition1.getY() == this.getMinBuildHeight() - 1) {
|
||||
blockposition1 = blockposition1.above(2);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index 26468a3788c157241ded0ef7c4c704f801ef53a0..fe27f31adb000ed5de86432dc4347cd19964e6f3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -698,6 +698,23 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
return (LightningStrike) lightning.getBukkitEntity();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public Location findLightningRod(Location location) {
|
||||
+ return this.world.findLightningRod(io.papermc.paper.util.MCUtil.toBlockPosition(location))
|
||||
+ .map(blockPos -> io.papermc.paper.util.MCUtil.toLocation(this.world, blockPos)
|
||||
+ // get the actual rod pos
|
||||
+ .subtract(0, 1, 0))
|
||||
+ .orElse(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location findLightningTarget(Location location) {
|
||||
+ final BlockPos pos = this.world.findLightningTargetAround(io.papermc.paper.util.MCUtil.toBlockPosition(location), true);
|
||||
+ return pos == null ? null : io.papermc.paper.util.MCUtil.toLocation(this.world, pos);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean generateTree(Location loc, TreeType type) {
|
||||
return generateTree(loc, CraftWorld.rand, type);
|
Loading…
Add table
Add a link
Reference in a new issue