@Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) { // can sustain both slimeplants and normal plants return plantable.getPlantType(world, pos) == TinkerWorld.slimePlantType || plantable.getPlantType(world, pos) == EnumPlantType.Plains; }
protected IBlockState getPlant(@Nonnull IFarmer farm, IPlantable plantable) { return plantable.getPlant(farm.getWorld(), farm.getLocation().up(256)); }
@Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) { // can sustain both slimeplants and normal plants return plantable.getPlantType(world, pos) == TinkerWorld.slimePlantType || plantable.getPlantType(world, pos) == EnumPlantType.Plains; }
private IBlockState getPlantablePlantFromStack(ItemStack stack, World world, BlockPos pos) { if (StackUtil.isValid(stack)) { IPlantable plantable = this.getPlantableFromStack(stack); if (plantable != null) { IBlockState state = plantable.getPlant(world, pos); if (state != null && state.getBlock() instanceof IGrowable) return state; } } return null; }
@Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) { EnumPlantType type = plantable.getPlantType(world, pos.down()); return type == EnumPlantType.Plains || type == EnumPlantType.Beach; }
public boolean generate(World world, Random rng, BlockPos start) { for (int i = 0; i < 20; ++i) { BlockPos spot = start.add(rng.nextInt(4) - rng.nextInt(4), -1, rng.nextInt(4) - rng.nextInt(4)); BlockPos prevSpot = spot; IBlockState prevState = world.getBlockState(spot); final int n = 2 + rng.nextInt(rng.nextInt(3) + 1); for (int y = 0; y < n; y++) { spot = spot.add(0, +1, 0); IBlockState toPlant = plant.getPlant(world, spot); if (!world.isAirBlock(spot) || !prevState.getBlock().canSustainPlant(prevState, world, prevSpot, EnumFacing.UP, plant) || !plant.getPlant(world, spot).getBlock().canPlaceBlockAt(world, spot)) break; setBlockAndNotifyAdequately(world, spot, toPlant); prevState = toPlant; prevSpot = spot; } } return true; } }
@Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) { SoilTypes type = world.getBlockState(pos).getValue(TYPE); if(type == SoilTypes.SLIMY_MUD_GREEN || type == SoilTypes.SLIMY_MUD_BLUE) { // can sustain slimeplants return plantable.getPlantType(world, pos) == TinkerWorld.slimePlantType; } return super.canSustainPlant(state, world, pos, direction, plantable); }
@Nullable public static IBlockState getBlockState(IBlockAccess world, BlockPos pos, @Nullable ItemStack stack) { if (stack != null) { Item item = stack.getItem(); if (item instanceof ItemBlockSpecial) { return ((ItemBlockSpecial) item).getBlock().getDefaultState(); } else if (item instanceof ItemBlock) { return (((ItemBlock) item).getBlock()).getDefaultState(); } else if (item instanceof IPlantable) { return ((IPlantable) item).getPlant(world, pos); } else if (item instanceof ItemSkull) { return Blocks.SKULL.getDefaultState(); } } return null; } }
@Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) { return plantable.getPlantType(world, pos.down()) == EnumPlantType.Plains; }
String plantName = ((IPlantable) item).getPlant(null, null).getBlock().getRegistryName().toString(); cropSet.add(plantName);
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { EnumPlantType plantType = plantable.getPlantType(world, pos); return plantType == EnumPlantType.Crop || plantType == EnumPlantType.Plains; }
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { IBlockState plant = plantable.getPlant(world, pos.up()); if (ModuleManager.isModuleEnabled(Constants.BOTANY_MOD_ID, BotanyModuleUIDs.FLOWERS)) { if (plant.getBlock() == ModuleFlowers.flower) { return true; } } if (plant.getBlock() == ModuleGardening.plant) { return !weedKilled || !BlockPlant.isWeed(world, pos); } return world instanceof World && Blocks.DIRT.canSustainPlant(state, world, pos, direction, plantable); }
private boolean canHarvest(World world, BlockPos pos, IBlockState state) { Block block = state.getBlock(); if(block instanceof IPlantable) { IPlantable plant = (IPlantable) block; EnumPlantType type = plant.getPlantType(world, pos); return type != EnumPlantType.Water && type != EnumPlantType.Desert; } return false; }
/** * Plants the crop at a given location. * * @param item the crop. * @param position the location. * @return true if succesful. */ private boolean plantCrop(final ItemStack item, @NotNull final BlockPos position) { final int slot = worker.getCitizenInventoryHandler().findFirstSlotInInventoryWith(item.getItem(), item.getItemDamage()); if (slot == -1) { return false; } @NotNull final IPlantable seed = (IPlantable) item.getItem(); if ((seed == Items.MELON_SEEDS || seed == Items.PUMPKIN_SEEDS) && prevPos != null && !world.isAirBlock(prevPos.up())) { return true; } world.setBlockState(position.up(), seed.getPlant(world, position)); worker.decreaseSaturationForContinuousAction(); new InvWrapper(getInventory()).extractItem(slot, 1, false); return true; }
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable) { EnumPlantType plantType = plantable.getPlantType(world, pos.up()); if (plantType == EnumPlantType.Nether) { return true; } return super.canSustainPlant(state, world, pos, direction, plantable); }
public static ItemStack tryPlantSeed(World world, BlockPos posForPlant, ItemStack stack) { BlockPos posSoil = posForPlant.down(); if (stack != null && stack.getItem() instanceof IPlantable) { IPlantable seed = (IPlantable) stack.getItem(); IBlockState crop = seed.getPlant(world, posForPlant); if (crop != null) { // mimic exactly what onItemUse.onItemUse is doing IBlockState state = world.getBlockState(posSoil); boolean canSustainPlant = state.getBlock().canSustainPlant(state, world, posSoil, EnumFacing.UP, seed); if (canSustainPlant) { if (world.isAirBlock(posForPlant)) { world.setBlockState(posForPlant, crop); stack.shrink(1); return stack; } else { return stack;// ie, dont do super } } } } return null; } }
@Override public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing direction, IPlantable plantable) { EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction)); if (plantType == EnumPlantType.Plains) { return true; } return super.canSustainPlant(state, world, pos, direction, plantable); }
world.setBlockState(currentPos.up(), plant.getPlant(world, currentPos.up())); player.inventory.decrStackSize(s.slot, 1); player.inventoryContainer.detectAndSendChanges();
@Override protected boolean isFarmable(Block block, BlockPos farmablePos) { if (super.isFarmable(block, farmablePos)) { return ((IPlantable) block).getPlantType(world, farmablePos) == EnumPlantType.Crop; } return block instanceof BlockCrops || block instanceof BlockStem; }