mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Move classes added to net.minecraft.server to paper packages (#8500)
This commit is contained in:
parent
95bd943ca3
commit
b9481cae74
45 changed files with 1389 additions and 1387 deletions
|
@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ private static void glow(LivingEntity entity) { glow(entity, null); }
|
+ private static void glow(LivingEntity entity) { glow(entity, null); }
|
||||||
+ private static void glow(LivingEntity entity, @javax.annotation.Nullable BlockPos pos) {
|
+ private static void glow(LivingEntity entity, @javax.annotation.Nullable BlockPos pos) {
|
||||||
+ if (pos != null && !new io.papermc.paper.event.block.BellRevealRaiderEvent(entity.level.getWorld().getBlockAt(net.minecraft.server.MCUtil.toLocation(entity.level, pos)), entity.getBukkitEntity()).callEvent()) return;
|
+ if (pos != null && !new io.papermc.paper.event.block.BellRevealRaiderEvent(entity.level.getWorld().getBlockAt(io.papermc.paper.util.MCUtil.toLocation(entity.level, pos)), entity.getBukkitEntity()).callEvent()) return;
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
entity.addEffect(new MobEffectInstance(MobEffects.GLOWING, 60));
|
entity.addEffect(new MobEffectInstance(MobEffects.GLOWING, 60));
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
+import net.minecraft.server.MCUtil;
|
+import io.papermc.paper.util.MCUtil;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.stats.Stats;
|
import net.minecraft.stats.Stats;
|
||||||
|
|
|
@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
@@ -0,0 +0,0 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||||
new com.destroystokyo.paper.block.TargetBlockInfo(org.bukkit.craftbukkit.block.CraftBlock.at(getHandle().level, ((net.minecraft.world.phys.BlockHitResult)rayTrace).getBlockPos()),
|
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()));
|
io.papermc.paper.util.MCUtil.toBukkitBlockFace(((net.minecraft.world.phys.BlockHitResult)rayTrace).getDirection()));
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+ public Entity getTargetEntity(int maxDistance, boolean ignoreBlocks) {
|
+ public Entity getTargetEntity(int maxDistance, boolean ignoreBlocks) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
+import net.minecraft.server.MCUtil;
|
+import io.papermc.paper.util.MCUtil;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.stats.ServerStatsCounter;
|
import net.minecraft.stats.ServerStatsCounter;
|
||||||
|
|
|
@ -58,7 +58,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ boolean willNotify = false;
|
+ boolean willNotify = false;
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
boolean flag2 = pos.equals(this.respawnPosition) && dimension.equals(this.respawnDimension);
|
boolean flag2 = pos.equals(this.respawnPosition) && dimension.equals(this.respawnDimension);
|
||||||
+ spawnLoc = net.minecraft.server.MCUtil.toLocation(this.getServer().getLevel(dimension), pos);
|
+ spawnLoc = io.papermc.paper.util.MCUtil.toLocation(this.getServer().getLevel(dimension), pos);
|
||||||
+ spawnLoc.setYaw(angle);
|
+ spawnLoc.setYaw(angle);
|
||||||
+ willNotify = sendMessage && !flag2;
|
+ willNotify = sendMessage && !flag2;
|
||||||
+ }
|
+ }
|
||||||
|
@ -68,7 +68,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ if (event.getLocation() != null) {
|
+ if (event.getLocation() != null) {
|
||||||
+ dimension = event.getLocation().getWorld() != null ? ((CraftWorld) event.getLocation().getWorld()).getHandle().dimension() : dimension;
|
+ dimension = event.getLocation().getWorld() != null ? ((CraftWorld) event.getLocation().getWorld()).getHandle().dimension() : dimension;
|
||||||
+ pos = net.minecraft.server.MCUtil.toBlockPosition(event.getLocation());
|
+ pos = io.papermc.paper.util.MCUtil.toBlockPosition(event.getLocation());
|
||||||
+ angle = (float) event.getLocation().getYaw();
|
+ angle = (float) event.getLocation().getYaw();
|
||||||
+ forced = event.isForced();
|
+ forced = event.isForced();
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
|
@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
if (itemstack.is(Items.SHEARS)) {
|
if (itemstack.is(Items.SHEARS)) {
|
||||||
+ // Paper start - Add PlayerShearBlockEvent
|
+ // Paper start - Add PlayerShearBlockEvent
|
||||||
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), net.minecraft.server.MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>());
|
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>());
|
||||||
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.HONEYCOMB, 3)));
|
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.HONEYCOMB, 3)));
|
||||||
+ if (!event.callEvent()) {
|
+ if (!event.callEvent()) {
|
||||||
+ return InteractionResult.PASS;
|
+ return InteractionResult.PASS;
|
||||||
|
@ -47,7 +47,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
if (itemStack.is(Items.SHEARS)) {
|
if (itemStack.is(Items.SHEARS)) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
+ // Paper start - Add PlayerShearBlockEvent
|
+ // Paper start - Add PlayerShearBlockEvent
|
||||||
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), net.minecraft.server.MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>());
|
+ io.papermc.paper.event.block.PlayerShearBlockEvent event = new io.papermc.paper.event.block.PlayerShearBlockEvent((org.bukkit.entity.Player) player.getBukkitEntity(), io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (hand == InteractionHand.OFF_HAND ? org.bukkit.inventory.EquipmentSlot.OFF_HAND : org.bukkit.inventory.EquipmentSlot.HAND), new java.util.ArrayList<>());
|
||||||
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.PUMPKIN_SEEDS, 4)));
|
+ event.getDrops().add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(Items.PUMPKIN_SEEDS, 4)));
|
||||||
+ if (!event.callEvent()) {
|
+ if (!event.callEvent()) {
|
||||||
+ return InteractionResult.PASS;
|
+ return InteractionResult.PASS;
|
||||||
|
|
|
@ -64,7 +64,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ private void addTicket(int x, int z) {
|
+ private void addTicket(int x, int z) {
|
||||||
+ net.minecraft.server.MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper
|
+ io.papermc.paper.util.MCUtil.MAIN_EXECUTOR.execute(() -> world.getChunkSource().addRegionTicket(TicketType.PLUGIN, new ChunkPos(x, z), 0, Unit.INSTANCE)); // Paper
|
||||||
}
|
}
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
return true;
|
return true;
|
||||||
// Paper end
|
// Paper end
|
||||||
@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
@@ -0,0 +0,0 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||||
net.minecraft.server.ChunkSystem.scheduleChunkLoad(this.getHandle(), x, z, gen, ChunkStatus.FULL, true, priority, (c) -> {
|
io.papermc.paper.chunk.system.ChunkSystem.scheduleChunkLoad(this.getHandle(), x, z, gen, ChunkStatus.FULL, true, priority, (c) -> {
|
||||||
net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> {
|
net.minecraft.server.MinecraftServer.getServer().scheduleOnMain(() -> {
|
||||||
net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)c;
|
net.minecraft.world.level.chunk.LevelChunk chunk = (net.minecraft.world.level.chunk.LevelChunk)c;
|
||||||
+ if (chunk != null) addTicket(x, z); // Paper
|
+ if (chunk != null) addTicket(x, z); // Paper
|
||||||
|
|
|
@ -81,7 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
public Pair<BlockPos, Holder<Structure>> findNearestMapStructure(ServerLevel world, HolderSet<Structure> structures, BlockPos center, int radius, boolean skipReferencedStructures) {
|
public Pair<BlockPos, Holder<Structure>> findNearestMapStructure(ServerLevel world, HolderSet<Structure> structures, BlockPos center, int radius, boolean skipReferencedStructures) {
|
||||||
+ // Paper start - StructureLocateEvent
|
+ // Paper start - StructureLocateEvent
|
||||||
+ final org.bukkit.World bukkitWorld = world.getWorld();
|
+ final org.bukkit.World bukkitWorld = world.getWorld();
|
||||||
+ final org.bukkit.Location origin = net.minecraft.server.MCUtil.toLocation(world, center);
|
+ final org.bukkit.Location origin = io.papermc.paper.util.MCUtil.toLocation(world, center);
|
||||||
+ final var paperRegistry = io.papermc.paper.registry.PaperRegistry.getRegistry(io.papermc.paper.registry.RegistryKey.CONFIGURED_STRUCTURE_REGISTRY);
|
+ final var paperRegistry = io.papermc.paper.registry.PaperRegistry.getRegistry(io.papermc.paper.registry.RegistryKey.CONFIGURED_STRUCTURE_REGISTRY);
|
||||||
+ final List<io.papermc.paper.world.structure.ConfiguredStructure> configuredStructures = new ArrayList<>();
|
+ final List<io.papermc.paper.world.structure.ConfiguredStructure> configuredStructures = new ArrayList<>();
|
||||||
+ paperRegistry.convertToApi(structures, configuredStructures::add, false); // gracefully handle missing api, use tests to check (or exclude)
|
+ paperRegistry.convertToApi(structures, configuredStructures::add, false); // gracefully handle missing api, use tests to check (or exclude)
|
||||||
|
@ -91,9 +91,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
+ if (event.getResult() != null) {
|
+ if (event.getResult() != null) {
|
||||||
+ return Pair.of(net.minecraft.server.MCUtil.toBlockPosition(event.getResult().position()), paperRegistry.getMinecraftHolder(event.getResult().configuredStructure()));
|
+ return Pair.of(io.papermc.paper.util.MCUtil.toBlockPosition(event.getResult().position()), paperRegistry.getMinecraftHolder(event.getResult().configuredStructure()));
|
||||||
+ }
|
+ }
|
||||||
+ center = net.minecraft.server.MCUtil.toBlockPosition(event.getOrigin());
|
+ center = io.papermc.paper.util.MCUtil.toBlockPosition(event.getOrigin());
|
||||||
+ radius = event.getRadius();
|
+ radius = event.getRadius();
|
||||||
+ skipReferencedStructures = event.shouldFindUnexplored();
|
+ skipReferencedStructures = event.shouldFindUnexplored();
|
||||||
+ structures = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures());
|
+ structures = HolderSet.direct(paperRegistry::getMinecraftHolder, event.getConfiguredStructures());
|
||||||
|
|
|
@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
if (block instanceof TntBlock) {
|
if (block instanceof TntBlock) {
|
||||||
+ // Paper start - TNTPrimeEvent
|
+ // Paper start - TNTPrimeEvent
|
||||||
+ org.bukkit.block.Block tntBlock = net.minecraft.server.MCUtil.toBukkitBlock(world, blockposition);
|
+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, blockposition);
|
||||||
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.FIRE, null).callEvent()) {
|
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.FIRE, null).callEvent()) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
|
@ -54,7 +54,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
if (!oldState.is(state.getBlock())) {
|
if (!oldState.is(state.getBlock())) {
|
||||||
if (world.hasNeighborSignal(pos)) {
|
if (world.hasNeighborSignal(pos)) {
|
||||||
+ // Paper start - TNTPrimeEvent
|
+ // Paper start - TNTPrimeEvent
|
||||||
+ org.bukkit.block.Block tntBlock = net.minecraft.server.MCUtil.toBukkitBlock(world, pos);;
|
+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos);;
|
||||||
+ if(!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent())
|
+ if(!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent())
|
||||||
+ return;
|
+ return;
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
@ -66,7 +66,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
|
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
|
||||||
if (world.hasNeighborSignal(pos)) {
|
if (world.hasNeighborSignal(pos)) {
|
||||||
+ // Paper start - TNTPrimeEvent
|
+ // Paper start - TNTPrimeEvent
|
||||||
+ org.bukkit.block.Block tntBlock = net.minecraft.server.MCUtil.toBukkitBlock(world, pos);;
|
+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos);;
|
||||||
+ if(!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent())
|
+ if(!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent())
|
||||||
+ return;
|
+ return;
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
public void wasExploded(Level world, BlockPos pos, Explosion explosion) {
|
public void wasExploded(Level world, BlockPos pos, Explosion explosion) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
+ // Paper start - TNTPrimeEvent
|
+ // Paper start - TNTPrimeEvent
|
||||||
+ org.bukkit.block.Block tntBlock = net.minecraft.server.MCUtil.toBukkitBlock(world, pos);
|
+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos);
|
||||||
+ org.bukkit.entity.Entity source = explosion.source != null ? explosion.source.getBukkitEntity() : null;
|
+ org.bukkit.entity.Entity source = explosion.source != null ? explosion.source.getBukkitEntity() : null;
|
||||||
+ if(!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, source).callEvent())
|
+ if(!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, source).callEvent())
|
||||||
+ return;
|
+ return;
|
||||||
|
@ -91,7 +91,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
return super.use(state, world, pos, player, hand, hit);
|
return super.use(state, world, pos, player, hand, hit);
|
||||||
} else {
|
} else {
|
||||||
+ // Paper start - TNTPrimeEvent
|
+ // Paper start - TNTPrimeEvent
|
||||||
+ org.bukkit.block.Block tntBlock = net.minecraft.server.MCUtil.toBukkitBlock(world, pos);
|
+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, pos);
|
||||||
+ if(!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.ITEM, player.getBukkitEntity()).callEvent())
|
+ if(!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.ITEM, player.getBukkitEntity()).callEvent())
|
||||||
+ return InteractionResult.FAIL;
|
+ return InteractionResult.FAIL;
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
@ -103,7 +103,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
+ // Paper start - TNTPrimeEvent
|
+ // Paper start - TNTPrimeEvent
|
||||||
+ org.bukkit.block.Block tntBlock = net.minecraft.server.MCUtil.toBukkitBlock(world, blockposition);
|
+ org.bukkit.block.Block tntBlock = io.papermc.paper.util.MCUtil.toBukkitBlock(world, blockposition);
|
||||||
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.PROJECTILE, projectile.getBukkitEntity()).callEvent()) {
|
+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.PROJECTILE, projectile.getBukkitEntity()).callEvent()) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
|
|
|
@ -39,8 +39,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Location findLightningRod(Location location) {
|
+ public Location findLightningRod(Location location) {
|
||||||
+ return this.world.findLightningRod(net.minecraft.server.MCUtil.toBlockPosition(location))
|
+ return this.world.findLightningRod(io.papermc.paper.util.MCUtil.toBlockPosition(location))
|
||||||
+ .map(blockPos -> net.minecraft.server.MCUtil.toLocation(this.world, blockPos)
|
+ .map(blockPos -> io.papermc.paper.util.MCUtil.toLocation(this.world, blockPos)
|
||||||
+ // get the actual rod pos
|
+ // get the actual rod pos
|
||||||
+ .subtract(0, 1, 0))
|
+ .subtract(0, 1, 0))
|
||||||
+ .orElse(null);
|
+ .orElse(null);
|
||||||
|
@ -48,8 +48,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Location findLightningTarget(Location location) {
|
+ public Location findLightningTarget(Location location) {
|
||||||
+ final BlockPos pos = this.world.findLightningTargetAround(net.minecraft.server.MCUtil.toBlockPosition(location), true);
|
+ final BlockPos pos = this.world.findLightningTargetAround(io.papermc.paper.util.MCUtil.toBlockPosition(location), true);
|
||||||
+ return pos == null ? null : net.minecraft.server.MCUtil.toLocation(this.world, pos);
|
+ return pos == null ? null : io.papermc.paper.util.MCUtil.toLocation(this.world, pos);
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
|
|
|
@ -4,10 +4,10 @@ Date: Mon, 3 Sep 2018 18:20:03 -0500
|
||||||
Subject: [PATCH] Add ray tracing methods to LivingEntity
|
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
|
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
@@ -0,0 +0,0 @@ public final class MCUtil {
|
@@ -0,0 +0,0 @@ public final class MCUtil {
|
||||||
return getNMSWorld(entity.getWorld());
|
return getNMSWorld(entity.getWorld());
|
||||||
}
|
}
|
||||||
|
@ -66,22 +66,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Block getTargetBlock(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
|
+ 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));
|
+ net.minecraft.world.phys.HitResult rayTrace = getHandle().getRayTrace(maxDistance, io.papermc.paper.util.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());
|
+ 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
|
+ @Override
|
||||||
+ public org.bukkit.block.BlockFace getTargetBlockFace(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
|
+ 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));
|
+ net.minecraft.world.phys.HitResult rayTrace = getHandle().getRayTrace(maxDistance, io.papermc.paper.util.MCUtil.getNMSFluidCollisionOption(fluidMode));
|
||||||
+ return !(rayTrace instanceof net.minecraft.world.phys.BlockHitResult) ? null : net.minecraft.server.MCUtil.toBukkitBlockFace(((net.minecraft.world.phys.BlockHitResult)rayTrace).getDirection());
|
+ return !(rayTrace instanceof net.minecraft.world.phys.BlockHitResult) ? null : io.papermc.paper.util.MCUtil.toBukkitBlockFace(((net.minecraft.world.phys.BlockHitResult)rayTrace).getDirection());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public com.destroystokyo.paper.block.TargetBlockInfo getTargetBlockInfo(int maxDistance, com.destroystokyo.paper.block.TargetBlockInfo.FluidMode fluidMode) {
|
+ 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));
|
+ net.minecraft.world.phys.HitResult rayTrace = getHandle().getRayTrace(maxDistance, io.papermc.paper.util.MCUtil.getNMSFluidCollisionOption(fluidMode));
|
||||||
+ return !(rayTrace instanceof net.minecraft.world.phys.BlockHitResult) ? null :
|
+ 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()),
|
+ 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()));
|
+ io.papermc.paper.util.MCUtil.toBukkitBlockFace(((net.minecraft.world.phys.BlockHitResult)rayTrace).getDirection()));
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
|
|
|
@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
this.receiving = side;
|
this.receiving = side;
|
||||||
}
|
}
|
||||||
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||||
net.minecraft.server.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
|
io.papermc.paper.util.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
|
||||||
(packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
|
(packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
|
||||||
))) {
|
))) {
|
||||||
- this.sendPacket(packet, callbacks);
|
- this.sendPacket(packet, callbacks);
|
||||||
|
|
|
@ -76,7 +76,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ };
|
+ };
|
||||||
+ if (asyncSave) {
|
+ if (asyncSave) {
|
||||||
+ net.minecraft.server.MCUtil.scheduleAsyncTask(save);
|
+ io.papermc.paper.util.MCUtil.scheduleAsyncTask(save);
|
||||||
+ } else {
|
+ } else {
|
||||||
+ save.run();
|
+ save.run();
|
||||||
+ }
|
+ }
|
||||||
|
|
|
@ -97,7 +97,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
|
|
||||||
- TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers);
|
- TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers);
|
||||||
+ TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers, message.startsWith("/") || forceCommand, pos != null ? net.minecraft.server.MCUtil.toLocation(((CraftWorld) player.getWorld()).getHandle(), new BlockPos(pos)) : null); // Paper
|
+ TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers, message.startsWith("/") || forceCommand, pos != null ? io.papermc.paper.util.MCUtil.toLocation(((CraftWorld) player.getWorld()).getHandle(), new BlockPos(pos)) : null); // Paper
|
||||||
this.getPluginManager().callEvent(tabEvent);
|
this.getPluginManager().callEvent(tabEvent);
|
||||||
|
|
||||||
return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions();
|
return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions();
|
||||||
|
|
|
@ -554,12 +554,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ @NotNull GameProfile buildGameProfile();
|
+ @NotNull GameProfile buildGameProfile();
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +0,0 @@
|
||||||
package net.minecraft.server;
|
package io.papermc.paper.util;
|
||||||
|
|
||||||
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||||
+import com.destroystokyo.paper.profile.PlayerProfile;
|
+import com.destroystokyo.paper.profile.PlayerProfile;
|
||||||
|
|
|
@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
+import net.minecraft.server.MCUtil;
|
+import io.papermc.paper.util.MCUtil;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ChunkHolder;
|
import net.minecraft.server.level.ChunkHolder;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
|
|
@ -12,14 +12,14 @@ Shulkers) may need to be changed in order for it to re-save properly
|
||||||
|
|
||||||
No more crashing though.
|
No more crashing though.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MCUtil.java
|
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||||
@@ -0,0 +0,0 @@ import java.lang.ref.Cleaner;
|
@@ -0,0 +0,0 @@ import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
||||||
import it.unimi.dsi.fastutil.objects.ReferenceArrayList;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
+import net.minecraft.nbt.CompoundTag;
|
+import net.minecraft.nbt.CompoundTag;
|
||||||
+import net.minecraft.network.chat.Component;
|
+import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.server.level.ChunkHolder;
|
import net.minecraft.server.level.ChunkHolder;
|
||||||
|
@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
this.successCount = nbt.getInt("SuccessCount");
|
this.successCount = nbt.getInt("SuccessCount");
|
||||||
if (nbt.contains("CustomName", 8)) {
|
if (nbt.contains("CustomName", 8)) {
|
||||||
- this.setName(Component.Serializer.fromJson(nbt.getString("CustomName")));
|
- this.setName(Component.Serializer.fromJson(nbt.getString("CustomName")));
|
||||||
+ this.setName(net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt)); // Paper - Catch ParseException
|
+ this.setName(io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt)); // Paper - Catch ParseException
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbt.contains("TrackOutput", 1)) {
|
if (nbt.contains("TrackOutput", 1)) {
|
||||||
|
@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
super.load(nbt);
|
super.load(nbt);
|
||||||
if (nbt.contains("CustomName", 8)) {
|
if (nbt.contains("CustomName", 8)) {
|
||||||
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
||||||
+ this.name = net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
+ this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||||
}
|
}
|
||||||
|
|
||||||
this.itemPatterns = nbt.getList("Patterns", 10);
|
this.itemPatterns = nbt.getList("Patterns", 10);
|
||||||
|
@ -82,7 +82,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
this.lockKey = LockCode.fromTag(nbt);
|
this.lockKey = LockCode.fromTag(nbt);
|
||||||
if (nbt.contains("CustomName", 8)) {
|
if (nbt.contains("CustomName", 8)) {
|
||||||
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
||||||
+ this.name = net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
+ this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
if (nbt.contains("CustomName", 8)) {
|
if (nbt.contains("CustomName", 8)) {
|
||||||
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
||||||
+ this.name = net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
+ this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lockKey = LockCode.fromTag(nbt);
|
this.lockKey = LockCode.fromTag(nbt);
|
||||||
|
@ -108,7 +108,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
super.load(nbt);
|
super.load(nbt);
|
||||||
if (nbt.contains("CustomName", 8)) {
|
if (nbt.contains("CustomName", 8)) {
|
||||||
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
||||||
+ this.name = net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
+ this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
|
||||||
import net.minecraft.network.protocol.game.DebugPackets;
|
import net.minecraft.network.protocol.game.DebugPackets;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
+import net.minecraft.server.MCUtil;
|
+import io.papermc.paper.util.MCUtil;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.ServerScoreboard;
|
import net.minecraft.server.ServerScoreboard;
|
||||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||||
|
|
|
@ -35,11 +35,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public org.bukkit.Location getTreasureLocation() {
|
+ public org.bukkit.Location getTreasureLocation() {
|
||||||
+ return net.minecraft.server.MCUtil.toLocation(this.getHandle().level, this.getHandle().getTreasurePos());
|
+ return io.papermc.paper.util.MCUtil.toLocation(this.getHandle().level, this.getHandle().getTreasurePos());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void setTreasureLocation(org.bukkit.Location location) {
|
+ public void setTreasureLocation(org.bukkit.Location location) {
|
||||||
+ this.getHandle().setTreasurePos(net.minecraft.server.MCUtil.toBlockPosition(location));
|
+ this.getHandle().setTreasurePos(io.papermc.paper.util.MCUtil.toBlockPosition(location));
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,10 @@ But for those who are ok with leaving this inconsistent behavior, you may use WA
|
||||||
|
|
||||||
It is recommended you regenerate the entities, as these were legit entities, and deserve your love.
|
It is recommended you regenerate the entities, as these were legit entities, and deserve your love.
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/ChunkSystem.java b/src/main/java/net/minecraft/server/ChunkSystem.java
|
diff --git a/src/main/java/io/papermc/paper/chunk/system/ChunkSystem.java b/src/main/java/io/papermc/paper/chunk/system/ChunkSystem.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/server/ChunkSystem.java
|
--- a/src/main/java/io/papermc/paper/chunk/system/ChunkSystem.java
|
||||||
+++ b/src/main/java/net/minecraft/server/ChunkSystem.java
|
+++ b/src/main/java/io/papermc/paper/chunk/system/ChunkSystem.java
|
||||||
@@ -0,0 +0,0 @@ public final class ChunkSystem {
|
@@ -0,0 +0,0 @@ public final class ChunkSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveAll() {
|
public void saveAll() {
|
||||||
+ net.minecraft.server.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main
|
+ io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main
|
||||||
MinecraftTimings.savePlayers.startTiming(); // Paper
|
MinecraftTimings.savePlayers.startTiming(); // Paper
|
||||||
for (int i = 0; i < this.players.size(); ++i) {
|
for (int i = 0; i < this.players.size(); ++i) {
|
||||||
- this.save((ServerPlayer) this.players.get(i));
|
- this.save((ServerPlayer) this.players.get(i));
|
||||||
|
|
|
@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ boolean copiedSet = false;
|
+ boolean copiedSet = false;
|
||||||
+ for (BlockPos possibleTarget : positions) {
|
+ for (BlockPos possibleTarget : positions) {
|
||||||
+ if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(),
|
+ if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(),
|
||||||
+ net.minecraft.server.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
|
+ io.papermc.paper.util.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
|
||||||
+ if (!copiedSet) {
|
+ if (!copiedSet) {
|
||||||
+ copiedSet = true;
|
+ copiedSet = true;
|
||||||
+ positions = new java.util.HashSet<>(positions);
|
+ positions = new java.util.HashSet<>(positions);
|
||||||
|
|
|
@ -84,7 +84,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public ChunkAccess getUnloadingChunk(int chunkX, int chunkZ) {
|
+ public ChunkAccess getUnloadingChunk(int chunkX, int chunkZ) {
|
||||||
+ ChunkHolder chunkHolder = net.minecraft.server.ChunkSystem.getUnloadingChunkHolder(this.level, chunkX, chunkZ);
|
+ ChunkHolder chunkHolder = io.papermc.paper.chunk.system.ChunkSystem.getUnloadingChunkHolder(this.level, chunkX, chunkZ);
|
||||||
+ return chunkHolder == null ? null : chunkHolder.getAvailableChunkNow();
|
+ return chunkHolder == null ? null : chunkHolder.getAvailableChunkNow();
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
|
|
@ -79,7 +79,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ if (org.spigotmc.SpigotConfig.logCommands) {
|
+ if (org.spigotmc.SpigotConfig.logCommands) {
|
||||||
+ LOGGER.info("{} issued server command: {}", player.getScoreboardName(), command);
|
+ LOGGER.info("{} issued server command: {}", player.getScoreboardName(), command);
|
||||||
+ }
|
+ }
|
||||||
+ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent(player.getBukkitEntity(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(player.getServer()), (org.bukkit.block.Sign) net.minecraft.server.MCUtil.toBukkitBlock(this.level, this.worldPosition).getState());
|
+ io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent event = new io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent(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()) {
|
+ if (!event.callEvent()) {
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
|
|
|
@ -11,6 +11,26 @@ server threads
|
||||||
|
|
||||||
Allow usage of a single thread executor by not using ForkJoin so single core CPU's.
|
Allow usage of a single thread executor by not using ForkJoin so single core CPU's.
|
||||||
|
|
||||||
|
diff --git a/src/main/java/io/papermc/paper/util/ServerWorkerThread.java b/src/main/java/io/papermc/paper/util/ServerWorkerThread.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/io/papermc/paper/util/ServerWorkerThread.java
|
||||||
|
@@ -0,0 +0,0 @@
|
||||||
|
+package io.papermc.paper.util;
|
||||||
|
+
|
||||||
|
+import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
+import net.minecraft.Util;
|
||||||
|
+
|
||||||
|
+public class ServerWorkerThread extends Thread {
|
||||||
|
+ private static final AtomicInteger threadId = new AtomicInteger(1);
|
||||||
|
+ public ServerWorkerThread(Runnable target, String poolName, int prioritityModifier) {
|
||||||
|
+ super(target, "Worker-" + poolName + "-" + threadId.getAndIncrement());
|
||||||
|
+ setPriority(Thread.NORM_PRIORITY+prioritityModifier); // Deprioritize over main
|
||||||
|
+ this.setDaemon(true);
|
||||||
|
+ this.setUncaughtExceptionHandler(Util::onThreadException);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/Util.java
|
--- a/src/main/java/net/minecraft/Util.java
|
||||||
|
@ -43,7 +63,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
} else {
|
} else {
|
||||||
- executorService = new ForkJoinPool(i, (forkJoinPool) -> {
|
- executorService = new ForkJoinPool(i, (forkJoinPool) -> {
|
||||||
- ForkJoinWorkerThread forkJoinWorkerThread = new ForkJoinWorkerThread(forkJoinPool) {
|
- ForkJoinWorkerThread forkJoinWorkerThread = new ForkJoinWorkerThread(forkJoinPool) {
|
||||||
+ executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<Runnable>(), target -> new net.minecraft.server.ServerWorkerThread(target, s, priorityModifier));
|
+ executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<Runnable>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier));
|
||||||
+ }
|
+ }
|
||||||
+ /*
|
+ /*
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,23 +89,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
thread.start();
|
thread.start();
|
||||||
return s0;
|
return s0;
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/server/ServerWorkerThread.java b/src/main/java/net/minecraft/server/ServerWorkerThread.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/net/minecraft/server/ServerWorkerThread.java
|
|
||||||
@@ -0,0 +0,0 @@
|
|
||||||
+package net.minecraft.server;
|
|
||||||
+
|
|
||||||
+import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
+import net.minecraft.Util;
|
|
||||||
+
|
|
||||||
+public class ServerWorkerThread extends Thread {
|
|
||||||
+ private static final AtomicInteger threadId = new AtomicInteger(1);
|
|
||||||
+ public ServerWorkerThread(Runnable target, String poolName, int prioritityModifier) {
|
|
||||||
+ super(target, "Worker-" + poolName + "-" + threadId.getAndIncrement());
|
|
||||||
+ setPriority(Thread.NORM_PRIORITY+prioritityModifier); // Deprioritize over main
|
|
||||||
+ this.setDaemon(true);
|
|
||||||
+ this.setUncaughtExceptionHandler(Util::onThreadException);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ final net.minecraft.world.level.ChunkPos pos = new net.minecraft.world.level.ChunkPos(chunkX, chunkZ);
|
+ final net.minecraft.world.level.ChunkPos pos = new net.minecraft.world.level.ChunkPos(chunkX, chunkZ);
|
||||||
+ net.minecraft.server.level.ChunkMap playerChunkMap = worldserver1.getChunkSource().chunkMap;
|
+ net.minecraft.server.level.ChunkMap playerChunkMap = worldserver1.getChunkSource().chunkMap;
|
||||||
+ net.minecraft.server.level.DistanceManager distanceManager = playerChunkMap.distanceManager;
|
+ net.minecraft.server.level.DistanceManager distanceManager = playerChunkMap.distanceManager;
|
||||||
+ net.minecraft.server.ChunkSystem.scheduleTickingState(
|
+ io.papermc.paper.chunk.system.ChunkSystem.scheduleTickingState(
|
||||||
+ worldserver1, chunkX, chunkZ, net.minecraft.server.level.ChunkHolder.FullChunkStatus.ENTITY_TICKING, true,
|
+ worldserver1, chunkX, chunkZ, net.minecraft.server.level.ChunkHolder.FullChunkStatus.ENTITY_TICKING, true,
|
||||||
+ ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGHEST,
|
+ ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGHEST,
|
||||||
+ (chunk) -> {
|
+ (chunk) -> {
|
||||||
|
|
|
@ -421,7 +421,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
@@ -0,0 +0,0 @@
|
@@ -0,0 +0,0 @@
|
||||||
+package com.destroystokyo.paper.loottable;
|
+package com.destroystokyo.paper.loottable;
|
||||||
+
|
+
|
||||||
+import net.minecraft.server.MCUtil;
|
+import io.papermc.paper.util.MCUtil;
|
||||||
+import net.minecraft.world.level.Level;
|
+import net.minecraft.world.level.Level;
|
||||||
+import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
+import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||||
+import org.bukkit.Bukkit;
|
+import org.bukkit.Bukkit;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -240,14 +240,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ return net.minecraft.server.MCUtil.toLocation(this.getHandle().getLevel(), pos);
|
+ return io.papermc.paper.util.MCUtil.toLocation(this.getHandle().getLevel(), pos);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void setTargetLocation(org.bukkit.Location location) {
|
+ public void setTargetLocation(org.bukkit.Location location) {
|
||||||
+ net.minecraft.core.BlockPos pos = null;
|
+ net.minecraft.core.BlockPos pos = null;
|
||||||
+ if (location != null) {
|
+ if (location != null) {
|
||||||
+ pos = net.minecraft.server.MCUtil.toBlockPosition(location);
|
+ pos = io.papermc.paper.util.MCUtil.toBlockPosition(location);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ this.getHandle().targetPosition = pos;
|
+ this.getHandle().targetPosition = pos;
|
||||||
|
@ -678,14 +678,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ return net.minecraft.server.MCUtil.toLocation(this.getHandle().getLevel(), pos);
|
+ return io.papermc.paper.util.MCUtil.toLocation(this.getHandle().getLevel(), pos);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void setAnchorLocation(org.bukkit.Location location) {
|
+ public void setAnchorLocation(org.bukkit.Location location) {
|
||||||
+ net.minecraft.core.BlockPos pos = null;
|
+ net.minecraft.core.BlockPos pos = null;
|
||||||
+ if (location != null) {
|
+ if (location != null) {
|
||||||
+ pos = net.minecraft.server.MCUtil.toBlockPosition(location);
|
+ pos = io.papermc.paper.util.MCUtil.toBlockPosition(location);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ this.getHandle().anchorPoint = pos;
|
+ this.getHandle().anchorPoint = pos;
|
||||||
|
@ -899,14 +899,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ return net.minecraft.server.MCUtil.toLocation(this.getHandle().getLevel(), pos);
|
+ return io.papermc.paper.util.MCUtil.toLocation(this.getHandle().getLevel(), pos);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void setWanderingTowards(org.bukkit.Location location) {
|
+ public void setWanderingTowards(org.bukkit.Location location) {
|
||||||
+ net.minecraft.core.BlockPos pos = null;
|
+ net.minecraft.core.BlockPos pos = null;
|
||||||
+ if (location != null) {
|
+ if (location != null) {
|
||||||
+ pos = net.minecraft.server.MCUtil.toBlockPosition(location);
|
+ pos = io.papermc.paper.util.MCUtil.toBlockPosition(location);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ this.getHandle().wanderTarget = pos;
|
+ this.getHandle().wanderTarget = pos;
|
||||||
|
|
|
@ -56,7 +56,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
// Paper start - distance maps
|
// Paper start - distance maps
|
||||||
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
|
private final com.destroystokyo.paper.util.misc.PooledLinkedHashSets<ServerPlayer> pooledLinkedPlayerHashSets = new com.destroystokyo.paper.util.misc.PooledLinkedHashSets<>();
|
||||||
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
trackMap.add(player, chunkX, chunkZ, Math.min(trackRange, net.minecraft.server.ChunkSystem.getSendViewDistance(player)));
|
trackMap.add(player, chunkX, chunkZ, Math.min(trackRange, io.papermc.paper.chunk.system.ChunkSystem.getSendViewDistance(player)));
|
||||||
}
|
}
|
||||||
// Paper end - use distance map to optimise entity tracker
|
// Paper end - use distance map to optimise entity tracker
|
||||||
+ this.playerGeneralAreaMap.add(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn
|
+ this.playerGeneralAreaMap.add(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn
|
||||||
|
@ -72,7 +72,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
if (this.playerMobDistanceMap != null) {
|
if (this.playerMobDistanceMap != null) {
|
||||||
this.playerMobDistanceMap.remove(player);
|
this.playerMobDistanceMap.remove(player);
|
||||||
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, net.minecraft.server.ChunkSystem.getSendViewDistance(player)));
|
trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, io.papermc.paper.chunk.system.ChunkSystem.getSendViewDistance(player)));
|
||||||
}
|
}
|
||||||
// Paper end - use distance map to optimise entity tracker
|
// Paper end - use distance map to optimise entity tracker
|
||||||
+ this.playerGeneralAreaMap.update(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn
|
+ this.playerGeneralAreaMap.update(player, chunkX, chunkZ, GENERAL_AREA_MAP_SQUARE_RADIUS); // Paper - optimise checkDespawn
|
||||||
|
|
|
@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
+ // Paper start - ensure we don't load chunks
|
+ // Paper start - ensure we don't load chunks
|
||||||
+ final @Nullable Entity source = this.context instanceof net.minecraft.world.phys.shapes.EntityCollisionContext entityContext ? entityContext.getEntity() : null;
|
+ final @Nullable Entity source = this.context instanceof net.minecraft.world.phys.shapes.EntityCollisionContext entityContext ? entityContext.getEntity() : null;
|
||||||
+ boolean far = source != null && net.minecraft.server.MCUtil.distanceSq(source.getX(), y, source.getZ(), x, y, z) > 14;
|
+ boolean far = source != null && io.papermc.paper.util.MCUtil.distanceSq(source.getX(), y, source.getZ(), x, y, z) > 14;
|
||||||
+ this.pos.set(x, y, z);
|
+ this.pos.set(x, y, z);
|
||||||
|
|
||||||
- BlockGetter blockGetter = this.getChunk(i, k);
|
- BlockGetter blockGetter = this.getChunk(i, k);
|
||||||
|
|
|
@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+ packet.onPacketDispatch(getPlayer());
|
+ packet.onPacketDispatch(getPlayer());
|
||||||
+ if (connected && (InnerUtil.canSendImmediate(this, packet) || (
|
+ if (connected && (InnerUtil.canSendImmediate(this, packet) || (
|
||||||
+ net.minecraft.server.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
|
+ io.papermc.paper.util.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
|
||||||
+ (packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
|
+ (packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
|
||||||
+ ))) {
|
+ ))) {
|
||||||
this.sendPacket(packet, callbacks);
|
this.sendPacket(packet, callbacks);
|
||||||
|
@ -194,7 +194,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ if (!isConnected()) {
|
+ if (!isConnected()) {
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
+ if (net.minecraft.server.MCUtil.isMainThread()) {
|
+ if (io.papermc.paper.util.MCUtil.isMainThread()) {
|
||||||
+ return processQueue();
|
+ return processQueue();
|
||||||
+ } else if (isPending) {
|
+ } else if (isPending) {
|
||||||
+ // Should only happen during login/status stages
|
+ // Should only happen during login/status stages
|
||||||
|
|
|
@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
public void onChunkAdd() {
|
public void onChunkAdd() {
|
||||||
-
|
-
|
||||||
+ // Paper start - optimise anyPlayerCloseEnoughForSpawning
|
+ // Paper start - optimise anyPlayerCloseEnoughForSpawning
|
||||||
+ long key = net.minecraft.server.MCUtil.getCoordinateKey(this.pos);
|
+ long key = io.papermc.paper.util.MCUtil.getCoordinateKey(this.pos);
|
||||||
+ this.playersInMobSpawnRange = this.chunkMap.playerMobSpawnMap.getObjectsInRange(key);
|
+ this.playersInMobSpawnRange = this.chunkMap.playerMobSpawnMap.getObjectsInRange(key);
|
||||||
+ this.playersInChunkTickRange = this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(key);
|
+ this.playersInChunkTickRange = this.chunkMap.playerChunkTickRangeMap.getObjectsInRange(key);
|
||||||
+ // Paper end - optimise anyPlayerCloseEnoughForSpawning
|
+ // Paper end - optimise anyPlayerCloseEnoughForSpawning
|
||||||
|
@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
|
+ this.playerChunkTickRangeMap.add(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
|
||||||
// Paper start - per player mob spawning
|
// Paper start - per player mob spawning
|
||||||
if (this.playerMobDistanceMap != null) {
|
if (this.playerMobDistanceMap != null) {
|
||||||
this.playerMobDistanceMap.add(player, chunkX, chunkZ, net.minecraft.server.ChunkSystem.getTickViewDistance(player));
|
this.playerMobDistanceMap.add(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
|
||||||
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
void removePlayerFromDistanceMaps(ServerPlayer player) {
|
void removePlayerFromDistanceMaps(ServerPlayer player) {
|
||||||
this.playerChunkManager.removePlayer(player); // Paper - replace chunk loader
|
this.playerChunkManager.removePlayer(player); // Paper - replace chunk loader
|
||||||
|
@ -88,7 +88,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
|
+ this.playerChunkTickRangeMap.update(player, chunkX, chunkZ, DistanceManager.MOB_SPAWN_RANGE); // Paper - optimise ChunkMap#anyPlayerCloseEnoughForSpawning
|
||||||
// Paper start - per player mob spawning
|
// Paper start - per player mob spawning
|
||||||
if (this.playerMobDistanceMap != null) {
|
if (this.playerMobDistanceMap != null) {
|
||||||
this.playerMobDistanceMap.update(player, chunkX, chunkZ, net.minecraft.server.ChunkSystem.getTickViewDistance(player));
|
this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
|
||||||
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
this.regionManagers.add(this.dataRegionManager);
|
this.regionManagers.add(this.dataRegionManager);
|
||||||
// Paper end
|
// Paper end
|
||||||
|
@ -292,8 +292,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ int range = Math.min(event.getSpawnRadius(), 32); // limit to max view distance
|
+ int range = Math.min(event.getSpawnRadius(), 32); // limit to max view distance
|
||||||
+ int chunkX = net.minecraft.server.MCUtil.getChunkCoordinate(player.getX());
|
+ int chunkX = io.papermc.paper.util.MCUtil.getChunkCoordinate(player.getX());
|
||||||
+ int chunkZ = net.minecraft.server.MCUtil.getChunkCoordinate(player.getZ());
|
+ int chunkZ = io.papermc.paper.util.MCUtil.getChunkCoordinate(player.getZ());
|
||||||
+
|
+
|
||||||
+ playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range);
|
+ playerChunkMap.playerMobSpawnMap.addOrUpdate(player, chunkX, chunkZ, range);
|
||||||
+ player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in anyPlayerCloseEnoughForSpawning
|
+ player.lastEntitySpawnRadiusSquared = (double)((range << 4) * (range << 4)); // used in anyPlayerCloseEnoughForSpawning
|
||||||
|
|
|
@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||||
+import net.minecraft.server.MCUtil;
|
+import io.papermc.paper.util.MCUtil;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
|
|
@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
||||||
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
||||||
+ net.minecraft.server.MCUtil.toLocation(worldserver, blockposition),
|
+ io.papermc.paper.util.MCUtil.toLocation(worldserver, blockposition),
|
||||||
+ type,
|
+ type,
|
||||||
+ reason
|
+ reason
|
||||||
+ );
|
+ );
|
||||||
|
@ -71,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ if (type != null) {
|
+ if (type != null) {
|
||||||
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
||||||
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
||||||
+ net.minecraft.server.MCUtil.toLocation(worldserver, blockposition),
|
+ io.papermc.paper.util.MCUtil.toLocation(worldserver, blockposition),
|
||||||
+ type,
|
+ type,
|
||||||
+ spawnReason
|
+ spawnReason
|
||||||
+ );
|
+ );
|
||||||
|
@ -112,7 +112,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ if (type != null) {
|
+ if (type != null) {
|
||||||
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
||||||
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
||||||
+ net.minecraft.server.MCUtil.toLocation(world, d0, d1, d2),
|
+ io.papermc.paper.util.MCUtil.toLocation(world, d0, d1, d2),
|
||||||
+ type,
|
+ type,
|
||||||
+ org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER
|
+ org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER
|
||||||
+ );
|
+ );
|
||||||
|
@ -160,7 +160,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(EntityType.getKey(entitytypes).getPath());
|
+ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(EntityType.getKey(entitytypes).getPath());
|
||||||
+ if (type != null) {
|
+ if (type != null) {
|
||||||
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
||||||
+ net.minecraft.server.MCUtil.toLocation(world, pos),
|
+ io.papermc.paper.util.MCUtil.toLocation(world, pos),
|
||||||
+ type, SpawnReason.NATURAL
|
+ type, SpawnReason.NATURAL
|
||||||
+ );
|
+ );
|
||||||
+ if (!event.callEvent()) {
|
+ if (!event.callEvent()) {
|
||||||
|
|
|
@ -20,10 +20,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
- event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
||||||
+ com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent event;
|
+ com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent event;
|
||||||
+ event = new com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent(
|
+ event = new com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent(
|
||||||
net.minecraft.server.MCUtil.toLocation(world, d0, d1, d2),
|
io.papermc.paper.util.MCUtil.toLocation(world, d0, d1, d2),
|
||||||
type,
|
type,
|
||||||
- org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER
|
- org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER
|
||||||
+ net.minecraft.server.MCUtil.toLocation(world, pos)
|
+ io.papermc.paper.util.MCUtil.toLocation(world, pos)
|
||||||
);
|
);
|
||||||
if (!event.callEvent()) {
|
if (!event.callEvent()) {
|
||||||
flag = true;
|
flag = true;
|
||||||
|
|
|
@ -22,6 +22,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
for (BlockPos possibleTarget : positions) {
|
for (BlockPos possibleTarget : positions) {
|
||||||
- if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(),
|
- if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(),
|
||||||
+ if (!this.mob.getCommandSenderWorld().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border
|
+ if (!this.mob.getCommandSenderWorld().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border
|
||||||
net.minecraft.server.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
|
io.papermc.paper.util.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
|
||||||
if (!copiedSet) {
|
if (!copiedSet) {
|
||||||
copiedSet = true;
|
copiedSet = true;
|
||||||
|
|
|
@ -33,7 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ boolean isOp = this.ops.contains(gameprofile);
|
+ boolean isOp = this.ops.contains(gameprofile);
|
||||||
+ boolean isWhitelisted = !this.doWhiteList || isOp || this.whitelist.contains(gameprofile);
|
+ boolean isWhitelisted = !this.doWhiteList || isOp || this.whitelist.contains(gameprofile);
|
||||||
+ final com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent event;
|
+ final com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent event;
|
||||||
+ event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(net.minecraft.server.MCUtil.toBukkit(gameprofile), this.doWhiteList, isWhitelisted, isOp, org.spigotmc.SpigotConfig.whitelistMessage);
|
+ event = new com.destroystokyo.paper.event.profile.ProfileWhitelistVerifyEvent(io.papermc.paper.util.MCUtil.toBukkit(gameprofile), this.doWhiteList, isWhitelisted, isOp, org.spigotmc.SpigotConfig.whitelistMessage);
|
||||||
+ event.callEvent();
|
+ event.callEvent();
|
||||||
+ if (!event.isWhitelisted()) {
|
+ if (!event.isWhitelisted()) {
|
||||||
+ if (loginEvent != null) {
|
+ if (loginEvent != null) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ public int getTileEntityCount() {
|
+ public int getTileEntityCount() {
|
||||||
+ // We don't use the full world tile entity list, so we must iterate chunks
|
+ // We don't use the full world tile entity list, so we must iterate chunks
|
||||||
+ int size = 0;
|
+ int size = 0;
|
||||||
+ for (ChunkHolder playerchunk : net.minecraft.server.ChunkSystem.getVisibleChunkHolders(this.world)) {
|
+ for (ChunkHolder playerchunk : io.papermc.paper.chunk.system.ChunkSystem.getVisibleChunkHolders(this.world)) {
|
||||||
+ net.minecraft.world.level.chunk.LevelChunk chunk = playerchunk.getTickingChunk();
|
+ net.minecraft.world.level.chunk.LevelChunk chunk = playerchunk.getTickingChunk();
|
||||||
+ if (chunk == null) {
|
+ if (chunk == null) {
|
||||||
+ continue;
|
+ continue;
|
||||||
|
@ -62,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ public int getChunkCount() {
|
+ public int getChunkCount() {
|
||||||
+ int ret = 0;
|
+ int ret = 0;
|
||||||
+
|
+
|
||||||
+ for (ChunkHolder chunkHolder : net.minecraft.server.ChunkSystem.getVisibleChunkHolders(this.world)) {
|
+ for (ChunkHolder chunkHolder : io.papermc.paper.chunk.system.ChunkSystem.getVisibleChunkHolders(this.world)) {
|
||||||
+ if (chunkHolder.getTickingChunk() != null) {
|
+ if (chunkHolder.getTickingChunk() != null) {
|
||||||
+ ++ret;
|
+ ++ret;
|
||||||
+ }
|
+ }
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4357,7 +4357,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+import io.papermc.paper.command.PaperSubcommand;
|
+import io.papermc.paper.command.PaperSubcommand;
|
||||||
+import java.util.ArrayDeque;
|
+import java.util.ArrayDeque;
|
||||||
+import java.util.Deque;
|
+import java.util.Deque;
|
||||||
+import net.minecraft.server.MCUtil;
|
+import io.papermc.paper.util.MCUtil;
|
||||||
+import net.minecraft.server.MinecraftServer;
|
+import net.minecraft.server.MinecraftServer;
|
||||||
+import net.minecraft.server.level.ChunkHolder;
|
+import net.minecraft.server.level.ChunkHolder;
|
||||||
+import net.minecraft.server.level.ServerLevel;
|
+import net.minecraft.server.level.ServerLevel;
|
||||||
|
@ -4581,7 +4581,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+
|
+
|
||||||
+ final Long id = Long.valueOf(this.relightCounter++);
|
+ final Long id = Long.valueOf(this.relightCounter++);
|
||||||
+
|
+
|
||||||
+ ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().addTicketAtLevel(TicketType.CHUNK_RELIGHT, chunkPos, net.minecraft.server.MCUtil.getTicketLevelFor(ChunkStatus.LIGHT), id);
|
+ ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().addTicketAtLevel(TicketType.CHUNK_RELIGHT, chunkPos, io.papermc.paper.util.MCUtil.getTicketLevelFor(ChunkStatus.LIGHT), id);
|
||||||
+ ticketIds.put(chunkPos, id);
|
+ ticketIds.put(chunkPos, id);
|
||||||
+
|
+
|
||||||
+ ++totalChunks;
|
+ ++totalChunks;
|
||||||
|
@ -4592,7 +4592,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ chunkLightCallback.accept(chunkPos);
|
+ chunkLightCallback.accept(chunkPos);
|
||||||
+ ((java.util.concurrent.Executor)((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().mainThreadProcessor).execute(() -> {
|
+ ((java.util.concurrent.Executor)((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().mainThreadProcessor).execute(() -> {
|
||||||
+ ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().chunkMap.getUpdatingChunkIfPresent(chunkPos.toLong()).broadcast(new net.minecraft.network.protocol.game.ClientboundLightUpdatePacket(chunkPos, ThreadedLevelLightEngine.this, null, null, true), false);
|
+ ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().chunkMap.getUpdatingChunkIfPresent(chunkPos.toLong()).broadcast(new net.minecraft.network.protocol.game.ClientboundLightUpdatePacket(chunkPos, ThreadedLevelLightEngine.this, null, null, true), false);
|
||||||
+ ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().removeTicketAtLevel(TicketType.CHUNK_RELIGHT, chunkPos, net.minecraft.server.MCUtil.getTicketLevelFor(ChunkStatus.LIGHT), ticketIds.get(chunkPos));
|
+ ((ServerLevel)this.theLightEngine.getWorld()).getChunkSource().removeTicketAtLevel(TicketType.CHUNK_RELIGHT, chunkPos, io.papermc.paper.util.MCUtil.getTicketLevelFor(ChunkStatus.LIGHT), ticketIds.get(chunkPos));
|
||||||
+ });
|
+ });
|
||||||
+ }, onComplete);
|
+ }, onComplete);
|
||||||
+ });
|
+ });
|
||||||
|
|
|
@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
if (!this.turtle.isInWater() && this.isReachedTarget()) {
|
if (!this.turtle.isInWater() && this.isReachedTarget()) {
|
||||||
if (this.turtle.layEggCounter < 1) {
|
if (this.turtle.layEggCounter < 1) {
|
||||||
- this.turtle.setLayingEgg(true);
|
- this.turtle.setLayingEgg(true);
|
||||||
+ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), net.minecraft.server.MCUtil.toLocation(this.turtle.level, this.getTargetPosition())).callEvent()); // Paper
|
+ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), io.papermc.paper.util.MCUtil.toLocation(this.turtle.level, this.getTargetPosition())).callEvent()); // Paper
|
||||||
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
|
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
|
||||||
Level world = this.turtle.level;
|
Level world = this.turtle.level;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1)).isCancelled()) {
|
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1)).isCancelled()) {
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ int eggCount = this.turtle.random.nextInt(4) + 1;
|
+ int eggCount = this.turtle.random.nextInt(4) + 1;
|
||||||
+ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), net.minecraft.server.MCUtil.toLocation(this.turtle.level, this.blockPos.above()), eggCount);
|
+ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), io.papermc.paper.util.MCUtil.toLocation(this.turtle.level, this.blockPos.above()), eggCount);
|
||||||
+ if (layEggEvent.callEvent() && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount())).isCancelled()) {
|
+ if (layEggEvent.callEvent() && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount())).isCancelled()) {
|
||||||
world.playSound((Player) null, blockposition, SoundEvents.TURTLE_LAY_EGG, SoundSource.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
|
world.playSound((Player) null, blockposition, SoundEvents.TURTLE_LAY_EGG, SoundSource.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
|
||||||
- world.setBlock(this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1), 3);
|
- world.setBlock(this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1), 3);
|
||||||
|
@ -63,12 +63,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public org.bukkit.Location getHome() {
|
+ public org.bukkit.Location getHome() {
|
||||||
+ return net.minecraft.server.MCUtil.toLocation(getHandle().getLevel(), getHandle().getHomePos());
|
+ return io.papermc.paper.util.MCUtil.toLocation(getHandle().getLevel(), getHandle().getHomePos());
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void setHome(org.bukkit.Location location) {
|
+ public void setHome(org.bukkit.Location location) {
|
||||||
+ getHandle().setHomePos(net.minecraft.server.MCUtil.toBlockPosition(location));
|
+ getHandle().setHomePos(io.papermc.paper.util.MCUtil.toBlockPosition(location));
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
|
|
@ -12,7 +12,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket;
|
@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket;
|
||||||
import net.minecraft.network.protocol.game.ClientboundSetPassengersPacket;
|
import net.minecraft.network.protocol.game.ClientboundSetPassengersPacket;
|
||||||
import net.minecraft.network.protocol.game.DebugPackets;
|
import net.minecraft.network.protocol.game.DebugPackets;
|
||||||
import net.minecraft.server.MCUtil;
|
import io.papermc.paper.util.MCUtil;
|
||||||
+import net.minecraft.server.MinecraftServer;
|
+import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||||
import net.minecraft.server.network.ServerPlayerConnection;
|
import net.minecraft.server.network.ServerPlayerConnection;
|
||||||
|
@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
void addPlayerToDistanceMaps(ServerPlayer player) {
|
void addPlayerToDistanceMaps(ServerPlayer player) {
|
||||||
this.playerChunkManager.addPlayer(player); // Paper - replace chunk loader
|
this.playerChunkManager.addPlayer(player); // Paper - replace chunk loader
|
||||||
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
this.playerMobDistanceMap.add(player, chunkX, chunkZ, net.minecraft.server.ChunkSystem.getTickViewDistance(player));
|
this.playerMobDistanceMap.add(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
|
||||||
}
|
}
|
||||||
// Paper end - per player mob spawning
|
// Paper end - per player mob spawning
|
||||||
+ // Paper start - use distance map to optimise entity tracker
|
+ // Paper start - use distance map to optimise entity tracker
|
||||||
|
@ -50,7 +50,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ com.destroystokyo.paper.util.misc.PlayerAreaMap trackMap = this.playerEntityTrackerTrackMaps[i];
|
+ com.destroystokyo.paper.util.misc.PlayerAreaMap trackMap = this.playerEntityTrackerTrackMaps[i];
|
||||||
+ int trackRange = this.entityTrackerTrackRanges[i];
|
+ int trackRange = this.entityTrackerTrackRanges[i];
|
||||||
+
|
+
|
||||||
+ trackMap.add(player, chunkX, chunkZ, Math.min(trackRange, net.minecraft.server.ChunkSystem.getSendViewDistance(player)));
|
+ trackMap.add(player, chunkX, chunkZ, Math.min(trackRange, io.papermc.paper.chunk.system.ChunkSystem.getSendViewDistance(player)));
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - use distance map to optimise entity tracker
|
+ // Paper end - use distance map to optimise entity tracker
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
|
|
||||||
void updateMaps(ServerPlayer player) {
|
void updateMaps(ServerPlayer player) {
|
||||||
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
@@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||||
this.playerMobDistanceMap.update(player, chunkX, chunkZ, net.minecraft.server.ChunkSystem.getTickViewDistance(player));
|
this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
|
||||||
}
|
}
|
||||||
// Paper end - per player mob spawning
|
// Paper end - per player mob spawning
|
||||||
+ // Paper start - use distance map to optimise entity tracker
|
+ // Paper start - use distance map to optimise entity tracker
|
||||||
|
@ -77,7 +77,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ com.destroystokyo.paper.util.misc.PlayerAreaMap trackMap = this.playerEntityTrackerTrackMaps[i];
|
+ com.destroystokyo.paper.util.misc.PlayerAreaMap trackMap = this.playerEntityTrackerTrackMaps[i];
|
||||||
+ int trackRange = this.entityTrackerTrackRanges[i];
|
+ int trackRange = this.entityTrackerTrackRanges[i];
|
||||||
+
|
+
|
||||||
+ trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, net.minecraft.server.ChunkSystem.getSendViewDistance(player)));
|
+ trackMap.update(player, chunkX, chunkZ, Math.min(trackRange, io.papermc.paper.chunk.system.ChunkSystem.getSendViewDistance(player)));
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - use distance map to optimise entity tracker
|
+ // Paper end - use distance map to optimise entity tracker
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
import net.minecraft.network.syncher.SynchedEntityData;
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
+import net.minecraft.server.MCUtil;
|
+import io.papermc.paper.util.MCUtil;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
|
|
@ -269,7 +269,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
// Note: players need to be explicitly added to distance maps before they can be updated
|
// Note: players need to be explicitly added to distance maps before they can be updated
|
||||||
+ // Paper start - per player mob spawning
|
+ // Paper start - per player mob spawning
|
||||||
+ if (this.playerMobDistanceMap != null) {
|
+ if (this.playerMobDistanceMap != null) {
|
||||||
+ this.playerMobDistanceMap.add(player, chunkX, chunkZ, net.minecraft.server.ChunkSystem.getTickViewDistance(player));
|
+ this.playerMobDistanceMap.add(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - per player mob spawning
|
+ // Paper end - per player mob spawning
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
this.playerChunkManager.updatePlayer(player); // Paper - replace chunk loader
|
this.playerChunkManager.updatePlayer(player); // Paper - replace chunk loader
|
||||||
+ // Paper start - per player mob spawning
|
+ // Paper start - per player mob spawning
|
||||||
+ if (this.playerMobDistanceMap != null) {
|
+ if (this.playerMobDistanceMap != null) {
|
||||||
+ this.playerMobDistanceMap.update(player, chunkX, chunkZ, net.minecraft.server.ChunkSystem.getTickViewDistance(player));
|
+ this.playerMobDistanceMap.update(player, chunkX, chunkZ, io.papermc.paper.chunk.system.ChunkSystem.getTickViewDistance(player));
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - per player mob spawning
|
+ // Paper end - per player mob spawning
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public void saveAll(int interval) {
|
+ public void saveAll(int interval) {
|
||||||
net.minecraft.server.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main
|
io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main
|
||||||
MinecraftTimings.savePlayers.startTiming(); // Paper
|
MinecraftTimings.savePlayers.startTiming(); // Paper
|
||||||
+ int numSaved = 0;
|
+ int numSaved = 0;
|
||||||
+ long now = MinecraftServer.currentTick;
|
+ long now = MinecraftServer.currentTick;
|
||||||
|
|
Loading…
Reference in a new issue