use of binnie.botany.api.gardening.EnumMoisture in project Binnie by ForestryMC.
the class BlockSoil method getStateFromMeta.
@Override
@SuppressWarnings("deprecation")
public IBlockState getStateFromMeta(int meta) {
EnumMoisture moisture = EnumMoisture.values()[meta % 3];
EnumAcidity acidity = EnumAcidity.values()[meta / 3];
return getDefaultState().withProperty(MOISTURE, moisture).withProperty(ACIDITY, acidity);
}
use of binnie.botany.api.gardening.EnumMoisture in project Binnie by ForestryMC.
the class GardenLogic method getAvailableLoam.
private ItemStack getAvailableLoam(IFarmHousing housing) {
EnumMoisture[] moistures;
if (moisture == EnumMoisture.DAMP) {
moistures = new EnumMoisture[] { EnumMoisture.DAMP, EnumMoisture.NORMAL, EnumMoisture.DRY };
} else if (moisture == EnumMoisture.DRY) {
moistures = new EnumMoisture[] { EnumMoisture.DRY, EnumMoisture.DAMP, EnumMoisture.DRY };
} else {
moistures = new EnumMoisture[] { EnumMoisture.DRY, EnumMoisture.NORMAL, EnumMoisture.DAMP };
}
EnumAcidity[] acidities = { EnumAcidity.NEUTRAL, EnumAcidity.ACID, EnumAcidity.ALKALINE };
for (EnumMoisture moist : moistures) {
for (EnumAcidity acid : acidities) {
for (Block type : new Block[] { ModuleGardening.flowerbed, ModuleGardening.loam, ModuleGardening.soil }) {
int meta = acid.ordinal() * 3 + moist.ordinal();
NonNullList<ItemStack> resources = NonNullList.create();
ItemStack resourceStack = new ItemStack(type, 1, meta);
resources.add(resourceStack);
if (housing.getFarmInventory().hasResources(resources)) {
return resourceStack;
}
}
}
}
NonNullList<ItemStack> resources = NonNullList.create();
ItemStack resourceStack = new ItemStack(Blocks.DIRT);
resources.add(resourceStack);
if (housing.getFarmInventory().hasResources(resources)) {
return new ItemStack(Blocks.DIRT);
}
return ItemStack.EMPTY;
}
use of binnie.botany.api.gardening.EnumMoisture in project Binnie by ForestryMC.
the class ItemTrowel method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (!player.canPlayerEdit(pos, facing, stack)) {
return EnumActionResult.FAIL;
}
Block block = worldIn.getBlockState(pos).getBlock();
if (facing == EnumFacing.DOWN || (!worldIn.isAirBlock(pos.up()) && ModuleManager.isModuleEnabled(Constants.BOTANY_MOD_ID, BotanyModuleUIDs.FLOWERS) && worldIn.getBlockState(pos.up()).getBlock() != ModuleFlowers.flower) || (block != Blocks.GRASS && block != Blocks.DIRT && block != Blocks.GRASS_PATH)) {
return EnumActionResult.PASS;
}
worldIn.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (worldIn.isRemote) {
return EnumActionResult.SUCCESS;
}
IGardeningManager gardening = BotanyCore.getGardening();
EnumMoisture moisture = gardening.getNaturalMoisture(worldIn, pos);
EnumAcidity acidity = gardening.getNaturalPH(worldIn, pos);
gardening.plantSoil(worldIn, pos, EnumSoilType.SOIL, moisture, acidity);
stack.damageItem(1, player);
return EnumActionResult.SUCCESS;
}
use of binnie.botany.api.gardening.EnumMoisture in project Binnie by ForestryMC.
the class ModuleFarming method doInit.
@Override
public void doInit() {
ItemStack yellow = new ItemStack(Blocks.YELLOW_FLOWER, 1);
ItemStack red = new ItemStack(Blocks.RED_FLOWER, 1);
ItemStack blue = new ItemStack(Blocks.RED_FLOWER, 1, 7);
for (boolean manual : new boolean[] { true, false }) {
for (boolean fertilised : new boolean[] { true, false }) {
for (EnumMoisture moist : EnumMoisture.values()) {
ItemStack icon;
if (moist == EnumMoisture.DRY) {
icon = yellow;
} else if (moist == EnumMoisture.NORMAL) {
icon = red;
} else {
icon = blue;
}
int insulate = 2 - moist.ordinal();
if (fertilised) {
insulate += 3;
}
new CircuitGarden(moist, null, manual, fertilised, new ItemStack(insulatedTube, 1, 128 * insulate), icon);
new CircuitGarden(moist, EnumAcidity.ACID, manual, fertilised, new ItemStack(insulatedTube, 1, 1 + 128 * insulate), icon);
new CircuitGarden(moist, EnumAcidity.NEUTRAL, manual, fertilised, new ItemStack(insulatedTube, 1, 2 + 128 * insulate), icon);
new CircuitGarden(moist, EnumAcidity.ALKALINE, manual, fertilised, new ItemStack(insulatedTube, 1, 3 + 128 * insulate), icon);
}
}
}
for (EnumTubeMaterial mat : EnumTubeMaterial.VALUES) {
RecipeUtil recipeUtil = new RecipeUtil(Constants.BOTANY_MOD_ID);
for (EnumTubeInsulate insulate : EnumTubeInsulate.VALUES) {
ItemStack tubes = new ItemStack(insulatedTube, 2, mat.ordinal() + 128 * insulate.ordinal());
ItemStack insulateStack = ItemInsulatedTube.getInsulateStack(tubes);
ItemStack forestryTube = new ItemStack(Mods.Forestry.item("thermionic_tubes"), 1, mat.ordinal());
String recipeName = "thermionic_tubes_" + insulate.getUid() + '_' + mat.getUid();
recipeUtil.addShapelessRecipe(recipeName, tubes, forestryTube, forestryTube, insulateStack);
}
}
}
use of binnie.botany.api.gardening.EnumMoisture in project Binnie by ForestryMC.
the class ModuleGardening method addFertiliserRecipes.
private void addFertiliserRecipes(RecipeUtil recipeUtil) {
IGardeningManager gardening = BotanyCore.getGardening();
for (EnumMoisture moisture : EnumMoisture.values()) {
for (EnumAcidity acidity : EnumAcidity.values()) {
int pH = acidity.ordinal();
for (EnumSoilType type : EnumSoilType.values()) {
Map<EnumFertiliserType, Map<ItemStack, Integer>> fertilisers = gardening.getFertilisers();
for (EnumFertiliserType fertiliserType : EnumFertiliserType.values()) {
for (Map.Entry<ItemStack, Integer> entry : fertilisers.get(fertiliserType).entrySet()) {
ItemStack stack = entry.getKey();
int strengthMax = entry.getValue();
for (boolean weedkiller : new boolean[] { false, true }) {
int numOfBlocks = strengthMax * strengthMax;
for (int strength = 1; strength < strengthMax; ++strength) {
int endPh;
if (fertiliserType == EnumFertiliserType.ACID) {
endPh = pH - strength;
} else if (fertiliserType == EnumFertiliserType.ALKALINE) {
endPh = pH + strength;
} else {
endPh = type.ordinal() + strength;
}
if (endPh < 0 || endPh > 2 || pH == endPh) {
continue;
}
ItemStack start = getStack(type, acidity, moisture, weedkiller);
ItemStack end = getStack(type, EnumAcidity.values()[endPh], moisture, weedkiller);
if (!start.isEmpty() && !end.isEmpty()) {
end.setCount(numOfBlocks);
Object[] stacks = new Object[numOfBlocks + 1];
for (int i = 0; i < numOfBlocks; ++i) {
stacks[i] = start;
}
stacks[numOfBlocks] = stack.copy();
String recipeName = fertiliserType.name().toLowerCase(Locale.ENGLISH) + "_fertiliser_moisture" + moisture + "_ph" + pH + "_type" + type + "_strength" + strength;
recipeUtil.addShapelessRecipe(recipeName, end, stacks);
}
numOfBlocks /= 2;
}
}
}
}
ItemStack start = getStack(type, acidity, moisture, false);
ItemStack end = getStack(type, acidity, moisture, true);
String recipeName = "weedkiller_moisture" + moisture + "_ph" + pH + "_type" + type;
recipeUtil.addShapelessRecipe(recipeName, end, start, start, start, start, "weedkiller");
}
}
}
}
Aggregations