Yatopia/patches/server/0018-lithium-enum_values.patch
2020-06-27 19:00:18 +02:00

82 lines
3.3 KiB
Diff

From 5bae4d02da3220c14432d6cdbeb60bc5f15f950e Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
Date: Mon, 11 May 2020 21:37:44 +0200
Subject: [PATCH] lithium enum_values
---
src/main/java/net/minecraft/server/BlockPiston.java | 8 ++++----
src/main/java/net/minecraft/server/EntityLiving.java | 6 +++++-
.../java/net/minecraft/server/PistonExtendsChecker.java | 4 +++-
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/main/java/net/minecraft/server/BlockPiston.java b/src/main/java/net/minecraft/server/BlockPiston.java
index 4f10ca5ad..7f2ee293a 100644
--- a/src/main/java/net/minecraft/server/BlockPiston.java
+++ b/src/main/java/net/minecraft/server/BlockPiston.java
@@ -128,8 +128,9 @@ public class BlockPiston extends BlockDirectional {
}
+ private final static EnumDirection[] aenumdirection = EnumDirection.values(); // YAPFA - don't recreate
+
private boolean a(World world, BlockPosition blockposition, EnumDirection enumdirection) {
- EnumDirection[] aenumdirection = EnumDirection.values();
int i = aenumdirection.length;
int j;
@@ -146,12 +147,11 @@ public class BlockPiston extends BlockDirectional {
return true;
} else {
BlockPosition blockposition1 = blockposition.up();
- EnumDirection[] aenumdirection1 = EnumDirection.values();
- j = aenumdirection1.length;
+ j = aenumdirection.length;
for (int k = 0; k < j; ++k) {
- EnumDirection enumdirection2 = aenumdirection1[k];
+ EnumDirection enumdirection2 = aenumdirection[k];
if (enumdirection2 != EnumDirection.DOWN && world.isBlockFacePowered(blockposition1.shift(enumdirection2), enumdirection2)) {
return true;
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 617358db7..029454d1a 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2566,10 +2566,14 @@ public abstract class EntityLiving extends Entity {
}
+ /**
+ * @reason Avoid cloning enum values
+ */
+ private final static EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
+
@Nullable
private Map<EnumItemSlot, ItemStack> r() {
Map<EnumItemSlot, ItemStack> map = null;
- EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
int i = aenumitemslot.length;
for (int j = 0; j < i; ++j) {
diff --git a/src/main/java/net/minecraft/server/PistonExtendsChecker.java b/src/main/java/net/minecraft/server/PistonExtendsChecker.java
index dd64aad1e..18a136213 100644
--- a/src/main/java/net/minecraft/server/PistonExtendsChecker.java
+++ b/src/main/java/net/minecraft/server/PistonExtendsChecker.java
@@ -167,9 +167,11 @@ public class PistonExtendsChecker {
this.f.addAll(list2);
}
+ private final static EnumDirection[] aenumdirection = EnumDirection.values(); // YAPFA - don't recreate
+
private boolean a(BlockPosition blockposition) {
IBlockData iblockdata = this.a.getType(blockposition);
- EnumDirection[] aenumdirection = EnumDirection.values();
+
int i = aenumdirection.length;
for (int j = 0; j < i; ++j) {
--
2.25.1.windows.1