mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-21 16:09:19 +00:00
32 lines
1.6 KiB
Diff
32 lines
1.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
|
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
|
Subject: [PATCH] Remove stream in GolemSensor
|
|
|
|
Stream operations in GolemSensor is really expensive and takes
|
|
up 80% time per method call.
|
|
Before: 192ms
|
|
After: 17ms
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/GolemSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/GolemSensor.java
|
|
index 94d730e2d8159184a95da4b23266bf2e330be707..f78a342270104ca1082ea535d1152541d7297d8c 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/GolemSensor.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/GolemSensor.java
|
|
@@ -34,7 +34,15 @@ public class GolemSensor extends Sensor<LivingEntity> {
|
|
public static void checkForNearbyGolem(LivingEntity entity) {
|
|
Optional<List<LivingEntity>> optional = entity.getBrain().getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES);
|
|
if (!optional.isEmpty()) {
|
|
- boolean bl = optional.get().stream().anyMatch(livingEntity -> livingEntity.getType().equals(EntityType.IRON_GOLEM));
|
|
+ // Leaf start - Remove stream in GolemSensor
|
|
+ boolean bl = false;
|
|
+ for (LivingEntity livingEntity : optional.get()) {
|
|
+ if (livingEntity.getType().equals(EntityType.IRON_GOLEM)) {
|
|
+ bl = true;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+ // Leaf end - Remove stream in GolemSensor
|
|
if (bl) {
|
|
golemDetected(entity);
|
|
}
|