Skip to content

Commit

Permalink
Treat blocks as full when moving fast
Browse files Browse the repository at this point in the history
  • Loading branch information
Samsuik committed Nov 26, 2023
1 parent 3717d95 commit 5a6a5aa
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 50 deletions.
9 changes: 7 additions & 2 deletions patches/server/0004-Sakura-Configuration-Files.patch
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,10 @@ index 0000000000000000000000000000000000000000..5fc23a0b579d7cbe03baf5324bef887a
+}
diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..4c8e90dbfa8c3d6d211dc8890f7dfcc52667a180
index 0000000000000000000000000000000000000000..270ff55bc37e581be66e843cd8fe2a91b0d66d09
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
@@ -0,0 +1,152 @@
@@ -0,0 +1,157 @@
+package me.samsuik.sakura.configuration;
+
+import com.mojang.logging.LogUtils;
Expand Down Expand Up @@ -660,6 +660,11 @@ index 0000000000000000000000000000000000000000..4c8e90dbfa8c3d6d211dc8890f7dfcc5
+ public MergeLevel mergeLevel = MergeLevel.STRICT;
+ public boolean tntAndSandAffectedByBubbleColumns = true;
+
+ @NestedSetting({"treat-collidable-blocks-as-full", "while-moving"})
+ public boolean treatAllBlocksAsFullWhenMoving = false;
+ @NestedSetting({"treat-collidable-blocks-as-full", "moving-faster-than"})
+ public double treatAllBlocksAsFullWhenMovingFasterThan = 64.0;
+
+ public Tnt tnt = new Tnt();
+ public class Tnt extends ConfigurationPart {
+ public boolean loadsChunks;
Expand Down
38 changes: 25 additions & 13 deletions patches/server/0010-Load-Chunks-on-Movement.patch
Original file line number Diff line number Diff line change
Expand Up @@ -50,32 +50,44 @@ index 658e63ebde81dc14c8ab5850fb246dc0aab25dea..f1ff1a67fee37ee7b241ceaa164fa4ee
public static <T> TicketType<T> create(String name, Comparator<T> argumentComparator) {
return new TicketType<>(name, argumentComparator, 0L);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index a52530dbcd8a3e48a26f13fb246e8183ee560b07..1297012df74a2c955c4f0c87697f802a70ad16f3 100644
index a52530dbcd8a3e48a26f13fb246e8183ee560b07..f74e590a2f492fd54d3e718bed8b0b0cf5f12cea 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -398,6 +398,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
public boolean persistentInvisibility = false;
+ public boolean loadChunks = false; // Sakura - load chunks
public BlockPos lastLavaContact;
// Spigot start
public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
@@ -1490,7 +1491,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -533,6 +533,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// Paper end - make end portalling safe
public boolean isPrimedTNT; // Sakura
public boolean isFallingBlock; // Sakura
+ // Sakura start
+ protected boolean loadChunks = false;
+
+ private int getCollisionFlags() {
+ int flags = 0;
+
+ if (this.loadChunks) {
+ flags |= io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_LOAD_CHUNKS | io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_ADD_TICKET;
+ }
+
+ return flags;
+ }
+ // Sakura end

public boolean isLegacyTrackingEntity = false;

@@ -1490,7 +1503,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

io.papermc.paper.util.CollisionUtil.getCollisions(
world, this, collisionBox, potentialCollisionsVoxel, potentialCollisionsBB,
- (0),
+ (loadChunks ? io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_LOAD_CHUNKS | io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_ADD_TICKET : 0), // Sakura
+ this.getCollisionFlags(), // Sakura
null, null
);

@@ -4812,7 +4813,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4812,7 +4825,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

@Override
public boolean isAlwaysTicking() {
- return false;
+ return loadChunks; // Sakura - always tick in chunks
+ return this.loadChunks; // Sakura - always tick in chunks
}

public boolean mayInteract(Level world, BlockPos pos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ index 83c4639c2bdca4dc4281d9f5eca104af3063bfa5..f7d8aaededd39ce52a9d0105f66fd759

if (this.entity instanceof LivingEntity) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 1297012df74a2c955c4f0c87697f802a70ad16f3..a6c42038cba6b272a472a2b6c78cf741ff8228fd 100644
index f74e590a2f492fd54d3e718bed8b0b0cf5f12cea..f00a5a68e12f1881857eed7ffaf22a656a9ef2af 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3333,7 +3333,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -3345,7 +3345,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID);
return;
}
Expand Down
10 changes: 5 additions & 5 deletions patches/server/0018-Store-Entity-Data-State.patch
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ index 0000000000000000000000000000000000000000..c9f2c5ae57878283e8c8bc3847fe63b9
+
+}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index a6c42038cba6b272a472a2b6c78cf741ff8228fd..9118ebf8c0f2fc4cb8fb438426ef49cbdf9acc52 100644
index f00a5a68e12f1881857eed7ffaf22a656a9ef2af..cbb2853f56c3339826fcaaff20ba93f62e56a761 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -534,6 +534,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// Paper end - make end portalling safe
public boolean isPrimedTNT; // Sakura
public boolean isFallingBlock; // Sakura
@@ -546,6 +546,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return flags;
}
// Sakura end
+ // Sakura start - entity state (from start of tick)
+ private @Nullable me.samsuik.sakura.entity.EntityState entityState = null;
+
Expand Down
12 changes: 6 additions & 6 deletions patches/server/0019-Merge-Cannon-Entities.patch
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ index efba8d153b5838ff1dbc68d389b4d1529c951008..fd25999781d99526b1bc1677aaa3ff74
this.guardEntityTick(this::tickNonPassenger, entity);
gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 9118ebf8c0f2fc4cb8fb438426ef49cbdf9acc52..639712fe3e81703791b87622ae598c11b274802f 100644
index cbb2853f56c3339826fcaaff20ba93f62e56a761..9564477334755756b49fc7bf9f7344912758d47e 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -562,6 +562,105 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -574,6 +574,105 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return BlockPos.asLong(v.getBlockX(), v.getBlockY(), v.getBlockZ());
}
// Sakura end
Expand Down Expand Up @@ -298,15 +298,15 @@ index 9118ebf8c0f2fc4cb8fb438426ef49cbdf9acc52..639712fe3e81703791b87622ae598c11

public boolean isLegacyTrackingEntity = false;

@@ -640,6 +739,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -652,6 +751,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.getEntityData().registrationLocked = true; // Spigot
this.setPos(0.0D, 0.0D, 0.0D);
this.eyeHeight = this.getEyeHeight(net.minecraft.world.entity.Pose.STANDING, this.dimensions);
+ this.mergeLevel = level.sakuraConfig().cannons.mergeLevel; // Sakura
}

public boolean isColliding(BlockPos pos, BlockState state) {
@@ -2487,6 +2587,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2499,6 +2599,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
nbt.putBoolean("Paper.FreezeLock", true);
}
// Paper end
Expand All @@ -318,7 +318,7 @@ index 9118ebf8c0f2fc4cb8fb438426ef49cbdf9acc52..639712fe3e81703791b87622ae598c11
return nbt;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -2634,6 +2739,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2646,6 +2751,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
freezeLocked = nbt.getBoolean("Paper.FreezeLock");
}
// Paper end
Expand All @@ -330,7 +330,7 @@ index 9118ebf8c0f2fc4cb8fb438426ef49cbdf9acc52..639712fe3e81703791b87622ae598c11

} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
@@ -4796,6 +4906,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4808,6 +4918,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return;
}
// Paper end - rewrite chunk system
Expand Down
8 changes: 4 additions & 4 deletions patches/server/0021-Optimise-Fast-Movement.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Optimise Fast Movement


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 639712fe3e81703791b87622ae598c11b274802f..97b11192592f67c976dc5567cfeaad55e7780c18 100644
index 9564477334755756b49fc7bf9f7344912758d47e..ffa4bb17c002a953df4142e353ba9a05b362e3e6 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1198,6 +1198,95 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1210,6 +1210,95 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
// Paper end - detailed watchdog information

Expand Down Expand Up @@ -104,7 +104,7 @@ index 639712fe3e81703791b87622ae598c11b274802f..97b11192592f67c976dc5567cfeaad55
public void move(MoverType movementType, Vec3 movement) {
// Paper start - detailed watchdog information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
@@ -1575,6 +1664,99 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -1587,6 +1676,99 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return offsetFactor;
}

Expand Down Expand Up @@ -170,7 +170,7 @@ index 639712fe3e81703791b87622ae598c11b274802f..97b11192592f67c976dc5567cfeaad55
+ // Copied from the collide method below
+ io.papermc.paper.util.CollisionUtil.getCollisions(
+ level, this, collisionBox, voxelList, bbList,
+ (loadChunks ? io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_LOAD_CHUNKS | io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_ADD_TICKET : 0), // Sakura
+ this.getCollisionFlags(), // Sakura
+ null, null
+ );
+
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0023-isPushedByFluid-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ Subject: [PATCH] isPushedByFluid API


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 97b11192592f67c976dc5567cfeaad55e7780c18..9feef1fd078cd0ca59f4cc6a7346d8eaa24a15e1 100644
index ffa4bb17c002a953df4142e353ba9a05b362e3e6..a7984107161d74aed3f064df1e2576c39a88c506 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -661,6 +661,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -673,6 +673,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
discard();
}
// Sakura end
+ public boolean pushedByFluid = true; // Sakura

public boolean isLegacyTrackingEntity = false;

@@ -4166,7 +4167,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -4178,7 +4179,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}

public boolean isPushedByFluid() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Optimise TNT fluid state and pushing


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 9feef1fd078cd0ca59f4cc6a7346d8eaa24a15e1..eab1b1043f27c3f996e820b3b50e2689c84e8822 100644
index a7984107161d74aed3f064df1e2576c39a88c506..d4e4b74e153e5445e2319351c5fb8c17d115b26f 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2168,7 +2168,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2180,7 +2180,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return this.isInWater() || flag;
}

Expand Down
Loading

0 comments on commit 5a6a5aa

Please sign in to comment.