net.minecraftforge.fml.common.Optional Java Examples

The following examples show how to use net.minecraftforge.fml.common.Optional. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemCapeBauble.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
	if (player.world.isRemote) return;

	tickCape(itemstack);
}
 
Example #2
Source File: FabricatorTileEntity.java    From EmergingTechnology with MIT License 5 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] setProgram(Context context, Arguments args) {

    boolean success = false;
    String message = "There was an error setting the program";

    try {

        int max = FabricatorRecipes.getRecipes().size() - 1;

        Object[] arguments = args.toArray();

        if (arguments == null) {
            message = "Invalid argument. Must be integer between 0 and " + max;
            return new Object[] { success, message };
        }

        Double thing = (Double) arguments[0];

        int program = thing.intValue();

        if (program < 0 || program > max) {
            message = "Invalid argument. Must be integer between 0 and " + max;
        } else {
            this.setProgram(program);
            success = true;
            message = "Fabricator program set to " + program;
        }

    } catch (Exception ex) {
        message = ex.toString();
    }

    return new Object[] { success, message };
}
 
Example #3
Source File: BaublesSupport.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public List<ItemStack> getBaublesOnly(EntityLivingBase entity) {
	if (!(entity instanceof EntityPlayer)) return new ArrayList<>();
	if (BaublesApi.getBaublesHandler((EntityPlayer) entity) == null) return new ArrayList<>();

	ImmutableList.Builder<ItemStack> stacks = ImmutableList.builder();
	IBaublesItemHandler inv = BaublesApi.getBaublesHandler((EntityPlayer) entity);
	for (BaubleType type : BaubleType.values())
		for (int slot : type.getValidSlots()) {
			stacks.add(inv.getStackInSlot(slot));
		}
	return stacks.build();
}
 
Example #4
Source File: BaublesSupport.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public Iterable<ItemStack> getBaublesFallbackArmor(EntityLivingBase entity) {
	if (!(entity instanceof EntityPlayer)) return entity.getArmorInventoryList();
	if (BaublesApi.getBaublesHandler((EntityPlayer) entity) == null) return entity.getArmorInventoryList();

	ImmutableList.Builder<ItemStack> stacks = ImmutableList.builder();
	IBaublesItemHandler inv = BaublesApi.getBaublesHandler((EntityPlayer) entity);
	for (BaubleType type : BaubleType.values())
		for (int slot : type.getValidSlots()) {
			stacks.add(inv.getStackInSlot(slot));
		}
	return stacks.build();
}
 
Example #5
Source File: GPSTileEntity.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getPosition(Context context, Arguments args) {
    java.util.Optional<PhysicsObject> physicsObjectOptional = ValkyrienUtils
        .getPhysicsObject(getWorld(), getPos());
    if (physicsObjectOptional.isPresent()) {
        BlockPos pos = physicsObjectOptional.get()
            .getWrapperEntity()
            .getPosition();
        return new Object[]{pos.getX(), pos.getY(), pos.getZ()};
    }
    return null;
}
 
Example #6
Source File: GPSTileEntity.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getRotation(Context context, Arguments args) {
    java.util.Optional<PhysicsObject> physicsObjectOptional = ValkyrienUtils
        .getPhysicsObject(getWorld(), getPos());
    if (physicsObjectOptional.isPresent()) {
        PhysicsWrapperEntity ship = physicsObjectOptional.get()
            .getWrapperEntity();
        return new Object[]{ship.getYaw(), ship.getPitch(), ship.getRoll()};
    }
    return null;
}
 
Example #7
Source File: GTItemBaublesEnergyPack.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public boolean willAutoSync(ItemStack itemstack, EntityLivingBase player) {
	return true;
}
 
Example #8
Source File: BatteryTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Optional.Method(modid = "opencomputers")
@Override
public String getComponentName() {
    return "etech_battery";
}
 
Example #9
Source File: ItemRealHaloBauble.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Nonnull
@Optional.Method(modid = "baubles")
@Override
public BaubleType getBaubleType(@Nonnull ItemStack itemStack) {
	return BaubleType.HEAD;
}
 
Example #10
Source File: PiezoelectricTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] isSteppedOn(Context context, Arguments args) {
    boolean stepped = this.cooldown == 10;
    return new Object[] { stepped };
}
 
Example #11
Source File: HydroponicTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Optional.Method(modid = "opencomputers")
@Override
public String getComponentName() {
    return "etech_grow_bed";
}
 
Example #12
Source File: GTItemBaublesLithiumBattery.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public boolean willAutoSync(ItemStack itemstack, EntityLivingBase player) {
	return true;
}
 
Example #13
Source File: ShredderTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Optional.Method(modid = "opencomputers")
@Override
public String getComponentName() {
    return "etech_shredder";
}
 
Example #14
Source File: GTItemBaublesEnergyOrb.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public BaubleType getBaubleType(ItemStack itemStack) {
	return BaubleType.BELT;
}
 
Example #15
Source File: GTItemBaublesEnergyOrb.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public boolean willAutoSync(ItemStack itemstack, EntityLivingBase player) {
	return true;
}
 
Example #16
Source File: GTItemBaublesLithiumBattery.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@Optional.Method(modid = "baubles")
public BaubleType getBaubleType(ItemStack itemStack) {
	return BaubleType.BELT;
}
 
Example #17
Source File: ItemPearlBelt.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Nonnull
@Override
@Optional.Method(modid = "baubles")
public BaubleType getBaubleType(@NotNull ItemStack stack) {
	return BaubleType.BELT;
}
 
Example #18
Source File: ItemCapeBauble.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Nonnull
@Override
@Optional.Method(modid = "baubles")
public BaubleType getBaubleType(ItemStack itemStack) {
	return BaubleType.BODY;
}
 
Example #19
Source File: ShredderTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getProgress(Context context, Arguments args) {
    int value = getProgress();
    return new Object[] { value };
}
 
Example #20
Source File: ShredderTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getEnergyLevel(Context context, Arguments args) {
    int level = getEnergy();
    return new Object[] { level };
}
 
Example #21
Source File: SolarTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Optional.Method(modid = "opencomputers")
@Override
public String getComponentName() {
    return "etech_solar_generator";
}
 
Example #22
Source File: AlgaeBioreactorTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getProgress(Context context, Arguments args) {
    int value = getProgress();
    return new Object[] { value };
}
 
Example #23
Source File: AlgaeBioreactorTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getEnergyLevel(Context context, Arguments args) {
    int level = getEnergy();
    return new Object[] { level };
}
 
Example #24
Source File: AlgaeBioreactorTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getGasLevel(Context context, Arguments args) {
    int level = getGas();
    return new Object[] { level };
}
 
Example #25
Source File: AlgaeBioreactorTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getWaterLevel(Context context, Arguments args) {
    int level = getWater();
    return new Object[] { level };
}
 
Example #26
Source File: AlgaeBioreactorTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Optional.Method(modid = "opencomputers")
@Override
public String getComponentName() {
    return "etech_algaebioreactor";
}
 
Example #27
Source File: CookerTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getProgress(Context context, Arguments args) {
    int value = getProgress();
    return new Object[] { value };
}
 
Example #28
Source File: CookerTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getHeatLevel(Context context, Arguments args) {
    int level = getHeat();
    return new Object[] { level };
}
 
Example #29
Source File: CookerTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Optional.Method(modid = "opencomputers")
@Override
public String getComponentName() {
    return "etech_cooker";
}
 
Example #30
Source File: InjectorTileEntity.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Callback
@Optional.Method(modid = "opencomputers")
public Object[] getFluid(Context context, Arguments args) {
    int value = getNutrientFluid();
    return new Object[] { value };
}