text: package mekanism.common.tile.machine;
  
  import javax.annotation.Nonnull;
  import mekanism.api.Action;
  import mekanism.api.Coord4D;
  import mekanism.api.RelativeSide;
  import mekanism.api.inventory.AutomationType;
  import mekanism.api.math.FloatingLong;
  import mekanism.common.Mekanism;
  import mekanism.common.capabilities.energy.MachineEnergyContainer;
  import mekanism.common.capabilities.holder.energy.EnergyContainerHelper;
  import mekanism.common.capabilities.holder.energy.IEnergyContainerHolder;
  import mekanism.common.capabilities.holder.slot.IInventorySlotHolder;
  import mekanism.common.capabilities.holder.slot.InventorySlotHelper;
  import mekanism.common.inventory.slot.EnergyInventorySlot;
  import mekanism.common.registries.MekanismBlocks;
  import mekanism.common.tile.base.TileEntityMekanism;
  import mekanism.common.tile.interfaces.IBoundingBlock;
  import mekanism.common.util.MekanismUtils;
  import net.minecraft.block.BlockState;
  import net.minecraft.util.math.AxisAlignedBB;
  import net.minecraft.world.World;
  
  public class TileEntitySeismicVibrator extends TileEntityMekanism implements IBoundingBlock {
  
      public int clientPiston;
  
      private MachineEnergyContainer<TileEntitySeismicVibrator> energyContainer;
      private EnergyInventorySlot energySlot;
  
      public TileEntitySeismicVibrator() {
          super(MekanismBlocks.SEISMIC_VIBRATOR);
      }
  
      @Nonnull
      @Override
      protected IEnergyContainerHolder getInitialEnergyContainers() {
          EnergyContainerHelper builder = EnergyContainerHelper.forSide(this::getDirection);
          builder.addContainer(energyContainer = MachineEnergyContainer.input(this), RelativeSide.BACK);
          return builder.build();
      }
  
      @Nonnull
      @Override
      protected IInventorySlotHolder getInitialInventory() {
          InventorySlotHelper builder = InventorySlotHelper.forSide(this::getDirection);
          builder.addSlot(energySlot = EnergyInventorySlot.fillOrConvert(energyContainer, this::getWorld, this, 143, 35));
          return builder.build();
      }
  
      @Override
      protected void onUpdateClient() {
          super.onUpdateClient();
          if (getActive()) {
              clientPiston++;
          }
          updateActiveVibrators();
      }
  
      @Override
      protected void onUpdateServer() {
          super.onUpdateServer();
          energySlot.fillContainerOrConvert();
          if (MekanismUtils.canFunction(this)) {
              FloatingLong energyPerTick = energyContainer.getEnergyPerTick();
              if (energyContainer.extract(energyPerTick, Action.SIMULATE, AutomationType.INTERNAL).equals(energyPerTick)) {
                  setActive(true);
                  energyContainer.extract(energyPerTick, Action.EXECUTE, AutomationType.INTERNAL);
              } else {
                  setActive(false);
              }
          } else {
              setActive(false);
          }
          updateActiveVibrators();
      }
  
      private void updateActiveVibrators() {
          if (getActive()) {
              Mekanism.activeVibrators.add(Coord4D.get(this));
          } else {
              Mekanism.activeVibrators.remove(Coord4D.get(this));
          }
      }
  
      @Override
      public void remove() {
          super.remove();
          Mekanism.activeVibrators.remove(Coord4D.get(this));
      }
  
      @Override
      public boolean lightUpdate() {
          return true;
      }
  
      @Override
      public void onPlace() {
          MekanismUtils.makeBoundingBlock(getWorld(), getPos().up(), getPos());
      }
  
      @Override
      public void onBreak(BlockState oldState) {
          World world = getWorld();
          if (world != null) {
              world.removeBlock(getPos().up(), false);
              world.removeBlock(getPos(), false);
          }
      }
  
      @Nonnull
      @Override
      public AxisAlignedBB getRenderBoundingBox() {
          return new AxisAlignedBB(pos, pos.add(1, 2, 1));
      }
  
      public MachineEnergyContainer<TileEntitySeismicVibrator> getEnergyContainer() {
          return energyContainer;
      }
  }