mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 23:57:43 +01:00
173 lines
6.3 KiB
Diff
173 lines
6.3 KiB
Diff
From 280e4f94a1b0fc4a599baaeaa854ee2321990e9f 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 e27716b..69ffd30 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 d76a2b2..339e133 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/ChunkTileEntityList.java b/src/main/java/org/github/paperspigot/ChunkTileEntityList.java
|
|
index e673ba9..dac6463 100644
|
|
--- a/src/main/java/org/github/paperspigot/ChunkTileEntityList.java
|
|
+++ b/src/main/java/org/github/paperspigot/ChunkTileEntityList.java
|
|
@@ -25,14 +25,14 @@ public class ChunkTileEntityList {
|
|
TileEntityCommand.class,
|
|
TileEntitySkull.class,
|
|
TileEntityComparator.class,
|
|
- TileEntityFlowerPot.class
|
|
+ TileEntityFlowerPot.class,
|
|
+ TileEntityChest.class,
|
|
+ TileEntityEnderChest.class
|
|
}) {
|
|
put(ignored, 0);
|
|
}
|
|
|
|
// does findPlayer lookup, so this helps performance to slow down
|
|
- put(TileEntityChest.class, 20);
|
|
- put(TileEntityEnderChest.class, 20);
|
|
put(TileEntityEnchantTable.class, 20);
|
|
|
|
// Slow things down that players won't notice due to craftbukkit "wall time" patches.
|
|
--
|
|
1.9.1
|
|
|