even even even even more work

This commit is contained in:
Spottedleaf 2021-06-12 21:03:02 -07:00
parent 6690975133
commit 09721118a4
16 changed files with 223 additions and 397 deletions

View File

@ -1,99 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Mon, 3 Sep 2018 18:20:03 -0500
Subject: [PATCH] Add ray tracing methods to LivingEntity
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
this.broadcastBreakEvent(hand == InteractionHand.MAIN_HAND ? EquipmentSlot.MAINHAND : EquipmentSlot.OFFHAND);
}
// Paper start
+ public HitResult getRayTrace(int maxDistance) {
+ return getRayTrace(maxDistance, ClipContext.Fluid.NONE);
+ }
+
+ public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) {
+ if (maxDistance < 1 || maxDistance > 120) {
+ throw new IllegalArgumentException("maxDistance must be between 1-120");
+ }
+
+ Vec3 start = new Vec3(getX(), getY() + getEyeHeight(), getZ());
+ org.bukkit.util.Vector dir = getBukkitEntity().getLocation().getDirection().multiply(maxDistance);
+ Vec3 end = new Vec3(start.x + dir.getX(), start.y + dir.getY(), start.z + dir.getZ());
+ ClipContext raytrace = new ClipContext(start, end, ClipContext.Block.OUTLINE, fluidCollisionOption, this);
+
+ return level.clip(raytrace);
+ }
+
public int shieldBlockingDelay = level.paperConfig.shieldBlockingDelay;
public int getShieldBlockingDelay() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -0,0 +0,0 @@
package org.bukkit.craftbukkit.entity;
+import com.destroystokyo.paper.block.TargetBlockInfo;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import java.util.ArrayList;
@@ -0,0 +0,0 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.UUID;
+import net.minecraft.server.MCUtil;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.damagesource.DamageSource;
@@ -0,0 +0,0 @@ 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.phys.BlockHitResult;
+import net.minecraft.world.phys.HitResult;
import org.apache.commons.lang.Validate;
import org.bukkit.FluidCollisionMode;
import org.bukkit.Location;
@@ -0,0 +0,0 @@ import org.bukkit.attribute.AttributeInstance;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.memory.CraftMemoryKey;
import org.bukkit.craftbukkit.entity.memory.CraftMemoryMapper;
import org.bukkit.craftbukkit.inventory.CraftEntityEquipment;
@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return blocks.get(0);
}
+ // Paper start
+ @Override
+ public Block getTargetBlock(int maxDistance, TargetBlockInfo.FluidMode fluidMode) {
+ HitResult rayTrace = getHandle().getRayTrace(maxDistance, MCUtil.getNMSFluidCollisionOption(fluidMode));
+ return !(rayTrace instanceof BlockHitResult) ? null : CraftBlock.at(getHandle().level, ((BlockHitResult)rayTrace).getBlockPos());
+ }
+
+ @Override
+ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, TargetBlockInfo.FluidMode fluidMode) {
+ HitResult rayTrace = getHandle().getRayTrace(maxDistance, MCUtil.getNMSFluidCollisionOption(fluidMode));
+ return !(rayTrace instanceof BlockHitResult) ? null : MCUtil.toBukkitBlockFace(((BlockHitResult)rayTrace).getDirection());
+ }
+
+ @Override
+ public TargetBlockInfo getTargetBlockInfo(int maxDistance, TargetBlockInfo.FluidMode fluidMode) {
+ HitResult rayTrace = getHandle().getRayTrace(maxDistance, MCUtil.getNMSFluidCollisionOption(fluidMode));
+ return !(rayTrace instanceof BlockHitResult) ? null :
+ new TargetBlockInfo(CraftBlock.at(getHandle().level, ((BlockHitResult)rayTrace).getBlockPos()),
+ MCUtil.toBukkitBlockFace(((BlockHitResult)rayTrace).getDirection()));
+ }
+ // Paper end
+
@Override
public List<Block> getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) {
return getLineOfSight(transparent, maxDistance, 2);

View File

@ -1,83 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 10 Sep 2018 23:56:36 -0400
Subject: [PATCH] Prevent Mob AI Rules from Loading Chunks
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
private final Block blockToRemove;
private final Mob removerMob;
private int ticksSinceReachedGoal;
+ private Level world; // Paper
public RemoveBlockGoal(Block targetBlock, PathfinderMob mob, double speed, int maxYDifference) {
super(mob, speed, 24, maxYDifference);
this.blockToRemove = targetBlock;
this.removerMob = mob;
+ this.world = mob.level; // Paper
}
@Override
@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
@Nullable
private BlockPos getPosWithBlock(BlockPos pos, BlockGetter world) {
- if (world.getBlockState(pos).is(this.blockToRemove)) {
+ Block block = world.getBlockIfLoaded(pos); // Paper
+ if (block == null) return null; // Paper
+ if (block.is(this.blockToRemove)) { // Paper
return pos;
} else {
BlockPos[] ablockposition = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()};
@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
for (int j = 0; j < i; ++j) {
BlockPos blockposition1 = ablockposition1[j];
- if (world.getBlockState(blockposition1).is(this.blockToRemove)) {
+ if (world.getBlockIfLoaded(blockposition1).is(this.blockToRemove)) { // Paper
return blockposition1;
}
}
@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
@Override
protected boolean isValidTarget(LevelReader world, BlockPos pos) {
- ChunkAccess ichunkaccess = world.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.FULL, false);
+ ChunkAccess ichunkaccess = world.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); // Paper
return ichunkaccess == null ? false : ichunkaccess.getBlockState(pos).is(this.blockToRemove) && ichunkaccess.getBlockState(pos.above()).isAir() && ichunkaccess.getBlockState(pos.above(2)).isAir();
}
diff --git a/src/main/java/net/minecraft/world/entity/ai/util/RandomPos.java b/src/main/java/net/minecraft/world/entity/ai/util/RandomPos.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/util/RandomPos.java
+++ b/src/main/java/net/minecraft/world/entity/ai/util/RandomPos.java
@@ -0,0 +0,0 @@ import net.minecraft.util.Mth;
import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.ai.navigation.PathNavigation;
import net.minecraft.world.level.BlockGetter;
+import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.level.pathfinder.WalkNodeEvaluator;
import net.minecraft.world.phys.Vec3;
@@ -0,0 +0,0 @@ public class RandomPos {
}
blockposition2 = new BlockPos((double) k1 + mob.getX(), (double) l1 + mob.getY(), (double) i2 + mob.getZ());
+ if (!mob.level.hasChunkAt(blockposition2)) continue; // Paper
if (blockposition2.getY() >= 0 && blockposition2.getY() <= mob.level.getMaxBuildHeight() && (!flag3 || mob.isWithinRestriction(blockposition2)) && (!validPositionsOnly || navigationabstract.isStableDestination(blockposition2))) {
if (aboveGround) {
blockposition2 = moveUpToAboveSolid(blockposition2, random.nextInt(distanceAboveGroundRange + 1) + minDistanceAboveGround, mob.level.getMaxBuildHeight(), (blockposition3) -> {
@@ -0,0 +0,0 @@ public class RandomPos {
});
}
- if (notInWater || !mob.level.getFluidState(blockposition2).is((Tag) FluidTags.WATER)) {
+ FluidState fluid = mob.level.getFluidIfLoaded(blockposition2); // Paper
+ if (notInWater || (fluid != null && !fluid.is((Tag) FluidTags.WATER))) { // Paper
BlockPathTypes pathtype = WalkNodeEvaluator.getBlockPathTypeStatic((BlockGetter) mob.level, blockposition2.mutable());
if (mob.getPathfindingMalus(pathtype) == 0.0F) {

View File

@ -0,0 +1,90 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Mon, 3 Sep 2018 18:20:03 -0500
Subject: [PATCH] Add ray tracing methods to LivingEntity
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/MCUtil.java
+++ b/src/main/java/net/minecraft/server/MCUtil.java
@@ -0,0 +0,0 @@ public final class MCUtil {
return getNMSWorld(entity.getWorld());
}
+ public static ClipContext.Fluid getNMSFluidCollisionOption(com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
+ switch (fluidMode) {
+ case NEVER:
+ return ClipContext.Fluid.NONE;
+ case SOURCE_ONLY:
+ return ClipContext.Fluid.SOURCE_ONLY;
+ case ALWAYS:
+ return ClipContext.Fluid.ANY;
+ }
+ return null;
+ }
+
public static BlockFace toBukkitBlockFace(Direction enumDirection) {
switch (enumDirection) {
case DOWN:
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
}
// Paper start
+ public HitResult getRayTrace(int maxDistance) {
+ return getRayTrace(maxDistance, ClipContext.Fluid.NONE);
+ }
+
+ public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) {
+ if (maxDistance < 1 || maxDistance > 120) {
+ throw new IllegalArgumentException("maxDistance must be between 1-120");
+ }
+
+ Vec3 start = new Vec3(getX(), getY() + getEyeHeight(), getZ());
+ org.bukkit.util.Vector dir = getBukkitEntity().getLocation().getDirection().multiply(maxDistance);
+ Vec3 end = new Vec3(start.x + dir.getX(), start.y + dir.getY(), start.z + dir.getZ());
+ ClipContext raytrace = new ClipContext(start, end, ClipContext.Block.OUTLINE, fluidCollisionOption, this);
+
+ return level.clip(raytrace);
+ }
+
public int shieldBlockingDelay = level.paperConfig.shieldBlockingDelay;
public int getShieldBlockingDelay() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
return blocks.get(0);
}
+ // Paper start
+ @Override
+ public Block getTargetBlock(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
+ net.minecraft.world.phys.HitResult rayTrace = getHandle().getRayTrace(maxDistance, net.minecraft.server.MCUtil.getNMSFluidCollisionOption(fluidMode));
+ return !(rayTrace instanceof net.minecraft.world.phys.BlockHitResult) ? null : org.bukkit.craftbukkit.block.CraftBlock.at(getHandle().level, ((net.minecraft.world.phys.BlockHitResult)rayTrace).getBlockPos());
+ }
+
+ @Override
+ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
+ net.minecraft.world.phys.HitResult rayTrace = getHandle().getRayTrace(maxDistance, net.minecraft.server.MCUtil.getNMSFluidCollisionOption(fluidMode));
+ return !(rayTrace instanceof net.minecraft.world.phys.BlockHitResult) ? null : net.minecraft.server.MCUtil.toBukkitBlockFace(((net.minecraft.world.phys.BlockHitResult)rayTrace).getDirection());
+ }
+
+ @Override
+ public com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
+ net.minecraft.world.phys.HitResult rayTrace = getHandle().getRayTrace(maxDistance, net.minecraft.server.MCUtil.getNMSFluidCollisionOption(fluidMode));
+ return !(rayTrace instanceof net.minecraft.world.phys.BlockHitResult) ? null :
+ new com.destroystokyo.paper.block.TargetBlockInfo(org.bukkit.craftbukkit.block.CraftBlock.at(getHandle().level, ((net.minecraft.world.phys.BlockHitResult)rayTrace).getBlockPos()),
+ net.minecraft.server.MCUtil.toBukkitBlockFace(((net.minecraft.world.phys.BlockHitResult)rayTrace).getDirection()));
+ }
+ // Paper end
+
@Override
public List<Block> getLastTwoTargetBlocks(Set<Material> transparent, int maxDistance) {
return this.getLineOfSight(transparent, maxDistance, 2);

View File

@ -20,7 +20,7 @@ diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEnti
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java --- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
@@ -0,0 +0,0 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity { // Pape @@ -0,0 +0,0 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
// CraftBukkit start // CraftBukkit start
@Override @Override
public boolean onlyOpCanSetNbt() { public boolean onlyOpCanSetNbt() {

View File

@ -4,18 +4,6 @@ Date: Tue, 4 Sep 2018 15:02:00 -0500
Subject: [PATCH] Expose attack cooldown methods for Player Subject: [PATCH] Expose attack cooldown methods for Player
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
this.entityData.set(Player.DATA_SHOULDER_RIGHT, entityTag);
}
+ public float getCooldownPeriod() { return this.getCurrentItemAttackStrengthDelay(); } // Paper - OBFHELPER
public float getCurrentItemAttackStrengthDelay() {
return (float) (1.0D / this.getAttributeValue(Attributes.ATTACK_SPEED) * 20.0D);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@ -25,14 +13,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(0, slot, inventory.getSelected())); connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(0, slot, inventory.getSelected()));
} }
+ +
+ @Override
+ public float getCooldownPeriod() { + public float getCooldownPeriod() {
+ return getHandle().getCooldownPeriod(); + return getHandle().getCurrentItemAttackStrengthDelay();
+ } + }
+ +
+ @Override
+ public float getCooledAttackStrength(float adjustTicks) { + public float getCooledAttackStrength(float adjustTicks) {
+ return getHandle().getAttackStrengthScale(adjustTicks); + return getHandle().getAttackStrengthScale(adjustTicks);
+ } + }
+ +
+ @Override
+ public void resetCooldown() { + public void resetCooldown() {
+ getHandle().resetAttackStrengthTicker(); + getHandle().resetAttackStrengthTicker();
+ } + }

View File

@ -17,39 +17,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private StateDefinition<Block, BlockState> definition; private StateDefinition<Block, BlockState> definition;
private BlockState state; private BlockState state;
@Nullable @Nullable
@@ -0,0 +0,0 @@ public class BlockStateParser {
return this.nbt;
}
+ public final @Nullable ResourceLocation getTagKey() { return getTag(); } // Paper - OBFHELPER
@Nullable
public ResourceLocation getTag() {
return this.tag;
}
+ public final BlockStateParser parse(boolean parseTile) throws CommandSyntaxException { return this.parse(parseTile); } // Paper - OBFHELPER
public BlockStateParser parse(boolean allowNbt) throws CommandSyntaxException {
this.suggestions = this::suggestBlockIdOrTag;
if (this.reader.canRead() && this.reader.peek() == '#') {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -0,0 +0,0 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import net.minecraft.commands.arguments.blocks.BlockStateParser;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.TextComponent;
+import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.Validate;
@@ -0,0 +0,0 @@ import org.bukkit.persistence.PersistentDataContainer; @@ -0,0 +0,0 @@ import org.bukkit.persistence.PersistentDataContainer;
import static org.spigotmc.ValidateUtils.*; import static org.spigotmc.ValidateUtils.*;
// Spigot end // Spigot end
@ -102,7 +73,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw()); this.persistentDataContainer.putAll(meta.persistentDataContainer.getRaw());
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
persistentDataContainer.put(key, compound.get(key)); this.persistentDataContainer.put(key, compound.get(key));
} }
} }
+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values + // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values
@ -134,7 +105,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
Set<String> keys = tag.getAllKeys(); Set<String> keys = tag.getAllKeys();
for (String key : keys) { for (String key : keys) {
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
setDamage(damage); this.setDamage(damage);
} }
+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values + // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values
@ -169,7 +140,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (internal != null) { if (internal != null) {
ByteArrayInputStream buf = new ByteArrayInputStream(Base64.decodeBase64(internal)); ByteArrayInputStream buf = new ByteArrayInputStream(Base64.decodeBase64(internal));
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
if (hasDamage()) { if (this.hasDamage()) {
itemTag.putInt(DAMAGE.NBT, damage); itemTag.putInt(DAMAGE.NBT, damage);
} }
+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values + // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values
@ -190,7 +161,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end + // Paper end
for (Map.Entry<String, Tag> e : unhandledTags.entrySet()) { for (Map.Entry<String, Tag> e : this.unhandledTags.entrySet()) {
itemTag.put(e.getKey(), e.getValue()); itemTag.put(e.getKey(), e.getValue());
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
} }
@ -218,8 +189,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Overridden @Overridden
boolean isEmpty() { boolean isEmpty() {
- return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers()); - return !(this.hasDisplayName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isUnbreakable() || this.hasDamage() || this.hasAttributeModifiers());
+ return !(hasDisplayName() || hasLocalizedName() || hasEnchants() || (lore != null) || hasCustomModelData() || hasBlockData() || hasRepairCost() || !unhandledTags.isEmpty() || !persistentDataContainer.isEmpty() || hideFlag != 0 || isUnbreakable() || hasDamage() || hasAttributeModifiers() || hasPlaceableKeys() || hasDestroyableKeys()); // Paper - Implement an API for CanPlaceOn and CanDestroy NBT values + return !(this.hasDisplayName() || this.hasLocalizedName() || this.hasEnchants() || (this.lore != null) || this.hasCustomModelData() || this.hasBlockData() || this.hasRepairCost() || !this.unhandledTags.isEmpty() || !this.persistentDataContainer.isEmpty() || this.hideFlag != 0 || this.isUnbreakable() || this.hasDamage() || this.hasAttributeModifiers() || this.hasPlaceableKeys() || this.hasDestroyableKeys()); // Paper - Implement an API for CanPlaceOn and CanDestroy NBT values
} }
// Paper start // Paper start
@ -237,12 +208,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
/** /**
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
hash = 61 * hash + (hasDamage() ? this.damage : 0); hash = 61 * hash + (this.hasDamage() ? this.damage : 0);
hash = 61 * hash + (hasAttributeModifiers() ? this.attributeModifiers.hashCode() : 0); hash = 61 * hash + (this.hasAttributeModifiers() ? this.attributeModifiers.hashCode() : 0);
hash = 61 * hash + version; hash = 61 * hash + this.version;
+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values + // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values
+ hash = 61 * hash + (hasPlaceableKeys() ? this.placeableKeys.hashCode() : 0); + hash = 61 * hash + (this.hasPlaceableKeys() ? this.placeableKeys.hashCode() : 0);
+ hash = 61 * hash + (hasDestroyableKeys() ? this.destroyableKeys.hashCode() : 0); + hash = 61 * hash + (this.hasDestroyableKeys() ? this.destroyableKeys.hashCode() : 0);
+ // Paper end + // Paper end
return hash; return hash;
} }
@ -267,7 +238,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
+ // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values + // Paper start - Implement an API for CanPlaceOn and CanDestroy NBT values
+ if (hasPlaceableKeys()) { + if (this.hasPlaceableKeys()) {
+ List<String> cerealPlaceable = this.placeableKeys.stream() + List<String> cerealPlaceable = this.placeableKeys.stream()
+ .map(this::serializeNamespaced) + .map(this::serializeNamespaced)
+ .collect(java.util.stream.Collectors.toList()); + .collect(java.util.stream.Collectors.toList());
@ -275,7 +246,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ builder.put(CAN_PLACE_ON.BUKKIT, cerealPlaceable); + builder.put(CAN_PLACE_ON.BUKKIT, cerealPlaceable);
+ } + }
+ +
+ if (hasDestroyableKeys()) { + if (this.hasDestroyableKeys()) {
+ List<String> cerealDestroyable = this.destroyableKeys.stream() + List<String> cerealDestroyable = this.destroyableKeys.stream()
+ .map(this::serializeNamespaced) + .map(this::serializeNamespaced)
+ .collect(java.util.stream.Collectors.toList()); + .collect(java.util.stream.Collectors.toList());
@ -283,9 +254,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ builder.put(CAN_DESTROY.BUKKIT, cerealDestroyable); + builder.put(CAN_DESTROY.BUKKIT, cerealDestroyable);
+ } + }
+ // Paper end + // Paper end
+ final Map<String, Tag> internalTags = new HashMap<String, Tag>(this.unhandledTags);
final Map<String, Tag> internalTags = new HashMap<String, Tag>(unhandledTags); this.serializeInternal(internalTags);
serializeInternal(internalTags);
if (!internalTags.isEmpty()) { if (!internalTags.isEmpty()) {
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
CraftMetaArmorStand.SHOW_ARMS.NBT, CraftMetaArmorStand.SHOW_ARMS.NBT,
@ -392,7 +362,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ private @Nullable Namespaced deserializeNamespaced(String raw) { + private @Nullable Namespaced deserializeNamespaced(String raw) {
+ boolean isTag = raw.length() > 0 && raw.codePointAt(0) == '#'; + boolean isTag = raw.length() > 0 && raw.codePointAt(0) == '#';
+ BlockStateParser blockParser = new BlockStateParser(new com.mojang.brigadier.StringReader(raw), true); + net.minecraft.commands.arguments.blocks.BlockStateParser blockParser = new net.minecraft.commands.arguments.blocks.BlockStateParser(new com.mojang.brigadier.StringReader(raw), true);
+ try { + try {
+ blockParser = blockParser.parse(false); + blockParser = blockParser.parse(false);
+ } catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) { + } catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
@ -400,9 +370,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return null; + return null;
+ } + }
+ +
+ ResourceLocation key; + net.minecraft.resources.ResourceLocation key;
+ if (isTag) { + if (isTag) {
+ key = blockParser.getTagKey(); + key = blockParser.getTag();
+ } else { + } else {
+ key = blockParser.getBlockKey(); + key = blockParser.getBlockKey();
+ } + }

View File

@ -14,11 +14,15 @@ to cancel the death which has the benefit of also receiving the dropped
items and experience which is otherwise only properly possible by using items and experience which is otherwise only properly possible by using
internal code. internal code.
TODO 1.17: this needs to be checked (actually get off your lazy ass and cancel the events) for the following entities,
maybe more (please check patch overrides for drops for more):
- players, armor stands, foxes, chested donkeys/llamas
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
public int latency; public int latency;
public boolean wonGame; public boolean wonGame;
private int containerUpdateDelay; // Paper private int containerUpdateDelay; // Paper
@ -29,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit start // CraftBukkit start
public String displayName; public String displayName;
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
Component defaultMessage = this.getCombatTracker().getDeathMessage(); Component defaultMessage = this.getCombatTracker().getDeathMessage();
org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, PaperAdventure.asAdventure(defaultMessage), defaultMessage.getString(), keepInventory); // Paper - Adventure org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, PaperAdventure.asAdventure(defaultMessage), defaultMessage.getString(), keepInventory); // Paper - Adventure
@ -45,14 +49,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// SPIGOT-943 - only call if they have an inventory open // SPIGOT-943 - only call if they have an inventory open
if (this.containerMenu != this.inventoryMenu) { if (this.containerMenu != this.inventoryMenu) {
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
} }
} }
} }
- -
- return super.hurt(source, amount); - return super.hurt(source, amount);
+ // Paper start - cancellable death events + // Paper start - cancellable death events
+ //return super.damageEntity(damagesource, f); + //return super.hurt(source, amount);
+ this.queueHealthUpdatePacket = true; + this.queueHealthUpdatePacket = true;
+ boolean damaged = super.hurt(source, amount); + boolean damaged = super.hurt(source, amount);
+ this.queueHealthUpdatePacket = false; + this.queueHealthUpdatePacket = false;
@ -65,54 +69,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
} }
} }
diff --git a/src/main/java/net/minecraft/world/damagesource/CombatTracker.java b/src/main/java/net/minecraft/world/damagesource/CombatTracker.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/damagesource/CombatTracker.java
+++ b/src/main/java/net/minecraft/world/damagesource/CombatTracker.java
@@ -0,0 +0,0 @@ public class CombatTracker {
this.nextLocation = null;
}
+ public final void reset() { this.recheckStatus(); } // Paper - OBFHELPER
public void recheckStatus() {
int i = this.inCombat ? 300 : 100;
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
}
// CraftBukkit end
+ public final void runKillTrigger(Entity entity, int kills, DamageSource damageSource) { this.awardKillScore(entity, kills, damageSource); } // Paper - OBFHELPER
public void awardKillScore(Entity killer, int score, DamageSource damageSource) {
if (killer instanceof ServerPlayer) {
CriteriaTriggers.ENTITY_KILLED_PLAYER.trigger((ServerPlayer) killer, this, damageSource);
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
this.fallDistance = 0.0F;
}
+ public final void onKill(ServerLevel worldserver, net.minecraft.world.entity.LivingEntity entityLiving) { this.killed(worldserver, entityLiving); } // Paper - OBFHELPER
public void killed(ServerLevel worldserver, net.minecraft.world.entity.LivingEntity entityliving) {}
protected void moveTowardsClosestSpace(double x, double y, double z) {
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
protected float animStep;
protected float animStepO;
protected float rotOffs;
- protected int deathScore;
+ protected int deathScore;protected int getKillCount() { return this.deathScore; } // Paper - OBFHELPER
public float lastHurt;
protected boolean jumping;
public float xxa;
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
public Set<UUID> collidableExemptions = new HashSet<>(); public Set<UUID> collidableExemptions = new HashSet<>();
public boolean canPickUpLoot; public boolean bukkitPickUpLoot;
public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper
+ public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event + public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event
@ -123,15 +86,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.isDeadOrDying()) { if (this.isDeadOrDying()) {
if (!this.checkTotemDeathProtection(source)) { if (!this.checkTotemDeathProtection(source)) {
- SoundEvent soundeffect = this.getDeathSound(); - SoundEvent soundeffect = this.getDeathSound();
+ // Paper start - moved into CraftEventFactory event caller for cancellable death event -
+ //SoundEffect soundeffect = this.getSoundDeath();
- if (flag1 && soundeffect != null) { - if (flag1 && soundeffect != null) {
- this.playSound(soundeffect, this.getSoundVolume(), this.getVoicePitch()); - this.playSound(soundeffect, this.getSoundVolume(), this.getVoicePitch());
- } - }
+// if (flag1 && soundeffect != null) { + // Paper start - moved into CraftEventFactory event caller for cancellable death event
+// this.playSound(soundeffect, this.getSoundVolume(), this.dH());
+// }
+ this.silentDeath = !flag1; // mark entity as dying silently + this.silentDeath = !flag1; // mark entity as dying silently
+ // Paper end + // Paper end
@ -141,44 +100,45 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} else if (flag1) { } else if (flag1) {
this.playHurtSound(source); this.playHurtSound(source);
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
if (!this.isRemoved() && !this.dead) {
Entity entity = source.getEntity(); Entity entity = source.getEntity();
LivingEntity entityliving = this.getKillCredit(); LivingEntity entityliving = this.getKillCredit();
-
- if (this.deathScore >= 0 && entityliving != null) {
- entityliving.awardKillScore(this, this.deathScore, source);
+ /* // Paper - move down to make death event cancellable - this is the runKillTrigger below + /* // Paper - move down to make death event cancellable - this is the runKillTrigger below
+ if (this.aO >= 0 && entityliving != null) { if (this.deathScore >= 0 && entityliving != null) {
+ entityliving.a(this, this.aO, damagesource); entityliving.awardKillScore(this, this.deathScore, source);
} }
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
if (this.isSleeping()) { if (this.isSleeping()) {
- this.stopSleeping(); this.stopSleeping();
+ this.entityWakeup();
} }
+ */ // Paper + */ // Paper - move down to make death event cancellable - this is the runKillTrigger below
+
this.dead = true; this.dead = true;
- this.getCombatTracker().recheckStatus(); - this.getCombatTracker().recheckStatus();
+ // this.getCombatTracker().g(); // Paper - moved into if below as .reset() + // Paper - moved into if below
if (this.level instanceof ServerLevel) { if (this.level instanceof ServerLevel) {
if (entity != null) { if (entity != null) {
- entity.killed((ServerLevel) this.level, this); - entity.killed((ServerLevel) this.level, this);
+ // entity.a((WorldServer) this.world, this); // Paper - move below into if for onKill + // Paper - move below into if for onKill
} }
- this.dropAllDeathLoot(source); - this.dropAllDeathLoot(source);
+ // Paper start + // Paper start
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = this.d(source); + org.bukkit.event.entity.EntityDeathEvent deathEvent = this.dropAllDeathLoot(source);
+ if (deathEvent == null || !deathEvent.isCancelled()) { + if (deathEvent == null || !deathEvent.isCancelled()) {
+ if (this.getKillCount() >= 0 && entityliving != null) { + if (this.deathScore >= 0 && entityliving != null) {
+ entityliving.runKillTrigger(this, this.getKillCount(), source); + entityliving.awardKillScore(this, this.deathScore, source);
+ } + }
+
+ if (this.isSleeping()) { + if (this.isSleeping()) {
+ this.stopSleeping(); + this.stopSleeping();
+ } + }
+ this.getCombatTracker().reset(); +
+ this.getCombatTracker().recheckStatus();
+ if (entity != null) { + if (entity != null) {
+ entity.onKill((ServerLevel) this.level, this); + entity.killed((ServerLevel) this.level, this);
+ } + }
+ } else { + } else {
+ this.dead = false; + this.dead = false;
@ -209,21 +169,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- protected void dropAllDeathLoot(DamageSource source) { - protected void dropAllDeathLoot(DamageSource source) {
- Entity entity = source.getEntity(); + protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) { // Paper
+ protected org.bukkit.event.entity.EntityDeathEvent processDeath(DamageSource damagesource) { return d(damagesource); } // Paper - OBFHELPER Entity entity = source.getEntity();
+ protected org.bukkit.event.entity.EntityDeathEvent d(DamageSource damagesource) { // Paper
+ Entity entity = damagesource.getEntity();
int i; int i;
if (entity instanceof net.minecraft.world.entity.player.Player) {
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
this.dropCustomDeathLoot(source, i, flag);
this.dropEquipment(); // CraftBukkit - from below
if (this.shouldDropLoot() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- this.dropFromLootTable(source, flag);
- this.dropCustomDeathLoot(source, i, flag);
+ this.dropFromLootTable(damagesource, flag);
+ this.dropCustomDeathLoot(damagesource, i, flag);
} }
// CraftBukkit start - Call death event // CraftBukkit start - Call death event
- CraftEventFactory.callEntityDeathEvent(this, this.drops); - CraftEventFactory.callEntityDeathEvent(this, this.drops);
@ -246,23 +197,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return SoundEvents.GENERIC_HURT; return SoundEvents.GENERIC_HURT;
} }
+ public final SoundEvent getDeathSoundEffect() { return this.getDeathSound(); } // Paper - OBFHELPER +
@Nullable @Nullable
protected SoundEvent getDeathSound() { - protected SoundEvent getDeathSound() {
+ public final SoundEvent getDeathSoundPublic() { return this.getDeathSound(); } protected SoundEvent getDeathSound() { // Paper - provide PUBLIC accessor, overrides are hell to deal with
return SoundEvents.GENERIC_DEATH; return SoundEvents.GENERIC_DEATH;
}
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity { @@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity {
} }
+ public final float getDeathSoundVolume() { return this.getSoundVolume(); } // Paper - OBFHELPER - protected float getSoundVolume() {
protected float getSoundVolume() { + public final float getSoundVolumePublic() { return this.getSoundVolume(); } protected float getSoundVolume() { // Paper - provide PUBLIC accessor, overrides are hell
return 1.0F; return 1.0F;
} }
+ public float getSoundPitch() { return getVoicePitch();} // Paper - OBFHELPER
protected float getVoicePitch() {
return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F;
}
diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java --- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
@ -273,11 +223,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override @Override
- protected void dropAllDeathLoot(DamageSource source) { - protected void dropAllDeathLoot(DamageSource source) {
- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND); - ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND);
+ protected org.bukkit.event.entity.EntityDeathEvent d(DamageSource damagesource) { // Paper + // Paper start - Cancellable death event
+ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND).copy(); // Paper + protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) {
+ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND).copy(); // Paper - modified by supercall
+ +
+ // Paper start - Cancellable death event + org.bukkit.event.entity.EntityDeathEvent deathEvent = super.dropAllDeathLoot(source);
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = super.d(damagesource);
+ +
+ // Below is code to drop + // Below is code to drop
+ +
@ -301,7 +251,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java --- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java +++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
@@ -0,0 +0,0 @@ public abstract class AbstractChestedHorse extends AbstractHorse { @@ -0,0 +0,0 @@ public abstract class AbstractChestedHorse extends AbstractHorse {
this.spawnAtLocation((ItemLike) Blocks.CHEST); this.spawnAtLocation(Blocks.CHEST);
} }
- this.setChest(false); - this.setChest(false);
@ -319,21 +269,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end + // Paper end
+ +
@Override @Override
public void addAdditionalSaveData(CompoundTag tag) { public void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(tag); super.addAdditionalSaveData(nbt);
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java --- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
this.armorItems.set(i, ItemStack.EMPTY);
}
}
- this.dropAllDeathLoot(damageSource); // CraftBukkit - moved from above
+ this.d(damageSource); // CraftBukkit - moved from above
}
@@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity { @@ -0,0 +0,0 @@ public class ArmorStand extends LivingEntity {
@Override @Override
@ -341,22 +282,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event
+ org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event // Paper - make cancellable + org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event // Paper - make cancellable
+ if (event.isCancelled()) return; // Paper - make cancellable + if (event.isCancelled()) return; // Paper - make cancellable
this.remove(); this.remove(Entity.RemovalReason.KILLED);
} }
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -0,0 +0,0 @@ public abstract class Player extends LivingEntity {
super.die(source);
this.reapplyPosition();
if (!this.isSpectator()) {
- this.dropAllDeathLoot(source);
+ this.d(source);
}
if (source != null) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@ -365,10 +293,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
public void sendHealthUpdate() { public void sendHealthUpdate() {
- getHandle().connection.send(new ClientboundSetHealthPacket(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel())); - this.getHandle().connection.send(new ClientboundSetHealthPacket(this.getScaledHealth(), this.getHandle().getFoodData().getFoodLevel(), this.getHandle().getFoodData().getSaturationLevel()));
+ // Paper start - cancellable death event + // Paper start - cancellable death event
+ //getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel())); + ClientboundSetHealthPacket packet = new ClientboundSetHealthPacket(this.getScaledHealth(), this.getHandle().getFoodData().getFoodLevel(), this.getHandle().getFoodData().getSaturationLevel());
+ ClientboundSetHealthPacket packet = new ClientboundSetHealthPacket(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel());
+ if (this.getHandle().queueHealthUpdatePacket) { + if (this.getHandle().queueHealthUpdatePacket) {
+ this.getHandle().queuedHealthUpdatePacket = packet; + this.getHandle().queuedHealthUpdatePacket = packet;
+ } else { + } else {
@ -382,15 +309,6 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.game.ServerboundContainerClosePacket;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.sounds.SoundEvent;
+import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Unit;
import net.minecraft.world.Container;
import net.minecraft.world.InteractionHand;
@@ -0,0 +0,0 @@ public class CraftEventFactory { @@ -0,0 +0,0 @@ public class CraftEventFactory {
public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List<org.bukkit.inventory.ItemStack> drops) { public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, List<org.bukkit.inventory.ItemStack> drops) {
CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
@ -433,11 +351,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private static void populateFields(net.minecraft.world.entity.LivingEntity victim, EntityDeathEvent event) { + private static void populateFields(net.minecraft.world.entity.LivingEntity victim, EntityDeathEvent event) {
+ event.setReviveHealth(event.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue()); + event.setReviveHealth(event.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue());
+ event.setShouldPlayDeathSound(!victim.silentDeath && !victim.isSilent()); + event.setShouldPlayDeathSound(!victim.silentDeath && !victim.isSilent());
+ SoundEvent soundEffect = victim.getDeathSoundEffect(); + net.minecraft.sounds.SoundEvent soundEffect = victim.getDeathSoundPublic();
+ event.setDeathSound(soundEffect != null ? org.bukkit.craftbukkit.CraftSound.getBukkit(soundEffect) : null); + event.setDeathSound(soundEffect != null ? org.bukkit.craftbukkit.CraftSound.getBukkit(soundEffect) : null);
+ event.setDeathSoundCategory(org.bukkit.SoundCategory.valueOf(victim.getSoundSource().name())); + event.setDeathSoundCategory(org.bukkit.SoundCategory.valueOf(victim.getSoundSource().name()));
+ event.setDeathSoundVolume(victim.getDeathSoundVolume()); + event.setDeathSoundVolume(victim.getSoundVolumePublic());
+ event.setDeathSoundPitch(victim.getSoundPitch()); + event.setDeathSoundPitch(victim.getVoicePitch());
+ } + }
+ +
+ // Play death sound manually + // Play death sound manually
@ -447,8 +365,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ double x = event.getEntity().getLocation().getX(); + double x = event.getEntity().getLocation().getX();
+ double y = event.getEntity().getLocation().getY(); + double y = event.getEntity().getLocation().getY();
+ double z = event.getEntity().getLocation().getZ(); + double z = event.getEntity().getLocation().getZ();
+ SoundEvent soundEffect = org.bukkit.craftbukkit.CraftSound.getSoundEffect(event.getDeathSound()); + net.minecraft.sounds.SoundEvent soundEffect = org.bukkit.craftbukkit.CraftSound.getSoundEffect(event.getDeathSound());
+ SoundSource soundCategory = SoundSource.valueOf(event.getDeathSoundCategory().name()); + net.minecraft.sounds.SoundSource soundCategory = net.minecraft.sounds.SoundSource.valueOf(event.getDeathSoundCategory().name());
+ victim.level.playSound(source, x, y, z, soundEffect, soundCategory, event.getDeathSoundVolume(), event.getDeathSoundPitch()); + victim.level.playSound(source, x, y, z, soundEffect, soundCategory, event.getDeathSoundVolume(), event.getDeathSoundPitch());
+ } + }
+ } + }

View File

@ -18,12 +18,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Mob; +import org.bukkit.entity.Mob;
+
+import javax.annotation.Nonnull; +import javax.annotation.Nonnull;
+import javax.annotation.Nullable; +import javax.annotation.Nullable;
+import net.minecraft.world.level.pathfinder.Node; +import net.minecraft.world.level.pathfinder.Node;
+import net.minecraft.world.level.pathfinder.Path; +import net.minecraft.world.level.pathfinder.Path;
+import PathResult;
+import java.util.ArrayList; +import java.util.ArrayList;
+import java.util.List; +import java.util.List;
+ +
@ -171,11 +169,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Nullable @Nullable
- public Path createPath(Entity entity, int distance) { - public Path createPath(Entity entity, int distance) {
+ public final Path calculateDestination(Entity entity) { return createPath(entity, 0); } public Path createPath(Entity entity, int distance) { + public final Path calculateDestination(Entity entity) { return createPath(entity, 0); } public Path createPath(Entity entity, int distance) {
return this.a(ImmutableSet.of(entity.blockPosition()), entity, 16, true, distance); // Paper return this.createPath(ImmutableSet.of(entity.blockPosition()), entity, 16, true, distance); // Paper
} }
@@ -0,0 +0,0 @@ public abstract class PathNavigation { @@ -0,0 +0,0 @@ public abstract class PathNavigation {
return pathentity != null && this.moveTo(pathentity, speed); return path != null && this.moveTo(path, speed);
} }
+ public boolean setDestination(@Nullable Path pathentity, double speed) { return moveTo(pathentity, speed); } // Paper - OBFHELPER + public boolean setDestination(@Nullable Path pathentity, double speed) { return moveTo(pathentity, speed); } // Paper - OBFHELPER
@ -204,9 +202,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/pathfinder/Node.java --- a/src/main/java/net/minecraft/world/level/pathfinder/Node.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/Node.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/Node.java
@@ -0,0 +0,0 @@ import net.minecraft.util.Mth; @@ -0,0 +0,0 @@ import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3;
public class Node { public class Node {
- public final int x; - public final int x;
- public final int y; - public final int y;
- public final int z; - public final int z;
@ -231,20 +229,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ protected boolean canOpenDoors; public boolean shouldOpenDoors() { return canOpenDoors; } public void setShouldOpenDoors(boolean b) { canOpenDoors = b; } // Paper - obfhelper + protected boolean canOpenDoors; public boolean shouldOpenDoors() { return canOpenDoors; } public void setShouldOpenDoors(boolean b) { canOpenDoors = b; } // Paper - obfhelper
+ protected boolean canFloat; public boolean shouldFloat() { return canFloat; } public void setShouldFloat(boolean b) { canFloat = b; } // Paper - obfhelper + protected boolean canFloat; public boolean shouldFloat() { return canFloat; } public void setShouldFloat(boolean b) { canFloat = b; } // Paper - obfhelper
public NodeEvaluator() {} public void prepare(PathNavigationRegion cachedWorld, Mob entity) {
this.level = cachedWorld;
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/Path.java b/src/main/java/net/minecraft/world/level/pathfinder/Path.java diff --git a/src/main/java/net/minecraft/world/level/pathfinder/Path.java b/src/main/java/net/minecraft/world/level/pathfinder/Path.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/pathfinder/Path.java --- a/src/main/java/net/minecraft/world/level/pathfinder/Path.java
+++ b/src/main/java/net/minecraft/world/level/pathfinder/Path.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/Path.java
@@ -0,0 +0,0 @@ import net.minecraft.world.phys.Vec3; @@ -0,0 +0,0 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
public class Path { public class Path {
- private final List<Node> nodes; - private final List<Node> nodes;
+ private final List<Node> nodes; public List<Node> getPoints() { return nodes; } // Paper - OBFHELPER + private final List<Node> nodes; public List<Node> getPoints() { return nodes; } // Paper - OBFHELPER
private Node[] openSet = new Node[0]; private Node[] openSet = new Node[0];
private Node[] closedSet = new Node[0]; private Node[] closedSet = new Node[0];
private Set<Target> targetNodes;
- private int nextNodeIndex; - private int nextNodeIndex;
+ private int nextNodeIndex; public int getNextIndex() { return this.nextNodeIndex; } // Paper - OBFHELPER + private int nextNodeIndex; public int getNextIndex() { return this.nextNodeIndex; } // Paper - OBFHELPER
private final BlockPos target; private final BlockPos target;
@ -260,7 +259,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Nullable @Nullable
- public Node getEndNode() { - public Node getEndNode() {
+ public Node getFinalPoint() { return getEndNode(); } @Nullable public Node getEndNode() { // Paper - OBFHELPER + public Node getFinalPoint() { return getEndNode(); } @Nullable public Node getEndNode() { // Paper - OBFHELPER
return !this.nodes.isEmpty() ? (Node) this.nodes.get(this.nodes.size() - 1) : null; return !this.nodes.isEmpty() ? this.nodes.get(this.nodes.size() - 1) : null;
} }
@@ -0,0 +0,0 @@ public class Path { @@ -0,0 +0,0 @@ public class Path {
@ -269,7 +268,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- public BlockPos getNextNodePos() { - public BlockPos getNextNodePos() {
+ public BlockPos getNext() { return getNextNodePos(); } public BlockPos getNextNodePos() { // Paper - OBFHELPER + public BlockPos getNext() { return getNextNodePos(); } public BlockPos getNextNodePos() { // Paper - OBFHELPER
return ((Node) this.nodes.get(this.nextNodeIndex)).asBlockPos(); return this.nodes.get(this.nextNodeIndex).asBlockPos();
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@ -287,4 +286,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Override public com.destroystokyo.paper.entity.Pathfinder getPathfinder() { return paperPathfinder; } // Paper + @Override public com.destroystokyo.paper.entity.Pathfinder getPathfinder() { return paperPathfinder; } // Paper
@Override @Override
public void setTarget(LivingEntity target) { public void setTarget(LivingEntity target) {
net.minecraft.world.entity.Mob entity = getHandle(); net.minecraft.world.entity.Mob entity = this.getHandle();

View File

@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 10 Sep 2018 23:56:36 -0400
Subject: [PATCH] Prevent Mob AI Rules from Loading Chunks
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/RemoveBlockGoal.java
@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
@Nullable
private BlockPos getPosWithBlock(BlockPos pos, BlockGetter world) {
- if (world.getBlockState(pos).is(this.blockToRemove)) {
+ net.minecraft.world.level.block.state.BlockState block = world.getTypeIfLoaded(pos); // Paper
+ if (block == null) return null; // Paper
+ if (block.is(this.blockToRemove)) { // Paper
return pos;
} else {
BlockPos[] ablockposition = new BlockPos[]{pos.below(), pos.west(), pos.east(), pos.north(), pos.south(), pos.below().below()};
@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
for (int j = 0; j < i; ++j) {
BlockPos blockposition1 = ablockposition1[j];
- if (world.getBlockState(blockposition1).is(this.blockToRemove)) {
+ net.minecraft.world.level.block.state.BlockState block2 = world.getTypeIfLoaded(blockposition1); // Paper
+ if (block2 != null && block2.is(this.blockToRemove)) { // Paper
return blockposition1;
}
}
@@ -0,0 +0,0 @@ public class RemoveBlockGoal extends MoveToBlockGoal {
@Override
protected boolean isValidTarget(LevelReader world, BlockPos pos) {
- ChunkAccess ichunkaccess = world.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ()), ChunkStatus.FULL, false);
+ ChunkAccess ichunkaccess = world.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); // Paper
return ichunkaccess == null ? false : ichunkaccess.getBlockState(pos).is(this.blockToRemove) && ichunkaccess.getBlockState(pos.above()).isAir() && ichunkaccess.getBlockState(pos.above(2)).isAir();
}

View File

@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class FlowingFluid extends Fluid { @@ -0,0 +0,0 @@ public abstract class FlowingFluid extends Fluid {
if (enumdirection1 != enumdirection) { if (enumdirection1 != enumdirection) {
BlockPos blockposition2 = blockposition.relative(enumdirection1); BlockPos blockposition2 = blockposition.relative(enumdirection1);
short short0 = getCacheKey(blockposition1, blockposition2); short short0 = FlowingFluid.getCacheKey(blockposition1, blockposition2);
- Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (k) -> { - Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (k) -> {
- BlockState iblockdata1 = world.getBlockState(blockposition2); - BlockState iblockdata1 = world.getBlockState(blockposition2);
+ // Paper start - avoid loading chunks + // Paper start - avoid loading chunks
@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class FlowingFluid extends Fluid { @@ -0,0 +0,0 @@ public abstract class FlowingFluid extends Fluid {
Direction enumdirection = (Direction) iterator.next(); Direction enumdirection = (Direction) iterator.next();
BlockPos blockposition1 = pos.relative(enumdirection); BlockPos blockposition1 = pos.relative(enumdirection);
short short0 = getCacheKey(pos, blockposition1); short short0 = FlowingFluid.getCacheKey(pos, blockposition1);
- Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (j) -> { - Pair<BlockState, FluidState> pair = (Pair) short2objectmap.computeIfAbsent(short0, (j) -> {
- BlockState iblockdata1 = world.getBlockState(blockposition1); - BlockState iblockdata1 = world.getBlockState(blockposition1);
- -

View File

@ -25,8 +25,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (entityhuman != null) { if (entityhuman != null) {
double d2 = entityhuman.distanceToSqr(d0, (double) i, d1); double d2 = entityhuman.distanceToSqr(d0, (double) i, d1);
- if (isRightDistanceToPlayerAndSpawnPoint(world, chunk, blockposition_mutableblockposition, d2)) { - if (NaturalSpawner.isRightDistanceToPlayerAndSpawnPoint(world, chunk, blockposition_mutableblockposition, d2)) {
+ if (isRightDistanceToPlayerAndSpawnPoint(world, chunk, blockposition_mutableblockposition, d2) && world.isLoadedAndInBounds(blockposition_mutableblockposition)) { // Paper - don't load chunks for mob spawn + if (world.isLoadedAndInBounds(blockposition_mutableblockposition) && NaturalSpawner.isRightDistanceToPlayerAndSpawnPoint(world, chunk, blockposition_mutableblockposition, d2)) { // Paper - don't load chunks for mob spawn
if (biomesettingsmobs_c == null) { if (biomesettingsmobs_c == null) {
biomesettingsmobs_c = getRandomSpawnMobAt(world, structuremanager, chunkgenerator, group, world.random, (BlockPos) blockposition_mutableblockposition); Optional<MobSpawnSettings.SpawnerData> optional = NaturalSpawner.getRandomSpawnMobAt(world, structuremanager, chunkgenerator, group, world.random, (BlockPos) blockposition_mutableblockposition);
if (biomesettingsmobs_c == null) {