Skip to content

Commit

Permalink
Reduce skull ItemStack lookups for reduced visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnMuijsers committed Aug 30, 2023
1 parent e2ab191 commit 1248bf7
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions patches/server/0008-Gale-semantic-version.patch
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ index 2868dab7b100d9c325b0e5056f86660d631dec4b..2acad4c3fd58178b0f8b22bdb04eeeeb
}
diff --git a/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java
new file mode 100644
index 0000000000000000000000000000000000000000..0e9b11940513e96a21bed011afb0b05257782bfc
index 0000000000000000000000000000000000000000..d313213da0498d9229a3ac859513ed985fbfe381
--- /dev/null
+++ b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java
@@ -0,0 +1,37 @@
Expand Down Expand Up @@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..0e9b11940513e96a21bed011afb0b052
+ * The <code>patch</code> version is incremented for small changes that do not affect the goal of any feature,
+ * such as bug fixes, performance improvements or changes in wording.
+ */
+ public static final @NotNull String version = "0.6.8";
+ public static final @NotNull String version = "0.6.9";
+
+ /**
+ * The "<code>major.minor</code>" portion of the {@link #version}.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Aug 2023 20:17:20 +0200
Subject: [PATCH] Reduce skull ItemStack lookups for reduced visibility

License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org

This patch is based on the following patch:
"feat: reduce sensor work"
By: peaches94 <peachescu94@gmail.com>
As part of: Petal (https://github.com/Bloom-host/Petal)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)

* Petal description *

this patch is focused around the sensors used for ai
delete the line of sight cache less often and use a faster nearby comparison

diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index a35891723fad4fe984566c41cdd728004f8f371e..a30beddd896b8d36c48d442871818327a7e4810d 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1023,10 +1023,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
}

if (entity != null) {
- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
EntityType<?> entitytypes = entity.getType();

- if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.PIGLIN && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.PIGLIN_BRUTE && itemstack.is(Items.PIGLIN_HEAD) || entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) {
+ if (entitytypes == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL) || entitytypes == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD) || entitytypes == EntityType.PIGLIN && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD) || entitytypes == EntityType.PIGLIN_BRUTE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD) || entitytypes == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) { // Gale - Petal - reduce skull ItemStack lookups for reduced visibility
d0 *= 0.5D;
}
}

0 comments on commit 1248bf7

Please sign in to comment.