mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-23 16:59:16 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@7fbb827 Finish API patches PaperMC/Paper@8a37f93 62 PaperMC/Paper@2055809 117 PaperMC/Paper@0b75522 194 PaperMC/Paper@ec05cb8 279 PaperMC/Paper@0bc9aee 385 PaperMC/Paper@27e29cc 487/1053 PaperMC/Paper@083bd9e 531/1053 PaperMC/Paper@ed2ea45 538 PaperMC/Paper@ba163e1 585/1053 PaperMC/Paper@8731266 650/1053 PaperMC/Paper@52b49fb 788/1053 PaperMC/Paper@33b36cd update some patches PaperMC/Paper@14c0336 922 PaperMC/Paper@a399f23 956 PaperMC/Paper@4140de2 960 PaperMC/Paper@6d4e235 988 PaperMC/Paper@6a34750 Move unapplied patches to the back PaperMC/Paper@3c04f9f Fix a few compile errors PaperMC/Paper@0d3ce2d Fix more compile issues PaperMC/Paper@a308c7c Fix more compile issues PaperMC/Paper@69d1d0a Pretend to fix compile errors PaperMC/Paper@547f09d Some work on the ItemMend events PaperMC/Paper@184a943 Adopt previous commit changes in API PaperMC/Paper@5442bff Make it compile PaperMC/Paper@038f8d9 Fixup and deprecate player profiles in ping event PaperMC/Paper@66f7b67 Fix body equipmentslot and effect enum PaperMC/Paper@38b3182 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@df633e5 DataConverter 1.21 PaperMC/Paper@f569389 Update ConcurrentUtil PaperMC/Paper@5fca3ae update generated API PaperMC/Paper@188cff2 remove old vanilla goals PaperMC/Paper@ffe310a remove api that was scheduled for removal PaperMC/Paper@730882f Chunk System and Starlight WIP PaperMC/Paper@512fd08 Update Gradle Wrapper to v8.8 PaperMC/Paper@097284d Bump tiny-remapper to 0.10.3 PaperMC/Paper@ee9b820 Update more optimization patches PaperMC/Paper@5d834b1 rebuild patches PaperMC/Paper@4bc15f1 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@0b6701d Revert DamageSource#getCausingEntity to vanilla PaperMC/Paper@5bd7f4e Update AbstractArrow item method implementations for 1.20.6 (#10885) PaperMC/Paper@fb511c6 Fix Player#sendBlockState (#10855) PaperMC/Paper@b420038 Fix ItemMeta#removeEnchantments (#10886) PaperMC/Paper@a835ad1 Merge remote-tracking branch 'origin/dev/1.21' into dev/1.21 PaperMC/Paper@04dad71 Improve enchantWithLevels logic PaperMC/Paper@0008fa1 Add back more optimization patches PaperMC/Paper@56b5b7d Fix max chunk status checks PaperMC/Paper@c1aefee correctly change enchantment registry to a 'delayed' version PaperMC/Paper@d41636f Add back RecipeIterator fixes patch (#10887) PaperMC/Paper@7df4725 Configurable damage tick when blocking with shield (#10877) PaperMC/Paper@3555a77 Properly forward DispenseEvent #getItem to saddle PaperMC/Paper@e339ec2 Deprecate BlockData#getDestroySpeed for removal PaperMC/Paper@b090c65 Remove unnecessary changes from chunk status fix PaperMC/Paper@5e7cd07 add some generated typed/tag keys PaperMC/Paper@5a5412c Owen fixing stuff!!! PaperMC/Paper@7240d9d Restore functionality to sand dupe setting PaperMC/Paper@f873bce Fix NPE in V3808 PaperMC/Paper@1f8e7a7 address compile and test issue (#10890) PaperMC/Paper@60f3bd8 De-deprecate BlockData#getDestroySpeed PaperMC/Paper@752f957 Add back more patches PaperMC/Paper@dc684c6 Remove bad server.scheduleOnMain disconnect calls from old patches PaperMC/Paper@c84a3b5 Remove fully dropped patches PaperMC/Paper@d8c2980 Add Adventure API to ServerLinks (#10891) PaperMC/Paper@ec4c712 update 'improve mass craft perf' patch PaperMC/Paper@e1c0033 Updated Upstream (Bukkit/CraftBukkit) PaperMC/Paper@fbc2a55 Update Wither#canTravelThroughPortals PaperMC/Paper@167961e call EntityDamageItemEvent for thorns PaperMC/Paper@106dbae Fix getAddress connection check PaperMC/Paper@d9111cc Registry Modification API (#10893) PaperMC/Paper@f8ee0a0 Fix implementations of ChunkHolder#getChunkIfPresent PaperMC/Paper@61b85e4 Fix legacy cb version in remapper PaperMC/Paper@de8220c Update ChunkMap#distanceManager mapping patch PaperMC/Paper@8dfb85c Enchantment and GameEvent Registry builders (#10889) PaperMC/Paper@fb762cf remove remaining reference to 'pgive' PaperMC/Paper@a7f6633 make EntityPortalReadyEvent#setTargetWorld work again PaperMC/Paper@152f4fe Add back improved watchdog support patch PaperMC/Paper@13992b1 Make chunk system loggers calm down a bit PaperMC/Paper@bf8552f Delegate ItemStack (#10852) PaperMC/Paper@b3e072a Fix `hasFiredAsync` parameter when `AsyncPlayerSendCommandsEvent` is called (#10896) PaperMC/Paper@21c9a7c Rebuild patches PaperMC/Paper@b9f7098 [ci skip] Fix javadoc mistake in EnchantmentRegistryEntry.Builder (#10898) PaperMC/Paper@b4b8208 Fix NPE for Jukebox#setRecord PaperMC/Paper@4514f41 Correct duplicate attribute check (#10901) PaperMC/Paper@090775e Use ItemStack.empty() when air is passed into constructor PaperMC/Paper@7bbe682 Fix CraftWorld#isChunkGenerated PaperMC/Paper@126f6d7 Remove getUnloadingChunkHolder check PaperMC/Paper@d23825a Add missing null check to getFullChunkIfLoaded PaperMC/Paper@3b1c85b Execute chunk tasks while waiting for chunk load in isChunkGenerated PaperMC/Paper@4ea696f Add ticket for chunk load in isChunkGenerated PaperMC/Paper@250e78c Re-add fixlight command PaperMC/Paper@c0268ca Copy missing diff from old chunk system patch PaperMC/Paper@38428c0 Cleanup MCUtils patch for chunk system PaperMC/Paper@f4ddd4a Fix ChunkHolder#getFullChunkNow returning non-null when it should not PaperMC/Paper@e0d9d60 Add debug for chunk system unload crash PaperMC/Paper@2df432f Re-add chunk system debug commands PaperMC/Paper@cf60574 Fix jukebox playable component not being applied on item meta (#10922) PaperMC/Paper@666bc4d Experimental annotation changes (#10914) PaperMC/Paper@bab07e0 Validate speed for tool component rule (#10923) PaperMC/Paper@2118196 Fixes exception log messages getting dropped during bootstrap (#10935) PaperMC/Paper@8b1d26d Fix diff in sprint interruption option (Closes #10939) PaperMC/Paper@0a1b133 Revert "Fixes exception log messages getting dropped during bootstrap (#10935)" (Closes #10945) PaperMC/Paper@a0fad76 Fix base damage for trident (#10948) PaperMC/Paper@d64be7e Fix NPE of AbstractArrow#getWeapon (#10933) PaperMC/Paper@081146c Validate using_converts_to for food component (#10931) PaperMC/Paper@0409a68 deprecate and update some entity tags (#10932) PaperMC/Paper@9cd0201 Preserve velocity for fireball (#10934) PaperMC/Paper@19105a9 Fix unload queue storing chunks in wrong sections PaperMC/Paper@77c763b Fix PlayerShearBlockEvent drops ignored for Pumpkin (#10956) PaperMC/Paper@76c2f16 Fix wrong diff applying delta twice (#10959) PaperMC/Paper@812701d Do not crash when an exp orb attempts to mend an unrepairable item PaperMC/Paper@19eefe9 Fix SoundEffects only to players diff (#10966) PaperMC/Paper@95aa440 Add missing effect cause and deprecate PATROL_CAPTAIN cause (#10958) PaperMC/Paper@b2e5587 Expose LivingEntity#canUseSlot (#10930) PaperMC/Paper@97afc9a Fix StackOverflowError for new dispenser interaction (#10949) PaperMC/Paper@5ae4758 Fix speed for launched trident using api (#10936) PaperMC/Paper@897ece4 Call EntityPortalEnterEvent on endgateways and make cancellable (#10892) PaperMC/Paper@1d3fc0e Bump reflection-rewriter to 0.0.2 (#10927) PaperMC/Paper@b99d071 Swap some nullable annotations (#10960) PaperMC/Paper@dd31654 bump reflection-rewriter to 0.0.3 (#10969) PaperMC/Paper@dd49fba Fix NPE when retrieving an entity with a null UUID
288 lines
14 KiB
Diff
288 lines
14 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Mon, 22 Apr 2024 23:01:26 +0100
|
|
Subject: [PATCH] Replace explosion density cache
|
|
|
|
|
|
diff --git a/src/main/java/me/samsuik/sakura/explosion/density/BlockDensityCache.java b/src/main/java/me/samsuik/sakura/explosion/density/BlockDensityCache.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..b760b03f9ddc1fb2aed135105030fc1b5dc2c9c9
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/explosion/density/BlockDensityCache.java
|
|
@@ -0,0 +1,65 @@
|
|
+package me.samsuik.sakura.explosion.density;
|
|
+
|
|
+import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
|
+import net.minecraft.util.Mth;
|
|
+import net.minecraft.world.entity.Entity;
|
|
+import net.minecraft.world.phys.Vec3;
|
|
+
|
|
+/**
|
|
+ * This is a replacement for papers explosion density cache to be more lenient and efficient.
|
|
+ */
|
|
+public final class BlockDensityCache {
|
|
+ public static final float UNKNOWN_DENSITY = -1.0f;
|
|
+
|
|
+ private final Int2ObjectOpenHashMap<DensityData> densityDataMap = new Int2ObjectOpenHashMap<>();
|
|
+ private DensityData data;
|
|
+ private int key;
|
|
+ private boolean knownSource;
|
|
+
|
|
+ public float getDensity(Vec3 explosion, Entity entity) {
|
|
+ int key = getKey(explosion, entity);
|
|
+ DensityData data = this.densityDataMap.get(key);
|
|
+
|
|
+ if (data != null && data.hasPosition(explosion, entity.getBoundingBox())) {
|
|
+ return data.density();
|
|
+ } else {
|
|
+ this.knownSource = data != null && data.complete() && data.isExplosionPosition(explosion);
|
|
+ this.data = data;
|
|
+ this.key = key;
|
|
+ return UNKNOWN_DENSITY;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public float getKnownDensity(Vec3 point) {
|
|
+ if (this.knownSource && this.data.isKnownPosition(point)) {
|
|
+ return this.data.density();
|
|
+ } else {
|
|
+ return UNKNOWN_DENSITY;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public void putDensity(Vec3 explosion, Entity entity, float density) {
|
|
+ if (this.data == null || !this.data.complete()) {
|
|
+ this.densityDataMap.put(this.key, new DensityData(explosion, entity, density));
|
|
+ } else if (this.data.density() == density) {
|
|
+ this.data.expand(explosion, entity);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ public void clear(long tick) {
|
|
+ // trim size every 30 seconds
|
|
+ if (tick != -1 && tick % 600 == 0)
|
|
+ this.densityDataMap.trim();
|
|
+ this.densityDataMap.clear();
|
|
+ }
|
|
+
|
|
+ private static int getKey(Vec3 explosion, Entity entity) {
|
|
+ int key = Mth.floor(explosion.x());
|
|
+ key = 31 * key + Mth.floor(explosion.y());
|
|
+ key = 31 * key + Mth.floor(explosion.z());
|
|
+ key = 31 * key + entity.getBlockX();
|
|
+ key = 31 * key + entity.getBlockY();
|
|
+ key = 31 * key + entity.getBlockZ();
|
|
+ return key;
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/me/samsuik/sakura/explosion/density/DensityData.java b/src/main/java/me/samsuik/sakura/explosion/density/DensityData.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..d7e24638f07f243502004970ab4ce646cbe1e436
|
|
--- /dev/null
|
|
+++ b/src/main/java/me/samsuik/sakura/explosion/density/DensityData.java
|
|
@@ -0,0 +1,47 @@
|
|
+package me.samsuik.sakura.explosion.density;
|
|
+
|
|
+import net.minecraft.world.entity.Entity;
|
|
+import net.minecraft.world.phys.AABB;
|
|
+import net.minecraft.world.phys.Vec3;
|
|
+
|
|
+public final class DensityData {
|
|
+ private AABB source;
|
|
+ private AABB known;
|
|
+ private AABB entity;
|
|
+ private final float density;
|
|
+ private final boolean complete;
|
|
+
|
|
+ public DensityData(Vec3 explosion, Entity entity, float density) {
|
|
+ this.source = new AABB(explosion, explosion);
|
|
+ this.known = new AABB(entity.position(), entity.position());
|
|
+ this.entity = entity.getBoundingBox();
|
|
+ this.density = density;
|
|
+ this.complete = Math.abs(density - 0.5f) == 0.5f;
|
|
+ }
|
|
+
|
|
+ public float density() {
|
|
+ return this.density;
|
|
+ }
|
|
+
|
|
+ public boolean complete() {
|
|
+ return this.complete;
|
|
+ }
|
|
+
|
|
+ public boolean hasPosition(Vec3 explosion, AABB entity) {
|
|
+ return this.isExplosionPosition(explosion) && this.entity.isAABBInBounds(entity);
|
|
+ }
|
|
+
|
|
+ public boolean isKnownPosition(Vec3 point) {
|
|
+ return this.entity.isVec3InBounds(point);
|
|
+ }
|
|
+
|
|
+ public boolean isExplosionPosition(Vec3 explosion) {
|
|
+ return this.source.isVec3InBounds(explosion);
|
|
+ }
|
|
+
|
|
+ public void expand(Vec3 explosion, Entity entity) {
|
|
+ this.source = this.source.expand(explosion);
|
|
+ this.known = this.known.expand(entity.position());
|
|
+ this.entity = this.entity.minmax(entity.getBoundingBox());
|
|
+ }
|
|
+}
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 5b366c69a28e3806d5507ad029e27231f8ef7c5c..2df0f8a92174be654acb27785ff1f4880dcf3362 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -1753,6 +1753,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
worldserver.localConfig().expire(currentTickLong); // Sakura - add local config
|
|
worldserver.minimalTNT.clear(); // Sakura - visibility api
|
|
worldserver.mergeHistory.expire(currentTickLong); // Sakura - merge cannoning entities
|
|
+ worldserver.densityCache.clear(currentTickLong); // Sakura - explosion density cache
|
|
}
|
|
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
index b6364b02142a71741bdeb5df3da58dcbd41d1ba5..c5668c12a20628e1f3b216590488b432ad9a0adf 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
|
@@ -402,7 +402,12 @@ public class Explosion {
|
|
Math.fma(dz, diffZ, offZ)
|
|
);
|
|
|
|
- if (!this.clipsAnything(from, source, context, blockCache, blockPos)) {
|
|
+ // Sakura start - replace density cache
|
|
+ final float density = this.level.densityCache.getKnownDensity(from);
|
|
+ if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
|
|
+ missedRays += (int) density;
|
|
+ } else if (!this.clipsAnything(from, source, context, blockCache, blockPos)) {
|
|
+ // Sakura end - replace density cache
|
|
++missedRays;
|
|
}
|
|
}
|
|
@@ -437,7 +442,16 @@ public class Explosion {
|
|
double d10 = Mth.lerp(d7, axisalignedbb.minZ, axisalignedbb.maxZ);
|
|
Vec3 vec3d1 = new Vec3(d8 + d3, d9, d10 + d4);
|
|
|
|
- if (entity.level().clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() == HitResult.Type.MISS) {
|
|
+ // Sakura start - replace density cache
|
|
+ final net.minecraft.world.phys.HitResult.Type hitResult;
|
|
+ final float density = entity.level().densityCache.getKnownDensity(vec3d1);
|
|
+ if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
|
|
+ hitResult = density != 0.0f ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK;
|
|
+ } else {
|
|
+ hitResult = entity.level().clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType();
|
|
+ }
|
|
+ if (hitResult == HitResult.Type.MISS) {
|
|
+ // Sakura end - replace density cache
|
|
++i;
|
|
}
|
|
|
|
@@ -837,6 +851,11 @@ public class Explosion {
|
|
});
|
|
}
|
|
|
|
+ // Sakura start - explosion density cache
|
|
+ if (!this.toBlow.isEmpty() && !this.level.paperConfig().environment.optimizeExplosions) {
|
|
+ this.level.densityCache.clear(-1);
|
|
+ }
|
|
+ // Sakura end - explosion density cache
|
|
Iterator iterator = list.iterator();
|
|
|
|
while (iterator.hasNext()) {
|
|
@@ -965,14 +984,12 @@ public class Explosion {
|
|
}
|
|
// Paper start - Optimize explosions
|
|
private float getBlockDensity(Vec3 vec3d, Entity entity, ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) { // Paper - optimise explosions
|
|
- if (!this.level.paperConfig().environment.optimizeExplosions) {
|
|
- return this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions
|
|
- }
|
|
- CacheKey key = new CacheKey(this, entity.getBoundingBox());
|
|
- Float blockDensity = this.level.explosionDensityCache.get(key);
|
|
- if (blockDensity == null) {
|
|
+ // Sakura start - replace density cache
|
|
+ float blockDensity = this.level.densityCache.getDensity(vec3d, entity);
|
|
+ if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
|
|
blockDensity = this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions;
|
|
- this.level.explosionDensityCache.put(key, blockDensity);
|
|
+ this.level.densityCache.putDensity(vec3d, entity, blockDensity);
|
|
+ // Sakura end - replace density cache
|
|
}
|
|
|
|
return blockDensity;
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 66af21d21f42e796ae49a2ac8a4f7e2ef9fad99c..1d822411f6cef0137eeb6383f404500642d3a731 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -221,6 +221,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
|
// Paper start - rewrite chunk system
|
|
private ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup;
|
|
public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura - cannon entity merging
|
|
+ public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache
|
|
|
|
@Override
|
|
public final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup moonrise$getEntityLookup() {
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
|
|
index 8b33e35c843e5c0b8988a2ef2a38a2673035292f..5ec557652558bb44e9be7d32fc214091d29aac78 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java
|
|
@@ -109,6 +109,11 @@ public abstract class BasePressurePlateBlock extends Block {
|
|
if (output != j) {
|
|
BlockState iblockdata1 = this.setSignalForState(state, j);
|
|
|
|
+ // Sakura start - explosion density cache
|
|
+ if (!world.paperConfig().environment.optimizeExplosions) {
|
|
+ world.densityCache.clear(-1);
|
|
+ }
|
|
+ // Sakura end - explosion density cache
|
|
world.setBlock(pos, iblockdata1, 2);
|
|
this.updateNeighbours(world, pos);
|
|
world.setBlocksDirty(pos, state, iblockdata1);
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
|
index 76aca266d3f3222502ff4c196228f08fcd88c5f8..6a63e60d80ee53a4611dfcdd9ab974f8227fae59 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java
|
|
@@ -173,6 +173,11 @@ public class TripWireHookBlock extends Block {
|
|
blockposition1 = pos.relative(enumdirection, j);
|
|
Direction enumdirection1 = enumdirection.getOpposite();
|
|
|
|
+ // Sakura start - explosion density cache
|
|
+ if (!world.paperConfig().environment.optimizeExplosions) {
|
|
+ world.densityCache.clear(-1);
|
|
+ }
|
|
+ // Sakura end - explosion density cache
|
|
world.setBlock(blockposition1, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection1), 3);
|
|
TripWireHookBlock.notifyNeighbors(block, world, blockposition1, enumdirection1);
|
|
TripWireHookBlock.emitState(world, blockposition1, flag4, flag5, flag2, flag3);
|
|
diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java
|
|
index e4e99fb9f1670dbc1c032dd834c4bfb3c9d4a8ca..acbaa9f85caaadafb165d1fd835e4dde9e73e200 100644
|
|
--- a/src/main/java/net/minecraft/world/phys/AABB.java
|
|
+++ b/src/main/java/net/minecraft/world/phys/AABB.java
|
|
@@ -519,4 +519,28 @@ public class AABB {
|
|
public static AABB ofSize(Vec3 center, double dx, double dy, double dz) {
|
|
return new AABB(center.x - dx / 2.0, center.y - dy / 2.0, center.z - dz / 2.0, center.x + dx / 2.0, center.y + dy / 2.0, center.z + dz / 2.0);
|
|
}
|
|
+
|
|
+ // Sakura start - explosion density cache
|
|
+ public final boolean isAABBInBounds(AABB bb) {
|
|
+ return this.minX <= bb.minX && this.maxX >= bb.maxX
|
|
+ && this.minY <= bb.minY && this.maxY >= bb.maxY
|
|
+ && this.minZ <= bb.minZ && this.maxZ >= bb.maxZ;
|
|
+ }
|
|
+
|
|
+ public final boolean isVec3InBounds(Vec3 p) {
|
|
+ return this.minX <= p.x && this.maxX >= p.x
|
|
+ && this.minY <= p.y && this.maxY >= p.y
|
|
+ && this.minZ <= p.z && this.maxZ >= p.z;
|
|
+ }
|
|
+
|
|
+ public final AABB expand(Vec3 pos) {
|
|
+ double minX = Math.min(this.minX, pos.x);
|
|
+ double minY = Math.min(this.minY, pos.y);
|
|
+ double minZ = Math.min(this.minZ, pos.z);
|
|
+ double maxX = Math.max(this.maxX, pos.x);
|
|
+ double maxY = Math.max(this.maxY, pos.y);
|
|
+ double maxZ = Math.max(this.maxZ, pos.z);
|
|
+ return new AABB(minX, minY, minZ, maxX, maxY, maxZ);
|
|
+ }
|
|
+ // Sakura end - explosion density cache
|
|
}
|