diff options
author | Spottedleaf <[email protected]> | 2022-09-26 01:02:51 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-26 01:02:51 -0700 |
commit | 01a13871deefa50e186a10b63f71c5e0459e7d30 (patch) | |
tree | caf7056fa3ad155645b2dec6046b13841eb5d4a2 /patches/server/0214-RangedEntity-API.patch | |
parent | abe53a7eb477664aba5f32ff22d81f11ed48a44d (diff) | |
download | Paper-01a13871deefa50e186a10b63f71c5e0459e7d30.tar.gz Paper-01a13871deefa50e186a10b63f71c5e0459e7d30.zip |
Rewrite chunk system (#8177)
Patch documentation to come
Issues with the old system that are fixed now:
- World generation does not scale with cpu cores effectively.
- Relies on the main thread for scheduling and maintaining chunk state, dropping chunk load/generate rates at lower tps.
- Unreliable prioritisation of chunk gen/load calls that block the main thread.
- Shutdown logic is utterly unreliable, as it has to wait for all chunks to unload - is it guaranteed that the chunk system is in a state on shutdown that it can reliably do this? Watchdog shutdown also typically failed due to thread checks, which is now resolved.
- Saving of data is not unified (i.e can save chunk data without saving entity data, poses problems for desync if shutdown is really abnormal.
- Entities are not loaded with chunks. This caused quite a bit of headache for Chunk#getEntities API, but now the new chunk system loads entities with chunks so that they are ready whenever the chunk loads in. Effectively brings the behavior back to 1.16 era, but still storing entities in their own separate regionfiles.
The above list is not complete. The patch documentation will complete it.
New chunk system hard relies on starlight and dataconverter, and most importantly the new concurrent utilities in ConcurrentUtil.
Some of the old async chunk i/o interface (i.e the old file io thread reroutes _some_ calls to the new file io thread) is kept for plugin compat reasons. It will be removed in the next major version of minecraft.
The old legacy chunk system patches have been moved to the removed folder in case we need them again.
Diffstat (limited to 'patches/server/0214-RangedEntity-API.patch')
-rw-r--r-- | patches/server/0214-RangedEntity-API.patch | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/patches/server/0214-RangedEntity-API.patch b/patches/server/0214-RangedEntity-API.patch new file mode 100644 index 0000000000..94da937638 --- /dev/null +++ b/patches/server/0214-RangedEntity-API.patch @@ -0,0 +1,162 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar <[email protected]> +Date: Tue, 26 Jun 2018 22:00:49 -0400 +Subject: [PATCH] RangedEntity API + +Allows you to determine if an entity is capable of ranged attacks, +and to perform an attack. + +diff --git a/src/main/java/com/destroystokyo/paper/entity/CraftRangedEntity.java b/src/main/java/com/destroystokyo/paper/entity/CraftRangedEntity.java +new file mode 100644 +index 0000000000000000000000000000000000000000..d7a8eb1b8f24ed2741ae9dae62d3f6146f273e1d +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/entity/CraftRangedEntity.java +@@ -0,0 +1,20 @@ ++package com.destroystokyo.paper.entity; ++ ++import net.minecraft.world.entity.Mob; ++import net.minecraft.world.entity.monster.RangedAttackMob; ++import org.bukkit.craftbukkit.entity.CraftLivingEntity; ++import org.bukkit.entity.LivingEntity; ++ ++public interface CraftRangedEntity<T extends Mob & RangedAttackMob> extends RangedEntity { ++ T getHandle(); ++ ++ @Override ++ default void rangedAttack(LivingEntity target, float charge) { ++ getHandle().performRangedAttack(((CraftLivingEntity) target).getHandle(), charge); ++ } ++ ++ @Override ++ default void setChargingAttack(boolean raiseHands) { ++ getHandle().setAggressive(raiseHands); ++ } ++} +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java +index db6ad6eea8fa6f2755bbb0e1325df8bda98e708a..5ff566186431440c25a26900aba14e4adb642031 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java +@@ -4,7 +4,7 @@ import org.bukkit.craftbukkit.CraftServer; + import org.bukkit.entity.AbstractSkeleton; + import org.bukkit.entity.Skeleton; + +-public abstract class CraftAbstractSkeleton extends CraftMonster implements AbstractSkeleton { ++public abstract class CraftAbstractSkeleton extends CraftMonster implements AbstractSkeleton, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.AbstractSkeleton> { // Paper + + public CraftAbstractSkeleton(CraftServer server, net.minecraft.world.entity.monster.AbstractSkeleton entity) { + super(server, entity); +@@ -14,4 +14,10 @@ public abstract class CraftAbstractSkeleton extends CraftMonster implements Abst + public void setSkeletonType(Skeleton.SkeletonType type) { + throw new UnsupportedOperationException("Not supported."); + } ++ // Paper start ++ @Override ++ public net.minecraft.world.entity.monster.AbstractSkeleton getHandle() { ++ return (net.minecraft.world.entity.monster.AbstractSkeleton) super.getHandle(); ++ } ++ // Paper end + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java +index 34cb8062168258bfd168826ceeb2fde669f6d1a8..03e2acd4829da449a471b0fa1a311e74aee114d3 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java +@@ -4,7 +4,7 @@ import org.bukkit.craftbukkit.CraftServer; + import org.bukkit.entity.Drowned; + import org.bukkit.entity.EntityType; + +-public class CraftDrowned extends CraftZombie implements Drowned { ++public class CraftDrowned extends CraftZombie implements Drowned, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.Drowned> { // Paper + + public CraftDrowned(CraftServer server, net.minecraft.world.entity.monster.Drowned entity) { + super(server, entity); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java +index 59b866e54e0d7e1dd8815ffa85275e36271113da..bbf7189a0fc9921e7a6007494f91229d9fba0846 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java +@@ -4,7 +4,7 @@ import org.bukkit.craftbukkit.CraftServer; + import org.bukkit.entity.EntityType; + import org.bukkit.entity.Illusioner; + +-public class CraftIllusioner extends CraftSpellcaster implements Illusioner { ++public class CraftIllusioner extends CraftSpellcaster implements Illusioner, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.Illusioner> { // Paper + + public CraftIllusioner(CraftServer server, net.minecraft.world.entity.monster.Illusioner entity) { + super(server, entity); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +index 140a5e916b36bd6eeee5b1b636e950a49c421bfa..ae05f526f9ec70a2992ef3ee66b7f57eca2351fc 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +@@ -9,7 +9,7 @@ import org.bukkit.entity.Llama; + import org.bukkit.entity.Llama.Color; + import org.bukkit.inventory.LlamaInventory; + +-public class CraftLlama extends CraftChestedHorse implements Llama { ++public class CraftLlama extends CraftChestedHorse implements Llama, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.animal.horse.Llama> { // Paper + + public CraftLlama(CraftServer server, net.minecraft.world.entity.animal.horse.Llama entity) { + super(server, entity); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +index 27763d1eca832abda76c8b3c22595cbaf9b1fe45..aeda5fc001fe4ce55ee467240b275b6050a29f98 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +@@ -13,7 +13,7 @@ import org.bukkit.entity.EntityType; + import org.bukkit.entity.Piglin; + import org.bukkit.inventory.Inventory; + +-public class CraftPiglin extends CraftPiglinAbstract implements Piglin { ++public class CraftPiglin extends CraftPiglinAbstract implements Piglin, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.piglin.Piglin> { // Paper + + public CraftPiglin(CraftServer server, net.minecraft.world.entity.monster.piglin.Piglin entity) { + super(server, entity); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java +index 06786fba1fef36e8fc3d0f5650160123f728a6d1..beea227855f0b978e655efc298024120df8f4945 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java +@@ -6,7 +6,7 @@ import org.bukkit.entity.EntityType; + import org.bukkit.entity.Pillager; + import org.bukkit.inventory.Inventory; + +-public class CraftPillager extends CraftIllager implements Pillager { ++public class CraftPillager extends CraftIllager implements Pillager, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.Pillager> { // Paper + + public CraftPillager(CraftServer server, net.minecraft.world.entity.monster.Pillager entity) { + super(server, entity); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +index 6a82d567d96a42bfea0e38afb4e8de13eb3ad5a2..659e2959c5330e4764ea1edc7f8de9f464f9ff52 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java +@@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.CraftServer; + import org.bukkit.entity.EntityType; + import org.bukkit.entity.Snowman; + +-public class CraftSnowman extends CraftGolem implements Snowman { ++public class CraftSnowman extends CraftGolem implements Snowman, com.destroystokyo.paper.entity.CraftRangedEntity<SnowGolem> { // Paper + public CraftSnowman(CraftServer server, SnowGolem entity) { + super(server, entity); + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java +index 5fbb06e28d5c797cfb6859ce7ef05ba00949f690..eada1f0ff10d4c00f82a6f4411fe18b7184e9901 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java +@@ -4,7 +4,7 @@ import org.bukkit.craftbukkit.CraftServer; + import org.bukkit.entity.EntityType; + import org.bukkit.entity.Witch; + +-public class CraftWitch extends CraftRaider implements Witch { ++public class CraftWitch extends CraftRaider implements Witch, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.Witch> { // Paper + public CraftWitch(CraftServer server, net.minecraft.world.entity.monster.Witch entity) { + super(server, entity); + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +index 5f78b7ac2313cb8fe9ce835c0317217810a6b023..e92355fa2042c4cf15354a11b7058cacbe996f0d 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +@@ -10,7 +10,7 @@ import org.bukkit.entity.EntityType; + import org.bukkit.entity.LivingEntity; + import org.bukkit.entity.Wither; + +-public class CraftWither extends CraftMonster implements Wither { ++public class CraftWither extends CraftMonster implements Wither, com.destroystokyo.paper.entity.CraftRangedEntity<WitherBoss> { // Paper + + private BossBar bossBar; + |