use of mekanism.common.integration.computer.annotation.ComputerMethod in project Mekanism by mekanism.
the class TileEntityMekanism method getDirection.
// End methods IUpgradeableTile
// Methods for implementing ITileDirectional
@Nonnull
@Override
@ComputerMethod(restriction = MethodRestriction.DIRECTIONAL)
public final Direction getDirection() {
if (isDirectional()) {
if (cachedDirection != null) {
return cachedDirection;
}
BlockState state = getBlockState();
cachedDirection = Attribute.getFacing(state);
if (cachedDirection != null) {
return cachedDirection;
} else if (!getType().isValid(state.getBlock())) {
// This is probably always true if we couldn't get the direction it is facing
// but double check just in case before logging
Mekanism.logger.warn("Error invalid block for tile {} at {} in {}. Unable to get direction, falling back to north, " + "things will probably not work correctly. This is almost certainly due to another mod incorrectly " + "trying to move this tile and not properly updating the position.", getType().getRegistryName(), worldPosition, level);
}
}
// TODO: Remove, give it some better default, or allow it to be null
return Direction.NORTH;
}
use of mekanism.common.integration.computer.annotation.ComputerMethod in project Mekanism by mekanism.
the class TileComponentConfig method setEjecting.
@ComputerMethod
private void setEjecting(TransmissionType type, boolean ejecting) throws ComputerException {
tile.validateSecurityIsPublic();
validateSupportedTransmissionType(type);
ConfigInfo config = configInfo.get(type);
if (!config.canEject()) {
throw new ComputerException("This machine does not support auto-ejecting for transmission type '%s'.", type);
}
if (config.isEjecting() != ejecting) {
config.setEjecting(ejecting);
tile.markDirty(false);
}
}
use of mekanism.common.integration.computer.annotation.ComputerMethod in project Mekanism by mekanism.
the class TileEntityFormulaicAssemblicator method computerEncodeFormula.
@ComputerMethod(nameOverride = "encodeFormula")
private void computerEncodeFormula() throws ComputerException {
validateSecurityIsPublic();
ItemStack formulaStack = formulaSlot.getStack();
if (formulaStack.isEmpty() || !(formulaStack.getItem() instanceof ItemCraftingFormula)) {
throw new ComputerException("No formula found.");
} else if (formula != null && formula.isValidFormula() || ((ItemCraftingFormula) formulaStack.getItem()).getInventory(formulaStack) != null) {
throw new ComputerException("Formula has already been encoded.");
} else if (!hasRecipe()) {
throw new ComputerException("Encoding formulas require that there is a valid recipe to actually encode.");
}
encodeFormula();
}
Aggregations