Paper/Spigot-Server-Patches/0025-Move-sound-handling-out-of-the-chest-tick-loop.patch

199 lines
7.6 KiB
Diff
Raw Normal View History

From 3cb95d0d115022e965df1b2f3c38fa772cea4cca Mon Sep 17 00:00:00 2001
2014-11-28 02:17:45 +01:00
From: Iceee <andrew@opticgaming.tv>
2015-03-08 02:16:09 +01:00
Date: Sun, 8 Mar 2015 03:16:39 -0500
2014-11-28 02:17:45 +01:00
Subject: [PATCH] Move sound handling out of the chest tick loop
diff --git a/src/main/java/net/minecraft/server/TileEntityChest.java b/src/main/java/net/minecraft/server/TileEntityChest.java
index 07891ec..20f8d90 100644
2014-11-28 02:17:45 +01:00
--- a/src/main/java/net/minecraft/server/TileEntityChest.java
+++ b/src/main/java/net/minecraft/server/TileEntityChest.java
@@ -12,13 +12,13 @@ public class TileEntityChest extends TileEntityContainer implements IUpdatePlaye
private ItemStack[] items = new ItemStack[27];
public boolean a;
- public TileEntityChest f;
- public TileEntityChest g;
- public TileEntityChest h;
- public TileEntityChest i;
- public float j;
+ public TileEntityChest f; // PaperSpigot - adjacentChestZNeg
+ public TileEntityChest g; // PaperSpigot - adjacentChestXPos
+ public TileEntityChest h; // PaperSpigot - adjacentChestXNeg
+ public TileEntityChest i; // PaperSpigot - adjacentChestZPos
+ public float j; // PaperSpigot - lidAngle
public float k;
- public int l;
2014-12-07 21:52:19 +01:00
+ public int l; // PaperSpigot - numPlayersUsing
2014-11-28 02:17:45 +01:00
private int n;
private int o = -1;
private String p;
@@ -238,6 +238,8 @@ public class TileEntityChest extends TileEntityContainer implements IUpdatePlaye
}
public void c() {
2015-03-08 02:16:09 +01:00
+ // PaperSpigot - Move chest sounds out of the tick loop
2014-11-28 02:17:45 +01:00
+ /*
this.m();
int i = this.position.getX();
int j = this.position.getY();
2015-03-08 02:16:09 +01:00
@@ -318,7 +320,8 @@ public class TileEntityChest extends TileEntityContainer implements IUpdatePlaye
2014-11-28 02:17:45 +01:00
this.j = 0.0F;
}
}
2015-03-08 02:16:09 +01:00
-
2014-11-28 02:17:45 +01:00
+ */
+ // PaperSpigot end
}
2015-03-08 02:16:09 +01:00
public boolean c(int i, int j) {
@@ -339,6 +342,28 @@ public class TileEntityChest extends TileEntityContainer implements IUpdatePlaye
2014-11-28 02:17:45 +01:00
++this.l;
if (this.world == null) return; // CraftBukkit
+
2015-03-08 02:16:09 +01:00
+ // PaperSpigot start - Move chest open sound out of the tick loop
2014-12-07 21:52:19 +01:00
+ this.m();
+
+ if (this.l > 0 && this.j == 0.0F && this.f == null && this.h == null) {
+ this.j = 0.7F;
+
2015-03-08 02:16:09 +01:00
+ double d0 = (double) this.position.getZ() + 0.5D;
+ double d1 = (double) this.position.getX() + 0.5D;
2014-11-28 02:17:45 +01:00
+
+ if (this.i != null) {
+ d0 += 0.5D;
+ }
+
+ if (this.g != null) {
+ d1 += 0.5D;
+ }
+
2015-03-08 02:16:09 +01:00
+ this.world.makeSound(d1, (double) this.position.getY() + 0.5D, d0, "random.chestopen", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
2014-11-28 02:17:45 +01:00
+ }
2014-12-08 05:57:26 +01:00
+ // PaperSpigot end
2014-11-28 02:17:45 +01:00
+
this.world.playBlockAction(this.position, this.w(), 1, this.l);
// CraftBukkit start - Call redstone event
2015-03-08 02:16:09 +01:00
@@ -361,6 +386,33 @@ public class TileEntityChest extends TileEntityContainer implements IUpdatePlaye
int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added
2014-11-28 02:17:45 +01:00
--this.l;
if (this.world == null) return; // CraftBukkit
+
+ // PaperSpigot start - Move chest close sound handling out of the tick loop
+ if (this.l == 0 && this.j > 0.0F || this.l > 0 && this.j < 1.0F) {
+ float f = 0.1F;
+
+ if (this.l > 0) {
+ this.j += f;
+ } else {
+ this.j -= f;
+ }
+
2015-03-08 02:16:09 +01:00
+ double d0 = (double) this.getPosition().getX() + 0.5D;
+ double d2 = (double) this.getPosition().getZ() + 0.5D;
2014-11-28 02:17:45 +01:00
+
+ if (this.i != null) {
+ d2 += 0.5D;
+ }
+
+ if (this.g != null) {
+ d0 += 0.5D;
+ }
+
2015-03-08 02:16:09 +01:00
+ this.world.makeSound(d0, (double) this.getPosition().getY() + 0.5D, d2, "random.chestclosed", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
2014-12-07 21:52:19 +01:00
+ this.j = 0.0F;
2014-11-28 02:17:45 +01:00
+ }
+ // PaperSpigot end
+
this.world.playBlockAction(this.position, this.w(), 1, this.l);
2015-03-08 02:16:09 +01:00
2014-11-28 02:17:45 +01:00
// CraftBukkit start - Call redstone event
diff --git a/src/main/java/net/minecraft/server/TileEntityEnderChest.java b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
2015-03-08 02:16:09 +01:00
index f712885..d2ef4c4 100644
2014-11-28 02:17:45 +01:00
--- a/src/main/java/net/minecraft/server/TileEntityEnderChest.java
+++ b/src/main/java/net/minecraft/server/TileEntityEnderChest.java
@@ -2,14 +2,16 @@ package net.minecraft.server;
public class TileEntityEnderChest extends TileEntity implements IUpdatePlayerListBox {
- public float a;
+ public float a; // PaperSpigot - lidAngle
public float f;
- public int g;
+ public int g; // PaperSpigot - numPlayersUsing
private int h;
public TileEntityEnderChest() {}
public void c() {
2015-03-08 02:16:09 +01:00
+ // PaperSpigot start - Move enderchest sound handling out of the tick loop
2014-11-28 02:17:45 +01:00
+ /*
2015-03-08 02:16:09 +01:00
if (++this.h % 4 == 0) { // PaperSpigot - Reduced (20 * 4) -> 4 interval due to reduced tick rate from improved tick handling
2014-11-28 02:17:45 +01:00
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.g);
}
2015-03-08 02:16:09 +01:00
@@ -54,7 +56,8 @@ public class TileEntityEnderChest extends TileEntity implements IUpdatePlayerLis
2014-11-28 02:17:45 +01:00
this.a = 0.0F;
}
}
2015-03-08 02:16:09 +01:00
-
2014-11-28 02:17:45 +01:00
+ */
+ // PaperSpigot end
}
2015-03-08 02:16:09 +01:00
public boolean c(int i, int j) {
@@ -73,11 +76,34 @@ public class TileEntityEnderChest extends TileEntity implements IUpdatePlayerLis
2014-11-28 02:17:45 +01:00
public void b() {
++this.g;
+
+ // PaperSpigot start - Move enderchest open sounds out of the tick loop
+ if (this.g > 0 && this.a == 0.0F) {
2014-12-07 21:52:19 +01:00
+ this.a = 0.7F;
+
2015-03-08 02:16:09 +01:00
+ double d1 = (double) this.getPosition().getX() + 0.5D;
+ double d0 = (double) this.getPosition().getZ() + 0.5D;
2014-11-28 02:17:45 +01:00
+
2015-03-08 02:16:09 +01:00
+ this.world.makeSound(d1, (double) this.getPosition().getY() + 0.5D, d0, "random.chestopen", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
2014-11-28 02:17:45 +01:00
+ }
+ // PaperSpigot end
+
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.g);
}
public void d() {
--this.g;
+
+ // PaperSpigot start - Move enderchest close sounds out of the tick loop
+ if (this.g == 0 && this.a > 0.0F || this.g > 0 && this.a < 1.0F) {
2015-03-08 02:16:09 +01:00
+ double d0 = (double) this.getPosition().getX() + 0.5D;
+ double d2 = (double) this.getPosition().getZ() + 0.5D;
2014-11-28 02:17:45 +01:00
+
2015-03-08 02:16:09 +01:00
+ this.world.makeSound(d0, (double) this.getPosition().getY() + 0.5D, d2, "random.chestclosed", 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
2014-12-07 21:52:19 +01:00
+ this.a = 0.0F;
2014-11-28 02:17:45 +01:00
+ }
+ // PaperSpigot end
+
this.world.playBlockAction(this.position, Blocks.ENDER_CHEST, 1, this.g);
}
2015-03-08 02:16:09 +01:00
diff --git a/src/main/java/org/github/paperspigot/WorldTileEntityList.java b/src/main/java/org/github/paperspigot/WorldTileEntityList.java
index 5af5dcc..693f75c 100644
--- a/src/main/java/org/github/paperspigot/WorldTileEntityList.java
+++ b/src/main/java/org/github/paperspigot/WorldTileEntityList.java
@@ -26,7 +26,9 @@ public class WorldTileEntityList extends HashSet<TileEntity> {
TileEntityCommand.class,
TileEntitySkull.class,
TileEntityComparator.class,
- TileEntityFlowerPot.class
+ TileEntityFlowerPot.class,
+ TileEntityChest.class,
+ TileEntityEnderChest.class
}) {
put(ignored, -1);
}
2014-11-28 02:17:45 +01:00
--
2.4.1.windows.1
2014-11-28 02:17:45 +01:00