mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
[1.16] Fix entity parts being ignored when collecting entities in an AABB (#8606)
Previously entity parts are only taken into consideration when the parent entity is in a chunk that intersects with the AABB
This commit is contained in:
1 parent
a4ca2c69f0
commit
9a21260575
5 files changed
+72
-14
No files matched your search
@@ -1,5 +1,13 @@
|
||||
--- a/net/minecraft/client/world/ClientWorld.java
|
||||
+++ b/net/minecraft/client/world/ClientWorld.java
|
||||
@@ -93,6 +_,7 @@
|
||||
p_228319_0_.put(BiomeColors.field_180290_c, new ColorCache());
|
||||
});
|
||||
private final ClientChunkProvider field_239129_E_;
|
||||
+ private final it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraftforge.entity.PartEntity<?>> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>();
|
||||
|
||||
public ClientWorld(ClientPlayNetHandler p_i242067_1_, ClientWorld.ClientWorldInfo p_i242067_2_, RegistryKey<World> p_i242067_3_, DimensionType p_i242067_4_, int p_i242067_5_, Supplier<IProfiler> p_i242067_6_, WorldRenderer p_i242067_7_, boolean p_i242067_8_, long p_i242067_9_) {
|
||||
super(p_i242067_2_, p_i242067_3_, p_i242067_4_, p_i242067_6_, true, p_i242067_8_, p_i242067_9_);
|
||||
@@ -104,6 +_,8 @@
|
||||
this.func_239136_a_(new BlockPos(8, 64, 8), 0.0F);
|
||||
this.func_72966_v();
|
||||
@@ -17,7 +25,7 @@
|
||||
p_217418_1_.func_70071_h_();
|
||||
this.func_217381_Z().func_76319_b();
|
||||
}
|
||||
@@ -285,9 +_,11 @@
|
||||
@@ -285,9 +_,16 @@
|
||||
}
|
||||
|
||||
private void func_217424_b(int p_217424_1_, Entity p_217424_2_) {
|
||||
@@ -26,15 +34,25 @@
|
||||
this.field_217429_b.put(p_217424_1_, p_217424_2_);
|
||||
this.func_72863_F().func_212849_a_(MathHelper.func_76128_c(p_217424_2_.func_226277_ct_() / 16.0D), MathHelper.func_76128_c(p_217424_2_.func_226281_cx_() / 16.0D), ChunkStatus.field_222617_m, true).func_76612_a(p_217424_2_);
|
||||
+ p_217424_2_.onAddedToWorld();
|
||||
+ if (p_217424_2_.isMultipartEntity()) {
|
||||
+ for(net.minecraftforge.entity.PartEntity<?> part : p_217424_2_.getParts()) {
|
||||
+ this.partEntities.put(part.func_145782_y(), part);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
public void func_217413_d(int p_217413_1_) {
|
||||
@@ -306,6 +_,8 @@
|
||||
@@ -306,6 +_,13 @@
|
||||
}
|
||||
|
||||
this.field_217431_w.remove(p_217414_1_);
|
||||
+ p_217414_1_.onRemovedFromWorld();
|
||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityLeaveWorldEvent(p_217414_1_, this));
|
||||
+ if (p_217414_1_.isMultipartEntity()) {
|
||||
+ for(net.minecraftforge.entity.PartEntity<?> part : p_217414_1_.getParts()) {
|
||||
+ this.partEntities.remove(part.func_145782_y());
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
public void func_217417_b(Chunk p_217417_1_) {
|
||||
@@ -70,3 +88,14 @@
|
||||
this.field_239153_j_ = p_239156_1_;
|
||||
}
|
||||
|
||||
@@ -890,5 +_,10 @@
|
||||
public double func_239160_g_() {
|
||||
return this.field_239146_c_ ? 1.0D : 0.03125D;
|
||||
}
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public java.util.Collection<net.minecraftforge.entity.PartEntity<?>> getPartEntities() {
|
||||
+ return this.partEntities.values();
|
||||
}
|
||||
}
|
||||
@@ -299,7 +299,18 @@
|
||||
AbstractChunkProvider abstractchunkprovider = this.func_72863_F();
|
||||
|
||||
for(int i1 = i; i1 <= j; ++i1) {
|
||||
@@ -671,10 +_,10 @@
|
||||
@@ -665,16 +_,21 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+ for (net.minecraftforge.entity.PartEntity<?> p : this.getPartEntities()) {
|
||||
+ if (p != p_175674_1_ && p.func_174813_aQ().func_72326_a(p_175674_2_) && (p_175674_3_ == null || p_175674_3_.test(p))) {
|
||||
+ list.add(p);
|
||||
+ }
|
||||
+ }
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public <T extends Entity> List<T> func_217394_a(@Nullable EntityType<T> p_217394_1_, AxisAlignedBB p_217394_2_, Predicate<? super T> p_217394_3_) {
|
||||
this.func_217381_Z().func_230035_c_("getEntities");
|
||||
|
||||
@@ -147,17 +147,14 @@
|
||||
i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1);
|
||||
j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1);
|
||||
|
||||
@@ -472,8 +_,8 @@
|
||||
@@ -472,6 +_,7 @@
|
||||
p_177414_3_.add(entity);
|
||||
}
|
||||
|
||||
- if (entity instanceof EnderDragonEntity) {
|
||||
- for(EnderDragonPartEntity enderdragonpartentity : ((EnderDragonEntity)entity).func_213404_dT()) {
|
||||
+ if (entity.isMultipartEntity()) {
|
||||
+ for(net.minecraftforge.entity.PartEntity<?> enderdragonpartentity : entity.getParts()) {
|
||||
+ if (false) // // Forge: Fix MC-158205: Moved into World.getEntities()
|
||||
if (entity instanceof EnderDragonEntity) {
|
||||
for(EnderDragonPartEntity enderdragonpartentity : ((EnderDragonEntity)entity).func_213404_dT()) {
|
||||
if (enderdragonpartentity != p_177414_1_ && enderdragonpartentity.func_174813_aQ().func_72326_a(p_177414_2_) && (p_177414_4_ == null || p_177414_4_.test(enderdragonpartentity))) {
|
||||
p_177414_3_.add(enderdragonpartentity);
|
||||
}
|
||||
@@ -486,8 +_,8 @@
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
public static final BlockPos field_241108_a_ = new BlockPos(100, 50, 0);
|
||||
private static final Logger field_147491_a = LogManager.getLogger();
|
||||
private final Int2ObjectMap<Entity> field_217498_x = new Int2ObjectLinkedOpenHashMap<>();
|
||||
@@ -173,6 +_,7 @@
|
||||
@@ -173,6 +_,8 @@
|
||||
private final DragonFightManager field_241105_O_;
|
||||
private final StructureManager field_241106_P_;
|
||||
private final boolean field_241107_Q_;
|
||||
+ private net.minecraftforge.common.util.WorldCapabilityData capabilityData;
|
||||
+ private final it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraftforge.entity.PartEntity<?>> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>();
|
||||
|
||||
public ServerWorld(MinecraftServer p_i241885_1_, Executor p_i241885_2_, SaveFormat.LevelSave p_i241885_3_, IServerWorldInfo p_i241885_4_, RegistryKey<World> p_i241885_5_, DimensionType p_i241885_6_, IChunkStatusListener p_i241885_7_, ChunkGenerator p_i241885_8_, boolean p_i241885_9_, long p_i241885_10_, List<ISpecialSpawner> p_i241885_12_, boolean p_i241885_13_) {
|
||||
super(p_i241885_4_, p_i241885_5_, p_i241885_6_, p_i241885_1_::func_213185_aS, false, p_i241885_9_, p_i241885_10_);
|
||||
@@ -140,7 +141,7 @@
|
||||
this.func_217465_m(p_217440_1_);
|
||||
return true;
|
||||
}
|
||||
@@ -879,10 +_,14 @@
|
||||
@@ -879,10 +_,15 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -155,6 +156,7 @@
|
||||
+ if (p_217484_1_.isMultipartEntity()) {
|
||||
+ for(net.minecraftforge.entity.PartEntity<?> enderdragonpartentity : p_217484_1_.getParts()) {
|
||||
+ enderdragonpartentity.remove(keepData);
|
||||
+ this.partEntities.remove(enderdragonpartentity.func_145782_y());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +170,7 @@
|
||||
}
|
||||
|
||||
private void func_217465_m(Entity p_217465_1_) {
|
||||
@@ -905,8 +_,8 @@
|
||||
@@ -905,9 +_,10 @@
|
||||
this.field_217499_z.add(p_217465_1_);
|
||||
} else {
|
||||
this.field_217498_x.put(p_217465_1_.func_145782_y(), p_217465_1_);
|
||||
@@ -177,8 +179,10 @@
|
||||
+ if (p_217465_1_.isMultipartEntity()) {
|
||||
+ for(net.minecraftforge.entity.PartEntity<?> enderdragonpartentity : p_217465_1_.getParts()) {
|
||||
this.field_217498_x.put(enderdragonpartentity.func_145782_y(), enderdragonpartentity);
|
||||
+ this.partEntities.put(enderdragonpartentity.func_145782_y(), enderdragonpartentity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -918,15 +_,19 @@
|
||||
}
|
||||
}
|
||||
@@ -243,7 +247,7 @@
|
||||
explosion.func_77278_a();
|
||||
explosion.func_77279_a(false);
|
||||
if (p_230546_12_ == Explosion.Mode.NONE) {
|
||||
@@ -1409,5 +_,15 @@
|
||||
@@ -1409,5 +_,20 @@
|
||||
BlockPos.func_191531_b(i - 2, j, k - 2, i + 2, j, k + 2).forEach((p_241122_1_) -> {
|
||||
p_241121_0_.func_175656_a(p_241122_1_, Blocks.field_150343_Z.func_176223_P());
|
||||
});
|
||||
@@ -257,5 +261,10 @@
|
||||
+
|
||||
+ public java.util.stream.Stream<Entity> getEntities() {
|
||||
+ return field_217498_x.values().stream();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public java.util.Collection<net.minecraftforge.entity.PartEntity<?>> getPartEntities() {
|
||||
+ return this.partEntities.values();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,11 @@
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.entity.PartEntity;
|
||||
|
||||
public interface IForgeWorld extends ICapabilityProvider
|
||||
{
|
||||
@@ -22,4 +26,12 @@ public interface IForgeWorld extends ICapabilityProvider
|
||||
* @return The new max radius
|
||||
*/
|
||||
public double increaseMaxEntityRadius(double value);
|
||||
/**
|
||||
* All part entities in this world. Used when collecting entities in an AABB to fix parts being
|
||||
* ignored whose parent entity is in a chunk that does not intersect with the AABB.
|
||||
*/
|
||||
public default Collection<PartEntity<?>> getPartEntities()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user