Move chest sound handling out of the tick loop...
and set them not to tick
This commit is contained in:
parent
2542c10a85
commit
0b8246dbb7
|
@ -1,4 +1,4 @@
|
|||
From 03a8823864b8a5bd6e36333137fb486378e3a63d Mon Sep 17 00:00:00 2001
|
||||
From d283bfd7d39924f8d6fcca0678422842f298b7dc Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <Zbob750@live.com>
|
||||
Date: Tue, 22 Jul 2014 21:05:53 -0500
|
||||
Subject: [PATCH] mc-dev imports
|
||||
|
@ -84,6 +84,96 @@ index 0000000..9342a3f
|
|||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
||||
new file mode 100644
|
||||
index 0000000..b205ab7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
||||
@@ -0,0 +1,84 @@
|
||||
+package net.minecraft.server;
|
||||
+
|
||||
+public class TileEntityEnderChest extends TileEntity {
|
||||
+
|
||||
+ public float a;
|
||||
+ public float i;
|
||||
+ public int j;
|
||||
+ private int k;
|
||||
+
|
||||
+ public TileEntityEnderChest() {}
|
||||
+
|
||||
+ public void h() {
|
||||
+ super.h();
|
||||
+ if (++this.k % 20 * 4 == 0) {
|
||||
+ this.world.playBlockAction(this.x, this.y, this.z, Blocks.ENDER_CHEST, 1, this.j);
|
||||
+ }
|
||||
+
|
||||
+ this.i = this.a;
|
||||
+ float f = 0.1F;
|
||||
+ double d0;
|
||||
+
|
||||
+ if (this.j > 0 && this.a == 0.0F) {
|
||||
+ double d1 = (double) this.x + 0.5D;
|
||||
+
|
||||
+ d0 = (double) this.z + 0.5D;
|
||||
+ this.world.makeSound(d1, (double) this.y + 0.5D, d0, "random.chestopen", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
||||
+ }
|
||||
+
|
||||
+ if (this.j == 0 && this.a > 0.0F || this.j > 0 && this.a < 1.0F) {
|
||||
+ float f1 = this.a;
|
||||
+
|
||||
+ if (this.j > 0) {
|
||||
+ this.a += f;
|
||||
+ } else {
|
||||
+ this.a -= f;
|
||||
+ }
|
||||
+
|
||||
+ if (this.a > 1.0F) {
|
||||
+ this.a = 1.0F;
|
||||
+ }
|
||||
+
|
||||
+ float f2 = 0.5F;
|
||||
+
|
||||
+ if (this.a < f2 && f1 >= f2) {
|
||||
+ d0 = (double) this.x + 0.5D;
|
||||
+ double d2 = (double) this.z + 0.5D;
|
||||
+
|
||||
+ this.world.makeSound(d0, (double) this.y + 0.5D, d2, "random.chestclosed", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
||||
+ }
|
||||
+
|
||||
+ if (this.a < 0.0F) {
|
||||
+ this.a = 0.0F;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public boolean c(int i, int j) {
|
||||
+ if (i == 1) {
|
||||
+ this.j = j;
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ return super.c(i, j);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void s() {
|
||||
+ this.u();
|
||||
+ super.s();
|
||||
+ }
|
||||
+
|
||||
+ public void a() {
|
||||
+ ++this.j;
|
||||
+ this.world.playBlockAction(this.x, this.y, this.z, Blocks.ENDER_CHEST, 1, this.j);
|
||||
+ }
|
||||
+
|
||||
+ public void b() {
|
||||
+ --this.j;
|
||||
+ this.world.playBlockAction(this.x, this.y, this.z, Blocks.ENDER_CHEST, 1, this.j);
|
||||
+ }
|
||||
+
|
||||
+ public boolean a(EntityHuman entityhuman) {
|
||||
+ return this.world.getTileEntity(this.x, this.y, this.z) != this ? false : entityhuman.e((double) this.x + 0.5D, (double) this.y + 0.5D, (double) this.z + 0.5D) <= 64.0D;
|
||||
+ }
|
||||
+}
|
||||
--
|
||||
1.9.1
|
||||
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
From 60ae5659d6d9a7a11949a3dbe2ec9ea0f8fa05a1 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <Zbob750@live.com>
|
||||
Date: Mon, 11 Aug 2014 19:30:19 -0500
|
||||
Subject: [PATCH] Move sound handling out of the chest tick loop
|
||||
|
||||
This allows us to disable ticking chests and enderchests without any
|
||||
noticeable difference to players
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java
|
||||
index c900caf..d2dfa8a 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityChest.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityChest.java
|
||||
@@ -275,6 +275,9 @@ public class TileEntityChest extends TileEntity implements IInventory {
|
||||
}
|
||||
|
||||
this.n = this.m;
|
||||
+
|
||||
+ // PaperSpigot start - Move chest sound handling out of the tick loop
|
||||
+ /*
|
||||
f = 0.1F;
|
||||
double d0;
|
||||
|
||||
@@ -327,6 +330,8 @@ public class TileEntityChest extends TileEntity implements IInventory {
|
||||
this.m = 0.0F;
|
||||
}
|
||||
}
|
||||
+ */
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
|
||||
public boolean c(int i, int j) {
|
||||
@@ -349,6 +354,26 @@ public class TileEntityChest extends TileEntity implements IInventory {
|
||||
if (this.world == null) return; // CraftBukkit
|
||||
this.world.playBlockAction(this.x, this.y, this.z, this.q(), 1, this.o);
|
||||
|
||||
+ // PaperSpigot start - Move chest open sound handling down to here
|
||||
+ this.i();
|
||||
+ double d0;
|
||||
+
|
||||
+ if (this.o > 0 && this.m == 0.0F && this.i == null && this.k == null) {
|
||||
+ double d1 = (double) this.x + 0.5D;
|
||||
+
|
||||
+ d0 = (double) this.z + 0.5D;
|
||||
+ if (this.l != null) {
|
||||
+ d0 += 0.5D;
|
||||
+ }
|
||||
+
|
||||
+ if (this.j != null) {
|
||||
+ d1 += 0.5D;
|
||||
+ }
|
||||
+
|
||||
+ this.world.makeSound(d1, (double) this.y + 0.5D, d0, "random.chestopen", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
||||
+ }
|
||||
+ // PaperSpigot end
|
||||
+
|
||||
// CraftBukkit start - Call redstone event
|
||||
if (this.q() == Blocks.TRAPPED_CHEST) {
|
||||
int newPower = Math.max(0, Math.min(15, this.o));
|
||||
@@ -371,6 +396,26 @@ public class TileEntityChest extends TileEntity implements IInventory {
|
||||
if (this.world == null) return; // CraftBukkit
|
||||
this.world.playBlockAction(this.x, this.y, this.z, this.q(), 1, this.o);
|
||||
|
||||
+ // PaperSpigot start - Move chest close sound handling down to here
|
||||
+ this.i();
|
||||
+ double d0;
|
||||
+
|
||||
+ if (this.o == 0 && this.i == null && this.k == null) {
|
||||
+ d0 = (double) this.x + 0.5D;
|
||||
+ double d2 = (double) this.z + 0.5D;
|
||||
+
|
||||
+ if (this.l != null) {
|
||||
+ d2 += 0.5D;
|
||||
+ }
|
||||
+
|
||||
+ if (this.j != null) {
|
||||
+ d0 += 0.5D;
|
||||
+ }
|
||||
+
|
||||
+ this.world.makeSound(d0, (double) this.y + 0.5D, d2, "random.chestclosed", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
||||
+ }
|
||||
+ // PaperSpigot end
|
||||
+
|
||||
// CraftBukkit start - Call redstone event
|
||||
if (this.q() == Blocks.TRAPPED_CHEST) {
|
||||
int newPower = Math.max(0, Math.min(15, this.o));
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
||||
index b205ab7..a4df9cb 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
|
||||
@@ -16,6 +16,9 @@ public class TileEntityEnderChest extends TileEntity {
|
||||
}
|
||||
|
||||
this.i = this.a;
|
||||
+
|
||||
+ // PaperSpigot start - Move chest sound handling out of the tick loop
|
||||
+ /*
|
||||
float f = 0.1F;
|
||||
double d0;
|
||||
|
||||
@@ -52,6 +55,8 @@ public class TileEntityEnderChest extends TileEntity {
|
||||
this.a = 0.0F;
|
||||
}
|
||||
}
|
||||
+ */
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
|
||||
public boolean c(int i, int j) {
|
||||
@@ -71,11 +76,39 @@ public class TileEntityEnderChest extends TileEntity {
|
||||
public void a() {
|
||||
++this.j;
|
||||
this.world.playBlockAction(this.x, this.y, this.z, Blocks.ENDER_CHEST, 1, this.j);
|
||||
+
|
||||
+ // PaperSpigot start - Move chest open sound handling down to here
|
||||
+ double d0;
|
||||
+
|
||||
+ if (this.j > 0 && this.a == 0.0F) {
|
||||
+ double d1 = (double) this.x + 0.5D;
|
||||
+
|
||||
+ d0 = (double) this.z + 0.5D;
|
||||
+ this.world.makeSound(d1, (double) this.y + 0.5D, d0, "random.chestopen", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
||||
+ }
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
|
||||
public void b() {
|
||||
--this.j;
|
||||
this.world.playBlockAction(this.x, this.y, this.z, Blocks.ENDER_CHEST, 1, this.j);
|
||||
+
|
||||
+ // PaperSpigot start - Move chest close sound handling down to here
|
||||
+ float f = 0.1F;
|
||||
+ double d0;
|
||||
+
|
||||
+ if (this.j == 0 && this.a == 0.0F || this.j > 0 && this.a < 1.0F) {
|
||||
+ float f1 = this.a;
|
||||
+ d0 = (double) this.x + 0.5D;
|
||||
+ double d2 = (double) this.z + 0.5D;
|
||||
+
|
||||
+ this.world.makeSound(d0, (double) this.y + 0.5D, d2, "random.chestclosed", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
||||
+
|
||||
+ if (this.a < 0.0F) {
|
||||
+ this.a = 0.0F;
|
||||
+ }
|
||||
+ }
|
||||
+ // PaperSpigot end
|
||||
}
|
||||
|
||||
public boolean a(EntityHuman entityhuman) {
|
||||
diff --git a/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java
|
||||
index 4eeb865..d02ce68 100644
|
||||
--- a/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java
|
||||
@@ -180,8 +180,6 @@ public class PaperSpigotWorldConfig
|
||||
private static final Map<String,Integer> defaultTileEntityTickIntervals = new HashMap<String, Integer>() {{
|
||||
// Use 0 for no ticking
|
||||
// does findPlayer lookup, so this helps performance to slow down
|
||||
- put("chest", 10);
|
||||
- put("enderchest", 10);
|
||||
put("enchanttable", 10);
|
||||
|
||||
// These TE's have empty tick methods, doing nothing. Never bother ticking them.
|
||||
@@ -195,6 +193,9 @@ public class PaperSpigotWorldConfig
|
||||
put("skull", 0);
|
||||
put("comparator", 0);
|
||||
put("flowerpot", 0);
|
||||
+ // PaperSpigot - We moved the chest sound handling out of the tick loop, so it's safe to not tick them
|
||||
+ put("chest", 0);
|
||||
+ put("enderchest", 0);
|
||||
|
||||
// Slow things down that players won't notice due to craftbukkit "wall time" patches.
|
||||
put("furnace", 4);
|
||||
--
|
||||
1.9.1
|
||||
|
Loading…
Reference in New Issue