Skip to content

Commit

Permalink
Revert replacing active effect map to fastutil map
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Nov 2, 2024
1 parent a4f6b92 commit 2d152a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ From: Dreeam <[email protected]>
Date: Tue, 17 Sep 2024 02:35:13 -0400
Subject: [PATCH] Replace Entity active effects map with optimized collection

Dreeam TODO: check this

diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 2539f688102a3c9c10ddeff39f3562668e9010be..827162f51cc58bd090ddc3576e5fe21043075e8d 100644
index 2539f688102a3c9c10ddeff39f3562668e9010be..d44e48719fcf51f6d425b9c18835ad44339177df 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -199,7 +199,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -199,6 +199,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
public static final String ATTRIBUTES_FIELD = "attributes";
private final AttributeMap attributes;
public CombatTracker combatTracker = new CombatTracker(this);
- public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = Maps.newHashMap();
+ public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(0); // Leaf - Replace Entity active effects map with optimized collection
+ // Need to figure out the difference of mem access pattern between hash map and obj2obj hash map (separate chaining vs open addressing)
+ // Benchmark is needed for get calls for this active effects map.
+ // Also need to check whether call from out of main using bukkit api
+ //public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(0); // Leaf - Replace Entity active effects map with optimized collection
public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = Maps.newHashMap();
private final NonNullList<ItemStack> lastHandItemStacks;
private final NonNullList<ItemStack> lastArmorItemStacks;
private ItemStack lastBodyItemStack;
@@ -1011,8 +1011,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1011,8 +1015,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
private void updateSynchronizedMobEffectParticles() {
// Leaf start - Remove stream in entity visible effects filter
List<ParticleOptions> list = new ArrayList<>();
Expand All @@ -28,7 +31,7 @@ index 2539f688102a3c9c10ddeff39f3562668e9010be..827162f51cc58bd090ddc3576e5fe210
if (effect.isVisible()) {
list.add(effect.getParticleOptions());
}
@@ -1020,7 +1021,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1020,7 +1025,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
// Leaf end - Remove stream in entity visible effects filter

this.entityData.set(LivingEntity.DATA_EFFECT_PARTICLES, list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] Configurable player knockback zombie


diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 827162f51cc58bd090ddc3576e5fe21043075e8d..328630ff8df5bf67e5df190443e436e996942257 100644
index d44e48719fcf51f6d425b9c18835ad44339177df..d99a80657db3a24f79f094d7dbf81faab506937c 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2037,6 +2037,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -2041,6 +2041,8 @@ public abstract class LivingEntity extends Entity implements Attackable {
}

public void knockback(double d0, double d1, double d2, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause cause) { // Paper - knockback events
Expand All @@ -17,7 +17,7 @@ index 827162f51cc58bd090ddc3576e5fe21043075e8d..328630ff8df5bf67e5df190443e436e9
d0 *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
if (true || d0 > 0.0D) { // CraftBukkit - Call event even when force is 0
//this.hasImpulse = true; // CraftBukkit - Move down
@@ -2064,6 +2066,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -2068,6 +2070,20 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ index 6469cd96f0ecb98f4e15e9865837d8c6a07128ad..846ddd4fcbb14db6f3eac9169de6850c

ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - fix slot desync - always refresh player inventory
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 328630ff8df5bf67e5df190443e436e996942257..b6402881d5ee626e07996c3ceac1ac49ce2751c1 100644
index d99a80657db3a24f79f094d7dbf81faab506937c..241e2598973939b7d19768cd9ca7cd8f3818c053 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3413,7 +3413,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3417,7 +3417,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
ItemStack itemstack1 = itemstack;
ItemStack itemstack2 = this.getItemBySlot(enumitemslot);

Expand All @@ -90,7 +90,7 @@ index 328630ff8df5bf67e5df190443e436e996942257..b6402881d5ee626e07996c3ceac1ac49
// Paper start - PlayerArmorChangeEvent
if (this instanceof ServerPlayer && enumitemslot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
final org.bukkit.inventory.ItemStack oldItem = CraftItemStack.asBukkitCopy(itemstack1);
@@ -3497,7 +3497,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3501,7 +3501,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
equipmentChanges.forEach((enumitemslot, itemstack) -> {
ItemStack itemstack1 = itemstack.copy();

Expand Down

0 comments on commit 2d152a0

Please sign in to comment.