Silences shulker boxes but breaks sound/animation till tile is reloaded
Time for relaxation and sleep, too much actual effort expended today
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<artifactId>openinv</artifactId>
|
<artifactId>openinv</artifactId>
|
||||||
<name>OpenInv</name>
|
<name>OpenInv</name>
|
||||||
<version>2.5.2</version>
|
<version>2.5.3-SNAPSHOT</version>
|
||||||
|
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
||||||
|
@@ -116,9 +116,11 @@ public class AnySilentContainer implements IAnySilentContainer {
|
|||||||
|
|
||||||
player.b(StatisticList.ae);
|
player.b(StatisticList.ae);
|
||||||
|
|
||||||
if (silentchest) {
|
if (silentchest && tile instanceof TileEntityShulkerBox) {
|
||||||
// TODO We need to go deeper: Box is not anumated, but sound plays.
|
// TODO: This fixes sound, but the box is then silent for anyone until the tile entity is recreated
|
||||||
|
SilentContainerShulkerBox.increaseOpenQuantity((TileEntityShulkerBox) tile);
|
||||||
container = new SilentContainerShulkerBox(player.inventory, ((IInventory) tile), player);
|
container = new SilentContainerShulkerBox(player.inventory, ((IInventory) tile), player);
|
||||||
|
SilentContainerShulkerBox.decreaseOpenQuantity((TileEntityShulkerBox) tile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,22 +1,49 @@
|
|||||||
package com.lishid.openinv.internal.v1_11_R1;
|
package com.lishid.openinv.internal.v1_11_R1;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import net.minecraft.server.v1_11_R1.ContainerShulkerBox;
|
import net.minecraft.server.v1_11_R1.ContainerShulkerBox;
|
||||||
import net.minecraft.server.v1_11_R1.EntityHuman;
|
import net.minecraft.server.v1_11_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_11_R1.IInventory;
|
import net.minecraft.server.v1_11_R1.IInventory;
|
||||||
import net.minecraft.server.v1_11_R1.ItemStack;
|
import net.minecraft.server.v1_11_R1.ItemStack;
|
||||||
import net.minecraft.server.v1_11_R1.PlayerInventory;
|
import net.minecraft.server.v1_11_R1.PlayerInventory;
|
||||||
|
import net.minecraft.server.v1_11_R1.TileEntityShulkerBox;
|
||||||
|
|
||||||
public class SilentContainerShulkerBox extends ContainerShulkerBox {
|
public class SilentContainerShulkerBox extends ContainerShulkerBox {
|
||||||
|
|
||||||
|
private static Field h;
|
||||||
|
|
||||||
|
private static Field exposeOpenStatus() throws NoSuchFieldException, SecurityException {
|
||||||
|
if (h == null) {
|
||||||
|
h = TileEntityShulkerBox.class.getDeclaredField("h");
|
||||||
|
h.setAccessible(true);
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void increaseOpenQuantity(TileEntityShulkerBox containerShulkerBox) {
|
||||||
|
try {
|
||||||
|
exposeOpenStatus().set(containerShulkerBox, ((Integer) exposeOpenStatus().get(containerShulkerBox)) + 1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decreaseOpenQuantity(TileEntityShulkerBox containerShulkerBox) {
|
||||||
|
try {
|
||||||
|
exposeOpenStatus().set(containerShulkerBox, ((Integer) exposeOpenStatus().get(containerShulkerBox)) - 1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SilentContainerShulkerBox(PlayerInventory playerInventory, IInventory iInventory,
|
public SilentContainerShulkerBox(PlayerInventory playerInventory, IInventory iInventory,
|
||||||
EntityHuman entityHuman) {
|
EntityHuman entityHuman) {
|
||||||
super(playerInventory, iInventory, entityHuman);
|
super(playerInventory, iInventory, entityHuman);
|
||||||
iInventory.closeContainer(entityHuman);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void b(EntityHuman entityHuman) {
|
public void b(EntityHuman entityHuman) {
|
||||||
// Don't send close signal twice, might screw up
|
|
||||||
PlayerInventory playerinventory = entityHuman.inventory;
|
PlayerInventory playerinventory = entityHuman.inventory;
|
||||||
|
|
||||||
if (!playerinventory.getCarried().isEmpty()) {
|
if (!playerinventory.getCarried().isEmpty()) {
|
||||||
|
Reference in New Issue
Block a user