mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-23 00:15:08 +00:00
More clear error when loot is not generated
This commit is contained in:
parent
db27d25a93
commit
3faf41ef18
1 changed files with 20 additions and 13 deletions
|
@ -18,8 +18,6 @@ package com.lishid.openinv.internal.v1_14_R1;
|
||||||
|
|
||||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import net.minecraft.server.v1_14_R1.AxisAlignedBB;
|
|
||||||
import net.minecraft.server.v1_14_R1.Block;
|
import net.minecraft.server.v1_14_R1.Block;
|
||||||
import net.minecraft.server.v1_14_R1.BlockBarrel;
|
import net.minecraft.server.v1_14_R1.BlockBarrel;
|
||||||
import net.minecraft.server.v1_14_R1.BlockChest;
|
import net.minecraft.server.v1_14_R1.BlockChest;
|
||||||
|
@ -33,7 +31,7 @@ import net.minecraft.server.v1_14_R1.Container;
|
||||||
import net.minecraft.server.v1_14_R1.ContainerChest;
|
import net.minecraft.server.v1_14_R1.ContainerChest;
|
||||||
import net.minecraft.server.v1_14_R1.EntityHuman;
|
import net.minecraft.server.v1_14_R1.EntityHuman;
|
||||||
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
import net.minecraft.server.v1_14_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_14_R1.EnumDirection;
|
import net.minecraft.server.v1_14_R1.EnumChatFormat;
|
||||||
import net.minecraft.server.v1_14_R1.EnumGamemode;
|
import net.minecraft.server.v1_14_R1.EnumGamemode;
|
||||||
import net.minecraft.server.v1_14_R1.IBlockData;
|
import net.minecraft.server.v1_14_R1.IBlockData;
|
||||||
import net.minecraft.server.v1_14_R1.IChatBaseComponent;
|
import net.minecraft.server.v1_14_R1.IChatBaseComponent;
|
||||||
|
@ -45,7 +43,7 @@ import net.minecraft.server.v1_14_R1.PlayerInventory;
|
||||||
import net.minecraft.server.v1_14_R1.TileEntity;
|
import net.minecraft.server.v1_14_R1.TileEntity;
|
||||||
import net.minecraft.server.v1_14_R1.TileEntityChest;
|
import net.minecraft.server.v1_14_R1.TileEntityChest;
|
||||||
import net.minecraft.server.v1_14_R1.TileEntityEnderChest;
|
import net.minecraft.server.v1_14_R1.TileEntityEnderChest;
|
||||||
import net.minecraft.server.v1_14_R1.TileEntityShulkerBox;
|
import net.minecraft.server.v1_14_R1.TileEntityLootable;
|
||||||
import net.minecraft.server.v1_14_R1.TileInventory;
|
import net.minecraft.server.v1_14_R1.TileInventory;
|
||||||
import net.minecraft.server.v1_14_R1.World;
|
import net.minecraft.server.v1_14_R1.World;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -181,7 +179,7 @@ public class AnySilentContainer implements IAnySilentContainer {
|
||||||
|
|
||||||
final World world = player.world;
|
final World world = player.world;
|
||||||
final BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
|
final BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
|
||||||
final Object tile = world.getTileEntity(blockPosition);
|
final TileEntity tile = world.getTileEntity(blockPosition);
|
||||||
|
|
||||||
if (tile == null) {
|
if (tile == null) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -226,16 +224,17 @@ public class AnySilentContainer implements IAnySilentContainer {
|
||||||
if (adjacentTile instanceof TileEntityChest && tileInventory instanceof TileEntityChest) {
|
if (adjacentTile instanceof TileEntityChest && tileInventory instanceof TileEntityChest) {
|
||||||
TileEntityChest rightChest = chestType == BlockPropertyChestType.RIGHT ? ((TileEntityChest) tileInventory) : (TileEntityChest) adjacentTile;
|
TileEntityChest rightChest = chestType == BlockPropertyChestType.RIGHT ? ((TileEntityChest) tileInventory) : (TileEntityChest) adjacentTile;
|
||||||
TileEntityChest leftChest = chestType == BlockPropertyChestType.RIGHT ? (TileEntityChest) adjacentTile : ((TileEntityChest) tileInventory);
|
TileEntityChest leftChest = chestType == BlockPropertyChestType.RIGHT ? (TileEntityChest) adjacentTile : ((TileEntityChest) tileInventory);
|
||||||
|
|
||||||
|
if (rightChest.lootTable != null || leftChest.lootTable != null) {
|
||||||
|
player.a(new ChatMessage("Loot not generated! Please disable /silentcontainer.").a(EnumChatFormat.RED), true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
tileInventory = new ITileInventory() {
|
tileInventory = new ITileInventory() {
|
||||||
@Nullable
|
|
||||||
public Container createMenu(int containerCounter, PlayerInventory playerInventory, EntityHuman entityHuman) {
|
public Container createMenu(int containerCounter, PlayerInventory playerInventory, EntityHuman entityHuman) {
|
||||||
if (leftChest.e(entityHuman) && rightChest.e(entityHuman)) {
|
leftChest.d(playerInventory.player);
|
||||||
leftChest.d(playerInventory.player);
|
rightChest.d(playerInventory.player);
|
||||||
rightChest.d(playerInventory.player);
|
return ContainerChest.b(containerCounter, playerInventory, new InventoryLargeChest(rightChest, leftChest));
|
||||||
return ContainerChest.b(containerCounter, playerInventory, new InventoryLargeChest(rightChest, leftChest));
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IChatBaseComponent getScoreboardDisplayName() {
|
public IChatBaseComponent getScoreboardDisplayName() {
|
||||||
|
@ -273,6 +272,14 @@ public class AnySilentContainer implements IAnySilentContainer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tile instanceof TileEntityLootable) {
|
||||||
|
TileEntityLootable lootable = (TileEntityLootable) tile;
|
||||||
|
if (lootable.lootTable != null) {
|
||||||
|
player.a(new ChatMessage("Loot not generated! Please disable /silentcontainer.").a(EnumChatFormat.RED), true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
|
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
|
||||||
this.forceGameMode(player, EnumGamemode.SPECTATOR);
|
this.forceGameMode(player, EnumGamemode.SPECTATOR);
|
||||||
player.openContainer(tileInventory);
|
player.openContainer(tileInventory);
|
||||||
|
|
Loading…
Reference in a new issue