@Override public void updateEntity() { ticksExisted++; // If a comparator or such has accessed the container and // the contents have been changed, send a block update. if (hasComparatorAccessed() && hasContentsChanged()) comparatorUpdateAndReset(); if (syncPlayersUsing()) { int newPlayersUsing = WorldUtils.syncPlayersUsing(this, playersUsing); if (newPlayersUsing != playersUsing) doSyncPlayersUsing(playersUsing = newPlayersUsing); } prevLidAngle = lidAngle; if (playersUsing > 0) { if (lidAngle < 1.0F) lidAngle = Math.min(1.0F, lidAngle + getLidSpeed()); } else if (lidAngle > 0.0F) lidAngle = Math.max(0.0F, lidAngle - getLidSpeed()); }
/** * Returns if a player can use this container. This is called once before the GUI is opened and * then again every tick. Returning false when the GUI is open, like when the player is too far * away, will close the GUI. */ public boolean canPlayerUseContainer(EntityPlayer player) { return WorldUtils.isTileEntityUsableByPlayer(this, player); }
/** * Helper function. Returns the comparator signal strength of the container at this position, or 0 * if there is no container or the function is called on client-side. */ public static int getContainerComparatorSignalStrength(IBlockAccess world, int x, int y, int z) { TileEntityContainer container = WorldUtils.get(world, x, y, z, TileEntityContainer.class); return ((container != null) ? container.getComparatorSignalStrength() : 0); }
/** Called when the container is destroyed to drop its contents. */ public void dropContents() { if (contents != null) for (ItemStack stack : contents) WorldUtils.dropStackFromBlock(worldObj, xCoord, yCoord, zCoord, stack); }