use of forestry.api.apiculture.EnumBeeChromosome in project Railcraft by Railcraft.
the class ItemFilterBeeGenome method getBeeFilter.
@Nullable
public static BeeFilter getBeeFilter(ItemStack stack) {
NBTTagCompound nbt = InvTools.getItemDataRailcraft(stack, "filter");
if (nbt != null) {
try {
String typeName = nbt.getString("type");
EnumBeeType type = null;
try {
type = EnumBeeType.valueOf(typeName);
} catch (IllegalArgumentException ignored) {
}
EnumBeeChromosome chromosome = EnumBeeChromosome.SPECIES;
try {
chromosome = EnumBeeChromosome.valueOf(nbt.getString("chromosome"));
} catch (IllegalArgumentException ignored) {
}
ItemStack active = NBTPlugin.readItemStack(nbt, "active");
ItemStack inactive = NBTPlugin.readItemStack(nbt, "inactive");
return new BeeFilter(type, chromosome, active, inactive);
} catch (Throwable ignored) {
}
}
return new BeeFilter(null, EnumBeeChromosome.SPECIES, null, null);
}
use of forestry.api.apiculture.EnumBeeChromosome in project Railcraft by Railcraft.
the class ItemFilterBeeGenome method onItemRightClick.
@Optional.Method(modid = ForestryPlugin.FORESTRY_ID)
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
NBTTagCompound nbt = InvTools.getItemDataRailcraft(stack, "filter");
if (nbt != null) {
try {
EnumBeeChromosome chromosome = EnumBeeChromosome.SPECIES;
try {
chromosome = EnumBeeChromosome.valueOf(nbt.getString("chromosome"));
} catch (IllegalArgumentException ignored) {
}
chromosome = EnumTools.next(chromosome, EnumBeeChromosome.values());
nbt.setString("chromosome", chromosome.name());
} catch (Throwable throwable) {
Game.logErrorAPI(Mod.FORESTRY.modId, throwable, EnumBeeChromosome.class);
}
}
return new ActionResult<>(EnumActionResult.SUCCESS, stack.copy());
}
Aggregations