Codota Logo
IErrorLogic
Code IndexAdd Codota to your IDE (free)

How to use
IErrorLogic
in
forestry.api.core

Best Java code snippets using forestry.api.core.IErrorLogic (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: ForestryMC/ForestryMC

FluidHelper.FillStatus fillStatus;
IErrorLogic errorLogic = getErrorLogic();
errorLogic.clearErrors();
errorLogic.setCondition(fillStatus == FluidHelper.FillStatus.NO_FLUID, EnumErrorCode.NO_RESOURCE_LIQUID);
errorLogic.setCondition(fillStatus == FluidHelper.FillStatus.NO_SPACE, EnumErrorCode.NO_SPACE_INVENTORY);
errorLogic.setCondition(emptyStatus == FluidHelper.FillStatus.NO_SPACE_FLUID, EnumErrorCode.NO_SPACE_TANK);
if (emptyStatus == FillStatus.INVALID_INPUT || fillStatus == FillStatus.INVALID_INPUT || errorLogic.hasErrors()) {
  currentRecipe = null;
  return false;
origin: ForestryMC/ForestryMC

  /**
   * Return true if the tile given in parameter activates the trigger, given the parameters.
   */
  @Override
  public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {

    if (!(tile instanceof IErrorLogicSource)) {
      return false;
    }

    IErrorLogicSource apiary = (IErrorLogicSource) tile;
    return apiary.getErrorLogic().contains(EnumErrorCode.NO_QUEEN);
  }
}
origin: ForestryMC/ForestryMC

  @Override
  public void onPacketData(PacketBufferForestry data, EntityPlayer player) {
    Entity entity = data.readEntityById(player.world);
    if (entity instanceof IErrorLogicSource) {
      IErrorLogicSource errorSourceTile = (IErrorLogicSource) entity;
      IErrorLogic errorLogic = errorSourceTile.getErrorLogic();
      errorLogic.readData(data);
    }
  }
}
origin: ForestryMC/ForestryMC

private boolean tryAddPending() {
  if (pendingProducts.isEmpty()) {
    return false;
  }
  ItemStack next = pendingProducts.peek();
  boolean added = InventoryUtil.tryAddStack(this, next, InventoryCentrifuge.SLOT_PRODUCT_1, InventoryCentrifuge.SLOT_PRODUCT_COUNT, true);
  if (added) {
    pendingProducts.pop();
    if (pendingProducts.isEmpty()) {
      craftPreviewInventory.setInventorySlotContents(0, ItemStack.EMPTY);
    }
  }
  getErrorLogic().setCondition(!added, EnumErrorCode.NO_SPACE_INVENTORY);
  return added;
}
origin: ForestryMC/ForestryMC

@Override
public void updateServerSide() {
  if (updateOnInterval(20)) {
    IErrorLogic errorLogic = getErrorLogic();
    BlockPos pos = getPos();
    Biome biome = world.getBiome(pos);
    errorLogic.setCondition(!biome.canRain(), EnumErrorCode.NO_RAIN_BIOME);
    BlockPos posAbove = pos.up();
    boolean hasSky = world.canBlockSeeSky(posAbove);
    errorLogic.setCondition(!hasSky, EnumErrorCode.NO_SKY_RAIN_TANK);
    errorLogic.setCondition(!world.isRainingAt(posAbove), EnumErrorCode.NOT_RAINING);
    if (!errorLogic.hasErrors()) {
      resourceTank.fillInternal(WATER_PER_UPDATE, true);
    }
    containerFiller.updateServerSide();
  }
  if (canDumpBelow == null) {
    canDumpBelow = FluidHelper.canAcceptFluid(world, getPos().down(), EnumFacing.UP, STACK_WATER);
  }
  if (canDumpBelow) {
    if (dumpingFluid || updateOnInterval(20)) {
      dumpingFluid = dumpFluidBelow();
    }
  }
}
origin: SquidDev-CC/plethora

  @BasicObjectMethod.Inject(
    value = IErrorLogicSource.class, modId = Constants.MOD_ID,
    doc = "function():table -- Get any errors preventing operation"
  )
  public static Object[] getErrors(IContext<IErrorLogicSource> context, Object[] arg) {
    return new Object[]{
      context.getTarget().getErrorLogic().getErrorStates().stream()
        .map(IErrorState::getUniqueName)
        .collect(LuaList.toLuaList()).asMap()
    };
  }
}
origin: ForestryMC/ForestryMC

@Override
protected boolean hasErrors() {
  return delegate.getErrorLogic().hasErrors();
}
origin: ForestryMC/ForestryMC

@Override
protected void writeData(PacketBufferForestry data) {
  data.writeEntityById(entity);
  errorLogic.writeData(data);
}
origin: ForestryMC/ForestryMC

private boolean tryAddPending() {
  if (pendingProduct == null) {
    return false;
  }
  boolean added = InventoryUtil.tryAddStack(this, pendingProduct, InventoryMoistener.SLOT_PRODUCT, 1, true);
  getErrorLogic().setCondition(!added, EnumErrorCode.NO_SPACE_INVENTORY);
  if (added) {
    pendingProduct = null;
  }
  return added;
}
origin: ForestryMC/ForestryMC

  @Override
  public void detectAndSendChanges() {
    super.detectAndSendChanges();

    if (entity instanceof IErrorLogicSource) {
      IErrorLogicSource errorLogicSource = (IErrorLogicSource) entity;
      ImmutableSet<IErrorState> errorStates = errorLogicSource.getErrorLogic().getErrorStates();

      if (previousErrorStates == null || !errorStates.equals(previousErrorStates)) {
        PacketErrorUpdateEntity packet = new PacketErrorUpdateEntity(entity, errorLogicSource);
        sendPacketToListeners(packet);
      }

      previousErrorStates = errorStates;
    }
  }
}
origin: ForestryMC/ForestryMC

private boolean isThrottled(IEffectData storedData, IBeeHousing housing) {
  if (requiresWorkingQueen && housing.getErrorLogic().hasErrors()) {
    return true;
  }
  int time = storedData.getInteger(0);
  time++;
  storedData.setInteger(0, time);
  if (time < throttle) {
    return true;
  }
  // Reset since we are done throttling.
  storedData.setInteger(0, 0);
  return false;
}
origin: ForestryMC/ForestryMC

@Override
protected void writeData(PacketBufferForestry data) {
  data.writeBlockPos(pos);
  errorLogic.writeData(data);
}
origin: ForestryMC/ForestryMC

errorLogic.clearErrors();
errorLogic.setCondition(!hasSpace, EnumErrorCode.NO_SPACE_INVENTORY);
  errorLogic.setCondition(!hasDrone, EnumErrorCode.NO_DRONE);
  return !errorLogic.hasErrors();
if (errorLogic.setCondition(queen == null, EnumErrorCode.NO_QUEEN)) {
  setActive(false);
  beeProgress = 0;
  errorLogic.setCondition(true, errorState);
errorLogic.setCondition(!hasFlowers, EnumErrorCode.NO_FLOWER);
boolean canWork = !errorLogic.hasErrors();
if (active != canWork) {
  setActive(canWork);
origin: ForestryMC/ForestryMC

@Override
public boolean hasWork() {
  if (updateOnInterval(20)) {
    checkRecipe();
  }
  boolean hasRecipe = currentRecipe != null;
  boolean hasLiquidResources = true;
  boolean hasItemResources = true;
  boolean canAdd = true;
  if (hasRecipe) {
    hasLiquidResources = removeLiquidResources(false);
    hasItemResources = removeItemResources(false);
    ItemStack pendingProduct = currentRecipe.getCraftingGridRecipe().getOutput();
    canAdd = InventoryUtil.tryAddStack(this, pendingProduct, InventoryCarpenter.SLOT_PRODUCT, InventoryCarpenter.SLOT_PRODUCT_COUNT, true, false);
  }
  IErrorLogic errorLogic = getErrorLogic();
  errorLogic.setCondition(!hasRecipe, EnumErrorCode.NO_RECIPE);
  errorLogic.setCondition(!hasLiquidResources, EnumErrorCode.NO_RESOURCE_LIQUID);
  errorLogic.setCondition(!hasItemResources, EnumErrorCode.NO_RESOURCE_INVENTORY);
  errorLogic.setCondition(!canAdd, EnumErrorCode.NO_SPACE_INVENTORY);
  return hasRecipe && hasItemResources && hasLiquidResources && canAdd;
}
origin: ForestryMC/ForestryMC

ImmutableSet<IErrorState> errorStates = errorLogicSource.getErrorLogic().getErrorStates();
origin: ForestryMC/Binnie

  @Override
  public void onUpdate() {
    if (new Random().nextInt(2400) == 0) {
      TileEntity tile = this.getMachine().getTileEntity();
      if (tile instanceof TileExtraBeeAlveary) {
        final IBeeHousing house = ((TileExtraBeeAlveary) tile).getMultiblockLogic().getController();
        if (house != null && !house.getErrorLogic().hasErrors()) {
          final ItemStack queenStack = house.getBeeInventory().getQueen();
          final IBee queen = (queenStack.isEmpty()) ? null : Utils.getBeeRoot().getMember(queenStack);
          if (queen != null) {
            final ItemStack larvae = Utils.getBeeRoot().getMemberStack(Utils.getBeeRoot().getBee(queen.getGenome()), EnumBeeType.LARVAE);
            new TransferRequest(larvae, this.getInventory()).transfer(null, true);
          }
        }
      }
    }
  }
}
origin: ForestryMC/ForestryMC

/**
 * Return true if the tile given in parameter activates the trigger, given the parameters.
 */
@Override
public boolean isTriggerActive(TileEntity tile, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters) {
  if (!(tile instanceof IErrorLogicSource)) {
    return false;
  }
  IErrorLogicSource apiary = (IErrorLogicSource) tile;
  return apiary.getErrorLogic().contains(EnumErrorCode.NO_DRONE);
}
origin: ForestryMC/ForestryMC

  @Override
  public void onPacketData(PacketBufferForestry data, EntityPlayer player) {
    BlockPos pos = data.readBlockPos();
    TileUtil.actOnTile(player.world, pos, IErrorLogicSource.class, errorSourceTile -> {
      IErrorLogic errorLogic = errorSourceTile.getErrorLogic();
      errorLogic.readData(data);
    });
  }
}
origin: ForestryMC/ForestryMC

@Override
public boolean hasWork() {
  checkRecipe();
  checkFuel();
  int fermented = Math.min(fermentationTime, fuelCurrentFerment);
  boolean hasRecipe = currentRecipe != null;
  boolean hasFuel = fuelBurnTime > 0;
  boolean hasResource = fermentationTime > 0 || !getStackInSlot(InventoryFermenter.SLOT_RESOURCE).isEmpty();
  FluidStack drained = resourceTank.drain(fermented, false);
  boolean hasFluidResource = drained != null && drained.amount == fermented;
  boolean hasFluidSpace = true;
  if (hasRecipe) {
    int productAmount = Math.round(fermented * currentRecipe.getModifier() * currentResourceModifier);
    Fluid output = currentRecipe.getOutput();
    FluidStack fluidStack = new FluidStack(output, productAmount);
    hasFluidSpace = productTank.fillInternal(fluidStack, false) == fluidStack.amount;
  }
  IErrorLogic errorLogic = getErrorLogic();
  errorLogic.setCondition(!hasRecipe, EnumErrorCode.NO_RECIPE);
  errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL);
  errorLogic.setCondition(!hasResource, EnumErrorCode.NO_RESOURCE);
  errorLogic.setCondition(!hasFluidResource, EnumErrorCode.NO_RESOURCE_LIQUID);
  errorLogic.setCondition(!hasFluidSpace, EnumErrorCode.NO_SPACE_TANK);
  return hasRecipe && hasFuel && hasResource && hasFluidResource && hasFluidSpace;
}
origin: ForestryMC/ForestryMC

public boolean isLinked() {
  if (!address.isValid()) {
    return false;
  }
  IErrorLogic errorLogic = getErrorLogic();
  return !errorLogic.contains(EnumErrorCode.NOT_ALPHANUMERIC) && !errorLogic.contains(EnumErrorCode.NOT_UNIQUE);
}
forestry.api.coreIErrorLogic

Javadoc

Keeps track of all the IErrorStates for an object. Create a new IErrorLogic instance for your object with ForestryAPI.errorStateRegistry.createErrorLogic().

Most used methods

  • getErrorStates
  • hasErrors
  • clearErrors
    Sets all active error states to false
  • contains
  • readData
  • setCondition
    Sets the errorState when condition is true, and unsets it when condition is false.
  • writeData
    Network serialization for syncing errors to the client from the server.

Popular in Java

  • Reactive rest calls using spring rest template
  • startActivity (Activity)
  • scheduleAtFixedRate (Timer)
    Schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.
  • requestLocationUpdates (LocationManager)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • PriorityQueue (java.util)
    An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now