Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
svk написал(а):
public class ContainerYour extends Container {
private InventoryYour inv;
public ContainerYour(EntityPlayer player, InventoryYour inventoryYour) {
inv = inventoryYour;
inv.openInventory();
}
@Override
public void onContainerClosed(EntityPlayer player) {
super.onContainerClosed(player);
inv.closeInventory();
}
}
public class InventoryYour implements IInventory {//Возможно тут у тебя будет "extends TileEntity"
/** The number of players currently using this */
public int numPlayersUsing;
public InventoryYour() {
numPlayersUsing = 0;
}
public boolean isPlayersUsing() {
return numPlayersUsing > 0;
}
@Override
public void openInventory() {
++numPlayersUsing;
}
@Override
public void closeInventory() {
--numPlayersUsing;
}
}
А как и где проверять?timaxa007 написал(а):svk написал(а):Код:public class ContainerYour extends Container { private InventoryYour inv; public ContainerYour(EntityPlayer player, InventoryYour inventoryYour) { inv = inventoryYour; inv.openInventory(); } @Override public void onContainerClosed(EntityPlayer player) { super.onContainerClosed(player); inv.closeInventory(); } }
Это примерный код. Думаю сам додумаешься как сделать у себя.Код:public class InventoryYour implements IInventory {//Возможно тут у тебя будет "extends TileEntity" /** The number of players currently using this */ public int numPlayersUsing; public InventoryYour() { numPlayersUsing = 0; } public boolean isPlayersUsing() { return numPlayersUsing > 0; } @Override public void openInventory() { ++numPlayersUsing; } @Override public void closeInventory() { --numPlayersUsing; } }
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
TileEntity te = world.getTileEntity(x, y, z);
if (player.isSneaking()) return false;
if (te != null && te instanceof TileEntityYour) {
TileEntityYour te_your = (TileEntityYour)te;
if (!te_your.isPlayersUsing()) {
player.openGui(...);
return true;
} else {
player.addChatMessage(new ChatComponentText("Этот блок занят."));
return false;
}
}
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
}