Search in sources :

Example 21 with ComputerMethod

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;
}
Also used : BlockState(net.minecraft.block.BlockState) BoundComputerMethod(mekanism.common.integration.computer.BoundComputerMethod) ComputerMethod(mekanism.common.integration.computer.annotation.ComputerMethod) Nonnull(javax.annotation.Nonnull)

Example 22 with ComputerMethod

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);
    }
}
Also used : ConfigInfo(mekanism.common.tile.component.config.ConfigInfo) ComputerException(mekanism.common.integration.computer.ComputerException) ComputerMethod(mekanism.common.integration.computer.annotation.ComputerMethod)

Example 23 with ComputerMethod

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();
}
Also used : ItemCraftingFormula(mekanism.common.item.ItemCraftingFormula) ItemStack(net.minecraft.item.ItemStack) SyncableItemStack(mekanism.common.inventory.container.sync.SyncableItemStack) ComputerException(mekanism.common.integration.computer.ComputerException) WrappingComputerMethod(mekanism.common.integration.computer.annotation.WrappingComputerMethod) ComputerMethod(mekanism.common.integration.computer.annotation.ComputerMethod) SyntheticComputerMethod(mekanism.common.integration.computer.annotation.SyntheticComputerMethod)

Aggregations

ComputerMethod (mekanism.common.integration.computer.annotation.ComputerMethod)23 ComputerException (mekanism.common.integration.computer.ComputerException)10 WrappingComputerMethod (mekanism.common.integration.computer.annotation.WrappingComputerMethod)9 QIOFrequency (mekanism.common.content.qio.QIOFrequency)4 TeleporterFrequency (mekanism.common.content.teleporter.TeleporterFrequency)4 ConfigInfo (mekanism.common.tile.component.config.ConfigInfo)4 SyntheticComputerMethod (mekanism.common.integration.computer.annotation.SyntheticComputerMethod)3 FrequencyIdentity (mekanism.common.lib.frequency.Frequency.FrequencyIdentity)3 Nonnull (javax.annotation.Nonnull)2 FloatingLong (mekanism.api.math.FloatingLong)2 InventoryFrequency (mekanism.common.content.entangloporter.InventoryFrequency)2 DiversionTransporter (mekanism.common.content.network.transmitter.DiversionTransporter)2 BoundComputerMethod (mekanism.common.integration.computer.BoundComputerMethod)2 SyncableItemStack (mekanism.common.inventory.container.sync.SyncableItemStack)2 ItemStack (net.minecraft.item.ItemStack)2 Object2ObjectOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)1 ElementType (java.lang.annotation.ElementType)1 MethodHandle (java.lang.invoke.MethodHandle)1 MethodHandles (java.lang.invoke.MethodHandles)1 Field (java.lang.reflect.Field)1